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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Tue Apr 13, 2010 6:10 pm   

(@solved - %confused) confused on where to use %eval
 
in zmud part of an alias was:
Code:

#MATH quest_time (%secs - @quest_start_time)/1000
#IF (@quest_time > 59) {
  #MATH quest_minute_time {@quest_time/60}
  #MATH quest_leftover_time {@quest_minute_time*60}
  #MATH quest_second_time {@quest_time-@quest_leftover_time}
  } {quest_second_time = @quest_time}

to make it at least work in cmud it is now...
Code:

quest_time = %eval((%secs - @quest_start_time) / 1000)
#IF (@quest_time > 59) {
  quest_minute_time = %eval(@quest_time / 60)
  quest_leftover_time = %eval(@quest_minute_time * 60)
  quest_second_time = %eval(@quest_time - @quest_leftover_time)
  } {quest_second_time = @quest_time}

the 1st line is where i was having an issue... changed em all to eval anyways... it at least works now

the help file says only use %eval if you know you need to... how would i know?


Last edited by Private on Wed Apr 14, 2010 12:17 pm; edited 1 time in total
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Apr 13, 2010 6:15 pm   
 
You should be able to get rid of "%eval" in every single one of those lines. Just leave the parentheses.

The way you know you need to use it is if you can't get it to work without %eval. But "((%secs - @quest_start_time) / 1000)" works fine. For mathematical equations, all you need to do is make sure the entire thing is inside parentheses.
Code:

quest_time = ((%secs - @quest_start_time) / 1000)
#IF (@quest_time > 59) {
  quest_minute_time = (@quest_time / 60)
  quest_leftover_time = (@quest_minute_time * 60)
  quest_second_time = (@quest_time - @quest_leftover_time)
  } {quest_second_time = @quest_time}
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Apr 14, 2010 5:12 am   
 
As Rahab said, I just want to say it in hopefully more succinct terms:

If you can use the expression without an error, you don't need %eval. If you get an error using an expression somewhere, you need %eval.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Private
Adept


Joined: 10 Jan 2002
Posts: 264
Location: USA

PostPosted: Wed Apr 14, 2010 12:16 pm   
 
Thanks Rahab you stated it perfectly...
i edited the alias, i'll give it a go in 25mins on next quest :P

wtf is succinct? hate going to google to look up uncommonly used words
(p.s. that was retorical, you dont need to boost your post count by replying)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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