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
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Fri Aug 19, 2005 12:45 pm   

Help with Script
 
First off I take no credit for this script to monitor xp made on merentha. It was given to me by a friend who said he had no problem with me playing with it in an attempt to improve it.

My problem is this. Dispite my best efforts it continues to save veribles in multipul places instead of just in its class folder. Any assistance at debuggins this script or general improvements would be greatly appreciated.
Code:
#Class xptimer
#if (@showxp=1) {
  #math totalxp (%1-@offsetxp)
  #math perminute (@totalxp/@minutes)
  #math perhour (@perminute*60)
  pl You have made @totalxp xp in @minutes minutes (@perhour xp per hour)
  showxp=0
  }
#if (@savexp=1) {
  savexp=0
  minutes=0
  offsetxp=%1
  #alarm "mintimer" -1:00 {#math minutes (@minutes+1)}
  #say XP Timer started
  }
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Sat Aug 20, 2005 12:54 am   
 
Seeings there was no nibbles to assit useing that I figured I'd display the full script to see if that would be helpful. This is what i imported in.
Code:
#CLASS {xptimer}
#ALIAS showxp {showxp=1;cost}
#ALIAS startxp {savexp=1;cost}
#VAR minutes {11} {xptimer}
#VAR offsetxp {47361000}{xptimer}
#VAR savexp {0}{xptimer}
#VAR showxp {0}{xptimer}
#VAR totalxp {3712000}{xptimer}
#ALARM "mintimer" {-1:00} {#math minutes (@minutes+1)}
#REGEX {You have ((.+)) to spend on stats, skills or to use to level\.} {#if (@showxp=1) {#math totalxp (%1-@offsetxp);#math perminute (@totalxp/@minutes);#math perhour (@perminute*60);pl You have made @totalxp xp in @minutes minutes (@perhour xp per hour);showxp=0};#if (@savexp=1) {savexp=0;minutes=0;offsetxp=%1;#alarm "mintimer" -1:00 {#math minutes (@minutes+1)};#say XP Timer started}}
#CLASS 0
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Aug 20, 2005 3:32 am   
 
That's what I figured...I don't see anything obvious. When you say in multiple places, does it do it randomly or does it just keep creating them in the same place over and over? My guess is that #MATH is creating all the new variables and it might be relying on the default class rather than searching for existing variables. Are there any other triggers, aliases, etc which turn on/off this class and perhaps interfere with the variable creation (if the class is disabled, variables will be created in the default class wherever that might currently be)?

You said you imported it, did you check to make sure it imported correctly? Sometimes scripts import without problems yet ZMud will expand something you didn't expect it to.
_________________
EDIT: I didn't like my old signature
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Sat Aug 20, 2005 3:51 am   
 
dunno, but I dont see an alias for cost:
#ALIAS showxp {showxp=1;cost}
#ALIAS startxp {savexp=1;cost}

Is there a cost alias elsewhere?
of course, if cost is a mud side command ignore me :-)
_________________
http://www.Aardwolf.com
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Sat Aug 20, 2005 12:37 pm   
 
I've imported it several times and always get the same results. On the randomness it saves to one of 3 subfolders but they have absolutely nothing to do with the script. Cost is a mud command for displaying how much exp you have.
and umm...oh yeah. I corrected the defaults on some of the VAR as default was xptrigger. Thats my fault as i tried adding that to the script to fix it without any luck.
The only way it works any better is if i don't put it in a class folder. Then the only thing that gets saved to a folder is the alarm timer, which isn't a big deal as it overwrites itself if i start the script over.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Aug 20, 2005 4:00 pm   
 
Make sure to go through and delete all of the extra variables, This one has a few bugfixes and uses a data record to keep all the variables together.

Code:
#CLASS {xptimer}
#ALIAS showxp {xptimer.showxp=1;cost}
#ALIAS startxp {xptimer.savexp=1;cost}
#VAR xptimer.minutes {0} {_nodef} "xptimer"
#VAR xptimer.offsetxp {0} {_nodef} "xptimer"
#VAR xptimer.savexp {0} {_nodef} "xptimer"
#VAR xptimer.showxp {0} {_nodef} "xptimer"
#VAR xptimer.totalxp {0} {_nodef} "xptimer"
#ALARM "mintimer" {-1:00} {#ADD xptimer.minutes 1} "xptimer"
#REGEX {You have ((.+)) to spend on stats, skills or to use to level\.} {
 #IF (@xptimer.showxp=1) {
  #MATH xptimer.totalxp {%1-@xptimer.offsetxp}
  #MATH xptimer.perminute {@xptimer.totalxp/@xptimer.minutes}
  #MATH xptimer.perhour {@xptimer.perminute*60}
  pl You have made @xptimer.totalxp xp in @xptimer.minutes minutes ~(@xptimer.perhour xp per hour~)
  xptimer.showxp=0
 }
 #if (@xptimer.savexp=1) {
  xptimer.savexp=0
  xptimer.minutes=0
  xptimer.offsetxp=%1
  #ALARM "mintimer" {-1:00} {#ADD xptimer.minutes 1} "xptimer"
  #SAY XP Timer started
 }
} "xptimer"
#CLASS 0
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
trpstrife
Novice


Joined: 26 Jul 2005
Posts: 34

PostPosted: Sun Aug 21, 2005 1:06 pm   
 
that keeps the alarm from moving to a different folder but the xptimer data record is still making a copy of itself in a different folder.
**EDIT**
correction. the data record starts copying itself into EVERY class folder
Reply with quote
Atreides_096
Wanderer


Joined: 21 Jan 2005
Posts: 99
Location: Solvang, CA

PostPosted: Sun Aug 21, 2005 2:55 pm   
 
It sounds like your problem is similar to something that's happened to me in the past. I've actually found at least three seperate things that can cause this:

1) If you make use of the #prompt, %prompt, #yes, %yesno, or like commands for variable creation, and the class is left opened while the prompt is up, then scripts running in the backround will write into the open class. For example.. this is not how my alias is written, but if it WERE written this way (or in several similar ways), you could have this problem:

Code:
#al {udweap} {#CLASS {Weapons};#IF %yesno( "Do you want to change the name of your primary weapon?") {#VAR weapon %prompt( "", "Enter ONE of the keywords for your primary weapon:")};#CLASS 0}


Now that would "open" (I don't know a better term) the class "Weapons" -- so that when you enter the name for your primary weapon into the prompt, the variable will be written into the class weapons. When that variable is written, the class would be "closed" ... however, anything that zMUD is creating (variable-wise) while that is happening will ALSO be created in the class weapons, until you've finished with the onscreen prompts.

2) Simply "opening" a class in any script, and not "closing" it, would cause all variables to be written in that class until a different class is "opened":


Code:
#CLASS {Anyclass}
#var {anyvar} {anyvalue}


Note there is no #CLASS 0 there... so every variable written by zMUD from that point on will be written into "Anyclass" until another class is "opened"

3) Slow scripts that use the #CLASS {Class}/#CLASS 0 setups shown in 1 and 2 will also cause the same problem.

Say for example you have a script that tracks experience earned per second fighting (one I have, which was written by someone else, works very slowly, and caused this problem). At the end of each fight, it "opens" a class, and begins a series of calculations, writing multiple variables. When the calculations are done, it "closes" the class and displays the results. However, for the time that the script was calculating (in this case, was perhaps 1 second.. I've seen other scripts that can easily take 5-10+), every variable written by zMUD will go into this class.

----------------
In summation, the odds are good that either one of the 3 things I mentioned above, something similar, or more likely SEVERAL things from that list/similar are occuring for you. The best way to track down the problem is to look at the classes in which your variables are being written. While the scripts themselves may be unrelated, they are also the most likely culprits.[/code]
Reply with quote
Atreides_096
Wanderer


Joined: 21 Jan 2005
Posts: 99
Location: Solvang, CA

PostPosted: Sun Aug 21, 2005 3:02 pm   
 
Oh, a fourth thing... any very long string, which opens/closes a class, can also cause this to happen. for example, a "reset" alias to reset all vars in a script to 0:

Code:
#al {scriptreset} {
#class {Script}
#var {variable} {0}
#var {variable} {0}
#var {variable} {0}
#var {variable} {0}
#class 0


Only with a lot more actions that just 4 variable resets... even if it only takes zMUD 0.1 seconds to perform it, any variable that happens to be written at that time will also be written into "Script" class.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Aug 21, 2005 3:36 pm   
 
Yeah #CLASS should only be used for importing stuff into the correct folder, for modifying variables in the correct class folder use the class path format, for this to work though the class HAS to be enabled and exsist otherwise you will get a variable called path/var


path/var=1
#VAR path/var 1
_________________
Zmud Support Library
Zmud Knowledge Base
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