Hello, I create this code to increment a value when this chest is open but I have this error :
Error: Failed to load script 'maps/dungeons/tuto/place_holder': [string "maps/dungeons/tuto/place_holder.lua"]:5: <name> or '...' expected near '"sword"'
function sword_chest:on_opened("sword", 1, "sword_chest_save")
hero:unfreeze()
chest_open = chest_open + 1
test()
end
http://www.solarus-games.org/doc/latest/lua_api_chest.html#lua_api_chest_on_opened
The first argument need to be an item, what you've done is that the first argument is a string
Thank for the answere
With this code
function sword_chest:on_opened(sword, 1, "sword_chest_save")
hero:unfreeze()
chest_open = chest_open + 1
test()
end
I have another error
Error: Failed to load script 'maps/dungeons/tuto/place_holder': [string "maps/dungeons/tuto/place_holder.lua"]:5: <name> or '...' expected near '1'
I don't understand why...
Your first line is not valid Lua syntax. Are you trying to define a function or to call a function?
I just want to detect when the chest is open to open a door.
Quote from: dpro_games on July 11, 2017, 04:55:15 PM
Thank for the answere
With this code
function sword_chest:on_opened(sword, 1, "sword_chest_save")
hero:unfreeze()
chest_open = chest_open + 1
test()
end
I have another error
Error: Failed to load script 'maps/dungeons/tuto/place_holder': [string "maps/dungeons/tuto/place_holder.lua"]:5: <name> or '...' expected near '1'
I don't understand why...
Do like this
Don't know if this will work because I never use chest:on_opened() but that's the way to go
function sword_chest:on_opened(item, variant, savegame)
if item:get_name() == "sword" then
end
end
It work but there is still a problem... When I open the chest, the value is increase but the hero don't get the sword in the chest. May I need to give the sword by the code but I don't know the line which give the item like if the player open a chest...
Thank to help me.
I found by myself, that's work ! :D
I use this line:
hero:start_treasure(treasure_item, [treasure_variant, [treasure_savegame_variable, [callback]]])
To give the treasure to the hero when he open the chest.
Thanks you for helped me ! :D :D