So what exactly does the compiler have to see in order to accept the code?
It seems to me the syntax differs from case to case. For example when you call a tr function with the sendchat function you simply put it in quotes:
addXS("trUnitSelectClear(); trUnitSelectByID(revunit);");
So this is the syntax for tr functions without arguments, just inserted as string.
But in other maps (like AoE Racer), when you use the sendchat function to call tr functions which have arguments, you use a different syntax:
_LFDX("trQuestVarSet(\""+_LFPB+"\", trQuestVarGet(\""+_LFPB+"\") "+_NPLJ+" trQuestVarGet(\""+_PYAM+"\"));");
So, again, the tr function is simply inserted in quotes, but its arguments are preceded by a backslash and quotes. Then the actual variable is added then "\", etc.
I guess that's what I don't understand about this syntax -- is why does it vary from no backslash for functions without statements to first backslash two quotes and then quote-backslash-quote for tr functions with statements/variables/conditions. Is there any logic for the syntax to be this way, or it just is?
I tried to test this method with a sendchat and a tr function without statements/parameters.
So, I created a function with a Send Chat trigger:
int num=0;
void xsInject(string code=""){
rmCreateTrigger("Code feed"+num);
rmSwitchToTrigger(rmTriggerID("Code feed"+num));
rmSetTriggerActive(true);
rmSetTriggerRunImmediately(true);
rmSetTriggerLoop(false);
rmAddTriggerCondition("Timer");
rmSetTriggerConditionParamInt("Param1", 10);
rmAddTriggerEffect("Send Chat");
rmSetTriggerEffectParam("Message", "*/"+code+"/*", false);
num=num+1; }
And then I inserted an easy-to-test tr function:
xsInject("trRevealEntireMap();");
No result.
Well, I actually get an in-game string message with the command.
I also tried using the other syntax with \"" and "\" but it fails to load.
LE. And then, I found a reference to this method in an aom/aoe scripting guide, but the syntax is again different:
void rmInsertConditionCode(string xs="") {
rmAddTriggerCondition("Timer");
rmSetTriggerConditionParam("Param1","0==("+xs+"));//");
}
void rmInsertEffectCode(string xs="") {
rmAddTriggerEffect("SetIdleProcessing");
rmSetTriggerEffectParam("IdleProc", "true); "+xs+" //");
}
Are there more methods than one to make this work?