|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Wed Dec 27, 2006 12:49 am
expansion of %1 in #math command |
I have the following bit of code that is fed from a trigger :
it has an armor class bonus of (*)
For this example (*)=-0.1 and actemp is an autotype variable
Code: |
#math actemp 10*%1
#math item.ac @actemp+@item.ac
#show %1
#show @actemp
#show @item.ac
#cw @idddcol |
I used this in zmud except with brackets around each of the expressions, and the #math would have yielded -1 for @actemp as it should, however right now, it is equal to 0... I've played with the variable typ for actemp, trying floating, and initializing it as 0.0, but that didn't help. If I try it with brackets as I had it set up in zmud it yields something like 10 * -0.1 + 0 where it doesn't evaluate the expression... I've also tried to enclose the expressions within the %eval function... no luck... Any help would be nice! |
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Dec 27, 2006 3:23 pm |
okies, took me a while to figure this out, it looks like you needed to declare the %1 input as a float.
I cMudded your script too, removing the math command, as you dont need it now
Code: |
#var actemp (10 * %float(%1))
#var item.ac (@actemp + @item.ac)
#show %1
#show @actemp
#show @item.ac
#cw @idddcol
|
or, compressed a bit
Code: |
#var item,ac (@item.ac + (10 * %float(%1)))
#show %1
#show @item.ac
#cw @idddcol |
this works nicely |
|
_________________ 'Life is what happens, when your too busy doing something else'
_________________
XP Pro SP2
cMud 1.24
_________________ |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Dec 27, 2006 4:58 pm |
If your wildcard (assuming it's a trigger capture) is a floating-point match, CMUD should convert %1 into a floating-point value for you.
|
|
|
|
crycry Apprentice
Joined: 24 Jun 2006 Posts: 169 Location: UK - South Coast
|
Posted: Wed Dec 27, 2006 5:06 pm |
hms, i tested this as an alias.. so youll have to check Jed that it works ok as a trigger.
whatever it was though, it really didnt like it until you told it it was coming in as a floating point number.. bug? |
|
_________________ 'Life is what happens, when your too busy doing something else'
_________________
XP Pro SP2
cMud 1.24
_________________ |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Jan 17, 2007 10:13 pm |
Added to bug list. CMUD should be auto-typing %1, so this is supposed to work without the explicit %float call.
|
|
|
|
|
|