Page 1 of 1
Few aritmetic questions
Posted: 2005-03-01 18:04:48
by pegarion
I am trying to improve my scripts, but I can't solve few problems
1) I would like to ask how to ROUND a number
2) I would like to get distance between two creatures...Is there some function like sqrt ?
Thank you for your answer.
Posted: 2005-03-01 20:53:10
by Necr0Potenc3
1) use the ceil() or floor() functions. one rounds up and the other rounds down. (7.1 becomes 8 and 7.1 becomes 7)
2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)(y1 - y2));
x1 and y1 belong to one object. x2 and y2 belong to another
Posted: 2005-03-01 21:04:54
by pegarion
All the functions you wrote don't work

it writes : "line x: Function not found"
...maybe my injection is too old...I don't know..
Posted: 2005-03-01 22:56:30
by Necr0Potenc3
I thought you were talking about coding but you're talking about scripting, arent you?
Posted: 2005-03-01 23:47:29
by pegarion
Yes

Re: Few aritmetic questions
Posted: 2005-03-02 12:51:27
by Yoko
pegarion wrote:2) I would like to get distance between two creatures...Is there some function like sqrt ?
there is no need in sqrt function to find distance in UO
do not forget, distance always integral (integer) value.
if you will think a bit you will find formula yourself