The answer to the question "Can this be done?" is "No, it isn't possible to access the properties of a part via FUNK if the only thing that you have is its part ID, and there is no other way to access the maximum or current thrust of a single engine via Vizzy, with a few caveats".
If the part has a unique name, and that name contains no spaces, then you can access the properties of that part via Funk using the syntax "<part_name>", a period, and then one of the entries found on this page: https://wnp78.github.io/JunoXml/PartModifierScriptProperties
So, "MageEngine.RocketEngine.MaximumThrust" works, as long as there is only one engine on the craft named "MageEngine". If there are two, it will still work, but it'll only return data on one (likely the one that was placed first, but I didn't ask). If the part name contains spaces it can't be accessed via this method at all.
If there is only one engine on a stage, then you can access information about the engine via the GUI controls (Expressions / Performance). In addition, current stage performance data can be access via FUNK (via "FlightData.*").
To address my use case (detecting burn out when using parallel staging), it was pointed out that an engine that has no fuel no longer contributes to FlightData.MaxActiveEngineThrustUnscaled, so if this number drops then it is safe to assume that some engines have burned out. While this is less than an ideal solution (you can't detect when SRB's start to tail-off using this method, although you could monitor FlightData.CurrentEngineThrustUnscaled, but then you have to worry about throttling of liquid fueled engines...) it is what it is.
Doesn't produce an error, but it also doesn't set Tmp to anything (Tmp retains the same value as before the funk statement).
v:Tmp = *.2.RocketEngine.MaximumThrust
Returns the error "Unary operator not supported: Multiply".
I re-iterate that it appears to me (as a developer myself) that a prefix (like "p:") is required to access the parts search functionality. That's based on the fact that the parser is interpreting "*." as an attempt to multiply, and it shouldn't (given the syntax given described in the linked webpage).
As you wish, I'll post this question to Discord. Given that nobody has shared a rocket that uses this functionality, I don't have much hope of getting help, but I'll post it.
I'm not trying to set anything, at least not as part of the funk expression. The funk expression in the programming environment returns a value, right? I've seen lots of examples of people, for example using something like this (with far more complex expression)
Set variable MyVar to funk(join("cosh(", OtherVar, ")")
I want to do the same thing, except I want to set MyVar to the maximum thrust of the engine with an ID #2.
At this point, I'm getting the impression that this impossible. If that's the case, I guess that's that. But it seems an very odd and arbitrary limitation.
To clarify: I'm asking for you to confirm that this statement is true: "It is not possible to set a variable in the graphical programming environment to the maximum thrust of a single arbitrary engine (identified by its unique part ID)"
Or to provide an example of the a statement that performs this task (assuming the engine is named "Mage Engine", the ID is "2", and the variable is "MyVar").
Edited to add: Sorry for the double post -- the website retains the text of a new post after submission.
The web page you listed is... Well, it appears to be outright wrong.
At the bottom of the page, it says: "How awesome! Then it gets even more complex. You can get parameters from different parts in the crafts using the following format: [PartSelector].ModifierSelector[.Data][.PropertySelector].
Ok, so I can write a Vizzy program, use the FUNK operator to set a variable to "Mage Engine.2.RocketEngine.MaximumThrust"? Nope, that's a syntax error.
How about "*.2.RocketEngine.MaximumThrust"? Nope, still a syntax error.
How about "Mage.2.RocketEngine.MaximumThrust"? Hey, that returns a 0, that's progress, right?
Well... How about "sdkdk.2.RocketEngine.MaximumThrust"? That also returns a 0, so no go.
How about ".2.RocketEngine.MaximumThrust"? Back to a syntax error.
Well, maybe if I rename the engine to "MageEngine"? Nope, "MageEngine.2.RocketEngine.MaximumThrust" returns a 0. So does "abs(Mage_Engine.2.RocketEngine.MaximumThrust)"
And yes, I've verified by looking at the XML file that the part with ID="2" is, indeed, a Mage Engine, named originally "Mage Engine" and then later changed to "Mage_Engine".
The syntax given on the web page is obviously completely incorrect. I suspect that a prefix is required (like with "v:" to access variables) is required, but not mentioned on the web page.
Help?
For context: I'm trying to iterate over all the parts on the craft, find the active engines, and check their thrust levels (current / maximum) to determine which engines are producing the expected amount of thrust and which ones are not. When some / all of the engines aren't producing the expected amount of thrust I'll trigger a staging event. The goal is to support automatic staging when you one engine that is active over multiple stages (for example, a space shuttle). There are probably other ways to do it, but... This way should work.
To close the loop on this question:
The answer to the question "Can this be done?" is "No, it isn't possible to access the properties of a part via FUNK if the only thing that you have is its part ID, and there is no other way to access the maximum or current thrust of a single engine via Vizzy, with a few caveats".
If the part has a unique name, and that name contains no spaces, then you can access the properties of that part via Funk using the syntax "<part_name>", a period, and then one of the entries found on this page: https://wnp78.github.io/JunoXml/PartModifierScriptProperties
So, "MageEngine.RocketEngine.MaximumThrust" works, as long as there is only one engine on the craft named "MageEngine". If there are two, it will still work, but it'll only return data on one (likely the one that was placed first, but I didn't ask). If the part name contains spaces it can't be accessed via this method at all.
If there is only one engine on a stage, then you can access information about the engine via the GUI controls (Expressions / Performance). In addition, current stage performance data can be access via FUNK (via "FlightData.*").
To address my use case (detecting burn out when using parallel staging), it was pointed out that an engine that has no fuel no longer contributes to FlightData.MaxActiveEngineThrustUnscaled, so if this number drops then it is safe to assume that some engines have burned out. While this is less than an ideal solution (you can't detect when SRB's start to tail-off using this method, although you could monitor FlightData.CurrentEngineThrustUnscaled, but then you have to worry about throttling of liquid fueled engines...) it is what it is.
+3 1.8 years agoNow that I'm back at my desktop, I can try your suggestion:
0.FlightProgram.Tmp = Mage_Engine.2.RocketEngine.MaximumThrust
returns a syntax error.
v:Tmp = Mage_Engine.2.RocketEngine.MaximumThrust
Doesn't produce an error, but it also doesn't set Tmp to anything (Tmp retains the same value as before the funk statement).
v:Tmp = *.2.RocketEngine.MaximumThrust
Returns the error "Unary operator not supported: Multiply".
I re-iterate that it appears to me (as a developer myself) that a prefix (like "p:") is required to access the parts search functionality. That's based on the fact that the parser is interpreting "*." as an attempt to multiply, and it shouldn't (given the syntax given described in the linked webpage).
+2 1.8 years agoAs you wish, I'll post this question to Discord. Given that nobody has shared a rocket that uses this functionality, I don't have much hope of getting help, but I'll post it.
+1 1.8 years agoI'm not trying to set anything, at least not as part of the funk expression. The funk expression in the programming environment returns a value, right? I've seen lots of examples of people, for example using something like this (with far more complex expression)
Set variable MyVar to funk(join("cosh(", OtherVar, ")")
I want to do the same thing, except I want to set MyVar to the maximum thrust of the engine with an ID #2.
At this point, I'm getting the impression that this impossible. If that's the case, I guess that's that. But it seems an very odd and arbitrary limitation.
To clarify: I'm asking for you to confirm that this statement is true: "It is not possible to set a variable in the graphical programming environment to the maximum thrust of a single arbitrary engine (identified by its unique part ID)"
Or to provide an example of the a statement that performs this task (assuming the engine is named "Mage Engine", the ID is "2", and the variable is "MyVar").
Edited to add: Sorry for the double post -- the website retains the text of a new post after submission.
+1 1.8 years agoThe web page you listed is... Well, it appears to be outright wrong.
At the bottom of the page, it says: "How awesome! Then it gets even more complex. You can get parameters from different parts in the crafts using the following format:
[PartSelector].ModifierSelector[.Data][.PropertySelector]
.Ok, so I can write a Vizzy program, use the FUNK operator to set a variable to "Mage Engine.2.RocketEngine.MaximumThrust"? Nope, that's a syntax error.
How about "*.2.RocketEngine.MaximumThrust"? Nope, still a syntax error.
How about "Mage.2.RocketEngine.MaximumThrust"? Hey, that returns a 0, that's progress, right?
Well... How about "sdkdk.2.RocketEngine.MaximumThrust"? That also returns a 0, so no go.
How about ".2.RocketEngine.MaximumThrust"? Back to a syntax error.
Well, maybe if I rename the engine to "MageEngine"? Nope, "MageEngine.2.RocketEngine.MaximumThrust" returns a 0. So does "abs(Mage_Engine.2.RocketEngine.MaximumThrust)"
And yes, I've verified by looking at the XML file that the part with ID="2" is, indeed, a Mage Engine, named originally "Mage Engine" and then later changed to "Mage_Engine".
The syntax given on the web page is obviously completely incorrect. I suspect that a prefix is required (like with "v:" to access variables) is required, but not mentioned on the web page.
Help?
For context: I'm trying to iterate over all the parts on the craft, find the active engines, and check their thrust levels (current / maximum) to determine which engines are producing the expected amount of thrust and which ones are not. When some / all of the engines aren't producing the expected amount of thrust I'll trigger a staging event. The goal is to support automatic staging when you one engine that is active over multiple stages (for example, a space shuttle). There are probably other ways to do it, but... This way should work.
+1 1.8 years ago