Hi guys! I am making a shop, with NPCs for the items. The map script for the small heart works great for now.
function shop_heart:on_interaction()
if game:get_life(max)
then game:start_dialog("already_have")
sol.audio.play_sound("bounce")
elseif game:get_money() < 10 then
game:start_dialog("cant_buy")
sol.audio.play_sound("bounce")
else game:start_dialog("empty" , function()
hero:start_treasure("heart" , 1)
game:remove_money(10)
end)
end
end
but I am not sure how to properly use syntax to get the amount of the arrows item (the first "if" line).
function shop_arrows:on_interaction()
if item:get_amount("arrow" , 30)
then game:start_dialog("already_have")
elseif game:get_money() < 80 then
game:start_dialog("cant_buy")
sol.audio.play_sound("bounce")
else game:start_dialog("empty" , function()
hero:start_treasure("arrow" , 3)
game:remove_money(80)
end)
end
end
Thanks so much.