Absolute value

About advanced scenes, and the Thyme scripting language used in Algodoo.

Absolute value

Postby dsengere » Sun Jan 17, 2010 10:09 pm

Hi there. Is there a simple thyme piece of code to get the absolute value of whatever number/function?

Thanks!
dsengere
 
Posts: 12
Joined: Thu Oct 22, 2009 5:49 pm

Re: Absolute value

Postby link0007 » Sun Jan 17, 2010 10:12 pm

Link: "Surely somebody hates Walter Cronkite.."
Sonic: "Probably.. But somebody hates everyone."
:D
User avatar
link0007
 
Posts: 408
Joined: Thu Jun 11, 2009 2:45 pm

Re: Absolute value

Postby standardtoaster » Sun Jan 17, 2010 10:13 pm

Code: Select all
Scene.my.abs = (n)=>{n < 0 ? {n * (-1)} : {n}}
User avatar
standardtoaster
 
Posts: 606
Joined: Mon Aug 31, 2009 7:57 pm

Re: Absolute value

Postby Kilinich » Sun Jan 17, 2010 11:37 pm

Code: Select all
scene.my.abs = (n)=>{n < 0 ? - n : n}
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 13 guests