LUA scripting expert wanted for HELIOS prblem
-
Thanks Blu3wolf
Still struggling but I have found I can just call the individual positions of the switch (1) (2) etc in the Lua script and make the position step once up or down.
I am now trying to write a script that will recognise any position and step it up or down. The new picture shows an example with just three positions out of possible nineteen but the script is not recognised. Can you give me any pointers to improve it. -
This post is deleted! -
Cant you just use this for the decrement,
a = TriggerValue - 1 return a
and this for the increment?
a = TriggerValue + 1 return a
-
I tried it but no response.
I am encouraged by being able to step once with:-
if (2)
then
return (1) ;
endI just need to make it look at all cases, I presume my attempt at else/if is not allowed, so I hoped you might know the correct way to make it look further if
the first expression is false. -
Well, elseif should be one word. Also,
If (2)
Always returns true, so it will never get to the elseifs. So it will always do the
Return (1)
Line, which is obviously not what you want.
Does the encoder have the same number of positions as the rotary switch?
-
Does the encoder have the same number of positions as the rotary switch?
No and I have just come to the conclusion that this is my problem. The encoder only has two positions, inc or dec and the switch I am trying to drive has 19.
So what I need to know is how to name the Action Value and then either take one away or add one to when Trigger value = dec or inc. Ideas follow:-
For channel starting at default position 6 to dec or inc by 1.
(ActionValue) = a
a = 6
if (TriggerValue)
then
return a = a - 1
end(ActionValue) = a
a = 6
if (TriggerValue)
then
return a = a + 1
endI Will be trying this later today and would value your comments.
-
Well, to me it looks like you need to be able to read the position of the switch, to do what you want. Or store it in a global variable. This is the sort of thing that it would help to have details on the lua implementation for Helios.
-
I am just about ready to surrender, but before I do , I downloaded the helios program from Git Hub .
It looks too complicated for me to understand but there are references to trigger and action values that might make sense to someone with programming knowledge……Help!!
-
I am just about ready to surrender, but before I do , I downloaded the helios program from Git Hub .
It looks too complicated for me to understand but there are references to trigger and action values that might make sense to someone with programming knowledge……Help!!
I never used Lua before but i’ll take a look this evening at it if you don’t find something.
-
I have a sinking feeling that this is one of those bits of Helios that have not been finished
-
Decrement:
rotary = rotary or 1
if rotary > 1 then
rotary = rotary - 1
else
rotary = 19
end
return rotaryThe increments script would be similar
rotary = rotary or 1
if rotary < 19 then
rotary = rotary + 1
else
rotary = 1
end
return rotaryNote that these assume helios is started with the virtual knob in the number 1 position.
-
WOW Blu3wolf
That is very close to the solution. The only problem is that the two directions each remember there own stopping positions and carry on from that point.
eg Starting at 1, pressing inc three times results in 4 but then pressing dec starts again at 1 and steps back to 19 instead of starting at 4 and stepping to 3.
Pressing inc again starts from 4 and steps to 5.
Definitely on the right track though .
Cheers weepop
-
Then its a problem with the lua implementation. rotary in that script should be a global variable, and it should remember its value because of the line, rotary = rotary or 1.
That line basically says
if not rotary then rotary = 1 end
That expression should only evaluate as true when rotary hasnt been set. If it thinks rotary hasnt been set when it changes scripts, then the variables are not truly global. For it to be a valid implementation of lua, there should be some way of making such a variable global. I dont know enough about Helios to say if there is such a way, though. I really hoped that would work. It seems like there needs to be some variable store that can be accessed by all scripts for this method to work.
Does the encoder TriggerValue have any detail other than inc/dec? If you run the script,
return TriggerValue
what action value do you get?
The only other idea I have at the moment, is if some variable can be passed to the increment/decrement function to start with - like if the TriggerValue could contain the current rotary position, for instance. But Im not sure that will be possible.
-
Sorry, not sure if I follow 100% but are you making allowances for this situation:
Rotary is at start position, say 1
User inadvertently clicks counter-clockwise a few times
Make sure Rotarty stays at 1 and does not end up at 0 or negative number… -
Sorry, not sure if I follow 100% but are you making allowances for this situation:
Rotary is at start position, say 1
User inadvertently clicks counter-clockwise a few times
Make sure Rotarty stays at 1 and does not end up at 0 or negative number…With the script above I posted, the rotary wraps around, so it will first go to 19, then 18, 17, etc. It never gets to zero, but wraps from 19 to 1 and vice versa.
The issue above is that the rotary value is not synced up between the two scripts. Im not sure of there is a way to do that. Perhaps storing the variable in a text file that is written to and read by each script? Really need documentation for or experimentation on, helios and its lua implementation, to try to get any further.
-
Blu3wolf
Because the “in game” appearance of the channel change switch also passes from 19 to 1 I think I can make this work by only having either the inc or the dec
scripted and not both of them. This will only mean pilot can go one way with the switch. Not really a problem so I am going to attempt to implement this.I will post result.
Thanks for your input
weepop
-
Okay, the repo wouldn’t build and the last commit was 7 months ago, so if you get that^ to work that is probably best.
-
OK added channel control with increase only and it works perfect
YIPPEE
Now only backup TACAN to sort out using similar method then I will release.
Thank you heaps Blu3wolf
-
OK Blu3wolf I have added four more virtual controls for back up Tacan functions with slightly modified scripts to account for different number of steps and starting positions and they work great.
There is one tiny problem remaining, if the RESET function is used it resets the virtual controls but not "rotary globals ".
This is fine if the virtual controls have not been moved but no good if they have, because they start from last “global” position.
If not curable I can suggest not using reset and only use restart from scratch but it would be nice if I can make the reset button also send scripts that put the "rotary global " back to start position on each virtual control.
I tried :-
rotary = rotary or 1
if true
rotary = 1
end
return rotarybut no success, I think I need your brilliant expertise again please…
weepop
-
so, the reason the increment and decrement scripts didnt work is the same reason - the rotary variable isnt shared between the scripts. If I knew how to fix this reset button, Id know how to make the increment and decrement talk to each other. Sorry I cant help with that.