Solarus 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.