Jump to content
Sign in to follow this  
colonel_klink

Working fuel gauge

Recommended Posts

Ever wondered about how much fuel you vehicle is using (supposing the  on screen indicators are not present for the addon)?

Here's a way of getting a fuel gauge to work on your plane, car, or boat using the inbuilt fuel command:

This presumes you know how to make  gauges in Oxygen.

1.

Create the animated objects in O2 i.e. gas needle and axis points in the appropriate lods (driver view and memory)

2.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class aniDipGas

{

type = "rotation";

animperiod = 5;

selection ="diplomaticgas";

axis = "osa diplomaticgas";

angle0=0;

angle1= -2.844876;

};

angle0 is the start angle of your gas needle ( or Empty mark)

angle1 is the end angle of your gas needle (or Full tank mark on the gauge) . Note angle1 is in Radians. If you need to convert degrees to radians get my Degree to Radian convertor here:

http://www.dc3d.co.nz/Downloads/OFP/Tools/Degree2Radians.exe

3. The script code in gasgauge.sqs (note this script runs as long as the car is not destroyed):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_lincoln = _this select 0

#Start

_lincoln animate ["aniDipGas", 0]

#Repeat

~0.001

?!(isengineon _lincoln): goto "Start"

_lincoln animate ["aniDipGas", (fuel vehicle _lincoln)]

?(not alive _lincoln): goto "Exit"

goto "Repeat"

#Exit

exit

4. call the above script from the init eventhandler:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

init = [_this select 0] exec "\youraddonName\gasgauge.sqs"

That's about it.. I think smile_o.gif  blues.gif  Have fun.

Share this post


Link to post
Share on other sites

just a thought...not entirely sure which way would be better and use less cpu in the long run

but would "getin" be a better addevent handler to use rather than "init"?

That way it won't keep looping through the script during the whole game.

With getin it would only begin the loop once someone was in it.

Also, I think you could detect wether it was a player or AI? If it wasn't the player then you could have it exit the script so then it wouldn't use any cpu power for a function the AI wouldn't use.

I'm still new to the eventhandlers and scripting so I could be totally off on what it can do.

p.s. Colonel...thank you for all of the tutorials you've made since the beginning...I've been learning how to model and everything else from your web page and hard work ...I learn something new every day too smile_o.gif

Share this post


Link to post
Share on other sites
just a thought...not entirely sure which way would be better and use less cpu in the long run

but would  "getin" be a better addevent handler to use rather than "init"?

That way it won't keep looping through the script during the whole game.

With getin it would only begin the loop once someone was in it.

Also, I think you could detect wether it was a player or AI? If it wasn't the player then you could have it exit the script so then it wouldn't use any cpu power for a function the AI wouldn't use.

I'm still new to the eventhandlers and scripting so I could be totally off on what it can do.

p.s. Colonel...thank you for all of the tutorials you've made since the beginning...I've been learning how to model and everything else from your web page and hard work ...I learn something new every day too  smile_o.gif

Might try the getin/getout methods as it as you say would use less cpu.

Working on the ida of player and and ai too. As this is useful for aircraft with working animations as well.

Thanks

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×