my lua isn't working, how do I fix it?

Lua:
a
[CODE=lua]ddHook("PlayerThink",function(player,target)



            if player.mo.skin == "lightsonic"



            player.target = P_LookForEnemies(player)



            if not P_IsObjectOnGround(player.mo) and not (player.pflags & PF_THOKKED)

                    if player.target

                    P_SpawnLockOn(player,player.target,S_LOCKON1)

                    end
              end
         end
end)

addHook("AbilitySpecial",function(player)
if player.mo.skin == "lightsonic"
and not (player.pflags & PF_THOKKED)
and player.target
and not P_IsObjectOnGround(player.mo)

   P_HomingAttack(player.mo, player.target)

    P_Thrust(player.mo, player.mo.angle,30*FRACUNIT)
 
     player.mo.state = S_PLAY_THOK
 
     S_StartSound(player.mo,sfx_thok) -- the sound, u can change it if u want
--a effect!
P_SpawnMobj(player.mo.x - 30*FRACUNIT, player.mo.y, player.mo.z - 30*FRACUNIT, MT_SPINDUST)
P_SpawnMobj(player.mo.x + 30*FRACUNIT, player.mo.y , player.mo.z - 30*FRACUNIT, MT_SPINDUST)
P_SpawnMobj(player.mo.x - 30*FRACUNIT, player.mo.y ,player.mo.z +30*FRACUNIT, MT_SPINDUST)
P_SpawnMobj(player.mo.x + 30*FRACUNIT, player.mo.y, player.mo.z + 30*FRACUNIT, MT_SPINDUST)

P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z + 35*FRACUNIT, MT_SPINDUST)
P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z - 35*FRACUNIT, MT_SPINDUST)
P_SpawnMobj(player.mo.x + 35*FRACUNIT, player.mo.y, player.mo.z, MT_SPINDUST)
P_SpawnMobj(player.mo.x - 35*FRACUNIT, player.mo.y, player.mo.z, MT_SPINDUST)

player.pflags = $|PF_THOKKED
end
end)

try with this,i make this alot better!
 
Last edited:
oh cool thx lemme try
Post automatically merged:

uhhhh
srb20048.gif
 
Last edited:
You can't perform arithmetic with a string.
Remove the minus before "lightsonic", otherwise Lua thinks you're trying to numerically invert a word.


Partly off-topic, but you might want to consider learning the normal Lua syntax before delving into SRB2's Lua who adds and changes a lot of new things.
You might be interested on this particular Lua tutorial. There are plenty more out there, and there are probably better ones, but you might want to begin with non game-specific things first as to get used to its format.
 
Alright, I need help for 2 things, one is a sword spin for SATBK sonic and a homing attack (yes again)

Lua:
//Sword spin
addHook("PlayerThink", function(player)
            if player.mo.skin == "blackknight"
            if not P_IsObjectOnGround(player.mo)
            and (player.cmd.buttons & BT_CUSTOM2) then
            P_SpawnMobjFromMobj(p.mo,0,0,0,MT_THOK)
            S_StartSound(player.mo, sfx_spin)
            player.mo.momz = -23*FRACUNIT
            player.mo.state = S_PLAY_ROLL
        end
    end
end)


Lua:
addHook("AbilitySpecial",function(player,target)
            if player.mo.skin == "sonic"
            player.target = P_LookForEnemies(player, true, true)
            if player.mo.state = S_PLAY_JUMP and (player.pflags & PF_THOKKED)
            if player.target
            P_HomingAttack(player.mo, player.target)
            P_Thrust(player.mo, player.mo.angle,10*FRACUNIT)
            player.mo.state = S_PLAY_HOMING
            player.pflags = $|PF_THOKKED
            end
        end
     end
end)

addHook("PlayerThink",function(player,target)
    if P_LookForEnemies(player) and not P_IsObjectOnGround(player.mo) and not (player.mo.eflags & MFE_SPRUNG or player.pflags & PF_THOKKED)
        P_SpawnLockOn(player, P_LookForEnemies(player), S_LOCKON1)
    end
end)
 
i am trying to script a homing attack but its not working,, can anyone help?
Lua:
        addHook("PlayerThink",function(player,target)
            if player.mo.skin == "sonic"
            player.target = P_LookForEnemies(player, true)
            if not P_IsObjectOnGround(player.mo) and if player.target and if player.mo.state = S_PLAY_THOK
            P_HomingAttack(player.mo, player.target)
            P_Thrust(player.mo, player.mo.angle,30*FRACUNIT)
            player.mo.state = S_PLAY_JUMP
            end
        end
    end
end)
Not sure if you already know but there’s already a homeing thok you can use. Totally fine if you wanna make your own tho
 
Hi
Umm how do I make it so I don't do an ability after I do it? So its not OP
player.pflags = player.pflags | PF_THOKKED will stop the player from activating "AbilitySpecial" again in the same jump, but given this is a playerthink one make it check for player.pflags == player.pflags | PF_THOKKED and if true, return (return with no value at the end stops execution of the function)
 

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

Back
Top