Last active
August 29, 2015 14:05
-
-
Save 8bitgentleman/886fd907fa0cb90d3a91 to your computer and use it in GitHub Desktop.
Revisions
-
8bitgentleman revised this gist
Aug 18, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ { ['text']='flowers', freeze = true, affection = 5 }, --The first for loop looks for the "options” key in the root table of the talk_items. Inside this table we can look for all items in the table that have an affection attribute. --If the affection attribute is lower than the player affection then we remove the item from the table. -
8bitgentleman revised this gist
Aug 18, 2014 . 1 changed file with 15 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,16 +6,20 @@ --The first for loop looks for the "options” key in the root table of the talk_items. Inside this table we can look for all items in the table that have an affection attribute. --If the affection attribute is lower than the player affection then we remove the item from the table. function Menu:itemUpdate( npc, player) --adds and removes items from the talk items based on affection level local Player = require 'player' local player = Player.factory() local affection = player.affection[self.name] or 0 local props = require('npcs/' .. self.name) for k,v,w in pairs(self.props.talk_items) do if v["option"] then for kk,vv,ww in pairs(v["option"]) do if vv['affectionMin'] and vv['affectionMin'] <= affection then--and ww['affectionMax'] and ww['affectionMax'] >= affectionthen table.remove(self.props.talk_items[k]["option"],kk) end end end end end -
8bitgentleman created this gist
Aug 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ --this is an example of what talk_items could look like in the npc's file { ['text']='flowers', freeze = true, affection = 5 }, --this should be added before “newMenuItems" are called on line 308 of npc.lua --The first for loop looks for the "options” key in the root table of the talk_items. Inside this table we can look for all items in the table that have an affection attribute. --If the affection attribute is lower than the player affection then we remove the item from the table. local Player = require 'player' local player = Player.factory() local affection = player.affection.hilda or 0 for k,v in pairs(npc.props.talk_items) do if v["option"] then for kk,vv in pairs(v["option"]) do if vv["affection"] < affection then table.remove(npc.props.talk_items[k]["option"],kk) end end end end