Page 1 of 1
autoscroll.lua
Posted: Sat Oct 19, 2019 1:26 am
by Glixcor
I'm wanting to put an autoscroll on my level, but no way I'm getting it, I saw that without lua it only works at the beginning of the level, but I put the autoscroll on Level - Start, Autostart Event on, and I fall out. If I put any value above 0.000000000014550 at Horizontal Speed, less of that, without autoscroll, and I'm here because I want help on how to use this autoscroll.lua, I don't want to put an autoscroll in the beginning, I wanted to enable autoscrolls using Collectable Triggers, meaning I pass in the right place at the level I want, and autoscroll starts just as I pass and, for example, disappears a block using Layer visibility in Events, but since I am told that by Autoscroll section does not work if it is in the middle of the level, I was wondering how to use this autoscroll.lua file to do this, I already tried to open it with notepad, but it appears a lot of weird words. What do I do?
Re: autoscroll.lua
Posted: Sat Oct 19, 2019 5:51 am
by Emral
The handbook has usage instructions (you can find it in the root directory of your smbx2 installation).
The simplest way to use it in your scenario is the following:
Load the library:
local autoscroll = require("autoscroll")
Use onEvent so that the collectible triggers can define when a scroll starts. Then begin scrolling until the edge of the section.
function onEvent(eventName)
if eventName == "FIRST AUTOSCROLL EVENT" then
autoscroll.scrollRight(1.5)
elseif eventName == "SECOND AUTOSCROLL EVENT" then
autoscroll.scrollDown(1)
end
end
Smbx fills in eventName as the name of a triggered event, so you just have to make sure the event's names and the string in quotation marks for each triggered piece of code match.
The number in brackets is the speed. scrollLeft and scrollUp exist too.
For diagonal scroll, you need to use scrollTo, where you provide the coordinates of the lower left corner of where the scrolling should end. I think the order of parameters for scrollTo is on the handbook. If not, let me know if you struggle to use it and I'll leave another reply when I have access to smbx2.
Re: autoscroll.lua
Posted: Fri Oct 25, 2019 11:09 pm
by Glixcor
I'm not really understanding how to do this, I take the autoscroll.lua that SMBX2 already exists, and edit it the way I want, and move to my level folder? Or do I create a Lua file, if I have to create, then how do I create lua? And how do I put these codes where you spoke? Have to edit through notepad? What I have to do? From the manual I still do not understand.
Re: autoscroll.lua
Posted: Sat Oct 26, 2019 4:32 am
by cato
In PGE editor, move over the subwindow "Script" go over the " Lunalua scripts " to generate a " Level Script ( Lunalua ) ".
Copy the code in the script and change the "FIRST AUTOSCROLL EVENT" and "SECOND AUTOSCROLL EVENT" into what you named in the level.
It would be best if you use the Visual Studio Code instead of notepad. It is completely free and user-friendly with coloured text.