Nexus Math

by Shiri

Back to Mechanic's Corner.

Shiri2005-09-08 11:11:24
#math currentmath 3000 / 2000
Variable "currentmath" set to: 1

#math currentmath 2000 / 3000
Variable "currentmath" set to: 0

#math currentmath 2000 \\ 3000
line 1: unexpected '\\' (want Command Separator or End-of-Line

Ideally, I'd want this to give me something like 2/3 (or 66 when multiplied by 100, giving a percentage, which is what I want since this is for a contemplate/toadcurse trigger), but all it seems to want to give me is 1 or 0. Is asking it to divide too much, or can it just not handle fractional/decimal characters?
Unknown2005-09-08 11:17:22
It's integer division, so you lose all precision. I would be very surprised if Nexus had functions to cast the values as floating-point numbers or to normalize the operation to return the decimal value.
Shiri2005-09-08 11:20:04
QUOTE(Zarquan @ Sep 8 2005, 12:17 PM)
It's integer division, so you lose all precision. I would be very surprised if Nexus had functions to cast the values as floating-point numbers or to normalize the operation to return the decimal value.
182086



Incidentally, the forum kept blaming you and your character for me not being able to post the thread, it kept mentioning your name. Can you think of any reason for that? blink.gif

EDIT: Okay, I didn't realise it'd posted four times. *cough* THAT WASN'T MY FAULT. IT HAD ERROR MESSAGES. >_>
Unknown2005-09-08 12:44:19
Me and my character?

I wasn't sure which of the many to read, so I just picked one at random and responded to it. I figured you'd notice sooner or later that you'd posted five times and fix it up yourself. Heh.
Shiri2005-09-08 12:48:35
*coughcough*

Anyway. What I mean is, when I tried to "post topic," it apparently posted it, but then it went to an error screen complaining about mySQL like it normally does when the forums are down. But I asked a friend on MSN, who said the forums were fine, so I backed up and posted again. It came up with another error. I looked more closely at the message, and in the top bit above the bit complaining about its mySQL, it had references to "Z/arquan" and your character name. ...and I don't really know why. Then I tried it twice more and it worked.

¬_¬
Sylphas2005-09-08 16:48:29
I doubt it'll work in Nexus, but in zMUD it defaults to integer division if you're dividing integers, so you have to use 1000 / 2000.0 or something similar.
Hajamin2005-09-08 18:25:47
Try doing this, multiply the first number by 100 then divide by the second, it will give you the %.

IE:

A=1000
B=3000

Answer you want is .33333333 or 33%

1000/3000 gives you 0(from what I understand of your post)

100000/3000 should give you 33
Shiri2005-09-09 00:38:02
Yeah, that's what I did to fix it, but I thought I'd keep the topic here to see if Zarquan know wtf the reason was for the forums mentioning him when they messed up.

The actual code looks like this now.

CODE
{w} mana stands at {d}/{d}


CODE
#highlight 15
#math manapercent ( $2 * 100 ) / $3
#echo $manapercent %
#if $toad = on { #if $manapercent < 50 { to }
}
#set toad off


The $toad = on thing is just something I have so that I can turn it on and off when fighting so I don't accidentally contemplate a teammate and toadcurse them...also works as illusion proofing ("to" is my toadcurse alias.)
Unknown2005-09-09 15:06:35
I honestly don't know what happened to your topic, Shiri. I wasn't hacking the forums, though. Heh. It probably just hit a database contention problem when we were both trying to update the same topic at the same time or something goofy like that.
Shiri2005-09-10 01:18:24
Ah, weird. I was just curious, it was a pretty bizarre thing to have happen. happy.gif