Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Math error

Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
06-09-2007 14:20
Is there a quick way of finding which of many scripts is causing the script runtime error "math error"?
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
06-09-2007 15:51
It should tell you what object the error is coming from, and from that, look in the scripts, a common problem for math errors is dividing by 0. So look in your scripts that are doing math (especially division) and see if that is the problem.
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
06-10-2007 08:19
Yes it did. The problem is that there were 4 scripts in the prim and I couldn't tell which was running at the time.
I solved the problem by putting an llOwnerSay at the beginning of every script and branch within the script and thus it identified the problem script.
I would have thought that it would not be beyond the wit of man to display the offending script while showing the Math Error, but perhaps I am expecting too much LSL.

Is a divide by zero the only cause of Math Error?
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
06-10-2007 08:26
No it's not.
A Math error occurs when a mathematical operation returns NaN (not a number) or infinity.
http://rpgstats.com/wiki/index.php?title=Errors

(i.e., llSqrt(-1) throws a math error.)

But divide by zero is probably one of the most common.
Gregory McLeod
Registered User
Join date: 21 Oct 2006
Posts: 278
06-10-2007 08:44
Thanks for the reference to that page I had missed it. It is very instructive and covers a number of (my) mistakes. Particularly the one about sending link messages to more than 50 prims. I got that one back in version 1 of my game.