Skip to content

Instantly share code, notes, and snippets.

@8bitgentleman
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save 8bitgentleman/886fd907fa0cb90d3a91 to your computer and use it in GitHub Desktop.

Select an option

Save 8bitgentleman/886fd907fa0cb90d3a91 to your computer and use it in GitHub Desktop.

Revisions

  1. 8bitgentleman revised this gist Aug 18, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.lua
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@
    { ['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.

  2. 8bitgentleman revised this gist Aug 18, 2014. 1 changed file with 15 additions and 11 deletions.
    26 changes: 15 additions & 11 deletions gistfile1.lua
    Original 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.

    local Player = require 'player'
    local player = Player.factory()
    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)

    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
    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
  3. 8bitgentleman created this gist Aug 18, 2014.
    21 changes: 21 additions & 0 deletions gistfile1.lua
    Original 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