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


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 9:24 pm   

Average Experienced Gained
 
I got a real simple script i am designing just got stuck on it now...

#Alias {ExpHour} {#MATH Exphour @XPCount / @Kcount} {#ECHO @Exphour}

that is what i came up with, it won't actually divide the 2 variables...can ya help me out?



PS: Figured you might need this to...
#TR {^You receive your share of (%d) experience} {#ADD exp30 {%1};#ADD explevel {%1}}
#Alias {Exp} {Say i have gather @exp30 since login}}
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 27, 2007 9:43 pm   
 
You have spaces in the expression that's being evaluated. Remove them or surround the expression with {} or (). You could also use

Exphour = %eval(@XPCount/@Kcount)
_________________
Rorso's syntax colouriser.

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


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 9:55 pm   
 
Fang Xianfu wrote:
You have spaces in the expression that's being evaluated. Remove them or surround the expression with {} or (). You could also use

Exphour = %eval(@XPCount/@Kcount)



So its actually #Alias ExpHour=%eval(@XPCount/@Kcount} {#ECHO @Exphour}?

All i got to do is close the spaces? (sorry not quiet following what you are saying..)
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Nov 27, 2007 10:17 pm   
 
Code:

#alias ExpHour {ExpHour=%eval(@XPCount/@Kcount);#ECHO @Exphour}



ExpHour inside the #alias code is Variable that gets the value given the calculation made. then with #ECHO you'll capture the current value of that variable onto the screen.

Hope this helps.

Prog


Last edited by Progonoi on Tue Nov 27, 2007 10:26 pm; edited 1 time in total
Reply with quote
DaraisDarkwave
Beginner


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 10:25 pm   
 
Progonoi wrote:
Code:

#alias ExpHour {ExpHour=%eval(@XPCount/@Kcount);#ECHO @Exphour}



Prog


Thank you, that worked perfectly :-)
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Tue Nov 27, 2007 10:27 pm   
 
Heh, was writing explanation edit when you were posting.

Good it worked out for you :)


Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Nov 27, 2007 10:28 pm   
 
EDIT: Damn having to stop halfway through writing a post to get food out of the oven. Beaten to a pulp :( Perhaps this'll still be useful, anyway:

Spaces are very important in zScript syntax - they separate parameters, showing where the previous parameter ends and the next one begins. Your example there looks like this to zMUD:

#MATH Exphour @XPCount / @Kcount

Where the different colours represent different parameters. You want everything after Exphour to be seen as one parameter, so you remove the spaces:

#MATH Exphour @XPCount/@KCcount

and this works fine.

The example I gave with Exphour = %eval() was an alternative to the #math command, using the variablename = value syntax. Your alias would look like this:

#Alias {ExpHour} {ExpHour=%eval(@XPCount/@Kcount)}

I also just noticed something wrong with your #alias command, too - you've tacked an extra parameter on the end:

#Alias {ExpHour} {#MATH Exphour @XPCount/@Kcount} {#ECHO @Exphour}

If you want your alias to do more than one thing, you don't add another command to the end - you separate the commands with a semicolon like so:

#Alias {ExpHour} {#MATH Exphour @XPCount/@Kcount;#ECHO @Exphour}
_________________
Rorso's syntax colouriser.

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


Joined: 09 Nov 2007
Posts: 28
Location: Fairbanks, Alaska

PostPosted: Tue Nov 27, 2007 10:49 pm   
 
Fang Xianfu wrote:
EDIT: Damn having to stop halfway through writing a post to get food out of the oven. Beaten to a pulp :( Perhaps this'll still be useful, anyway:

Spaces are very important in zScript syntax - they separate parameters, showing where the previous parameter ends and the next one begins. Your example there looks like this to zMUD:

#MATH Exphour @XPCount / @Kcount

Where the different colours represent different parameters. You want everything after Exphour to be seen as one parameter, so you remove the spaces:

#MATH Exphour @XPCount/@KCcount

and this works fine.

The example I gave with Exphour = %eval() was an alternative to the #math command, using the variablename = value syntax. Your alias would look like this:

#Alias {ExpHour} {ExpHour=%eval(@XPCount/@Kcount)}

I also just noticed something wrong with your #alias command, too - you've tacked an extra parameter on the end:

#Alias {ExpHour} {#MATH Exphour @XPCount/@Kcount} {#ECHO @Exphour}

If you want your alias to do more than one thing, you don't add another command to the end - you separate the commands with a semicolon like so:

#Alias {ExpHour} {#MATH Exphour @XPCount/@Kcount;#ECHO @Exphour}


That actually did help me, the problem was i didn't know where to put the %eval variable. I did try it earlier just as:

#Alias {ExpHour}{#MATH Exphour @XPCount/@Kcount} {#ECHO @Exphour}

But now i see where i sent wrong and how i can fix that, thank you all for your help..
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