Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
droxon
Newbie


Joined: 13 Aug 2013
Posts: 8

PostPosted: Mon Jun 29, 2015 11:35 pm   

Infinite loops
 
Is there a way to allow an infinite event loop? I am trying to build a repeater to use health levels and a string list, but cmud keeps disabling my script because it repeats itself over and over.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Tue Jun 30, 2015 8:37 am   
 
No, because a true infinite loop will hog up available memory and never release priority, unless it was being executed in a thread, and even then I'm not sure if it's possible.
But really, there should be no need to have one.
Perhaps if you explain what your loop is trying to do i could help.
_________________
Discord: Shalimarwildcat
Reply with quote
droxon
Newbie


Joined: 13 Aug 2013
Posts: 8

PostPosted: Tue Jun 30, 2015 11:17 am   
 
well i push curing commands to a string list with triggers, there needs to be a delay between their uses so i use wait timers on separate aliases to switch variables on and off to time them properly. It tracks health and mana and uses a series of healing herbs and health potions to maintain health. I was using an alarm to space it out but it was deleting random settings from my package, and i was unable to use the settings window while it was running because of the spastic nature of the very short alarm repeating itself and firing the event.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Tue Jun 30, 2015 7:27 pm   
 
Were you using single use alarms, or a repeater?

#ALARM "HealerBot" -3 {#IF (@healCommands) {%pop(healCommands)}}

Every 3 seconds that will check to see if healCommands has any members, and if so, it will try to perform the first one.
_________________
Discord: Shalimarwildcat
Reply with quote
droxon
Newbie


Joined: 13 Aug 2013
Posts: 8

PostPosted: Tue Jun 30, 2015 10:59 pm   
 
i am using a repeater. #alarm +0.2 {pop}
pop has all the checks string list uses
then sets off the alarm again at the end
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Tue Jun 30, 2015 11:09 pm   
 
Seems like it would be going so fast it might try to execute the same code multiple times for only one injury. (as the commands haven't had time to resolve and update the stats used in your conditions).

i would suggest the use of #WAITFORs to ensure that each step has a chance to be completed.
_________________
Discord: Shalimarwildcat
Reply with quote
droxon
Newbie


Joined: 13 Aug 2013
Posts: 8

PostPosted: Tue Jun 30, 2015 11:16 pm   
 
Ok tried the #alarm - and it seems to have calmed things down. WIll wait and see if settings are still being deleted randomly
Reply with quote
droxon
Newbie


Joined: 13 Aug 2013
Posts: 8

PostPosted: Tue Jun 30, 2015 11:18 pm   
 
and thanks for your help shalimar! CMud will keep alive as long as people care enough to help others.
Reply with quote
droxon
Newbie


Joined: 13 Aug 2013
Posts: 8

PostPosted: Wed Jul 01, 2015 4:30 am   
 
is there a way to turn off the #alarm -1 with settings? I use a different version of the original for different envriments and would like to turn one off and switch the other on.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jul 01, 2015 6:44 am   
 
Sure. Set the ID for the alarms, and then use #T+ and #T- to control which ones are active.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net