coordinates texture
5 posts • Page 1 of 1
coordinates texture
Hi,
I want the x and y coordinates of a box to be shown on the box like a text.
It would be great if you could decrease the number so that there are only two numbers after the comma (for example 3,44 or -5,12)
But that's not important.
I hope some of you can help me.
I want the x and y coordinates of a box to be shown on the box like a text.
It would be great if you could decrease the number so that there are only two numbers after the comma (for example 3,44 or -5,12)
But that's not important.
I hope some of you can help me.
- MyMan
- Posts: 4
- Joined: Mon Sep 16, 2013 6:59 pm
Re: coordinates texture
Easiest way to put text onto a object is to concatenate stings and variables.
This is done in the script menu, as so:
\n is the newline character.
As for rounding, I think your best waiting for somebody else to come along, as I can't use the search feature as it pulls up a lot of rubbish which I'm clearing out (unapproved posts), but I'm sorta tethering a mobile connection, so it's not the best...
This is done in the script menu, as so:
- Code: Select all
{"x:" + pos(0) + "\ny:" + pos(1)}
\n is the newline character.
As for rounding, I think your best waiting for somebody else to come along, as I can't use the search feature as it pulls up a lot of rubbish which I'm clearing out (unapproved posts), but I'm sorta tethering a mobile connection, so it's not the best...
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: coordinates texture
thank you very much!!!!!!!!!!!!!!!!!!
it's perfect
it's perfect
- MyMan
- Posts: 4
- Joined: Mon Sep 16, 2013 6:59 pm
Re: coordinates texture
When digital readouts are difficult to read because of jitter and too many decimal places, use this code to reduce the precision and smooth the jitter (the constant 10000 can be changed to change the digits of precision. The number of zeros == the number of decimal places)....
math.tofloat(math.toint((variable or equation) *10000)) / 10000
Examples:
1.
text = {"B: " + math.tofloat(math.toint((Scene.my.x2 - Scene.my.x1) *10000)) / 10000}
2.
_Force = math.tofloat(math.toint(((pos(0) - 1.5) * 40)*1000))/1000
math.tofloat(math.toint((variable or equation) *10000)) / 10000
Examples:
1.
text = {"B: " + math.tofloat(math.toint((Scene.my.x2 - Scene.my.x1) *10000)) / 10000}
2.
_Force = math.tofloat(math.toint(((pos(0) - 1.5) * 40)*1000))/1000
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: coordinates texture
I would suggest to insert + 0.5 into the parameter for math.toint for better rounding because math.toint rounds to the first smaller integer. To make it shorter, math.tofloat can be replaced by a comma in the last number in the formula which will make it recognised as float.
math.toint((variable or equation) * 100 + 0.5) / 100.0
math.toint((variable or equation) * 100 + 0.5) / 100.0
-

Ivan - Posts: 203
- Joined: Tue Oct 06, 2009 2:01 pm
- Location: Croatia
5 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests



