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

Void Animates

Just a guy who loves... EVERYTHING!
Yeah, an ability for my mod. Its not working? I am trying to make it so w
srb20002.gif
hen u tap spin, u throw a red ring:
 

Attachments

  • itnowork.pk3
    465 bytes · Views: 82
Bruh
Post automatically merged:

First you need to set player.target because games doesnt know what it is.
Second you need P_SpawnMissile or something.
Third Why you wanna make player shoot a red ring?
 
first and second, I just started learning
Third, I just want to lol, and I want my mod to be unique, not just a sonic resprite
 
You just making my mod but its bad ._ .
Dude, did you really have to say that? First of all your red ring script also involves the jump thok and the red rings auto homes into enimies, thats nothing like yours. Second, even if you owned red ringslingers (which you don't) he has the right to do so because you made it reusable.
 
You just making my mod but its bad ._ .
Don't come to a Help thread if you can't actually offer help. No one necessarily knows what you have in the making and shooting a red ring isn't exactly an original concept if you're going to say you came up with it beforehand. This is a 100% unwelcome attitude and I don't want to see it from you again.

Yeah, an ability for my mod. Its not working? I am trying to make it so when u tap spin, u throw a red ring:
You are likely to get faster help if you post your code directly instead of embedding the PK3. The MB supports syntax highlighting for Lua.
Lua:
addHook("PlayerThink", function(p)
    print("Hello world!")
)
 
You are likely to get faster help if you post your code directly instead of embedding the PK3. The MB supports syntax highlighting for Lua.
Lua:
addHook("PlayerThink", function(p)
    print("Hello world!")
)
Oh ok I didn't know. Here is the code
Lua:
addHook("ThinkFrame", function()
    for player in players.iterate do
        if player.mo.skin ~= "sonic" then
            continue
        end
       
        if not (player.cmd.buttons & BT_USE) then
            player.spintapready = true
            player.spintapping = false
        elseif player.spintapready then
            player.spintapping = true
            player.spintapready = false
        else
            player.spintapping = false
        end
       
        if player.spintapping then
            P_SpawnMobj(player.mo, player.target, MT_REDRING)
        end
    end
end)
sorry if it bad :/
 
Lua:
P_SpawnMobj(player.mo, player.target, MT_REDRING)
According to the wiki, P_SpawnMobj takes four arguments: the X, Y and Z coordinates to spawn the object, and the type of the object to spawn. You are giving the wrong count and type of arguments, hence the error. Though even if you gave the correct arguments, since the red ring is a projectile, it would hurt you on spawn since it has no assigned target. A function that would solve this instead is P_SpawnMissile.
 
so I fixed it and changed it to P_SpawnMissile and another error, I need to get good at coding
1623383310746.png
I put it on my character mod as an example.
 
so I fixed it and changed it to P_SpawnMissile and another error, I need to get good at coding
View attachment 46861I put it on my character mod as an example.
Again, where's the code and your changes.

...wait nvm I saw it.
Lua:
        if not (player.cmd.buttons & BT_USE) then
            player.spintapready = true
            player.spintapping = false
        elseif player.spintapready then
            player.spintapping = true
            player.spintapready = false
        else
            player.spintapping = false
        end
This part of the code is a bit broken - BT_USE is not a valid button constant anymore. Use BT_SPIN instead.
Lua:
            P_SpawnMissile(player.mo, player.target, MT_REDRING) -- I think that's how you did it?
You have to set player.target first.
I'd do it like so:
player.target = P_LookForEnemies(player)
if player.spintapping and player.target then
    P_SpawnMissile(player.mo, player.target, MT_REDRING) -- This is the only line you have of this.
    -- Oh yeah you can highlight lines.
end
 
You have to set player.target first.
I'd do it like so'd do it like so:
player.target = P_LookForEnemies(player)
if player.spintapping and player.target then
    P_SpawnMissile(player.mo, player.target, MT_REDRING) -- This is the only line you have of this.
end
how do I do that?
 
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)
 
u try with this:
Lua:
Lua:

        addHook("PlayerThink",function(player,target)

            if player.mo.skin == "sonic"

            player.target = P_LookForEnemies(player, true)

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



            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)
 
Last edited:
Lua:
addHook("JumpSpecial", function(player)
    if player.mo.skin == "lightsonic"
        if not P_IsObjectOnGround(player.mo)
            and not (player.pflags & PF_THOKKED)
            player.pflags = $1 & ~PF_JUMPED
            P_Thrust(player.mo, player.mo.angle, 34*FRACUNIT)
            S_StartSound(player.mo, sfx_zoom)
            player.mo.state = S_PLAY_ROLL
            player.pflags = $1|PF_THOKKED
        end
    end
end)
There are console errors when I load the lua
Post automatically merged:

srb20017.png
 
Lua:
addHook("PlayerThink",function(player,target)

            if player.mo.skin == "lightsonic"

            player.target = P_LookForEnemies(player, true)

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



            P_HomingAttack(player.mo, player.target)

            P_Thrust(player.mo, player.mo.angle,30*FRACUNIT)

            player.mo.state = S_PLAY_THOK
            
            end

        end
end)
so I fixed it but every time I airdash, I destroy it but it also homes in on other enemies
 

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

Back
Top