[Tutorial series] Lession 2 - Bridges (Now including a sensor tutorial)

Started by ffomega, June 06, 2016, 08:17:29 PM

Previous topic - Next topic
Diarandor had a request earlier about bridges Link could walk under and on top of, using sensors.  While the concept didn't take too terribly long for me to grasp, I created a page to show you all how I did it.  There are probably other ways to do this, but this method seemed the most efficient for me.

Before you attempt this tutorial, I HIGHLY recommend downloading the updated data file, as it has had some changes made to it.  You can download a copy from here.

Now, without further ado, here is the link to the site.  I hope that I was able to explain things well :)

http://solarus_resource.site88.net/tutorial/bridges.htm



[Update 6-14-2016] I have included a second option for creating bridges that use sensors instead of teletransporters, as suggested by Christopho.  On my bridges tutorial page, I left the original tutorial in just in case, for whatever reason,
someone might want to use it.


Happy mapping!
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/

Nice!
I basically do the same thing expect that I use sensors rather than teletransporters. But it needs some scripting (even if it can be done once for all with a metatable). If the hero is carrying a stone or charging his sword, does it continues correctly after the teletransportation?

Sadly no, the hero's is completely reset when moving between layers.  As a result, whatever object he may be carrying will vanish as well.

I believe that you should consider making an actual ladder entity similar to the stairs sensor, except that it will not make a stepping sound, and that the player will still be able to control the hero while walking on it.  Its only purpose would be moving the hero between two given layers.  Just like the teletransporters, double-clicking on it would allow you to set an origin layer and a destination layer.
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/

In old versions, there was a specialized type of sensors to change the layer of the hero when activated. I removed them because it was very easy to script.

If you set up the sensor metatable like this, then all sensors whose name is prefixed by "layer_down_sensor" or "layer_up_sensor" will change the layer without any code needed.

I have not tested it, but probably there will not be problems when changing layers with a custom sword or custom carried entities (if an animation fix is used).
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Alright, I edited the bridges tutoriaal page I made.  It now states that the method I used will reset the hero's behaviors because the game assumes the hero is switching maps even though he is not.  I am also confused on the quest_manager.lua file a little.  I copied the script into my quest, and placed two sensors on the map in the same place as my old sensors and gave them both the names you specified but the hero did not change layers.
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/

Did you call the quest_manager initialization code at some point? (From main.lua normally)

I suggest a button or arrow to return to the main page of your website.
http://solarus_resource.site88.net/tutorial/bridges.htm

It might be annoying for some to have to edit the URL to return to the main page. Also, the pink text is a bit much on the eyes. It is hard to look at and the red would be more pleasant on the eyes too if it was a bit darker.

Great tutorial though!  :D


June 07, 2016, 07:43:06 PM #8 Last Edit: June 07, 2016, 08:04:09 PM by Diarandor
I was thinking that if you use hero:set_position(...) with a sensor (instead of hero:teleport(...) or using a teleporter), to change the layer, maybe there is no reset issue for the sword and carried entities.

I cannot test it this week since I am too busy at work.

Edit: another advantage of using sensors is that you do not have width restrictions (due to the non-resizable destinations). So I encourage you to try it. The code for the map script should be something similar to this code (just adapt it to make it work, I am not with my computer so I cannot test it):

local map = ...
function up_sensor_name:on_activated()
  local h = map:get_hero()
  local x, y, layer = h:get_position()
  local sx, sy, slayer = self:get_position()
  if layer == slayer then
    h:set_position(x, y, layer + 1)
  end
end

(and similar code for the sensor that sends you to a lower layer).
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

June 07, 2016, 07:58:06 PM #9 Last Edit: June 07, 2016, 08:10:40 PM by ffomega
Quote from: Zefk on June 07, 2016, 07:32:30 PM
I suggest a button or arrow to return to the main page of your website.
http://solarus_resource.site88.net/tutorial/bridges.htm

It might be annoying for some to have to edit the URL to return to the main page. Also, the pink text is a bit much on the eyes. It is hard to look at and the red would be more pleasant on the eyes too if it was a bit darker.

Great tutorial though!  :D

I agree with you :3  But don't worry, once I have a couple more tutorials uploaded, I do plan on putting up the actual main page for you to navigate between pages.  The only reason it's not linked to yet is because I didn't think that two tutorials would require a contents page or a return link :)

Stay tuned though <3
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/

Quote from: Christopho on June 07, 2016, 06:34:44 PM
Did you call the quest_manager initialization code at some point? (From main.lua normally)

Alright, I managed to get the script to work, but for me (since I am not a scriptor) had a bit of trouble figuring out how to get it to work right.  Now it does, I will put together a new tutorial just for this.  But it will take a little time to get it edited on my page.

I have a new issue though that I am unsure is my fault or the editor.  I placed a bush down and if I try to interact with it in any way, the game crashes and throws an error message:

"Attempt to read a surface that doesn't have pixel buffer in RAM"

This only happens on the green bush.  The purple and yellow bushes work fine, as do the vases.
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/

The bridges tutorial has been updated to include Christopho's suggestion for using sensors.  I hope it is informative to you all :)

Happy mapping!
My tilesets page can be found here:
http://absolute-hyrule-tutorials.solarus-games.org/