Under what circumstances is PF_SPINNING removed?

Status
Not open for further replies.

Lach

he/him
Kart Krew™️
Judge
I'm using a ThinkFrame hook so that under a certain condition, PF_SPINNING is added to the player flags.

Code:
	if player.cdspin
		player.mo.state = S_PLAY_ATK1
		player.pflags = $1 + PF_STARTDASH
		player.pflags = $1 + PF_SPINNING
	end

However, when I open devmode, I see the PF_SPINNING indicator alternating between true and false every tic, even when the condition is constantly true. Why is PF_SPINNING being removed?

EDIT: For some reason, checking for a missing player flag first before adding it fixed the issue. I'm still curious as to what the issue was, though. Does adding a player flag when it's already added remove the flag?
 
Last edited:
Try using $1|PF_STARTDASH instead of $1 + PF_STARTDASH and likewise for PF_SPINNING, using | (known as bitwise "or") instead of + makes sure adding the flag doesn't do something weird if the flag was already set.
 
Oh, okay. I'm not too familiar with the bitwise operators yet; guess this is the opportunity to learn them. Thank you!


Since I don't want to make two threads in one day, is there any way for Lua to detect the forward button apart from cmd.forwardmove? It doesn't seem to register it while the player is in the S_PLAY_PAIN state.
 
Yup, that's intentional. It appears the commands recieved from the keyboard aren't processed in the pain frame.

You could get around this by creating a new state with the same sprite and frame as S_PLAY_PAIN and setting the player to that. It'll break the hardcoded no-key-presses stuff, but the player will start flashing early, so it's up to you if you want to make that tradeoff.
 
Yeah, I figured it was intentional, but I wanted to see if there was another button indicator that I wasn't aware of before I tried using custom states. Thank you though!

Am I correct in assuming that defining a state's sprite parameter as PLAY as well as the frame of my choice will automatically use the frame from the character's skin? (I'm about to go to bed so I can't test it yet.)
 
Yes it would, assuming you're using it on the player or another object with a skin set. SPR_PLAY is basically a special sprite prefix that swaps itself with the sprite set of the object's current skin.
 
Okay sweet, so I don't have to add an unnecessary SPR set. Thank you both for your help on such noob questions!
 
Status
Not open for further replies.

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

Back
Top