i need help with a melee lua

chipakpaka

Member
last month i posted a thread about replicating the vanilla's melee in lua, but then changed my mind because i thought i could figure it out myself. anyway, i kinda forgot about it until today, and i came up with a code that kinda works, but also has a lot of problems.

here's the code:
Lua:
addHook("SpinSpecial", function()
    for p in players.iterate
        if p.mo.skin == "idk"
            if p.cmd.buttons & BT_SPIN
            and P_IsObjectOnGround then
            P_Thrust(p.mo, p.mo.angle, p.maxdash)
            P_SetObjectMomZ(p.mo, p.mindash, true)
            p.mo.state = S_PLAY_ROLL
            p.powers[pw_strong] = STR_MELEE
            end
        end
    end
end)

my first problem is that the ability works while the character is also in the air, and it shouldn't do that.
my second problem is that the ability works when holding the spin key, when it should only work when the key is just pressed.
 
My first problem is that the ability works while the character is also in the air, and it shouldn't do that.
My second problem is that the ability works when holding the spin key, when it should only work when the key is just pressed.

Let's see if this works it out...
Lua:
addHook("PlayerThink", function(p)
    if p.mo.skin == "idk"
        if p.cmd.buttons & BT_SPIN
        and not p.spin_time
        and P_IsObjectOnGround(p.mo)
            P_Thrust(p.mo, p.mo.angle, p.maxdash)
            P_SetObjectMomZ(p.mo, p.mindash, true)
            p.mo.state = S_PLAY_ROLL
            p.powers[pw_strong] = STR_MELEE
        end
    end
    if p.cmd.buttons & BT_USE
        p.spin_time = $+1
    else
        p.spin_time = 0
    end
end)
 

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

Back
Top