Talk:SailEvent
From Original War Support Wiki
Some Comments
This event would have been fantastic if it could be declared more than once, but as with all other events you can only declare it once. That fact makes you wonder: Why does function "RaiseSailEvent" then have to have a parameter? If there is only one "SailEvent" then why do you have to specify which "SailEvent" you want to raise? --- McBenn
Respond to comment up
You can set parameter with some value and then check the value of param through "if then". In this case, you can call various SailEvents. That's why SailEvent has a param. --- Josetto
RE: Respond to comment up
Thanks for the tip about the value exported by "RaiseSailEvent" :) odd I didn't think about that myself. But I still don't get your point with calling various SailEvents. Please illuminate us by rewriting this page. --- McBenn
- He is saying that you pass a parameter and check its value. That way you can then call seperate procedures for each different value of the parameter. Meaning you can have more than one type of SailEvent. --Stucuk 12:49, 7 May 2010 (UTC)
Respond to Stu
Ahh like that, of course. I thought maybe he was talking about triggering other events than "SailEvent" using "RaiseSailEvent". Hmm maybe one should add an example with this. --- McBenn 20:18, 8 May 2010 (UTC)
Sample Code
Here is code in my mod:
on SailEvent(param) do var a; begin if param = Frank then begin PlaceUnitXY(Frank,12,1,false); ComMoveXY(Frank,17,9); AddComMoveXY(Frank,16,18); AddComMoveXY(Frank,24,31); if (IsPlaced(JMM)) then AddComMoveUnit(Frank,JMM); AddComFree(Frank); end else if param = Nota then begin RemoveUnit(Nota); SetAttitude(7,2,att_enemy,true); RaiseSailEvent(listOfEnemyUnits); end else if param = listOfEnemyUnits then begin enable(2); for a in listOfEnemyUnits do begin PlaceUnitArea(a,arabianAttack,false); end; ComMoveXY(listOfEnemyUnits,69,27); AddComAgressiveMove(listOfEnemyUnits,62,51); end; end;
and here is its callings:
... param=Frank; //Frank is Frank Forsyth from original story RaiseSailEvent(param); ... param=Nota;// another using AddComSailEvent(Nota,param);
Maybe it's not best solution, but I think that instead of "every", that is taking some computing time every few ticks, this function is called only when I need it... and then the code should be faster I think :D
P.S.: I dint know how to put it in code code tag here so please someone update it :D
RE: Sample Code
Yeah, that's exactly what we are talking about :) but I think it's better with a "case value of" instead of all those "if's". And you can shorten
for a in listOfEnemyUnits do begin PlaceUnitArea(a,arabianAttack,false); end;
downto
for a in listOfEnemyUnits do PlaceUnitArea(a,arabianAttack,false);
Could you add an example with this to the explanation page? --- McBenn 03:33, 9 May 2010 (UTC)
RE: RE: Sample Code
Yes you were right case is better then if :D And "begin-end" in one-lined blocks I am using just because I am used to it (I work at work in team and for them is code more readable :D so sry :D) --Josetto 08:41, 9 May 2010 (UTC)