Unit Doctrine as String
Posted: Sun Feb 21, 2021 9:06 am
OK, Does anyone have an idea how to get a unit's doctrine as a string?
ScenEdit_SetDoctrine takes a table as a parameter.
ScenEdit_GetDoctrine returns a table.
FYI: an empty table is the default doctrige for all units, this corespondes to all doctrine values are inherited from the parent.
To Set the doctrine of a unit in an event to inherit all values from the parent, I must create a script for the action.
This appears as:Or I could go in with guns blazing with:Now it gets interesting. I could set up an event where the script was implemented as:This allows me to pass in any doctrine and have it set. I can even grab the various strings to pass in from the GUI, by setting various doctrine values and doing )filling in the ???.
This is all fine and dandy, but what if in a later event, I want to return the doctrine to whatever it was before I mucked with it? TO do this using my odd event, I need the doctrine table as a string. Something equivalent to what is printed to the screen/console when I execute a print on the ScenEdit_GetDoctrine call.
So one might say, just grab the table, and call tostring on it. It doesn not work. I ran the following code:and got the following results:The tostring gives the Table and an address, while the print gets me what I want.
So the short of all this is: does anyone know how to get the equivalent of a print(ScenEdit_GetDoctrine(???)) call into a string value without calling print?
[&:]
ScenEdit_SetDoctrine takes a table as a parameter.
ScenEdit_GetDoctrine returns a table.
FYI: an empty table is the default doctrige for all units, this corespondes to all doctrine values are inherited from the parent.
To Set the doctrine of a unit in an event to inherit all values from the parent, I must create a script for the action.
This appears as:
Code: Select all
script = "ScenEdit_SetDoctrine({})"Code: Select all
script = "ScenEdit_SetDoctrine({ "..
"weapon_control_status_land = '0',"..
"engage_opportunity_targets = '1' })"Code: Select all
script="ScenEdit_SetDoctrine("..doctrineStr..")"Code: Select all
print(ScenEdit_GetDoctrine({side="???", name="???",})This is all fine and dandy, but what if in a later event, I want to return the doctrine to whatever it was before I mucked with it? TO do this using my odd event, I need the doctrine table as a string. Something equivalent to what is printed to the screen/console when I execute a print on the ScenEdit_GetDoctrine call.
So one might say, just grab the table, and call tostring on it. It doesn not work. I ran the following code:
Code: Select all
docTable = ScenEdit_GetDoctrine({side='USA', name='73rd Batallion 2nd Company 1st Platoon (M2A3 Bradley AFV x 4)'})
docStr = tostring(docTable)
print(docStr)
print(docTable)Code: Select all
table: 2BB97C78
{ ignore_plotted_course = '1', engage_opportunity_targets = '1', weapon_control_status_land = '0' }So the short of all this is: does anyone know how to get the equivalent of a print(ScenEdit_GetDoctrine(???)) call into a string value without calling print?
[&:]

