-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use -1 as a property index in script events? #105
Comments
What I also noticed is that if I refer to the property without an index then the script appears to take that as an alias for the <event name="Increase Throttle">
<description>Increase throttle to max</description>
<condition> simulation/sim-time-sec >= 1.0 </condition>
<set name="fcs/throttle-cmd-norm" value="1" type="FG_RAMP" tc="2" />
</event> Based on looking at the logged values for the 2 engines, i.e. I see the thrust increasing for engine |
I think both issues here are by the design of the property tree. That the property fcs/throttle-cmd-norm |
@andgi so you're suggesting that you think that |
Yes, I think so. The property tree code (while not the script interface) comes from FlightGear/SimGear and I've never ever heard about any "-1" indices. Given that the tree can be serialized into XML (also by design) indices outside 0, 1, ... would be very strange indeed. (As would non-continuous ranges of indices but I think those are supported, though.) Is it a very big problem to repeat the set-element for each engine? Of course you could add a special case in the script parser fcs/throttle-cmd-norm[-1] but then someone else wants it for some other engine properties, and for all gear units and.... |
I had come across the Then more recently I noticed a bug in the engine initialization code for handling So I assumed that there was general support for the In terms of whether it's a big problem to add repeated IF we decided to add more support for the My thinking is that the script code would detect the That way script writers could write scripts that are agnostic to the exact number of indices for properties that they want to set uniformly for a range of indices, e.g. across engines etc. |
@seanmcleod Neither of those examples are directly indexing properties in the property tree. |
Correct, but they led me to believe as a user that there was a good chance that the And I think it would be a useful feature for users writing scripts, particularly as I mentioned for writing scripts that want to work across aircraft with varying numbers of engines as one example, and any other aircraft properties exposed via indices. |
@seanmcleod |
@bcoconni I've assigned it to myself in the meantime. I had started writing some code at the time to test out my proposal of having the script code generate multiple |
I have a multi-engine aircraft and I was trying to script a throttle increase for all engines in a script. So I tried the following:
However that results in an exception being thrown:
If I refer to all the engines individually then the script works as expected, e.g.
Now
FGFCS::SetThrottleCmd()
has explicit code to handle an index of-1
.However it looks as if the parsing code used by the script while processing
<set>
elements doesn't support negative index values.Is this limitation an oversight/bug or is this by design in terms of script events explicitly not supporting negative indices?
The text was updated successfully, but these errors were encountered: