G’day,
Outcome: best way to process and convert the “Flags” value into variables.
I am not a professional programmer, rather a bit of a hack with a bit of an idea.
I’ve written my own TARGET script for my Warthog (inspired by Aussiedroid’s script).
I want to do some state tracking. However, this is not easy within TARGET since it isn’t any way aligned to the game...hence the question.
Now, where I’m at is that I can read the status.json into TARGET, and can isolate and convert the ‘Flags’ value into an integer. My current solution is simply a bunch (up to 28....1 for each bit) of ‘if” statements one after the other.
Eg.
If (Flags >= number) {
...assign to a discrete boolean variable such as “LightsOn” or “Supercruise” etc
Flags = Flags - number;
}
...next If statement etc down until I get to Flags = 1.
This works, obviously and is pretty quick but, I’m not happy with it as a solution...I’m sure there’s a better way.
I’m thinking of creating an array with 28 elements and using a loop instead of the 28 ‘if’ statements, then doing the assignment somehow after that, but my feable mind keeps telling me this would be just as much work.
I’m hoping some clever programmer type can let me in on some method that’s elegent simple, effective etc. that I might be able to try convert into TARGET...which by the way seems like either a variation or subset of either “C” or javascript.
Cheers
Clicker
Outcome: best way to process and convert the “Flags” value into variables.
I am not a professional programmer, rather a bit of a hack with a bit of an idea.
I’ve written my own TARGET script for my Warthog (inspired by Aussiedroid’s script).
I want to do some state tracking. However, this is not easy within TARGET since it isn’t any way aligned to the game...hence the question.
Now, where I’m at is that I can read the status.json into TARGET, and can isolate and convert the ‘Flags’ value into an integer. My current solution is simply a bunch (up to 28....1 for each bit) of ‘if” statements one after the other.
Eg.
If (Flags >= number) {
...assign to a discrete boolean variable such as “LightsOn” or “Supercruise” etc
Flags = Flags - number;
}
...next If statement etc down until I get to Flags = 1.
This works, obviously and is pretty quick but, I’m not happy with it as a solution...I’m sure there’s a better way.
I’m thinking of creating an array with 28 elements and using a loop instead of the 28 ‘if’ statements, then doing the assignment somehow after that, but my feable mind keeps telling me this would be just as much work.
I’m hoping some clever programmer type can let me in on some method that’s elegent simple, effective etc. that I might be able to try convert into TARGET...which by the way seems like either a variation or subset of either “C” or javascript.
Cheers
Clicker