Solarus-Games English Forum

Solarus => Bugs & Feature requests => Topic started by: Zefk on July 26, 2018, 09:15:29 AM

Title: [Solved]door function issue?
Post by: Zefk on July 26, 2018, 09:15:29 AM
Version: Solarus 1.5.3
OS: Linux

This might be a bug?

I tried using door:on_opened() (http://www.solarus-games.org/doc/latest/lua_api_door.html#lua_api_door_on_opened), but it seems to not be working. I double checked the name and everything. This function is called during an opening of a door, right?

Code ( lua) Select
function door_1:on_opened()
  print("opened door")
  hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
end


The same occurred with door:is_open() (http://www.solarus-games.org/doc/latest/lua_api_door.html#lua_api_door_is_open). The door is indeed open, but nothing happens.

Code ( lua) Select
 
sol.timer.start(1000, function()
  if door_1:is_open() == true then
    hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
  end
  return true
end)


The function door:is_opening()  (http://www.solarus-games.org/doc/latest/lua_api_door.html#lua_api_door_is_opening)worked.

Code ( lua) Select
 
sol.timer.start(1000, function()
  if door_1:is_opening() == true then
    hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
  end
  return true
end)


Title: Re: door function issue?
Post by: Max on July 26, 2018, 06:57:10 PM
So, I tried to reproduce your error and couldn't. My code:

Code (lua) Select

function basement_door:on_opened()
  print("no problems here")
end


That worked fine, so maybe it's an issue with Solarus 1.5.3? I'm running 1.5.1. That or you actually do have a typo in your door entity's name on the map. Just to cover all the bases, it is a door entity, right? Sometimes I use NPCs as doors and just set them disabled whenever I need the door open, but that would never call door:on_opened().
Title: Re: door function issue?
Post by: Zefk on July 26, 2018, 07:51:01 PM
I am pretty sure. Here is an image to prove it. I made sure all the animations existed as stated in the documentation (http://www.solarus-games.org/doc/latest/lua_api_door.html#lua_api_door_overview).

(https://s22.postimg.cc/3md11qeap/Edit_an_entity_001.png)

Also, I mentioned the function door:is_opening()  (http://www.solarus-games.org/doc/latest/lua_api_door.html#lua_api_door_is_opening)working.

Code ( lua) Select
 
sol.timer.start(1000, function()
  if door_1:is_opening() == true then
    hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
  end
  return true
end)


Title: Re: door function issue?
Post by: Christopho on July 26, 2018, 08:16:04 PM
Does the animation "opening" of your door sprite correctly ends? Because if it loops, that might explain that the opening state never finishes.
Title: Re: [Solved]door function issue?
Post by: Zefk on July 26, 2018, 08:30:16 PM
@Christopho
No loop, but it seems the "opening" frame delay was the problem. The frame delay was at: 0 ms

It works now. Thank you Christopho!
Title: Re: [Solved]door function issue?
Post by: Christopho on July 26, 2018, 08:47:47 PM
Indeed, a delay of 0 means to loop forever.