Don't get what's wrong?

Tempmarrow

Average beatdown enjoyer
Basically my state works and all but there's this error that keeps popping up.
ERROR:
Cannot remove player mobj by setting it state to null
 
Attempting to set a player object's state to S_NULL or nil will cause that error to appear in console.

If you're not explicitly trying to do that, it's possible that there's a typo somewhere in your script, specifically in a line where you are setting a state to a player mobj. The typo basically makes it a different variable, and since the variable doesn't exist, it will have nil as its value.
The typo could be switched letters or wrong capitalization (Lua is case sensitive).

Or maybe you forgot to freeslot a state. That could be a reason too.
 
Here's my code for reference
My code:
freeslot(
"S_AIRDASH",
"SPR_AIRD"
)
states[S_AIRDASH] = {
    sprite = SPR_AIRD,
    tics = 1,
}

addHook("AbilitySpecial", function(player)
    if player.mo.skin == "sonic"
        if (player.mo.state == S_PLAY_JUMP)
           P_SpawnGhostMobj(player.mo)
           player.mo.state = S_AIRDASH
           S_StartSound(player.mo, sfx_thok)
           P_Thrust(player.mo, player.mo.angle, 50*FRACUNIT)
        end
    end
end)
Attempting to set a player object's state to S_NULL or nil will cause that error to appear in console.

If you're not explicitly trying to do that, it's possible that there's a typo somewhere in your script, specifically in a line where you are setting a state to a player mobj. The typo basically makes it a different variable, and since the variable doesn't exist, it will have nil as its value.
The typo could be switched letters or wrong capitalization (Lua is case sensitive).

Or maybe you forgot to freeslot a state. That could be a reason too.
Post automatically merged:

Here's my code for reference
My code:
freeslot(
"S_AIRDASH",
"SPR_AIRD"
)
states[S_AIRDASH] = {
    sprite = SPR_AIRD,
    tics = 1,
}

addHook("AbilitySpecial", function(player)
    if player.mo.skin == "sonic"
        if (player.mo.state == S_PLAY_JUMP)
           P_SpawnGhostMobj(player.mo)
           player.mo.state = S_AIRDASH
           S_StartSound(player.mo, sfx_thok)
           P_Thrust(player.mo, player.mo.angle, 50*FRACUNIT)
        end
    end
end)
Still don't get whats wrong
 
Here's my code
Don't forget that there's more to a state than just sprite and tics.
You're missing frame and nextstate.

Without a frame the game defaults to frame A. Assuming you do have a frame A, that's fine and all, but it's good practice to specify that.
Without a nextstate, the game defaults to S_NULL, which removes the object. This is the bit that causes the error, because as soon as the state ends (it lasts 1 tic), the game tries to remove the object, can't, and errors.
 

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

Back
Top