Setting up autoscroll to work in a specific section

Need help with any SMBX game-related issues? Ask your questions here.

Moderator: Userbase Moderators

SuperStache
Shy Guy
Shy Guy
Posts: 7
Joined: Fri Jul 05, 2024 8:53 pm
Flair: Food Fanatic
Pronouns: he/him
Contact:

Setting up autoscroll to work in a specific section

Postby SuperStache » Mon Jul 29, 2024 9:58 pm

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?

deice
Rocky Wrench
Rocky Wrench
Posts: 618
Joined: Fri Jul 23, 2021 7:35 am

Re: Setting up autoscroll to work in a specific section

Postby deice » Tue Jul 30, 2024 7:01 am

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

SuperStache
Shy Guy
Shy Guy
Posts: 7
Joined: Fri Jul 05, 2024 8:53 pm
Flair: Food Fanatic
Pronouns: he/him
Contact:

Re: Setting up autoscroll to work in a specific section

Postby SuperStache » Tue Jul 30, 2024 10:55 pm

Thanks, that worked wonderfully! Really appreciate the help.


Return to “Help and Support”

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari