About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
Odoth
Wanderer


Joined: 13 Nov 2004
Posts: 54
Location: Visalia, CA

PostPosted: Tue Nov 28, 2006 7:38 pm   

Flow control issues
 
I'm in the process of trying to automate as much as my questing procedure as possible. I'm generally running into the problem of not being able to effectively control the flow of the script. I don't really understand what the best/cleanest way is to execute a series of commands, wait for a process to be finished, then execute the rest of the commands. Let me show you what I've started to do:

Code:

#CLASS {Quest}
#ALIAS go {
  #var qvnumitem 1 {_nodef} {Quest}
  #var giveupdone 0 {_nodef} {Quest|giveup}
  giveup
  #while (!@giveupdone) {#noop}
  }
#ALIAS next {
  #add qvnumitem 1
  #while (%inwalk) {#noop}
  #walk %item( @qvnum, @qvnumitem)
  }
#ALIAS toroom {
  #while (%inwalk) {#noop}
  #walk %item( @qvnum, @qvnumitem)
  }
#VAR qvnum {182|195|197}
#VAR qvnumitem {1}
#TRIGGER {Quests: You have &qpvar quest points} {}
#TRIGGER {You ask * for a quest.} {#t+ qcapture}
#CLASS 0
#CLASS {Quest|qcapture}
#TRIGGER {El Cid exclaims 'Seek (*) out somewhere in the vicinity of (*)!'$El Cid says 'That location is in the general area of (*).'} {
  #show %concat( "~[Name~] ~= ~'", @tosql("%2"), "~' AND ~[ZoneID~] ~= ", %zonenum( %3))
  #show %mapquery( %concat( "~[Name~] ~= ~'", @tosql("%2"), "~' AND ~[ZoneID~] ~= ", %zonenum( %3)))
  #var qvnum %mapquery( %concat( "~[Name~] ~= ~'", @tosql("%2"), "~' AND ~[ZoneID~] ~= ", %zonenum( %3))) {_nodef} {Quest}
  }
#TRIGGER {El Cid exclaims 'Look in the general area of (*) for (*)!'} {
  #show %concat( "~[Name~] ~= ~'", @tosql("%2"), "~' AND ~[ZoneID~] ~= ", %zonenum( %1))
  #show %mapquery( %concat( "~[Name~] ~= ~'", @tosql("%2"), "~' AND ~[ZoneID~] ~= ", %zonenum( %1)))
  #var qvnum %mapquery( %concat( "~[Name~] ~= ~'", @tosql("%2"), "~' AND ~[ZoneID~] ~= ", %zonenum( %1))) {_nodef} {Quest}
  #var qvnumitem 1 {_nodef} {Quest}
  }
#TRIGGER {$} {#t- qcapture}
#CLASS 0
#CLASS {Quest|giveup}
#ALIAS giveup {
  ps
  #var affchecked 0 {_nodef} {Quest|giveup}
  aff
  #while !@affchecked {#noop}
  #if !%ismember( "haste", @spells) {gethaste}
  #while !%ismember( "haste", @spells) {#noop}
  #if !%ismember( "sanctuary", @spells) {getsanc}
  #while !%ismember( "sanctuary", @spells) {#noop}
  #if !%ismember( "giantstrength", @spells) {getgiant}
  #while !%ismember( "giantstrength", @spells) {#noop}
  #if !%ismember( "fly", @spells) {getfly}
  #while !%ismember( "fly", @spells) {#noop}
  #if !%ismember( "invisibility", @spells) {getinvis}
  #while !%ismember( "invisibility", @spells) {#noop}
  #var giveupdone 1 {_nodef} {Quest|giveup}
  }
#ALIAS gethaste {say haste}
#ALIAS getsanc {say sanc}
#ALIAS getgiant {say giant}
#ALIAS getinvis {say invis}
#ALIAS getfly {say fly}
#VAR giveupdone {1}
#VAR affchecked {1}
#ONINPUT {aff} {}
#COND {$} {#var affchecked 1 {_nodef} {Quest|giveup}}
#TRIGGER {utters the words, 'paghz'.$} {}
#COND {$} {#if !%ismember( "haste", @spells) {gethaste}}
#TRIGGER {utters the words, 'uizuguburuhl'.$} {}
#COND {$} {#if !%ismember( "invisibility", @spells) {getinvis}}
#TRIGGER {utters the words, 'gaiqhjabral'.} {}
#COND {$} {#if !%ismember( "sanctuary", @spells) {getsanc}}
#TRIGGER {utters the words, 'yrl'.$} {}
#COND {$} {#if !%ismember( "fly", @spells) {getfly}}
#TRIGGER {utters the words, 'ouaih ghcandusiohp'.$} {}
#COND {$} {#if !%ismember( "giantstrength", @spells) {getgiant}}
#CLASS 0


In several areas of this script I've used the following format:

Code:

#var indicator 0
aliasthatdoesstuff ;this alias will set indicator to 1 when it is finished
#while (!@indicator) {#noop}


This seemed to be working, but as I began using it more it seemed to create timing issues and things weren't firing off in the proper order, which leads me to believe that this is not a good way to do things.

Does anybody have some good suggestions for me? I'd really appreciate it.
_________________
*ribbit*
Reply with quote
Odoth
Wanderer


Joined: 13 Nov 2004
Posts: 54
Location: Visalia, CA

PostPosted: Thu Nov 30, 2006 7:02 am   Update
 
Well I feel kinda dumb. While in the process of completely reworking the script to not use the above format I realized that there were timing issues not because of the format I was using for flow control but because of a sloppy trigger I wrote.
Mad

So as far as I can tell the above format works well, though I'm not actually using it anymore. Wink
_________________
*ribbit*
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