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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
bluedrache
Newbie


Joined: 07 Jul 2006
Posts: 6
Location: Skei's Haven, Krynn

PostPosted: Fri Jul 07, 2006 5:42 pm   

Script Psudeocode for AFK bot. Discuss Please?
 
Yup, it's probably "just another AFK bot", but as a noob, I find these type of scripts excellent for jumping in and getting one's feet wet.

This is MUD specific, so I'm going to post pseudocode for the community to bugfix my train of thought.

Code:

; Start this program in Room B
; Initialize variables
#Var LoopCount 0
While {1=1} {
   LoopCount = 0
   While {LoopCount < 6} {
      #Math LoopCount (LoopCount+1)
      ; *** Kill Routine ***
      ; Move to Room A and kill the weaker enemies.
      #Wait (1000*60*10) // Sleep 10 Min
      ; Move to Room B and kill the weaker enemies.
      #Wait (1000*60*10) // Sleep 10 Min
   }
   ; *** Sell Routine ***
   ; Move to shop
   ; Sell Junk
   ; Move back to Room B
}


What I'm asking for is confirmation on my usage of #Var, #Math and my variable names.

I've already tested the While {1=1} { ; *** Kill Routine *** } section, and was thinking on getting fancier with it, writing an intelligent "bot" eventually...but need some more instruction on the useage of variables.

Thank you for your time.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Jul 08, 2006 3:25 am   
 
#variable is being used correctly. Any command referencing a variable as the destination (ie, #VARIABLE LoopCount 0) for it's processing requires you use the Variablename syntax. Any function at all, or any command or function that uses the variable as a value within its processing (ie, #WHILE (@LoopCount < 6) {stuff to do here}) requires you to use the @variablename syntax.

Your use of the A=B syntax is correct.

Your use of the variable name in the #WHILE condition is incorrect.

Your use of the variable name in the #MATH command's first parameter is correct.

Your use of the variable name in the #MATH command's second parameter is incorrect.

Beyond this, avoid #WAIT completely. #WAIT pauses all your trigger processing. Similarly, bow down to the Syntax Checker. If it's throwing up a red flag, fix it as soon as possible or it could potentially corrupt either what you are working on or your settings in general. Especially large, intensive settings.
_________________
EDIT: I didn't like my old signature
Reply with quote
bluedrache
Newbie


Joined: 07 Jul 2006
Posts: 6
Location: Skei's Haven, Krynn

PostPosted: Sat Jul 08, 2006 3:59 am   
 
Ah, I wrote it in SciTE, actually, and didn't have zMUD available for syntax checking, just a quick and dirty ditty that may grow into....a monster!!! Ahh!!! Thank you though, I'll fix that.

Ok, other than #wait, what should I use?

Code:

; Start this program in Room B
; Initialize variables
#Variable LoopCount 0
#While {1=1} {
  LoopCount = 0
  #While (@LoopCount < 6) {
    #Math LoopCount (@LoopCount+1)
;    *** Kill Routine ***   
;    Move to Room A and kill the weaker enemies.
    #send {n}
    #send {kill babies and children}
    #Wait (1000*60*5) // Sleep 5 Min
;    Move to Room B and kill the weaker enemies.
    #send {s}
    #send {kill babies and children}
    #Wait (1000*60*5) // Sleep 5 Min
    }
  LoopCount = 0
;  *** Sell Routine ***
;  Move to shop
  #slow (Nurse2Shop)
  #While (@LoopCount = 0) {#trigger {Daisy Damson is here} {@LoopCount = 1}}
;  Sell Junk
  #send {sell tops}
  #send {sell tops}
  #wait (1000*10)
  #send {sell tops}
  #send {sell tops}
  #wait (1000*10)
  #send {sell box}
  #send {sell box}
  #wait (1000*10)
  #send {sell box}
  #send {sell box}
  #wait (1000*10)
  #send {sell gums}
;  Move back to Room B
  #slow (Shop2Nurse)
  #While (@LoopCount = 0) {#trigger {Party Listing.} {@LoopCount = 1}}
  }


All right...this is what I have. Yes, I'm still using #Wait for lack of anything better. Would a tick timer work?

edit: Fixed syntax errors with #wait
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Sat Jul 08, 2006 6:34 am   
 
#ALARM Cool
Reply with quote
bluedrache
Newbie


Joined: 07 Jul 2006
Posts: 6
Location: Skei's Haven, Krynn

PostPosted: Sat Jul 08, 2006 3:55 pm   
 
Ok, #ALARM. I'll change that.....Fixed syntax error with #Slow ... was using parenthesis, not braces. *smacks forehead*

Ok, on #Alarm...I've read TFM, but ... it's still confusing.

instead of #wait (5*60*1000) for a wait of 5 minutes...

I'd use #Alarm "Sleeper" +5:00

As the script goes down the line, would it suspend at that point? Or just create a timer and keep on going?
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Sat Jul 08, 2006 4:49 pm   
 
It would just create a timer and keep on going.
_________________
Taz :)
Reply with quote
bluedrache
Newbie


Joined: 07 Jul 2006
Posts: 6
Location: Skei's Haven, Krynn

PostPosted: Sun Jul 09, 2006 12:10 am   
 
Then that's not what I want. I want something that pauses the execution of the script and #wait is the only thing that will do that.
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Sun Jul 09, 2006 2:37 am   
 
#alarm +300 {#send {s}
#send {kill babies and children}
#alarm +300 {} // Sleep 5 Min }
just put the next part of the script in the alarm
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Sun Jul 09, 2006 2:56 am   
 
Sorry, I wasn't paying attention. Please forgive me.

You could use #ALARM if you broke the script into several aliases and called each with an alarm from the previous one.

Another option would be a multistate wait trigger.

Finally, you can just leave the #WAIT commands in the script. This is something you'll need to decide. For a discussion of the problems associated with #Wait go here and scroll down to the appropriate section.
Reply with quote
bluedrache
Newbie


Joined: 07 Jul 2006
Posts: 6
Location: Skei's Haven, Krynn

PostPosted: Sun Jul 09, 2006 4:57 am   
 
So.... a better way to write it would be

#TRIGGER {} {} // trigger on anything
#CONDITION {} {} {Wait|Param=5*60*1000} // wait five minutes.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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