ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 1, 2014 12:38:52 GMT 1
The Check() function is not helpful because when one of the condition is met it keeps doing (displaying and changing) action every 2 seconds. If u put Suicide(); before end; then it wont run at all...
|
|
|
Post by Quintaxel on Oct 1, 2014 12:45:51 GMT 1
Yes, I'm aware of this. So what you would like is to check the condition for each unit, change the unit's party if a condition is met and then end; the function. If you put a Suicide(); before the last end; then it should work. I can not test this right now.
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 1, 2014 13:33:56 GMT 1
Unfortunately it doesn't work that way.
|
|
|
Post by Quintaxel on Oct 1, 2014 13:42:37 GMT 1
OK, I'll look into it. Give me some time.
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 3, 2014 11:20:55 GMT 1
How does repeat unitl works in blitz scite:
I' ve made this script but it wont run:
function Provjera() local i=1; local n=0; for i=1,2 do repeat if GetNUnitsInScriptGroup(100 + i )==0 then DisplayTrace("The unit %g is dead.",100+i); n=n+1; break; end; until (n<2) end; end; end;
function Init() RunScript("Provjera",1000); end;
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 3, 2014 12:13:21 GMT 1
If I could only assign global variable to array except by SetIGlobalVar() the problem could be solved easily:
function Provjera() local i; a={}; for i=1,2 do if GetNUnitsInScriptGroup(100+i)==0 and GetIGlobalVar("a",0)~=1 then DisplayTrace("The units %g is dead",100+i); SetIGlobalVar("a",1); end; end; end;
function Init() RunScript("Provjera",1000); end;
|
|
|
Post by Quintaxel on Oct 3, 2014 12:20:25 GMT 1
ecan, try putting ; after until (n<2)
until (n<2); What is it you are trying to do?
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 3, 2014 12:40:22 GMT 1
Finally! Test same condition and do something about it once if met, for units with multiple ID!
a={};
function Provjera() local i; for i=1,2 do if GetNUnitsInScriptGroup(100+i)==0 and (a~=1) then DisplayTrace("The units %g is dead",100+i); a=1; end; end; end;
function Init() RunScript("Provjera",1000); end;
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 3, 2014 12:44:01 GMT 1
Instead of writing multiple times functios like : if (condition) then (do something) for every ID unit.
|
|
|
Post by Quintaxel on Oct 3, 2014 14:30:31 GMT 1
Finally! Test same condition and do something about it once if met, for units with multiple ID! a={}; function Provjera() local i; for i=1,2 do if GetNUnitsInScriptGroup(100+i)==0 and (a ~=1) then DisplayTrace("The units %g is dead",100+i); a=1; end; end; end;
function Init() RunScript("Provjera",1000); end;ecan, does this now work ? Why would you use a table for the variable a ?
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 3, 2014 15:30:43 GMT 1
If condition for unit of ID = "i" is met then it will assign to a value 1 and it will DisplayTrace(). Because RunScript("Provjera",1000) executes function every second now it will check condition again but this time it will not meet second condition a~=1 so it will not execute comamnd block DisplayTrace() again.
This concept can be used to test same condition for any number of units and if the condition is met it will execute following command only once (or maybe more times if u want).
|
|