What would become of "goto" ?

Zirius

New member
Messages
261
Points
0
So I have read the potential of this: https://github.com/HerculesWS/Hercules/pull/374

And wondering what should i replace for "goto" function?

Most of my scripts are using goto even my healer NPC.

So, how do you make this not use goto?

- script Healer -1,{if ( Delay_Heal > gettimetick(2) ) goto deley; specialeffect2 EF_HEAL; percentheal 100,0; specialeffect2 EF_BLESSING; sc_start SC_BLESSING, 360000, 10; specialeffect2 EF_INCAGILITY; sc_start SC_INC_AGI, 360000, 10; set Delay_Heal,gettimetick(2)+3*60;end;deley: mes "[Healer]"; mes "Sorry, I can only help you once per 3 minutes."; close;end;}

Thanks!

 
Code:
if ( Delay_Heal > gettimetick(2) ) {    mes "[Healer]";    mes "Sorry, I can only help you once per 3 minutes.";    close;}
 
Yes, as Angelmelody showed, that is the proper way to handle your particular situation. However with other concerns where you may be using a make shift loop like the following:

L_Loop:.@a = rand(1,6);if( .@a != 2 ){ .@b++; goto L_Loop; }mes "It took you "+ .@b +" tries to roll a 2.";close;
You can replace goto L_Loop with 1 of the following. The first example being the correct way.

while( rand(1,6) != 2 ) {.@b++}mes "It took you "+ .@b +" tries to roll a 2.";close;
OR simply replace goto with callsub

.@a = rand(1,6);if( .@a != 2 ){ .@b++; callsub L_Loop; }mes "It took you "+ .@b +" tries to roll a 2.";close;

But lastly, if you read the documentation in that link, they did mention a synonym may be provided. Meaning a command which will act like goto " could " be created. The difference is, this will also act like jump_zero as well. So basically replacing 2 commands with 1 command.

 
goto will never be removed as it's used internally by some instruction (if, switch, for, do, while, function).

But it will be surely renamed as __goto (or similar name) to avoid it's used in script. In fact you don't need it, except if you do some awesome optimizations.

 
Back
Top