(2.4) Level Timer starting from Event

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Flarestripe
Spiny
Spiny
Posts: 29
Joined: Wed Jul 19, 2017 4:19 pm

(2.4) Level Timer starting from Event

Postby Flarestripe » Sun Aug 16, 2020 11:43 pm

I've been trying for at least 30 minutes, and I still can't figure out how to set a simple levek timer that starts AFTER an event.

Please help me (and the idiot of .Lua I am XD), someone.
I would GREATLY appreciate it pwp

(I understand that I'd have to put it "function onEvent" and set the event name there.
I just don't know what I need to put after that to make it ACTUALLY start the timer, with a certain amount of time.)

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

Re: (2.4) Level Timer starting from Event

Postby Emral » Mon Aug 17, 2020 12:25 am

Can you post the code you have so far?

Flarestripe
Spiny
Spiny
Posts: 29
Joined: Wed Jul 19, 2017 4:19 pm

Re: (2.4) Level Timer starting from Event

Postby Flarestripe » Mon Aug 17, 2020 12:39 am

Ok
(I kinda figured it out, I THINK. The timer works and everything, it just isn't visible. Besides that, everything SEEMS ok-?)

(I know it WORKS at least, because it was only set to 30, and killed me after that.
It also plays that little "Hurry Up!" Sound, which I kinda wanna remove, if you'd also be able to help me with that.

Oh, ALSO, if I make the timer start through the in-editor "Timer" in the Level Settings, it shows up fine. It's ONLY when I start it by the event that it won't show up)
Image

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

Re: (2.4) Level Timer starting from Event

Postby Emral » Mon Aug 17, 2020 2:22 am

The hurry up sound will always play when the timer has gone below a configurable timer.hurryTime variable. You can set that to a negative number if you don't want it to play.
Calling .activate used to be enough, but at some point the timer code got merged into hudoverride and a secondary check was added it seems. Try loading hudoverride and setting hudoverride.visible.timer to true.

Flarestripe
Spiny
Spiny
Posts: 29
Joined: Wed Jul 19, 2017 4:19 pm

Re: (2.4) Level Timer starting from Event

Postby Flarestripe » Mon Aug 17, 2020 2:50 am

What exactly do you mean by "calling"?
I'm gonna guess you don't mean to add it is a local thing, but to instead do a kind of "call" function / action?
It that's the case, how would I do that?
(Thank you for all the help today and yesterday, I'm really sorry if I'm getting tiring. XD)

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

Re: (2.4) Level Timer starting from Event

Postby Emral » Mon Aug 17, 2020 2:54 am

You're already calling activate. timer.activate(int seconds).
Function definition (declares a sequence of code):
function onEvent(eventname)
end

Function call (executes a sequence of code):
timer.activate(500)

Like I said, that USED to be enough, but now you need to load hudoverride and also set the hudoverride.visible.timer variable to true.

Flarestripe
Spiny
Spiny
Posts: 29
Joined: Wed Jul 19, 2017 4:19 pm

Re: (2.4) Level Timer starting from Event

Postby Flarestripe » Mon Aug 17, 2020 3:01 am

So, like...
Ok, I'm just confused a bit now. PwP
Can you please just tell me what I need to type for the "calling and setting true" parts?
I'll understand better-
(Again, I'm really sorry that I don't know Lua well XD)

Added in 5 minutes 12 seconds:
Also, I just realised that I was wrong about "EVERYTHING" with the timer working normally.
I'm using those clocks that add time (the ones that someone said you made, and then you corrected them), they don't add any time to the timer IF I do it with the Event Timer. It kills me after 30 seconds no matter what, without any time being added (once again, they work fine for the Level Settings' timer)

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

Re: (2.4) Level Timer starting from Event

Postby Emral » Mon Aug 17, 2020 3:13 am

You are already calling the function. NO NECESSARY CHANGE THERE.
Just load hudoverride and set the timer visibility variable to true.
local hudoverride = require("hudoverride")
hudoverride.visible.timer = true

The level settings timer is identical to timer.lua's timer.

Flarestripe
Spiny
Spiny
Posts: 29
Joined: Wed Jul 19, 2017 4:19 pm

Re: (2.4) Level Timer starting from Event

Postby Flarestripe » Mon Aug 17, 2020 3:15 am

Oki, thank chu.
I just needed the "Local" line to fully understand. XD
Sorry for not understanding the first time
Thank you for all this help that you've given me.
I'm gonna go ahead and say I've gotten everything I need now to make the bulk of this Episode.
I'm definitely gonna make sure it's known that you helped me, and give you credit for it. (If you want that, I mean)

Added in 5 minutes 21 seconds:
Well...
Ok, no, I still need help- pwp
This happens when I try to run the code by starting the stage.
Which part did I mess up now-? XD
(My guess is that maybe I need to capitalize some letters in "hudoverride", like how "onEvent", and "onStart", and just basically every word after the 1st one is capitalized. But I'm also thinking maybe that's just so we can read it easier, idk-)

Image

Image

Added in 4 minutes 48 seconds:
Wait, I might have just realised what I did wrong-

Added in 2 minutes 24 seconds:
Nvm.
Now the timer never happens-
Idk why adding "hudoverride" would do that-

(Random question: is anyone as tedious to help as me-? XD
I'm sorry, either way, no matter your answer pwp)

Added in 9 minutes 14 seconds:
Ok, so...
Fixed something.
Timer HAPPENS now.
Still can't see it, and Timer NPCs still don't add to timer

Added in 1 minute 51 seconds:
Here's the CURRENT code, and this time, I'll just wait for what you tell me to do, so I both:
1. Don't break anything,
And
2. Don't make everything more confusing-
Image

Added in 3 minutes 1 second:
...
Nvm, I changed one thing-
...
And then it fixed itself entirely-

Added in 26 seconds:
...
Um...
...
Thank you for all the help, I'm sorry for the trouble and waste of your time-

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: (2.4) Level Timer starting from Event

Postby MrDoubleA » Mon Aug 17, 2020 6:53 am

Enjl wrote:
Mon Aug 17, 2020 3:13 am
You are already calling the function. NO NECESSARY CHANGE THERE.
Just load hudoverride and set the timer visibility variable to true.
local hudoverride = require("hudoverride")
hudoverride.visible.timer = true

The level settings timer is identical to timer.lua's timer.
If I remember correctly, hudoverride.visible.timer starts off as true, even if the timer isn't active. The reason the timer isn't always visible is just because it also checks for Timer.isActive().

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

Re: (2.4) Level Timer starting from Event

Postby Emral » Mon Aug 17, 2020 7:51 am

MrDoubleA wrote:
Mon Aug 17, 2020 6:53 am
If I remember correctly, hudoverride.visible.timer starts off as true, even if the timer isn't active. The reason the timer isn't always visible is just because it also checks for Timer.isActive().
Timer.activate sets timer_paused to false and timer_visible to true.
Timer.isActive() returns the opposite of timer_paused.
Timer.isVisible() returns timer_visible.
So, if you call activate, isActive and isVisible will always be true. So they cannot be what stands in the way of the timer showing. Meaning it has to be hudoverride.

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: (2.4) Level Timer starting from Event

Postby MrDoubleA » Tue Aug 18, 2020 8:59 am

Enjl wrote:
Mon Aug 17, 2020 7:51 am
MrDoubleA wrote:
Mon Aug 17, 2020 6:53 am
If I remember correctly, hudoverride.visible.timer starts off as true, even if the timer isn't active. The reason the timer isn't always visible is just because it also checks for Timer.isActive().
Timer.activate sets timer_paused to false and timer_visible to true.
Timer.isActive() returns the opposite of timer_paused.
Timer.isVisible() returns timer_visible.
So, if you call activate, isActive and isVisible will always be true. So they cannot be what stands in the way of the timer showing. Meaning it has to be hudoverride.
I tested just putting "Timer.activate(10)" in my own level, and it worked fine, even without hudoverride. Additionally, hudoverride.visible.timer returned true, even when the timer was not active.

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

Re: (2.4) Level Timer starting from Event

Postby Emral » Tue Aug 18, 2020 10:19 am

MrDoubleA wrote:
Tue Aug 18, 2020 8:59 am
Timer.activate sets timer_paused to false and timer_visible to true.
Timer.isActive() returns the opposite of timer_paused.
Timer.isVisible() returns timer_visible.
So, if you call activate, isActive and isVisible will always be true. So they cannot be what stands in the way of the timer showing. Meaning it has to be hudoverride.
I tested just putting "Timer.activate(10)" in my own level, and it worked fine, even without hudoverride. Additionally, hudoverride.visible.timer returned true, even when the timer was not active.
[/quote]
Do you know what might be causing the issue from earlier then?

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: (2.4) Level Timer starting from Event

Postby MrDoubleA » Tue Aug 18, 2020 10:45 am

Enjl wrote:
Tue Aug 18, 2020 10:19 am
MrDoubleA wrote:
Tue Aug 18, 2020 8:59 am
Timer.activate sets timer_paused to false and timer_visible to true.
Timer.isActive() returns the opposite of timer_paused.
Timer.isVisible() returns timer_visible.
So, if you call activate, isActive and isVisible will always be true. So they cannot be what stands in the way of the timer showing. Meaning it has to be hudoverride.
I tested just putting "Timer.activate(10)" in my own level, and it worked fine, even without hudoverride. Additionally, hudoverride.visible.timer returned true, even when the timer was not active.
Do you know what might be causing the issue from earlier then?
[/quote]

Only thing I could think of is another file doing something with hudoverride.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari