Lat's Random Lua questions

Status
Not open for further replies.

Lat'

Absolute territory where
Kart Krew™️
Title... I don't have much to explain.
Would help preventing Lua stuff from happening in there.
 
Eep, decided to turn this thread into my random lua questions thread, that will avoid me from creating one every 2 weeks.
Anyway, this week's questions are:
How do I add emeralds flags for co-op/SP... (And I mean, without having to touch an actual emerald)? Because the (emeralds) variable happens to be read only =/
And, is it possible to properly "stop" the timer?
 
Like what kind of flags? For having a guaranteed Good Future for having all the emeralds, you could open a hook with
"if all7emeralds == 1" or something - This doesn't seem to work for me, try "if emeralds == 127" for all the emeralds.

For specific emeralds you'll use the "emeralds" flag and each number is a specific emerald.

1 = Green
2 = Purple
4 = Blue
8 = Turquoise
16 = Orange
32 = Red
64 = Grey.

For specific sets of emeralds, you'll add the numbers together.
Let's say you want something to happen ONLY if you have the Green and Blue emerald in your inventory. You would use emeralds == 5
This will only happen with those two emeralds, if you're missing either or have any of the other emeralds in your inventory., It won't activate
 
Last edited:
Barrels O' Fun, it sounds like Lat wants to change which emeralds the player has, not just get information about them. I don't know if that's possible without having the player collect an emerald object, since there doesn't seem to be a Lua function for it, but maybe there's a way. As for stopping the timer, you could just subtract 1 from the global leveltime variable every tic, but that wouldn't work if leveltime turns out to be read-only as well, and even if it did work, it would screw up a bunch of hardcoded effects that depend on leveltime continuously increasing (for example, super characters wouldn't lose rings while the timer was stopped).
 
Barrels O' Fun, it sounds like Lat wants to change which emeralds the player has, not just get information about them. I don't know if that's possible without having the player collect an emerald object, since there doesn't seem to be a Lua function for it, but maybe there's a way. As for stopping the timer, you could just subtract 1 from the global leveltime variable every tic, but that wouldn't work if leveltime turns out to be read-only as well, and even if it did work, it would screw up a bunch of hardcoded effects that depend on leveltime continuously increasing (for example, super characters wouldn't lose rings while the timer was stopped).

Well if that's the case then I don't know.
On the other hand, leveltime may be read-only, but realtime isn't.
If Lat were to count how long the cutscene takes,
All Lat needs to do is this
player.realtime = $1 - (Centiseconds)*TICRATE/100 before the hud reappears.
 
Last edited:
Okay, I got the timer thingy working ... by my ways, though, I'm still clueless about adding emerald flags without actually having to spawn an emerald. =/
 
Could you elaborate? Like what do you want to happen? What happens that adds the emeralds?
 
Last edited:
Actually, they're for the Sonic CD Special Stages thingy; I just want the player to get the EMERALDn flag when destroying the last UFO, because spawning an emerald still shows it for a tic since it takes one frame for Lua to make it disapear.
 
Well I don't know much more about LUA but you could create invisible and silent items with the spawn states being S_CEMG1-7, and have your script spawn those on the player instead.
 
No, your best bet is to actually spawn the emeralds themselves (read: the object types MT_EMERALD1 to MT_EMERALD7) at the player's position and just let them be collected. After all, nothing else in the game messes with the global variable "emeralds" as far as I can recall. Since Lua does not allow you actually modify that variable directly, you're kind of limited as to what you can do sadly.
 
Set the spawnstate of each of the Emeralds' sprites to a new state with sprite SPR_NULL, which - after a handful of tics - goes back to their original spawnstate. This prevents seeing them when they're immediately spawned but retains compatibility with placing them in maps.
 
As far as "stopping" the timer, you can modify player.realtime (in tics) to change what the HUD timer says, which will also be used when calculating bonuses/record attack times. The method I used in the Dumbventure 2.1 port was to store a variable somewhere (for the sake of this explanation, I'll call it timerAdjustment) that's set to 0 when the map loads, and constantly increment it by 1 when the timer should be stopped. Then in a ThinkFrame hook, constantly set player.realtime = leveltime-timerAdjustment.
 
Yay, I knew this thread'd be useful once more!

Basically, I'm trying to spawn an object when conditions are met and all...

Code:
local mobj = P_SpawnMobj(mo.x + mo.player.cmomx + mo.momx, mo.y + mo.player.cmomy + mo.momy, mo.z, MT_MOBJ)
            mobj.target = mo
            mobj.color = mobj.target.color
            mobj.angle = mobj.target.angle
            mobj.z = mobj.target.z
(Thrown in a MT_PLAYER MobjThinker Hook, if that matters)

But it has weird effects when the object needs to spawn and that the player is standing on a FOF, the object seems to spawn on the floor below the FOF... or the FOF's floor, whatever, and causes an awful sprite glitch that makes both the player and the spawned object disapear until the object disapears. Any idea on what I might've screwed up?
 
Is the object supposed to be repeatedly spawned every tic? Not sure what the whole script looks like, but that could be one thing to consider if it's not what you want.

No idea about the FOF issue though.
 
Yeah, the object is spawned at every tic, and it's intentionnal.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top