Skip to content

Instantly share code, notes, and snippets.

@chemputer
Last active February 19, 2023 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemputer/89a6c35290cafbdc5424d390e20dc9e9 to your computer and use it in GitHub Desktop.
Save chemputer/89a6c35290cafbdc5424d390e20dc9e9 to your computer and use it in GitHub Desktop.
WTRTI Indicator Scripts

WTRTI User Made Custom Indicator LUA Scripts

WTRTI (War Thunder Real Time Information) is a helper program created by GitHub User MeSoftHorny, available on the project's GitHub page here. With it, you can add custom indicators in addition to the built in ones, either by adding existing but not implemented State variables, or by using a LUA script to do math on any number of State indicators to return a customized indicator.

For example, I regularly use SEP (Specific Excess Power, essentially how many m/s of power the engine is producing that can be used to either increase the speed of the plane or climb with.) and the Climb rate (labeled as the State Vy), to help determine an optimal climb rate, so that I can get to speed then climb at the max speed possible without losing speed by keeping Vy below SEP. To assist me in this, I created a custom indicator I called Excess Power, shortened to XSPWR using a lua script included in this.

To create your own or to use mine, simply go into WTRTI, click add indicator, then click user made, this will likely be blank. Right click the white space and select new. Name it whatever you want, if you want to use mine, name it XSPWR (or just change the folder name later to whatever you put the name as) and check the Lua Script box. Enter one of the State Variables into the State box, in my example, that should be "Vy, m/s", and then it will create a folder called Indicators with another folder with whatever you named it, in my case, XSPWR, along with two files: Description and update.lua. You can simply download the update.lua file (renamed to XSPWR.lua on here for clarity) and overwrite the existing update.lua file. Or you can just edit the update.lua file to match that of the XSPWR.lua file. Your choice.

Notes

I found during testing that I was unable to get it to work without using the State section of the custom Indicator to pass a variable to the script. You can only pass one variable this way -- it will be pass to the lua script as "in_value" variable, any other state variable you might need can retrieved via the getStateValue("INSERT_STATE_NAME") function.

See the below example for a very simple script. all it is doing is taking the Specific Excess Power variable as well as the climb rate (Vy), and subtracting Vy from SEP, then returning the result. Much more complicated scripts can be made than this.

The Description file (no file extension) contains the information needed that is created in the WTRTI custom Indicator creation tool, and I've named it such that it is "Indicator_Name_Description", be sure to rename it to Description once in the proper directory.

Additional Resources

Additional information on creating Custom Indicators can be found on the forum post for WTRTI here. Scroll down to "Custom Indicators" and expand the spoiler tag. The entire post is helpful in detailing how it works. Importantly, LUA scripts only work in version 2.0+. As of writing, the current version is v2.1.

-- Be sure to rename file to update.lua once in the proper directory
-- in_value: "Vy"
function value_proc(in_value, value_idx)
-- get the value of the State Variable SEP in m/s
local SEP = getStateValue("SEP, m/s")
-- get the Climb Rate (Vy), also in m/s, this is set in the custom Indicator creation in WTRTI, it should be "Vy, m/s"
local Vy = in_value -- 'Vy'
-- get the difference between SEP and Vy, giving you the excess power available to the plane.
local diff = SEP - Vy
-- return the value to be displayed, along with whether or not it should be displayed or not.
return diff, true
end
[Info]
name=XSPWR
hash=Indc-63F150E9F2BAB4EE
wt_name=Vy, m/s
osd_name=XSPWR
value_units_str=
value_units=2
value_prec=2
custom_update_proc=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment