Author Topic: Save ground for when falling in water and lava  (Read 2194 times)

xavius

  • Newbie
  • *
  • Posts: 22
    • View Profile
Save ground for when falling in water and lava
« on: July 26, 2014, 03:42:11 pm »
Hi,

I know you can save ground to reset the hero to a position when he falls but is it possible to do the same with lava and water?

Thank you!

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Save ground for when falling in water and lava
« Reply #1 on: July 27, 2014, 10:28:50 pm »
This is apparently a bug. It works with holes, and it should also work with lava, water and prickles too.
I have just fixed the problem, it will be fixed in Solarus 1.3: https://github.com/christopho/solarus/issues/567
Thanks for the report!

xavius

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Save ground for when falling in water and lava
« Reply #2 on: July 31, 2014, 03:21:42 am »
Thank you Christopho. Another question on this. Is the character teleported to the saved ground or it is translated to it? I have remarked depending how far you are from the saved ground point, it will take longer to respawn. Is it possible to do a setHeroPosition(blabla)?

Thank you again!

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Save ground for when falling in water and lava
« Reply #3 on: August 01, 2014, 10:04:09 am »
The hero is translated to the solid-ground-position.
To teleport him directly, you can override the behavior of the "back to solid ground" state like this (untested):
Code: [Select]
function hero:on_state_changed(state)
  if state == "back to solid ground" then
    hero:set_position(x, y)
    hero:unfreeze()  -- Stop the "back to solid ground" built-in state, restore control to the player.
  end
end

xavius

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Save ground for when falling in water and lava
« Reply #4 on: August 02, 2014, 04:15:13 am »
Is there a way to get the position and layer of a solid ground? I did not see it a function for this in the documentation.

Thank you again!

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1172
    • View Profile
Re: Save ground for when falling in water and lava
« Reply #5 on: August 02, 2014, 08:28:48 am »
Not yet, this is missing. I just opened an issue to implement that for 1.3: https://github.com/christopho/solarus/issues/572

In the meantime, you should be able to implement your own functions:
Code: [Select]
function hero:my_save_solid_ground(x, y, layer)
  hero:save_solid_ground(x, y, layer)
  hero.solid_ground_position = { x = x, y = y, layer = layer}
end

function hero;my_get_solid_ground_position()
  if hero.solid_ground_position == nil then
    return nil
  end
  return hero.solid_ground_position.x, hero.solid_ground_position.y, hero.solid_ground_position.layer
end