I need help on how LUA works

A'Dilla

For The Win!
I created a mod. But because they are re-skins, I decided that I wanted to give them an ability. I took one look at how people do it and I'm never as confused as my life. Is there something like a simple video that can help me get to understand LUA a little bit?


Also I would send proof but I don't find a reason why everyone would want to see re-skins. Also because I don't how to do GIFS
 
I created a mod. But because they are re-skins, I decided that I wanted to give them an ability. I took one look at how people do it and I'm never as confused as my life. Is there something like a simple video that can help me get to understand LUA a little bit?


Also I would send proof but I don't find a reason why everyone would want to see re-skins. Also because I don't how to do GIFS
1. There's a wiki page dedicated to Lua scripting in SRB2. Go check that out if you need help with Lua.

2. You start recording a GIF in SRB2 when you press whatever's bound to "record gif" in the options - F9 by default. You stop with the same key.
 
You can try to make a lua version of the thok to train yourself on how to lua, you can study this lua thok script i made,


Lua:
addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo.skin == "tails"-- must be tails.
        and (player.cmd.buttons & BT_JUMP) --pressed jump?
        and (player.pflags & PF_JUMPED)-- have to be jumping
        and not (player.pflags & PF_THOKKED)-- dont be in your thokked state!
            P_InstaThrust(player.mo, player.mo,angle, 25*FRACUNIT)-- this will thrust you, if you make the value higher, it will thrust you more farther
            P_SetObjectMomZ(player.mo, 0*FRACUNIT)-- this is how you change the height, make it higher than 0 and it will set your height. Make the numbers in negative and it will send you down!
            P_SpawnThokMobj(player.mo)-- spawn thok
            S_StartSound(player.mo, sfx_thok)-- play thok sound
            player.pflags = $|PF_THOKKED-- put you in the thokked state, which in line 6 it tells you to not do it if you enter your PF_THOKKED, which makes you not able to do it again. lol idk if thats confusing .-.
        end --end this part (and my suffering)
        if player.mo.skin == "tails"-- must be tails!
            player.charability = CA_NONE --remove the flight lol
        end
    end
end)-- yeah it's not an exact thok, but it works(i think).

You can ignore the lines after the end my suffering, as that basically sets tails's charability to nothing.
 
  • Cool!
Reactions: M.K
You can try to make a lua version of the thok to train yourself on how to lua, you can study this lua thok script i made,


Lua:
addHook("ThinkFrame", do
    for player in players.iterate
        if player.mo.skin == "tails"-- must be tails.
        and (player.cmd.buttons & BT_JUMP) --pressed jump?
        and (player.pflags & PF_JUMPED)-- have to be jumping
        and not (player.pflags & PF_THOKKED)-- don't be in your thokked state!
            P_InstaThrust(player.mo, player.mo,angle, 25*FRACUNIT)-- this will thrust you, if you make the value higher, it will thrust you more farther
            P_SetObjectMomZ(player.mo, 0*FRACUNIT)-- this is how you change the height, make it higher than 0 and it will set your height. Make the numbers in negative and it will send you down!
            P_SpawnThokMobj(player.mo)-- spawn thok
            S_StartSound(player.mo, sfx_thok)-- play thok sound
            player.pflags = $|PF_THOKKED-- put you in the thokked state, which in line 6 it tells you to not do it if you enter your PF_THOKKED, which makes you not able to do it again. lol idk if that's confusing .-.
        end --end this part (and my suffering)
        if player.mo.skin == "tails"-- must be tails!
            player.charability = CA_NONE --remove the flight lol
        end
    end
end)-- yeah it's not an exact thok, but it works(i think).

You can ignore the lines after the end my suffering, as that basically sets tails's charability to nothing.
Jesus lord doc, Now that's a LOTTA LUA. (Funni meme refference go BRRRRRRRRRRRRRR)
 
First off, it's called Lua, not LUA. Contrary to common misconception, Lua is not an acronym.

With that extremely important fact out of the way, although I'm not familiar with Lua programing myself I highly recommend checking out the SRB2 Wiki page on Lua. The wiki is very useful for any and all modding advice.
 

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

Back
Top