Escape Sequence Levels?

General discussion about Super Mario Bros. X.

Moderator: Userbase Moderators

Sky-Streamer
Goomba
Goomba
Posts: 4
Joined: Sat Aug 31, 2019 2:19 pm
Flair: Disease is just drugs without consent

Escape Sequence Levels?

Postby Sky-Streamer » Tue Nov 05, 2019 7:35 am

Hello! I'm currently wanting to create some sort of timer for an escape sequence after an event in a level, similar to the escape sequences in Wario Land 4 and Pizza Tower. Are there any episodes or levels with this mechanic, and does anyone have any advice on how to make a timer and escape sequence in a level? Thank you!

Cedur
Link
Link
Posts: 7073
Joined: Tue Jun 28, 2016 10:14 am
Flair: I'm gone, for chess and minesweeper
Pronouns: he/him

Re: Escape Sequence Levels?

Postby Cedur » Thu Nov 07, 2019 4:03 pm

Check out on how to implement a timer in SMBX2 (leveltimer.lua is included by default). Look on Youtube for general Lua advice or maybe wait for an SMBX2 dev to post here

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Escape Sequence Levels?

Postby Emral » Fri Nov 08, 2019 1:32 pm

Making a timed event is as simple as triggering an event in the editor (i.e. making some sort of action like hitting a block or killing an enemy trigger an event), and having that event trigger another event after a certain delay (the bottommost function, in the SMBX2 editor).

For a more traditional timer (in SMBX2PAL), go to Scripts -> level local (luna.lua) in the SMBX2 editor, and type in the following code:
local timer = require("timer")
timer.activate(500)

This will activate a timer like in the traditional marios, set to 500 seconds. You can change the number of seconds by changing the number in parentheses. You can also trigger this timer from a SMBX event. Say, for example, if you have an event called "ActivateTimer" in the editor. This event doesn't need to do anything in the editor. But in the code we can do something when it gets activated. The code for that would look like this:

local timer = require("timer")
function onEvent(eventName)
if eventName == "ActivateTimer" then
timer.activate(500)
end
end

Same as before, but this time we only activate it once the event is triggered. onEvent basically is for pieces of code that should run when any SMBX event is triggered. Using the if statement we can narrow it down by the name of the event that's been triggered.

For more fancy secondary effects, you will have to experiment with events or lunalua.
You can find a guide on Layers and Events in this thread: viewtopic.php?f=35&t=10507
And the (older) documentation for lunalua here: https://wohlsoft.ru/pgewiki/Category:LunaLua_API
For the lunalua documentation, I recommend starting at the "How To" section if you haven't programmed much in the past. Also, stuff like timer.lua isn't documented there as we're moving the documentation elsewhere, but the new one isn't quite ready yet.
I've documented the new features on this handbook for the time being. Here's a link directly to the section about the timer: https://docs.google.com/document/d/1uOd ... 1h3s6vmjm7


Return to “General”

Who is online

Users browsing this forum: Amazon [Bot] and 5 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari