-
Notifications
You must be signed in to change notification settings - Fork 0
Lua Remap Profiles Basic Actions
Note: In case you have errors with the code blocks provided in this page, check the Advanced behavior page (Coming Soon) before raising an issue.
For this section we will use the standard format described below:
- For emulated state variable we will use
state(replace for the emulated controller state name) - For input state variable we will use
input(replace for the Remap function first argument name) - For a arbitrary index of an array we will use
idorindexwords (replace for a number) - For a user-defined number we will use
number(replace for a variable name or with a number with a decimal point) - Some other things may be discribed in corresponding section
You need to understand that any code block is writed for standard use. You can, and you will need in some cases, to modified it to make it correctly work.
state.Axis[index]state.Sliders[index]state.Buttons[index]Contains a processed IMU (Inertial Measurement Unit) data if controller supports it. (DualShock4 plugin provided in this repository generate this data by default).
state.SixAxis[index]Some axis and button indices are bound to variables with friendly names to make it easy to use.
You can find this definitions here (Coming soon)
These blocks are made to understand the behavior of Lua Remap profiles for non-programmers. If you have some experience in programing this may be intuitive.
Don't forget to call Update() function of the emulated controller after set all the state values (or following code blocks) you want.
state.Axis[index] = input.Axis[index]state.Sliders[index] = input.Sliders[index]state.Buttons[index] = input.Buttons[index]-- for positive axis value
state.Buttons[index] = input.Axis[index] > number
-- for negative axis value (index can be another of the previous line)
state.Buttons[index] = input.Axis[index] < number-- for positive slider value
state.Buttons[index] = input.Sliders[index] > number
-- for negative slider value (index can be another of the previous line)
state.Buttons[index] = input.Sliders[index] < numberNote: sliders normally do not have negative values, but there may be exceptions (check on the Input Test window to be sure)
This is a bit more complicated than the previous code block, but still simply enough to be understood by everyone.
-- if you place a button variable as a condicion for an if, it will be true if the button is pressed
if input.Buttons[index] then
-- if button is pressed
state.Axis[index] = 1 --"1" can be replaced with any number with a decimal point or a variable name
else
-- if button is not pressed
state.Axis[index] = 0 --"0" can be replaced with any number with a decimal point or a variable name
endNote: repeate the same block, but with a negative number on the button pressed code, to set a negative axis value
-- if you place a button variable as a condicion for an if, it will be true if the button is pressed
if input.Buttons[index] then
-- if button is pressed
state.Sliders[index] = 1 --"1" can be replaced with any number with a decimal point or a variable name
else
-- if button is not pressed
state.Sliders[index] = 0 --"0" can be replaced with any number with a decimal point or a variable name
endNote: repeate the same block, but with a negative number on the button pressed code, to set a negative slider value (depending on the emulated controller a negative number can be the same as 0 if emulated controller isn't calibrated correctly, case of VJoy emulated controllers)