Escape Sequence Levels?

General discussion about Super Mario Bros. X.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on-topic/appropriate?
-Are you posting in the right forum/following the forum rules?
Sky-Streamer
Goomba
Goomba
Posts: 4
Joined: Sat Aug 31, 2019 2:19 pm
Flair: Disease is just drugs without consent
Chat Username: Skyler

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!

User avatar
Cedur
Blue Yoshi Egg
Blue Yoshi Egg
Posts: 4831
Joined: Tue Jun 28, 2016 10:14 am
Flair: Save climate, cut fridays for whole-week future
Current Project: various playthroughs and tests

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
Image

Supports: show
Image
Image
Image
Image

Image

Still using the legacy editor? Get SMBX2 and PGE, it will improve your experience significantly. Here's why.

iphtechnologies wrote: NEO super mario world x is a really nice game. This Episode is 2,7 GB large at the moment.That`s crazy!
Please find similar post:
[ads]

If you're not smart enough to plan ahead, then DOOM ON YOU!

User avatar
Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 7566
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Escape Sequence Levels?

Postby Enjl » 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
ImageImageImageImage
ImageImageImageImageImageImage


Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests