Rumia's Lua Abominations

Status
Not open for further replies.

Rumia1

Backseat Developer
I have decided to make this thread for when I can't figure things out, probably because I did something stupid

First off I'm trying to edit the waiting animation's frame durations for a certain character, however it tells me that I'm trying to index a global variable "state" and I have no clue how to work fix that.

Here is my code:
Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo.skin == "sonic"
			if player.mo.state == S_PLAY_TAP1
				state.tics = 1
			elseif player.mo.state == S_PLAY_TAP2
				state.tics = 3
				state.nextstate = S_PLAY_STAND
			end
		end
	end
end)

Also please tell me if I'm going about this in the wrong way, I'm just starting LUA and I feel as though I either know exactly what I'm doing or I don't know at all and I can't figure out why
 
Last edited:
Use player.mo.tics and player.mo.nextstate instead. Those variables belong to the player's mobj.

Also in its current state, you'll get stuck at S_PLAY_TAP2, since it'll constantly check itself and set its tics to 3, never advancing to the next state you made, S_PLAY_STND(NOT "STAND").

Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo.skin == "sonic"
			if player.mo.state == S_PLAY_TAP1
				player.mo.tics = 1
			elseif player.mo.state == S_PLAY_TAP2
				if player.mo.tics > 3
					player.mo.tics = 3
				end
				player.mo.nextstate = S_PLAY_STND
			end
		end
	end
end)

I tried to do some minor modifications to help you, but something tells me this isn't what you want.

(also why not just use SOC to edit the state durations, it's easier)
 
I would use SOC to edit the durations but then you end up with EVERY character added using the same durrations, and I like my mods to be as compatible with everything else as possible.

And as you said, sticking on frame 2 isn't really what I want, but thank you for fixing the global variable issue. For now, I suppose I can just use SOC.
 
RISE FROM THE GRAVE and such

I have a new challenge, is it possible to get if the player has analog mode enabled and is there a way to turn it on and off using LUA?

From what I've F3'd from the wiki, there is none but hopefully someone could prove me wrong.

EDIT: Also, is there any way to check if the player has just killed an enemy (excluding bosses)?
EDIT2: And one last thing, is there a way to give the player ring attraction without using an attraction shield?
 
Last edited:
You can check analog mode by checking (mo.player.pflags & PF_ANALOGMODE), though for setting it it's probably a better idea to use COM_BufInsertText(mo.player, "analog 0/1").
 
On a more practical note, how would you go about making a GFZ3 Eggman laser? Not just the single sausage that everything else fires, but like the smooth, actually laser-like laser that he shoots in 2.1.
 
The Eggmobile uses A_Boss1Laser to do a laser trail and all.
There is no documentation yet on the action, but I think it will be executed every tic of the frame where it is used. (For instance the EggMobile calls this action for 45 tics to fire a continuous laser of 45 tics too.)

Hope that helped.
 
I call this thread to rise once again!

This time I have no clue what I'm doing so I haven't the slightest idea what I'm even doing wrong

Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if (player.mo and player.mo.skin == "sonic")
			if not player.mo.hovertimer
				player.mo.hovertimer = 2*TICRATE
			end
			if P_IsObjectOnGround(player.mo)
				player.mo.hovertimer = 2*TICRATE
				player.charability = CA_FLOAT
			end
			if player.mo.hovertimer == 0
				player.charability = CA_NONE
			end
			if  (player.pflags & PF_JUMPED)
			and (player.pflags & PF_JUMPDOWN)
				player.mo.hovertimer = $1 - 1*TICRATE
			end
		end 
	end
end)

I understand that this might be slightly easier to make work if I used AbilitySpecial, but again, I have no clue what I'm doing in the first place. The script is supposed to be a timed hover, making you fall after a short amount of time of using the ability.
 
"player.mo.hovertimer = $1 - 1*TICRATE"

This will subtract TICRATE from a timer that only has a maximum of 2*TICRATE every tic, meaning you'll only get 2 tics of hovering time. If you want the player to hover for 2 seconds, just subtract 1 from the timer every tic.
 
That's pretty much what I wanted but I wanted it to allow the player to float for 2 seconds. However, this code doesn't seem to work at all, like, it still makes the player able to float for as long as they want, and something's telling me that something isn't triggering. Checking if the player had thokked didn't work and this isn't working either, so I'm curious what I'm doing wrong.
 
I think I've found another problem. "not player.mo.hovertimer" is true both if the hovertimer variable hasn't been initialized yet and if the variable is zero. That means whenever hovertimer runs out, the game resets it to 2*TICRATE before the player can lose the ability to hover. To fix this problem, try replacing "if not player.mo.hovertimer" with "if player.mo.hovertimer == nil".
 
Alright, thank you for your help! I eventually found another problem with the script, I was checking if jump was pressed the last tic, making it so that even if you hadn't pressed jump after jumping, the timer would still tick down, making it nearly impossible to actually use the move, I fixed this by using if (player.pflags & PF_JUMPED) and (player.cmd.buttons & BT_JUMP) instead and it works now.
 
Alright, I'm back again and this time I'm asking about something non-lua! This time I'm wondering how to animate MD2 models in misfit 3d since that's what the wiki reccomends for MD2 modeling (I suppose?) however no one's put up a guide for this sort of thing.

First things first I would like to know how to properly rig a model, I've tried in MilkShape and that went nowhere quickly (as most things have). Secondly I'd like to know what sort of rules there are in maybe naming frames and what order they go in, seeing as no one on the internet seems to have this information (or any information at all other than "MD2 is a file type from Quake II.")

Thank you in advance!
 
Hello again!

I'm tryig to make a script that keeps certain non-vanilla characters from breaking while using some new animations, but now it's breaking the script without giving an error message.

here's the code i'm trying to use
Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo
			if player.mo.state == S_PLAY_FALL1
			and not player.mo.skin == "amy"
			and not player.mo.skin == "jasper"
			and not player.mo.skin == "hinote"
			and not (player.pflags & PF_JUMPED)
			and not (player.pflags & PF_THOKKED)
				player.mo.state = S_PLAY_RUN1
			end
		end
	end
end)
 
I can't see any problems right off the bat, but to be safe, I would change what you've got to this:
Code:
addHook("ThinkFrame", do
     for player in players.iterate
         if (player.mo) and (player.mo.valid)
             if (player.mo.state == S_PLAY_FALL1)
             and not (player.mo.skin == "amy")
             and not (player.mo.skin == "jasper")
             and not (player.mo.skin == "hinote")
             and not (player.pflags & PF_JUMPED)
             and not (player.pflags & PF_THOKKED)
                 player.mo.state = S_PLAY_RUN1
             end
         end
     end
end)
I added "and (player.mo.valid)" so the script doesn't try to interact with any player objects that have previously been removed, and I sprinkled some extra parentheses around to make sure certain conditions are all evaluated exactly how they should be. Let me know how it works.
 
I'm back once again with a new problem

Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if (player.mo) and (player.mo.valid)
		and not (player.mo.skin == "marisa")
		and not (player.mo.skin == "alice")
		and not (player.mo.skin == "mario")
		and not (player.mo.skin == "luigi")
		and not (player.mo.skin == "modernsonic")
		and not (player.mo.skin == "sonicre")
		and not (player.mo.skin == "tailsre")
		and not (player.mo.skin == "knuxre")
				player.thrustfactor = 4 + (1/2)
				player.accelstart = 140
				player.acceleration = 40
				player.spinitem = 0
				player.revitem = 0
				player.mindash = 23 * FRACUNIT
					if (player.mo.skin == "sonic")
						player.charability = CA_NONE
					end
					if gamemap == 24
						player.normalspeed = 36 * FRACUNIT
					end
					if (player.powers[pw_super])
						if (player.mo.skin == "tails")
							player.actionspd = 130 * FRACUNIT
						elseif (player.mo.skin == "knuckles")
							player.actionspd = 40 * FRACUNIT
						end
				if gametype == GT_COOP
				and not gametype == GT_RACE
				and not gametype == GT_MATCH
				and notgametype == GT_TEAMMATCH
				and notgametype == GT_TAG
				and not gametype == GT_HIDEANDSEEK
				and not gametype == GT_CTF
					player.runspeed = 30 * FRACUNIT
					player.normalspeed = 36 * FRACUNIT
					player.maxdash = 50 * FRACUNIT
						if (player.powers[pw_super])
							player.normalspeed = 42 * FRACUNIT
							player.acceleration = 50
							player.thrustfactor = 6
						end
					end
				end
				if gametype == GT_RACE
				or gametype == GT_MATCH
				or gametype == GT_TEAMMATCH
				or gametype == GT_TAG
				or gametype == GT_HIDEANDSEEK
				or gametype == GT_CTF
				and not gametype == GT_COOP
					player.thrustfactor = 4 + (1/2)
					player.accelstart = 140
					player.acceleration = 40
					player.spinitem = 0
					player.revitem = 0
					player.mindash = 25 * FRACUNIT
							if (player.powers[pw_super])
								player.acceleration = 50
								player.thrustfactor = 6
							end
						if (player.mo.skin == "sonic")
							player.runspeed = 30 * FRACUNIT
							player.normalspeed = 40 * FRACUNIT
							player.maxdash = 60 * FRACUNIT
								if (player.powers[pw_super])
									player.normalspeed = 41 * FRACUNIT
								end
						else
							player.runspeed = 26 * FRACUNIT
							player.normalspeed = 30 * FRACUNIT
							player.maxdash = 55 * FRACUNIT
						end
					end
			if (player.mo.state == S_PLAY_FALL1)
             and not (player.mo.skin == "amy")
             and not (player.mo.skin == "hinote")
             and not (player.pflags & PF_JUMPED)
             and not (player.pflags & PF_THOKKED)
                 player.mo.state = S_PLAY_RUN1
            end
		end
	end
end)

For some odd reason, this isn't working properly in multiplayer. When I use this in co-op, it still uses the stats for every other gamemode
 
It's because you have "notgametype" twice by mistake in part of your massive (and rather redundant) check for all the other gametypes. And by that I mean you omitted the space between "not" and "gametype" twice
 
Last edited:
Two posts in the same day, woo!

I'm curious about how I would go about implimenting falling damage, the way I've been going about it so far is when the character falls faster than 22 * FRACUNIT, they die, this is impractical but it works as a temporary solution. Does anyone have any ideas on how this could be made more like actual falling damage?
 
Two posts in the same day, woo!

I'm curious about how I would go about implimenting falling damage, the way I've been going about it so far is when the character falls faster than 22 * FRACUNIT, they die, this is impractical but it works as a temporary solution. Does anyone have any ideas on how this could be made more like actual falling damage?

You could hurt them with P_DamageMobj instead of killing them.
 
Status
Not open for further replies.

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

Back
Top