Author Topic: Key save error message  (Read 786 times)

zutokaza

  • Full Member
  • ***
  • Posts: 146
  • Active - Making stories can take the most time.
    • View Profile
Key save error message
« 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))

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: Key save error message
« Reply #1 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

zutokaza

  • Full Member
  • ***
  • Posts: 146
  • Active - Making stories can take the most time.
    • View Profile
Re: Key save error message
« Reply #2 on: March 06, 2017, 05:20:32 am »
Thank you. It works now.