I already read the guide in http://openkore.com/index.php/Macro_plugin, but still I don't know how to use 'else' in a macro. I always got a syntax error when using it. I concluded that else statement is not supported in macro. I already tried to update macro plugin and openkore. I like to try perl subroutine, but I think it will make my macro much more complex cause it has a lot of macro instruction like call, goto, do
Is there a way to use 'else' or code it?? a script that run like an else in if statement
how to use else and elsif in if statement?
Moderator: Moderators
-
- Noob
- Posts: 1
- Joined: 04 Feb 2013, 22:07
- Noob?: No
-
- Plain Yogurt
- Posts: 51
- Joined: 02 Sep 2012, 11:09
- Noob?: No
- Location: Brazil - PR
Re: how to use else and elsif in if statement?
It really is a bit confusing examples that have this link, a look at the code below, hope it helps.nightwing_crisis wrote:I already read the guide in http://openkore.com/index.php/Macro_plugin, but still I don't know how to use 'else' in a macro. I always got a syntax error when using it. I concluded that else statement is not supported in macro. I already tried to update macro plugin and openkore. I like to try perl subroutine, but I think it will make my macro much more complex cause it has a lot of macro instruction like call, goto, do
Is there a way to use 'else' or code it?? a script that run like an else in if statement
Code: Select all
$Map = @eval($::config{Battle_Map})
if ($Map == tierra1) goto Pos1
if ($Map == tierra2) goto Pos2
if ($Map == tierra3) goto Pos3
if ($Map == tierra4) goto Pos4
if ($Map == flavius1) goto Pos1
if ($Map == flavius2) goto Pos2
if ($Map == flavius3) goto Pos3
if ($Map == flavius4) goto Pos4
:Pos1 *<< This - would be like if you were using a Else
Code: Select all
A more complicated macro
macro if {
$i = 1
log \$i = $i
if (((($i = 1 || $i < 5 || $i ~ 0 .. 5) && @eval(@eval($i - 1) - @eval($i - 0)) = -1) && ($i != 2 && $i > 0 && @eval($i - 1) = 0) && ($i != 2 && $i > 0 && @eval($i - 1) = 0)) && $i = 1) goto somewhere
if (($i = 1 || $i < 5 || $i ~ 0 .. 5) && ($i != "" && $i > 0 && @eval($i - 1) = 0)) goto somewhere
if (@eval (@eval($i-1) - 1) != "") goto somewhere
if ((($i = 1) || ($i < 5 && $i ~ 0 .. 5)) && ($i != "" && $i > 0 && @eval($i - 1) > 0)) goto somewhere
log ko
stop
:somewhere * <<< example
log OK
}