Some more questions

Pizza

Member
How do i make flight in lua ?

How do i disable super color and make super form not drain rings

How do i add a cap to an energy bar

How do i make an ability to charge the energy bar

Lastly how do i make so flight drains said energy bar

all of this is for a character lua I'm making

I will give credit to however can help me answer these questions
 

How do i make flight in lua ?
If you want to use the game's flight, set the player's charability to CA_FLY, then adjust actionspd as neccesary.
If you don't want to use the native way, just set the player object's momz to something positive to send the player upwards.


How do i disable super color and make super form not drain rings
Natively, you can't prevent super color nor disable the ring cost.
You can fake it by force setting the player object's color to something and giving one ring to the player on the following condition:
Code:
player.powers[pw_super] > 0 and player.powers[pw_super] % TICRATE == 0
Otherwise, you can fake super.


How do i add a cap to an energy bar
(assuming "player.energy" holds the player's energy, and "cap" is the maximum value it can reach...)
Just prevent it from increasing once your energy variable is past some value.
if player.energy < cap should do the trick.
You can also use the min function to clamp the value if it goes past the limit, like so:
player.energy = min($, cap)


How do i make an ability to charge the energy bar
Uh... that one is very open ended. There are multiple ways to get what you want and lots of factors I don't know.
Just increase your energy variable when something happens?


Lastly how do i make so flight drains said energy bar
If using native flight,
if player.panim == PA_ABILITY then player.energy = $-(some value) end
Change the check if that's not the case.



Make sure to keep an eye to the Lua section of the SRB2 Wiki and this Lua tutorial.
 
I require an example for the first question

Questions 2 and 3 and 4 worked

All is left is flight
 
Quite literally player.charability and player.actionspd, respectively.
One takes an integer denoting ability, which the constant CA_FLY provides, and the other also takes an integer on fixed point, which for this ability it would be flight speed.
Code:
player.charability = CA_FLY -- the player can now fly
player.actionspd = 100*FRACUNIT -- Tails' default actionspd

Or you can do it the hard way by forcing the player object's momentum to something else.
Code:
player.mo.momz = 10*FRACUNIT -- This would send the player upwards

Use one or the other, not both, or you'll get unexpected behaviour. Probably.
 

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

Back
Top