Page 1 of 1

Setting up autoscroll to work in a specific section

Posted: Mon Jul 29, 2024 9:58 pm
by SuperStache
I'm pretty new to writing lua scripts for my SMBX2 episode, so basically what I want to do is have autoscroll activate when I enter area 4 of my level. I have the following code in my local script:

local autoscroll = require("autoscroll")

function onEvent(scroll)
autoscroll.scrollRight(1, nil, 4)
end

There is an event trigger overlayed with the warp exit at the start of area 4 that is supposed to call the "scroll" event and run that code when Mario enters the room, but when testing the level, the autoscroll had already run and the camera was stopped at the far-right side of the room, so I'm guessing that means the code just ran at the start of the level. I'm clearly missing something here. Can anyone help me out?

Re: Setting up autoscroll to work in a specific section

Posted: Tue Jul 30, 2024 7:01 am
by deice
onEvent runs upon any event being activated, which includes the automatic basegame event that triggers at the start of a level. you're probably looking for this:

Code: Select all

function onEvent(e)
    if(e == "scroll") then
        autoscroll.scrollRight(1, nil, 4)
    end
end

Re: Setting up autoscroll to work in a specific section

Posted: Tue Jul 30, 2024 10:55 pm
by SuperStache
Thanks, that worked wonderfully! Really appreciate the help.