--this is an example of what talk_items could look like in the npc's file { ['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. 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