PDA

View Full Version : How to call a macro within a script ?



sonata31
April 16th, 2007, 09:16 AM
All is in the title

Ron
April 16th, 2007, 10:48 AM
You can but should not, what are you trying to do? Quite possibly you should do this differently.

sonata31
April 16th, 2007, 10:50 PM
Here is an example of my code :

macro1
--action1
--script1
--action2


script1 :
--if x ~= 1 then
----gir.TriggerEvent("EVENT1",18)
--end


macro2
--action3
--action4
--EVENT1


the problem is than action2 is executed before than macro2 is finished

Rob H
April 17th, 2007, 12:10 AM
It would be. Events are queued up and will be executed in order after the current action is finished.

I'd suggest that your script should look like this


if x ~= 1 then
gir.TriggerEvent("EVENT1",18)
else
gir.TriggerEvent("EVENT2", 18)
end

Then move action 2 to a separate action triggered by EVENT2, and add another call to gir.TriggerEvent("EVENT2", 18) to the end of macro2

sonata31
April 17th, 2007, 01:04 AM
It would be. Events are queued up and will be executed in order after the current action is finished.

I'd suggest that your script should look like this


if x ~= 1 then
gir.TriggerEvent("EVENT1",18)
else
gir.TriggerEvent("EVENT2", 18)
end

Then move action 2 to a separate action triggered by EVENT2, and add another call to gir.TriggerEvent("EVENT2", 18) to the end of macro2

Ok, it's a solution, thank You

But I found the plugins "Variable Conditionnal" and "Trigger node if" and it's ok

Rob H
April 17th, 2007, 01:19 AM
Yes, those will work nicely too.