How to deal with indefinite numbers?

I have a mathematical function that changes the rotation of an object. Unfortunately, this function sometimes produces indefinite numbers: the console outputs “-1.#IND”. How can you check for an indefinite number? Also I have been trying to use a ternary operator according to Lua’s wiki website, yet I can’t get it to work.
It is a simple as:
[lua]object.rotation = ( angle > 0 ) ? angle : object.rotation[/lua]
Yet I get the error “unexpected symbol near ‘?’”.
So how do I check for -1.#IND and use it in a ternary operator? [import]uid: 54716 topic_id: 9895 reply_id: 309895[/import]

There is no ternary operator in Lua. There is an ugly hack with the use of “and” and “or” but it is complex and there are some issues so my advice: stay away from it.

As for your other problem, just check that your angle is between the limits:

[lua]if angle >= 0 and angle < 360 then
object.rotation = angle
end[/lua] [import]uid: 51516 topic_id: 9895 reply_id: 36095[/import]

@ir8primate,
your handle sounds like a cool new game title after Angry Birds. Let us have evolution and move ahead.

OK, back to your question…

you can use the ternary operator as
object.rotation = angle>0 and angle or object.rotation

hope that helps,

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 9895 reply_id: 36408[/import]