Jump to content

Question

Posted (edited)

Is there a way to loop the special effect command? I want the effect to repeat itself for the same duration as progress bar. In my case 10 secs. I want the effect to go off while charging and loop until charge is completed.

Edited by ScriptingPhailure

8 answers to this question

Recommended Posts

Posted (edited)

I tried that and it gave me an infinite loop. Could you take a look at my script and tell me where to apply and what?

 new_1-3,100,120,3	script	Fishing Spot	857,15,15,{

mes "[Yourself]";
mes "Maybe I should go fishing.";
switch(select("yes:no")) {
case 1:
close2;
goto OnAction;
end;



case 2:
mes "ok bye failure";
close;
}

OnAction:
[b]specialeffect 54;  [/b]//I want this to loop for 10 secs while the progress bar charges up
progressbar "^000000",10;
set fishingz, rand(7);
if (fishingz == 0) goto gotfish;
if (fishingz == 1) goto gotfish;
if (fishingz == 2) goto gotfish;
if (fishingz == 3) goto gotfish;
if (fishingz == 4) goto gotfish;
if (fishingz == 5) goto gotfish;
if (fishingz == 6) goto gotfish;
close;

OnTouch:						   
showevent 2,0;					
end;	  

specialeffect2 14 ;
getitem 579,1;
close;
} 

Edited by ScriptingPhailure
Posted

1.

set .@duration, 10;
set .@delay, 1000;
set .@timeToEnd, gettimetick(2) + 
while (gettimetick(2)<.@timeToEnd) {
specialeffect whatever;
sleep2 .@delay;
}

2.

set .working, 1;
set .@delay, 1000;
initnpctimer;
while (.working) {
specialeffect whatever;
sleep2 .@delay;
}
end;

OnTimer[something]:
.working = 0;
end;

Needless to mention the 1) is much better, but you can choose the one is more convenient for you.

Posted

OnEffect:
set @loop_effect, 1;
set .@delay, 500;
while ( @loop_effect ) {
	specialeffect 54;
	sleep2 .@delay;
}
end;

OnAction:
doevent strnpcinfo(3) + "::OnEffect";
progressbar "^000000",10;
set @loop_effect, 0;

Since progressbar() pause the script you have to do the effect loop in another """thread""".

Posted (edited)

OnEffect:
set @loop_effect, 1;
set .@delay, 500;
while ( @loop_effect ) {
	specialeffect 54;
	sleep2 .@delay;
}
end;

OnAction:
doevent strnpcinfo(3) + "::OnEffect";
progressbar "^000000",10;
set @loop_effect, 0;

Since progressbar() pause the script you have to do the effect loop in another """thread""".

This effect still triggers after the progress bar finishes charging not while. Then it's an infinite loop.

Is it possible to use doevent to trigger two events at once?

Edited by ScriptingPhailure

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...