Author Topic: [Solved]door function issue?  (Read 242 times)

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
[Solved]door function issue?
« 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(), 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
  1. function door_1:on_opened()
  2.   print("opened door")
  3.   hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
  4. end

The same occurred with door:is_open(). The door is indeed open, but nothing happens.

Code: Lua
  1.  
  2. sol.timer.start(1000, function()
  3.   if door_1:is_open() == true then
  4.     hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
  5.   end
  6.   return true
  7. end)
  8.  

The function door:is_opening() worked.

Code: Lua
  1.  
  2. sol.timer.start(1000, function()
  3.   if door_1:is_opening() == true then
  4.     hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
  5.   end
  6.   return true
  7. end)
  8.  


Max

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Re: door function issue?
« Reply #1 on: July 26, 2018, 06:57:10 pm »
So, I tried to reproduce your error and couldn't. My code:

Code: Lua
  1. function basement_door:on_opened()
  2.   print("no problems here")
  3. end
  4.  

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

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: door function issue?
« Reply #2 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.



Also, I mentioned the function door:is_opening() working.

Code: Lua
  1.  
  2. sol.timer.start(1000, function()
  3.   if door_1:is_opening() == true then
  4.     hero:teleport("chain_village/underground_miniboss", "boss_destination", "fade")
  5.   end
  6.   return true
  7. end)
  8.  


Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1138
    • View Profile
Re: door function issue?
« Reply #3 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.

Zefk

  • Hero Member
  • *****
  • Posts: 536
  • Just helping Solarus
    • View Profile
    • Zelzec
Re: [Solved]door function issue?
« Reply #4 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!

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1138
    • View Profile
Re: [Solved]door function issue?
« Reply #5 on: July 26, 2018, 08:47:47 pm »
Indeed, a delay of 0 means to loop forever.