my script is not working!can someone help? (simple script)

redhot69

amongus
so...i was trying to make an mod where shadow gets new abilities but somehow the script got no error but when i tried using them nothing happened.
addHook("PlayerThink", function(player)
if player.mo.skin == "shadow"
if (player.cmd.buttons & BT_CUSTOM2)
and P_IsObjectOnGround(player.mo)
and (player.mo.state = S_PLAY_STND) then
P_InstaThrust(player.mo, player.mo.angle, 20*FRACUNIT)
P_SetObjectMomZ(player.mo, 5*FRACUNIT)
player.mo.state = S_PLAY_SPRING
end
end
end)

addHook("PlayerThink", function(player)
if player.mo.skin == "shadow"
if (player.cmd.buttons & BT_CUSTOM1)
and not P_IsObjectOnGround(player.mo)
and (player.mo.state = S_PLAY_JUMP) then
P_InstaThrust(player.mo, player.mo.angle, 30*FRACUNIT)
player.mo.state = S_PLAY_ROLL
end
end
end)
 
so...i was trying to make an mod where shadow gets new abilities but somehow the script got no error but when i tried using them nothing happened.

*The code*
You just put a single equals (=) instead of a double equals (==) when checking if the player is using a specific state.

Wrong: if player.mo.state = ...
Correct: if player.mo.state == ...
 
You just put a single equals (=) instead of a double equals (==) when checking if the player is using a specific state.

Wrong: if player.mo.state = ...
Correct: if player.mo.state == ...
ok tysm,so all of the things that have = in it i use 2 equals (this code in specific
 
ok tysm,so all of the things that have = in it i use 2 equals (this code in specific
Only when you are checking for a state, not when setting a state.

Example:
Example:
...
if player.mo.state == S_PLAY_WAIT
    player.mo.state = S_PLAY_STND
    ...
end
...
 
Only when you are checking for a state, not when setting a state.

Example:
Example:
...
if player.mo.state == S_PLAY_WAIT
    player.mo.state = S_PLAY_STND
    ...
end
...
alright ty,and btw what if that "if" is replaced by an "and" statement
 
alright ty,and btw what if that "if" is replaced by an "and" statement
If it's an and, put the double equals too. Nothing needs to be changed.

Another funny example:
...
if P_IsObjectOnGround(player.mo)
and player.mo.state == S_PLAY_WAIT
    player.mo.state = S_PLAY_STND
    ...
end
...
 
If it's an and, put the double equals too. Nothing needs to be changed.

Another funny example:
...
if P_IsObjectOnGround(player.mo)
and player.mo.state == S_PLAY_WAIT
    player.mo.state = S_PLAY_STND
    ...
end
...
alright thanks,also (this is the last question dont worry.) where can i find player.pflags on srb2 wiki?
 

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

Back
Top