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

0 Members and 1 Guest are viewing this topic.

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: 535
  • Just helping Solarus
    • View Profile
    • Zefk Design
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.