Illegal division by zero

Non-platform specific questions.

Illegal division by zero

Postby Troodon » Sat Jun 30, 2007 9:53 am

Hi
I get this error when I turn the engines on in my rocket launch project: "Illegal division by zero in draw actor of smoke".
Here is the draw actor of smoke and I don't see there illegal division:

Code: Select all
angle = (Rocket.animpos/Rocket.nframes)*360.0;
directional_velocity = -6;
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby DocRabbit » Sat Jun 30, 2007 11:59 am

Rocket.nframes would be the most likely candidate here. I would create a text actor and check the values of it and see if you get a zero.

Another way is you could wrap it with an IF statement like this:

Code: Select all
if(Rocket.nframes!=0)
{
...
}


That would prevent it from using a zero in the division area.
Don't know what it would do with the rest of your program, just try and see it affects it in a negative way.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby Oman » Sat Jun 30, 2007 2:27 pm

wat does if (something != number meane... (i mean, what does the != do?
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Postby Kodo » Sat Jun 30, 2007 2:41 pm

!= means 'not equal to'
Inogames: http://www.inogames.com iOS gaming
Firetop Adventure (app store): http://itunes.apple.com/us/app/firetop- ... ?mt=8&ls=1
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby metal_pt » Sat Jun 30, 2007 2:43 pm

Means:
if (something is different from something else)
It is like <> in other script laguages.
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby DocRabbit » Sat Jun 30, 2007 2:57 pm

Off the subject but funny none the less...

Doing a google search for != vs == yielded the top link to Victoria's Secret website. :lol:

Would have thought it would have been something in C or Java...
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby Fuzzy » Sat Jun 30, 2007 10:25 pm

append 0.0001 to the frame number just for the division.

angle = (Rocket.animpos/(Rocket.nframes+0.0001))*360.0;
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Troodon » Sun Jul 01, 2007 5:12 am

Well...I found no errors in that code so the error object display must have been a bug. I tested the whole formula with text actors and it works. The problem became after I inserted this lines of code.

Code: Select all
if (burning == 1 && strcmp(tankstatus, "closed") == 0)
{
    DAMAGE = 1;
}
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby DocRabbit » Sun Jul 01, 2007 12:52 pm

maybe it stems from a null or zero length string in tankstatus variable. I am sure that strcmp uses the length of in its calculations, so that may be where it is at. Maybe initialize tankstatus with content that won't trigger any of your checks, but will fill it with something. Also, may be try this in place of code you have, just in case. Should not make a difference, but you never know.

Code: Select all
if (burning == 1 && !strcmp(tankstatus, "closed"))
{
    DAMAGE = 1;
}
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby Troodon » Sun Jul 01, 2007 4:51 pm

Thanks for the help guys (or/and ladies) but nothing suggested yet haven't work. As you can see from my signature, I'll be off for a week.
I could send the project to someone but it's still very complicated (complex rocket launching system what is controlled by multifunctional displays where you enter commands). Because it's not ready yet, I should write a manual to the tester just to be able to see the error. :P
See you after one week!
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest