[Solved]door function issue?

Started by Zefk, July 26, 2018, 09:15:29 AM

Previous topic - Next topic
July 26, 2018, 09:15:29 AM Last Edit: July 26, 2018, 08:31:00 PM by Zefk
Version: Solarus 1.5.3
OS: Linux

This might be a bug?

I tried using 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(). 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() 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)



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().

July 26, 2018, 07:51:01 PM #2 Last Edit: July 26, 2018, 07:52:58 PM by Zefk
I am pretty sure. Here is an image to prove it. I made sure all the animations existed as stated in the documentation.



Also, I mentioned the function 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)



Does the animation "opening" of your door sprite correctly ends? Because if it loops, that might explain that the opening state never finishes.

July 26, 2018, 08:30:16 PM #4 Last Edit: July 26, 2018, 08:32:56 PM by Zefk
@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!

Indeed, a delay of 0 means to loop forever.