2 Lua Questions

SIG7Pro

I hate my life.
1. how would a boost hud work? i just want the word boost, and a meter on screen, and the boost meter gets larger or smaller depending on a variable named "boost"
nothing else, i dont want a lua boost
just the hud that has a meter that gets larger or smaller with the boost variable



2. and also how would it work as if a character was in their dash mode and have a different running animation, in a different script

would it be something like
Code:
addHook("PlayerThink", function(player)
    if player.mo.skin == "Sonic" then
        if ( (PLAYERSPEEDVARIABLE IDK THE NAME OF) = (the maximum speed) and if player = (in dashmode))  then
            (command that plays an animation) = ANIM_DASH
        end
    end
end)
 
To draw the "boost" text, you can have the game draw the word using v.drawString.
To draw the meter... It kind of depends on the style of the meter you want to go for.
You can have a bar whose contents are a solid color that fills or drains as the meter changes, or you can have a bar with multiple segments, both fit the "gets larger or smaller" description... there's several things you can go for.
If you want to make a simple bar, some users use v.drawFill, however it is rather limited.
If you want to stretch some graphic, you can use v.drawStretched to stretch it to the maximum then have the graphic become smaller if the meter variable is lower than the maximum.

Make sure whatever you do for the HUD is done within a HUD hook.

I've uploaded an example as an attachment. Hope it helps!



By the way:
Skin internal names are strictly lowercase.
Player speed can be obtained with player.speed.
The player's maximum speed, or at least the maximum they can achieve by just running normally, that would be their normalspeed, obtained with player.normalspeed.
To check if a player is in dash mode, check that player.dashmode > 3*TICRATE.
Variables are not "commands", they're variables. If anything, object variables can also be called "attributes".
You can read about the player_t structure here, that is, all player variables you can use.

Can't answer the second one, sorry.
 

Attachments

  • bar_example.zip
    1.9 KB · Views: 130
Last edited:
The second one is easy.
Code:
addHook("PlayerThink", function(player)
     if player.mo and player.mo.valid and player.mo.skin = "skinnamehere" and P_IsObjectOnTheGround(player.mo) // I guess?
          if player.speed >= player.normalspeed and player.dashmode >= 3*TICRATE
               player.mo.state = SPR2_DASH // This sets the state to the dash state, correct me if this doesn't work
          end
     end
end)
 
The second one doesn't need any scripting in order to have a dash animation, it would play the running animation by default. But if you want to make your character use a dash animation then you can name the sprites "DASHAX" for example (AX is just an example, the X is representing the rotation number or letter.) You can know more about sprite rotations here
 

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

Back
Top