Solarus-Games English Forum

Solarus => Development => Topic started by: zutokaza on March 06, 2017, 05:12:58 AM

Title: Key save error message
Post by: zutokaza on March 06, 2017, 05:12:58 AM
I made a key item. I require the key for opening the door, but I get this error message. The door entity never shows.

Code ( lua) Select
2140] Error: In create_door: bad argument #1 to ? (Bad field 'opening_condition' (equipment item 'key' is not saved))
Title: Re: Key save error message
Post by: Zefk on March 06, 2017, 05:17:58 AM
You got to save it.

Example:

Code ( lua) Select
local item = ...
local game = item:get_game()


function item:on_created()
  -- Define the properties of key.
  self:set_savegame_variable("key")
  self:set_assignable(true)

end

function item:on_obtaining()
  game:set_item_assigned(1, self)
end
Title: Re: Key save error message
Post by: zutokaza on March 06, 2017, 05:20:32 AM
Thank you. It works now.