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


Joined: 01 Oct 2005
Posts: 54

PostPosted: Sun May 25, 2008 11:47 pm   

Converting
 
got the first part working, but now I'm getting illegal token in this alias

#ALIAS damreport {#VAR DamTotal {0} {0} {run};#FORALL @PlayerFighters {#ADD DamTotal {%db(@%i,damage)};#ADD Damtotal {@main.damage};gt ~|c~|%proper( @character.name)~|w~|: ~|r~|@main.damage~|w~| damage ~(~|r~|%eval( @main.damage*100/@DamTotal)~|w~|.~|r~|%mod( %eval( @main.damage*1000/@DamTotal), 10)~|w~|%~) ~|g~|%eval( @main.damage/@main.hit) ~|w~|average
#FORALL @playerfighters {gt ~|c~|%proper( %i)~|w~|: ~|r~|%db(@%i,damage)~|w~| damage ~(~|r~|%eval( %db(@%i,damag)*100/@DamTotal)~|w~|.~|r~|%mod( %eval( %db(@%i,damage)*1000/@DamTotal), 10)~|w~|%~) ~|g~|%eval( %db(@%i,damage)/%db(@%i,hit)) ~|w~|average}}

just gtells my damage and groupmembers damage, my damage is gtell'd correctly, but the #FORALL @playerfighters part is all screwed up :(...I tried changing it to %db, and still couldn't get it to work
Reply with quote
Sir1l
Wanderer


Joined: 01 Oct 2005
Posts: 54

PostPosted: Mon May 26, 2008 10:40 pm   
 
I think using @%i is what's screwing it up...is there anyway to do this better? cmud isn't recognizing it as a variable :(
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Mon May 26, 2008 10:59 pm   
 
try %eval(@%i)
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Sir1l
Wanderer


Joined: 01 Oct 2005
Posts: 54

PostPosted: Mon May 26, 2008 11:58 pm   
 
That works, but like #FORALL @groupmem {#SHOW @%i.damage} or #FORALL @groupmem {#SHOW %db(@%i,damage)} is all wonky.
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Tue May 27, 2008 12:53 am   
 
IMO, I would try %db(@{%i},damage). Since %i contains the name of the player, then @{%i} should access the variable @playername. Of course, %eval will do the same thing, so it is your choice.
I tried loading your posted code but it appears that you have a missing brace or some of the code is missing after @main.damage/@main.hit) ~|w~|average.
_________________
Sic itur ad astra.

Last edited by Anaristos on Thu May 29, 2008 12:39 am; edited 2 times in total
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue May 27, 2008 5:31 am   
 
I'm surprised the %eval thing works. You should use @{%i} and %db(@{%i},damage) or @{%i.damage}.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Tue May 27, 2008 5:44 am   
 
Well, Fang, {} is the new (CMUD's) way of doing %eval. So until it gets removed from the repertoire it will still work, but it (%eval) is not recommended.
_________________
Sic itur ad astra.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue May 27, 2008 7:17 am   
 
Not quite. %eval evaluates expressions like () does. {} creates what Zugg's called an expanded string - that is, a string that contains variable references that need expansion before the string is used for anything. I guess that makes it most similar to %expand.

But, regardless, no function works quite like @{} does, syntactically anyway.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Sir1l
Wanderer


Joined: 01 Oct 2005
Posts: 54

PostPosted: Tue May 27, 2008 7:49 pm   
 
Well I got
Lash.damage=100
lash.hit=1
playerfighters=Lash
#ALIAS damreport {#VAR damtotal 0;#FORALL @PlayerFighters {#ADD damtotal @{%i.damage}};#SHOW @damtotal}}
Shouldn't running damreport add lash.damage to damtotal? It's not atm :(
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed May 28, 2008 3:17 am   
 
Change @{%i.damage} to %db(@{%i},"damage"). I guess %i.damage is looking for the damage key of the %i variable, but of course %i isn't a data record variable and that screws it up. I did give you a few options to try ;)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Wed May 28, 2008 7:19 am   
 
Quote:
IMO, I would try %db(@{%i},damage).


That was my suggestion (in bold text). I guess he missed it with all the clutter.
_________________
Sic itur ad astra.
Reply with quote
Sir1l
Wanderer


Joined: 01 Oct 2005
Posts: 54

PostPosted: Tue Jun 10, 2008 12:52 am   
 
Another problem, when I do this
#ALIAS resetr {#FORALL @fighters {%i.damage=0}}

It says unmatched braces????? wth.....I can do %i.damage, and nothing happens, but once I add the =0 it says unmatched braces

Then I try #alias resetr {#FORALL @fighters {#VAR %i.damage 0}} and this does nothing....I'm confused with cmud, making no sense
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jun 10, 2008 12:59 am   
 
It follows from the same principle I talked about above. When you do %i.damage, CMUD is looking for the damage key of the %i variable. Because it doesn't have a damage key, it returns null - that causes the #var command in your second example to set a null variable. The first example is probably a result of trying to set the value of %i, which won't work.

You want #var %concat(%i,".damage") 0, which unambiguously joins the %i to the ".damage" before it starts setting variables.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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