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
Kurt_DH
Wanderer


Joined: 26 Oct 2000
Posts: 62

PostPosted: Fri May 24, 2002 9:21 am   

Script Question
 
On the MUD I play, every 60 seconds, a prompt shows up telling me my hp's and mana. When this prompt shows up, I trigger it to type a command that shows me my experience points. This is what I want to do:

Everytime I see my experience points, I want it to subtract the current number from the previous number. For example, my experience points come up and they are at 100. A minute later when the prompt shows up and my experience points show up, it shows my experience points at 25. I want it now subtract 25 from 100, and come up with 75. I now want to place 75 in a list of 10 numbers. I want this whole process to repeat itself indefinitely, but while only keeping a list of the last 10 numbers. Once this list is created, and there are ten numbers, I want it to perform a calculation when my prompt shows up (once a minute) that will add all ten numbers and divide by ten, thus giving me an average of how many experience points I'm receiving every minute. Any help would be greatly appreciated! Note: Yes, if you were wondering, when your experience points decrease, you're actually advancing in this MUD.

-Kurt
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri May 24, 2002 11:09 am   
 
#TR {prompt text here exp-(%d)} {#ADDITEM ExpTable %1};#IF (%numitems(@ExpTable)>9) {#IF (%numitems(@ExpTable>10) {#DELNITEM ExpTable 1};EXPAverage=%eval((%replace(@ExpTable,"|","+"))/10)}}

You just have to fill in the actual prompt text. It leaves the average in a variable so you can do whatever you want with it.

I did not put a subtraction in because it would produce some odd numbers after you level. If your mud has a fixed exp per level then you should simply do the subtraction at the end.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri May 24, 2002 12:57 pm   
 
#VAR lastexp 100
#TR {prompt text here exp-(%d)} {#ADDITEM ExpTable {@lastexp - %1);#VAR lastexp %1;#IF (%numitems(@ExpTable)>9) {#IF (%numitems(@ExpTable>10) {#DELNITEM ExpTable 1};EXPAverage=%eval((%replace(@ExpTable,"|","+"))/10)}}

Without the subtraction, it will show some strange numbers whether he levels or not. That is, it will show his average exp when he wants to see his average exp rate.

LightBulb
Vague questions get vague answers
Reply with quote
Kurt_DH
Wanderer


Joined: 26 Oct 2000
Posts: 62

PostPosted: Fri May 24, 2002 8:34 pm   
 
quote:

#VAR lastexp 100
#TR {prompt text here exp-(%d)} {#ADDITEM ExpTable {@lastexp - %1);#VAR lastexp %1;#IF (%numitems(@ExpTable)>9) {#IF (%numitems(@ExpTable>10) {#DELNITEM ExpTable 1};EXPAverage=%eval((%replace(@ExpTable,"|","+"))/10)}}

Without the subtraction, it will show some strange numbers whether he levels or not. That is, it will show his average exp when he wants to see his average exp rate.

LightBulb
Vague questions get vague answers



I inputted that trigger into my zMUD, and it created the prompt text here trigger but with only this in it:

{#ADDITEM

Can you tell me what I'm doing wrong, or revise the trigger? Thanks.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri May 24, 2002 9:04 pm   
 
Lightbulb has a statement opened with { and closed with ). I would suggest you find it, as many typos occur when you fly out scripts like that. You should at the very least be able to find a typo in such a short script.

Just a hint for ya it is in red in Lightbulb's post.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri May 24, 2002 11:24 pm   
 
Yep. Should open with ( instead of {.

LightBulb
Vague questions get vague answers
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