This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
trillilyy's profile picture

[Lua]

Started by trillilyy, 12 April 2013 - 12:33 PM
trillilyy #1
Posted 12 April 2013 - 02:33 PM
Ok so I get an error with this code


((x)^2)0.5 = disX

Im doing a moving system for turtle and this code is to remove the minus to calcul the distance betwen the 2 coords
but I get a syntax error when I run it
Spongy141 #2
Posted 12 April 2013 - 02:41 PM
Well are you manually typing in a coord for X? Because its hard to get a variable into a number, make sure you are having the variable being converted into a number so it can do that equation.
PixelToast #3
Posted 12 April 2013 - 02:42 PM
because your supposed to do this:

disX=((x)^2)0.5
Kingdaro #4
Posted 12 April 2013 - 02:43 PM
Could just do this:

disX = x^2 / 2
trillilyy #5
Posted 19 April 2013 - 01:21 PM
I mean to remove any minus coord to get the distance betwen the 2 x's coord.

disX = ((x^2)^0.5)
Kingdaro #6
Posted 19 April 2013 - 02:20 PM
To convert a number to a positive number, just use math.abs(num).