Help needed with component coding |
Hi guys, I apologize for asking so many questions but I have another question. In my mod all space vehicles(except units) require an energy reactor. (Nuclear,fusion,fission,quantum etc,.) I had an idea that more advanced components require a better reactor. Anti - Matter engines require at least a fusion reactor. The function get_specific_component_design works fine for this. The problem is how do I also code it to accept higher up reactors? Putting "or" between the functions didn't work.
An example of what I want to do, in vehicle sizes the Bridge requirement has an "or" between the two functions for Bridge and Master Computer. Is this not possible for the Components file?
Re: Help needed with component coding
This is definitely doable. What have you tried doing that did not work (just the component name and requirement fields for each component will suffice)? Make sure you are doing this in 1.66, since these sorts of function calls did not even work in the component req fields until very recent versions.
Re: Help needed with component coding
Just to be sure, you didn't use commas in the actual formula did you?
Re: Help needed with component coding
Its a single boolean formula, not a list. The whole thing has to evaluate to TRUE for the requirement to be satisfied. You have 3 separate items that could all trigger the requirement, which is of the form A OR B OR C (where A is a GSDCC()=1 bit).
Note that GSDCC() is a function that returns a number. That number is then tested to see if it is equal to one by the = operator. If it is, the = operation returns TRUE. Else, it returns FALSE. OR is an operator that compares two boolean values (TRUE/FALSE), and returns TRUE if at least one of those values is TRUE. Else, it returns FALSE.
I would recommend using >= 1 instead of just =, since the requirement will fail to be satisfied if you add two Fusion Reactors to a ship (even if they are one per ship, its a better habit to always do >= when you don't explicitly need = ).
(Get_Specific_Design_Component_Count("Fusion Reactor") >= 1) OR (Get_Specific_Design_Component_Count("Fission Reactor") >= 1) OR (Get_Specific_Design_Component_Count("Quantum Reactor") >= 1)
If you look more carefully at the bridge/master computer requirement in VehicleSizes.txt, you will see that it is written in the same format (OR is apparently not case sensitive):
(Get_Design_Ability_Component_Count("Control Center") = 1) or (Get_Design_Ability_Component_Count("Master Computer") >= 1)




Re: Help needed with component coding
I don't know for sure, but I think that you can make one rquirement field for each Reactor the engine can require and set an OR in the Placement field...