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
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon Mar 02, 2009 6:12 am   

Infinite loop toggle?
 
I have an alias that intentionally runs on an infinite loop, resetting itself with a wait timer every 5 seconds. However every now and then the client will come up with an error, notifying me of the infinite loop.

This isn't a huge problem since all I do is click the box and enter the alias again, but I was wondering if there was a toggle to disable this, or a way to not trigger it. The full alias is as follows, and handles alot of my buffing.

#SWITCH ((@mana > 10) and (@frenzy = no)) {c frenzy} ((@lkicks = no) and (@mana > 10)) {c 'lightning kick'} ((@stonefist = no) and (@mana > 10)) {c 'stone fist'} ((@elfists = no) and (@mana > 10)) {c '@fistele fi'} ((@combat = no) and (@stoneskin = No) and (@ctype = muser) and (@mana > 10)) {Cast 'stone skin'} ((@combat = no) and (@talons = no) and (@mana > 10)) {Cast 'talon'} ((@combat = no) and (@@bless = no) and (@mana > 10)) {Cast 'bless'} ((@combat = no) and (@ctype = muser) and (@mvm < 75) and (@mana > 50)) {c refresh} ((@bless = no) and (@combat = no) and (@mana > 10)) {c bless} ((@combat = yes) and (@Mana > @stol) and (@HP > 50) and (@spellmode = on) and (@ctype = muser)) {c @ospell} ((@ctype = muser) and (@combat = no) and (@blind = no)) {c 'locate person' @hunted2} ((@ctype = warrior) and (@combat = no)) {hunt @hunted2} (@combat = yes) {@downing}
#WAIT 5000
buffupkeep
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Mar 02, 2009 11:36 am   
 
Don't use #wait, use #alarm +5 {buffupkeep} at the end, or #alarm 5 {buffupkeep} which will call the buffupkeep alias every 5 seconds.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Mar 02, 2009 11:47 am   
 
Instead of a recursive alias, split it into the alias and an alarm type trigger which calls the alias. Alternatively, if you're not using the tick timer for anything at the moment you can run it off of that.

Edit: Too slow, ninja'd! :(
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon Mar 02, 2009 2:02 pm   
 
What's the fundamental difference in wait and alarm?
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon Mar 02, 2009 2:08 pm   
 
I've made the recommended alteration:

#alarm +5 {buffupkeep}

However now it seems like every other iteration it doubles the command.

c talons

c talons
c talons

(Changed to #alarm 5 {buffupkeep}, fixed problem)

Thanks!


Last edited by Khana on Mon Mar 02, 2009 2:09 pm; edited 1 time in total
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Mar 02, 2009 2:09 pm   
 
Using

#alarm +5 {buffupkeep}

Creates a temporary trigger which fires five seconds after it was created (calling the alias, and then having the line at the end of the alias recreates the trigger every time).

#alarm 5 {buffupkeep}

Creates a permanent trigger which fires every five seconds. This should be a little faster than the above method, since in general creating a new setting like a trigger is slow, additionally you don't need to recreate the trigger at the end of your alias, since it never goes away.

#wait doesn't use normal triggers at all, and instead uses multi-threading.

Anyway, the point is to remove the direct call to buffupkeep from buffupkeep which is what is triggering the infinite loop prompt.

Edit: Can you post the whole new text of your alias, so we can see exactly what changes you made, please?
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon Mar 02, 2009 2:12 pm   
 
Thanks Gamma, that explains alot.

Here's the new alias:

Code:
#SWITCH ((@mana > 10) and (@frenzy = no)) {c frenzy} ((@lkicks = no) and (@mana > 10)) {c 'lightning kick'} ((@stonefist = no) and (@mana > 10)) {c 'stone fist'} ((@elfists = no) and (@mana > 10)) {c '@fistele fi'} ((@combat = no) and (@stoneskin = No) and (@ctype = muser) and (@mana > 10)) {Cast 'stone skin'} ((@combat = no) and (@talons = no) and (@mana > 10)) {Cast 'talon'} ((@combat = no) and (@bless = no) and (@mana > 10)) {Cast 'bless'} ((@combat = no) and (@ctype = muser) and (@mvm < 75) and (@mana > 50)) {c refresh} ((@bless = no) and (@combat = no) and (@mana > 10))  {c bless} ((@combat = yes) and (@Mana > @stol) and (@HP > 50) and (@spellmode = on) and (@ctype = muser)) {c @ospell} ((@ctype = muser) and (@combat = no) and (@blind = no)) {c 'locate person' @hunted2} ((@ctype = warrior) and (@combat = no)) {hunt @hunted2} (@combat = yes) {@downing}
#alarm 5 {buffupkeep}


One more thing. Everyone elses coding appears to look much more organized than mine, this really looks like a jumble, I tried punctuating each iteration in the switch by pressing return and indenting it like I see most coding done on here but it appears to break the string. IE:

Code:
#SWITCH ((@mana > 10) and (@frenzy = no)) {c frenzy}
((@lkicks = no) and (@mana > 10)) {c 'lightning kick'}
 ((@stonefist = no) and (@mana > 10)) {c 'stone fist'}
 ((@elfists = no) and (@mana > 10)) {c '@fistele fi'}
((@combat = no) and (@stoneskin = No) and (@ctype = muser) and (@mana > 10)) {Cast 'stone skin'}
((@combat = no) and (@talons = no) and (@mana > 10)) {Cast 'talon'}
((@combat = no) and (@bless = no) and (@mana > 10)) {Cast 'bless'}
((@combat = no) and (@ctype = muser) and (@mvm < 75) and (@mana > 50)) {c refresh}
((@bless = no) and (@combat = no) and (@mana > 10))  {c bless}
((@combat = yes) and (@Mana > @stol) and (@HP > 50) and (@spellmode = on) and (@ctype = muser)) {c @ospell}
((@ctype = muser) and (@combat = no) and (@blind = no)) {c 'locate person' @hunted2} ((@ctype = warrior) and (@combat = no)) {hunt @hunted2}
(@combat = yes) {@downing}
#alarm 5 {scriptcommand}


appears defunct. How do I better organize my code, or is it because I use zScript instead of the other languages that I'm relegated to paragraphs?
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Mar 02, 2009 3:08 pm   
 
You just need to indent every line properly, um, like this:
Code:
#SWITCH ((@mana > 10) and (@frenzy = no)) {c frenzy}
  ((@lkicks = no) and (@mana > 10)) {c 'lightning kick'}
  ((@stonefist = no) and (@mana > 10)) {c 'stone fist'}
  ((@elfists = no) and (@mana > 10)) {c '@fistele fi'}
  ((@combat = no) and (@stoneskin = No) and (@ctype = muser) and (@mana > 10)) {Cast 'stone skin'}
  ((@combat = no) and (@talons = no) and (@mana > 10)) {Cast 'talon'}
  ((@combat = no) and (@bless = no) and (@mana > 10)) {Cast 'bless'}
  ((@combat = no) and (@ctype = muser) and (@mvm < 75) and (@mana > 50)) {c refresh}
  ((@bless = no) and (@combat = no) and (@mana > 10))  {c bless}
  ((@combat = yes) and (@Mana > @stol) and (@HP > 50) and (@spellmode = on) and (@ctype = muser)) {c @ospell}
  ((@ctype = muser) and (@combat = no) and (@blind = no)) {c 'locate person' @hunted2}
  ((@ctype = warrior) and (@combat = no)) {hunt @hunted2}
  (@combat = yes) {@downing}


Also you shouldn't need the last line, once the alarm is created (since it uses 5 and not +5) it should be permanent.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Mar 02, 2009 3:17 pm   
 
The first example isn't how you should be using #alarm. That alias will create a new alarm each time it's run. Each alarm will then run every five seconds, and so you might get duplicate commands. It's possible that CMUD is smart and will know not to create another identical alarm, but if that's the case you still don't need a command to create a new one.

Using #alarm 5 {}, you need to run the command once and you're set forever.

In CMUD, a linebreak indicates a new command. So if you were to type

Code:
#if (@blah) {true-command}
{else-command}


CMUD would see the {else-command} part as a new command and not part of the #if. If you want CMUD to join the two lines together, you need to indent them:

Code:
#if (@blah) {true-command}
  {else-command}


You can even do things like:

Code:
#say Hello
  world,
  this
  is
  Fang.


I'm not sure quite how the rules work in this case, but this sort of construct is also possible:

Code:
#if (@blah) {
  command1
  command2
} {
  command3
  command4
}


So that's something you can play with as well. There's also a "reformat script" option under the Editor menu in the package editor which works a bit like an on-demand version of zMUD's pretty printer - but check that your script compiles before you run it, or it may cause problems.

Finally, this is how I'd format your particular example:

Code:
#SWITCH ((@mana > 10) and (@frenzy = no)) {c frenzy}
  ((@lkicks = no) and (@mana > 10)) {c 'lightning kick'}
  ((@stonefist = no) and (@mana > 10)) {c 'stone fist'}
  ((@elfists = no) and (@mana > 10)) {c '@fistele fi'}
  ((@combat = no) and (@stoneskin = No) and (@ctype = muser) and (@mana > 10)) {Cast 'stone skin'}
  ((@combat = no) and (@talons = no) and (@mana > 10)) {Cast 'talon'}
  ((@combat = no) and (@@bless = no) and (@mana > 10)) {Cast 'bless'}
  ((@combat = no) and (@ctype = muser) and (@mvm < 75) and (@mana > 50)) {c refresh}
  ((@bless = no) and (@combat = no) and (@mana > 10)) {c bless}
  ((@combat = yes) and (@Mana > @stol) and (@HP > 50) and (@spellmode = on) and (@ctype = muser)) {c @ospell}
  ((@ctype = muser) and (@combat = no) and (@blind = no)) {c 'locate person' @hunted2}
  ((@ctype = warrior) and (@combat = no)) {hunt @hunted2}
  (@combat = yes) {@downing}


Oh, and one last thing - your final clause there, with @downing, will probably suffer from this problem.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Mar 02, 2009 3:36 pm   
 
Reformat seems to be non-functional in this instance. I formatted everything correctly, made sure it was working, took out my tabs and newlines, made sure it was still working, tried to reformat--nothing.
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon Mar 02, 2009 3:38 pm   
 
Hm, I appreciate the formatting for me, but I still can't figure out how to do it manually. Does the entire script have to be formatted the same in order for it to compile? So that when I'm in the midst of formatting it would appear as if it doesn't? I copy/pasted your example into my alias, and it works, I was just curious. Is there a certain # of spaces in the indentation, or just the tab button?

Also as for the @downing portion, so far it's run perfectly despite whatever bugs, but I really appreciate the heads up, and I'll keep an eye out.

One more thing, the alias is linked to a button that activates/deactivates the automatic buffing, if this is the case should I still remove the #alert function from the alias?

Edit: Or do I add the alert function to the button?

Edit edit: and then if I add the alert function to the button, how do I put the alert trigger in the class that's deactivated with the button toggle off?

Thanks in advance.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Mar 02, 2009 3:55 pm   
 
Just the tab button for the indentation.

And if you open up the settings editor, you should have a trigger somewhere with the pattern of "5". Just move that to whatever class you want, and enable/disable that class with your button. (The alias and everything else can be outside of that class if you like, just disabling the trigger will keep it from trying to re-buff every 5 seconds.)
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon Mar 02, 2009 4:01 pm   
 
Interesting. That only just occurred to me since I realized the trigger was self-sustaining.

Thanks again.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Mar 02, 2009 4:02 pm   
 
Khana wrote:
Hm, I appreciate the formatting for me, but I still can't figure out how to do it manually. Does the entire script have to be formatted the same in order for it to compile? So that when I'm in the midst of formatting it would appear as if it doesn't?

Not sure what you're asking - please clarify. Don't use words like "manually", explain exactly what you're pressing or typing or whatever.

Khana wrote:
Is there a certain # of spaces in the indentation, or just the tab button?

One works, more is fine too.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon Mar 02, 2009 5:45 pm   
 
Fang Xianfu wrote:

Not sure what you're asking - please clarify. Don't use words like "manually", explain exactly what you're pressing or typing or whatever.


Well, I meant I was typing return, then a few spaces and indenting that way, as opposed to the reformat script option. Since then however I've realized that after organizing it like that I had to "refresh script" or something to make it show that it would compile.
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