Key save error message

Started by zutokaza, March 06, 2017, 05:12:58 AM

Previous topic - Next topic
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))
Solarus Works on ReactOS Opensource Windows OS

https://www.reactos.org/forum/viewtopic.php?f=2&t=14759&p=120616#p120616

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