How to make it to work it gave the error "pseudo-variable out of range or not in assignment near '$' ?

SapphireTheGreat

Your average coder.
addHook("PlayerThink", function(player)
if player.mo and player.mo.skin == "h.r"
if player.pflags == $2|PF_STARTJUMP|PF_STARTDASH
player.mo.state = S_PLAY_JUMP
P_SetObjectMomZ(player.mo, 15*FRACUNIT)
P_SpawnThokMobj(player)
end
end)
 
Last edited:
addHook("PlayerThink", function(player)
if player.mo and player.mo.skin == "h.r"
if player.pflags == $2|PF_STARTJUMP|PF_STARTDASH
player.mo.state = S_PLAY_JUMP
P_SetObjectMomZ(player.mo, 15*FRACUNIT)
P_SpawnThokMobj(player)
end
end)

As far as I'm aware $2 isn't a thing. What you're probably looking for is $1. So change if player.pflags == $2|PF_STARTJUMP|PF_STARTDASH to if player.pflags == $1|PF_STARTJUMP|PF_STARTDASH.

In SRB2's Lua, using $1 in a variable assignment or comparison is a shorthand for the variable you're making the comparison with.
So typing if player.pflags == $1|PF_STARTJUMP|PF_STARTDASH is effectively the same as typing if player.pflags == player.pflags|PF_STARTJUMP|PF_STARTDASH.

On a sidenote I'm not sure if $1|PF_STARTJUMP|PF_STARTDASH is correct syntax. I could be wrong, but I believe it should be $1 & PF_STARTJUMP|PF_STARTDASH.
 
Last edited:
Lua:
addHook("PlayerThink", function(player)
   if player.mo and player.mo.skin == "h.r"
   if player.pflags == $1 & PF_STARTJUMP|PF_STARTDASH
       player.mo.state = S_PLAY_JUMP
       P_SetObjectMomZ(player.mo, 15*FRACUNIT)
       P_SpawnThokMobj(player)
    end
end)

This is what it's supposed to be like.
 
As far as I'm aware $2 isn't a thing. What you're probably looking for is $1. So change if player.pflags == $2|PF_STARTJUMP|PF_STARTDASH to if player.pflags == $1|PF_STARTJUMP|PF_STARTDASH.

In SRB2's Lua, using $1 in a variable assignment or comparison is a shorthand for the variable you're making the comparison with.
So typing if player.pflags == $1|PF_STARTJUMP|PF_STARTDASH is effectively the same as typing if player.pflags == player.pflags|PF_STARTJUMP|PF_STARTDASH.

On a sidenote I'm not sure if $1|PF_STARTJUMP|PF_STARTDASH is correct syntax. I could be wrong, but I believe it should be $1 & PF_STARTJUMP|PF_STARTDASH.
I'm an absolute buffoon and I couldn't be more wrong.
Okay I'm not aware of WHY it happens but seems like you cannot use pseudo-variables ($1) in this case for some reason. If someone else knows why I'd love to know but anyway:

Change $1 to player.pflags.

On a sidenote I'm not sure if $1|PF_STARTJUMP|PF_STARTDASH is correct syntax. I could be wrong, but I believe it should be $1 & PF_STARTJUMP|PF_STARTDASH.
I've went ahead and tested this out myself anyway (changing $1 to player.pflags) and I didn't run into any errors with either form, so I suppose it is correct syntax.

Although nothing really happened anyway?? I changed the skin name obviously but still didn't see anything happening.
 
Lua:
addHook("PlayerThink", function(player)
   if player.mo and player.mo.skin == "h.r"
   if player.pflags == $1 & PF_STARTJUMP|PF_STARTDASH
       player.mo.state = S_PLAY_JUMP
       P_SetObjectMomZ(player.mo, 15*FRACUNIT)
       P_SpawnThokMobj(player)
    end
end)

This is what it's supposed to be like.
Gave the same error.
 
God. Please just use player.pflags & PF_STARTDASH|PF_STARTJUMP
Its the correct way and please dont spread (probably) misinformation.
 
When i executed it, it messed up and i didnt press jump and spin and it go upwards forever bruh not helpful
Actually its your problem. PF_STARTDASH is when you spindash. PF_STARTJUMP is when you jumped and didnt release jump yet to cut it. Basically the thing wont work unless you set them specifically.
If you want to check if you pressed jump and spin then maybe use SpinSpecial with a check if you have PF_JUMPED flag.


if you want to know more about pflags then just check the wiki
 
Actually its your problem. PF_STARTDASH is when you spindash. PF_STARTJUMP is when you jumped and didnt release jump yet to cut it. Basically the thing wont work unless you set them specifically.
If you want to check if you pressed jump and spin then maybe use SpinSpecial with a check if you have PF_JUMPED flag.


if you want to know more about pflags then just check the wiki
But how would it look like?
 
But how would it look like?
Lua:
addHook("SpinSpecial",function(player)
    if player.valid
    and player.mo.skin == "h.r"
    and player.pflags & PF_JUMPED
        player.mo.state = S_PLAY_JUMP
        P_SetObjectMomZ(player.mo, 15*FRACUNIT)
        P_SpawnThokMobj(player)
    end
end)
Could be cool if you checked the wiki a bit more and learned some more stuff.
 
Lua:
addHook("SpinSpecial",function(player)
    if player.valid
    and player.mo.skin == "h.r"
    and player.pflags & PF_JUMPED
        player.mo.state = S_PLAY_JUMP
        P_SetObjectMomZ(player.mo, 15*FRACUNIT)
        P_SpawnThokMobj(player)
    end
end)
Could be cool if you checked the wiki a bit more and learned some more stuff.
It does the same thing.
 
Ok then it's ok, so could u help me on making sparkles like super sonic that only works with the skin "h.r" and can kill enemies but not players with the skin "h.r" ?
P_SpawnMobjFromMobj and P_RadiusAttack can help you
 

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

Back
Top