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

Lightspeed_

A Character Modder and Lua-Learner
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: 11

BuggieTheBug

Probably a robot
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?
 

Lightspeed_

A Character Modder and Lua-Learner
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
 

BuggieTheBug

Probably a robot
The last thing you should be here for is to diss on people trying to learn.
You just making my mod but its bad ._ .
 

A'Dilla

For The Win!
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.
 

Tatsuru

2.3 will have menus
Moderator
Sonic Team Junior
Judge
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!")
)
 

Lightspeed_

A Character Modder and Lua-Learner
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 :/
 

Tatsuru

2.3 will have menus
Moderator
Sonic Team Junior
Judge
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.
 

Lightspeed_

A Character Modder and Lua-Learner
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.
 

antonretrojr

Mediocre Lua scripter
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
 

Lightspeed_

A Character Modder and Lua-Learner
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?
 

Lightspeed_

A Character Modder and Lua-Learner
I literally just provided an examp-
sorry, I was tired, I didn't read that lol. I should read next time
Post automatically merged:

omg thank you guys so much! I coded my first ability (with the help of u guys), I happy
 

Attachments

  • srb20004.gif
    srb20004.gif
    5.2 MB · Views: 3
Last edited:

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

Top