Rumia's Lua Abominations

Status
Not open for further replies.
That's what I've been doing, but the problem is the thing I'm working on relies on the fact that you only have 1 HP, also I want the character to die when they hit the ground too hard or something like that, is that even possible with lua though?
 
That's what I've been doing, but the problem is the thing I'm working on relies on the fact that you only have 1 HP, also I want the character to die when they hit the ground too hard or something like that, is that even possible with lua though?

Well, if the character has only 1 HP, then how can they take any falling damage without dying? As for damaging them when they actually hit the ground rather than when they accelerate past a certain speed, you could store variables in the player mobj - let's call them mo.lastonground and mo.lastmomz - that record P_IsObjectOnGround(mo) and mo.momz and update themselves only at the end of your hook, so they're effectively copies of those values from one tic ago. Then, you could check if P_IsObjectOnGround(mo) is true this tic, mo.lastonground is false (so the player was in the air last tic), and mo.lastmomz is a large negative number, and if they are, damage the player.
 
I think you can also use MFE_JUSTHITFLOOR as eflag (it does... its name, it's only present when the object just hit the floor and gets removed next tic); and do what 742mph said about mo.lastmomz.
 
Well, if the character has only 1 HP, then how can they take any falling damage without dying?
What if I told you that that was the whole point? *Insert evil laugh here*


Also it works flawlessly, thank you both!
 
Last edited:
With the advent of Zone Builder, I am now able to create maps! Seeing as I have no experience with mapping (Though I am slowly learning how things work), I require assistance with lua in mapping.

How would I go about making something that triggers the level to end if your health is below a certain amount?
 
I'm back and with yet more questions, yaaaaay!

Is there a way to turn off water skimming while spinning into water, and if so, how?

and secondly, is there a way to turn off super flight as Sonic? I have a feeling that turning off the SF_SUPER flag would be involved.
 
For the first question, to my knowledge there is no way to do this, save for recoding spindash in Lua completely.

For the second, you could try to use the JumpSpinSpecial hook to overwrite that ability when super. Not sure if it'll work, but worth a shot.
 
For the second, you could try to use the JumpSpinSpecial hook to overwrite that ability when super. Not sure if it'll work, but worth a shot.

It won't. JumpSpinSpecial won't overwrite it because it's in the wrong part of the source code for that to be possible.
 
So I'm trying to make a script that allows the player to fire the boss laser with A_Boss1Laser. However, every time I run the code here:
Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo.skin ==  "sonic"
			player.ability2 = CA2_NONE
			if (player.cmd.buttons & BT_USE)
				"A_Boss1Laser(MT_LASER)"
			end
		end
	end
end)
it comes up with WARNING: lasertest.lua:6: attempt to call a number value
Hook removed.

clearly this script has no numbers in it, except MT_LASER which has a thing number but MT_LASER is supposed to substitute for that.

If I remove the quotes around A_Boss1Laser, it ends up spitting out the same error and depending on which version of the script I use when trying to impliment it into the megamari level lua code (from S_Quickman2 edited by me to specifically use this), it either breaks EVERY mobj in the game as soon as I try using the key (when using no quotes), or it gives the same error as before when using it (when using quotes).
 
clearly this script has no numbers in it, except MT_LASER
Exactly. MT_LASER is just a simple number. You should replace MT_LASER with the player's object, so it should look something like this:
Code:
addHook("MobjThinker", function(playermobj)
    local player = playermobj.player
    if playermobj.skin == "sonic"
        player.ability2 = CA2_NONE
        if player.cmd.buttons & BT_USE
            A_Boss1Laser(playermobj)
        end
    end
end, MT_PLAYER)
Untested, but I don't see why it shouldn't work. Though if you only plan on doing something for when holding spin, you might want to try out the SpinSpecial hook instead.
Edit: Also, looking at the source code for A_Boss1Laser, make sure to set the player's object's "target" variable to an object first, otherwise it won't do anything.
 
Last edited:
Heh, I thought people had stopped using MT_ constants as mobj_t arguments ages ago...

From the wiki description for mobj_t:

"This is not to be confused with an Object type (e.g. MT_PLAYER) – these are just constants representing Object type numbers, and will not be accepted in functions requiring mobj_t variables (e.g. P_SpawnGhostMobj(MT_PLAYER) will cause Lua to give an error)."

Also, why are you trying to put quotes around A_Boss1Laser and everything you put in it anyway? If you're thinking of THIS bug report, the quotes fix I mentioned there only applies to assigning an action to a state, which accepts strings and can then convert them to the actual action functions themselves. It doesn't work for calling A_Boss1Laser on its own, because then it suddenly stops being an action and now you're just trying to call a string with the contents "A_Boss1Laser"! (or rather, you made a string with the contents "A_Boss1Laser(MT_LASER)" which means it does absolutely nothing even without the wrong type argument problem =V)

Either way, you're kind of stumped, A_Boss1Laser was just not meant to be used as a standalone thing anyway, it's meant to be a state's action in the first place.
 
Last edited:
Hello again! I'm having trouble with SLADE, I'm using version 3.1.1.3 and I just upgraded to Windows 10 not too long ago. When I installed the latest version, I started getting asked every time where the main iWAD would be located and also asking where to store temp files. I can not find a single bit of information inside the editor's preferences, settings, or otherwise on how to fix this. Does anybody know of a solution?
 
I think the IWAD for SRB2 is srb2.srb, and simply just tell it where to store temporary files when it asks for it. (Like a "temp" folder inside Slade's installation directory, perhaps. Be warned that it deletes all files in the folder when cleaning up temporary files or something like that, so I'd advice making a new "temp" folder just for Slade.)
 
I've done this, the thing is, it asks for it any time I reopen the program no matter how many times I direct it.
 
Then it might be time to un-install and re-install it (whether it be from the installer or the 7z archive, preferably try both if the one you try first doesn't work). If that doesn't fix it either, perhaps try installing an older version.
 
Okay so for some reason, there was a file named "portable" in the installation folder and after deleting the file, SLADE stopped asking for first-time setup details every time it was opened, I have no clue why that was there but ok.
 
Status
Not open for further replies.

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

Back
Top