Math in a chat box

bt54

Lifetimer
Joined
Mar 7, 2012
Messages
114
Reaction score
2
Points
18
It seems I cant do a Math.Calc from a chatbox command line.

It works if I parse it through echo or bc but not from the chat box.
This also seems to effect events.
Code:
/timed ${Math.Calc[3+${Math.Rand[30]}].Int}s /say leave
From events or in a chatbox wont work.
Code:
/bct ${Me.Name} //timed ${Math.Calc[3+${Math.Rand[30]}].Int}s /say leave
Works
Code:
/echo /timed ${Math.Calc[3+${Math.Rand[30]}].Int}s /say leave
[code]
Will show the correct Math.
[code]
/timed 5s /say leave
That works as well.

I can only assume its the Math.Calc in the chat window since timed works....
What exactly am I missing that it wont function from a chat window?

Thanks
 
What is it showing on the receiving characters chat box when you send something like this?

When you send something over eqbc any mq2 variables are parsed before the command is bc command is executed. So your example there would parse the math and should actually send something like //timed 5s /say leave

If you are wanting to do something where each character you send it to will execute something at a random time you need to use /noparse in front of the bc command so that it doesn't parse the variables on the senders side.

Now that also means you can't use a variable to specify the recipient name since that would not parse either, so it would only work for something like:

Code:
/noparse /bca //timed ${Math.Calc[3+${Math.Rand[30]}].Int}s /say leave

Or if you did /bct to a specific character not a variable like ${Me.Name}
 
Last edited:
/timed directly calls DoTimedCmd(), which will just atoi() (ascii to int) the first parameter. Speaking of which, I don't think you are going to get '5 seconds' from that, since it'll stop conversion at the first non-numeric character, so you'd get 50ms when doing 5s. If you want 5 seconds, then you want to do 50.

So, since it doesn't parse, you can use docommand with it, and it will parse it first, then call the function.

Code:
/docommand /timed ${Math.Calc[30+${Math.Rand[300]}].Int} /say leave

htw
 
Dev, he's saying bct works already (which makes sense, because the eqbc commands do the variable parsing). As noted, /timed itself will not parse macro data.

htw
 
Thanks. The /docommand did the trick.

Was annoying to /bct myself on each guy.

Trying to randomize the chars going in and out of instances so they aren't so obvious being all at the same time.