Jump to content
  • 0
Sign in to follow this  
Zirius

What would become of "goto" ?

Question

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!

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.