That's nifty! Excellent work.
You should consider defining the items eligible to appear in the picker as part of the item scripts with some sort of custom property rather than inside the picker script itself. Perhaps add an is_giftable() method to the item metatable?
Thanks!
In general, items you trade will always be non-equipment items (as with most Zelda games). So I'm planning to add something like
item:set_key_item(boolean), where "true" means a non-equipment item.
I'm not sure how fancy I want to get yet, but I've been thinking about
npc:ask_item(filter, callback) where "filter" is a function like
filter(item) that returns true if the given item should be listed.
Eg,
local function filter(item)
if item:get_name() == "bad_item" then
return false
end
return item:is_key_item()
end
npc:ask_item(filter, function(item)
print(item:get_name()
)
The only thing blocking me is that Solarus doesn't seem to have a way to list all the possible items in the quest, so I can't loop through them.