utility SLRR_Coordinates "SLRR Coordinates"
(
groupBox grp1 "SLRR Cordinates" pos:[10,12] width:142 height:110
button btn1 "Get Coordinates" pos:[19,30] width:125 height:22
button btn2 "Get Linked Coordinates" pos:[19,90] width:125 height:22 enabled:false
checkbox box1 "Object linked" pos:[19,63] width:125 height:15 
GroupBox grp2 "Copy to your parent.cfg" pos:[10,130] width:142 height:40
editText edt1 "" pos:[19,143] width:125 height:22
GroupBox grp3 "Copy to your child.cfg" pos:[10,170] width:142 height:40
editText edt2 "" pos:[19,183] width:125 height:22

fn round val = 
(
	local mult = 10.0 ^ 3
	((floor ((val * mult) + 0.5)) / mult) as string
)--end fn

on box1 changed theState do
(
	if theState then
	(
		btn2.enabled = true
	)
	else
	(
	btn2.enabled = false
	)
)--end box1

on btn2 pressed do
	(

		if(selection.count == 1)then
		(
			output = ""

			outputb = ""

			for obj in selection do
			(
				pos_x = (round(($.pos.x-($.parent.pos.x))/100))
				pos_z = (round(($.pos.z-($.parent.pos.z))/100))
				pos_y = (round(($.pos.y-($.parent.pos.y))/100*(-1)))

				pos_xb = (round(($.pos.x-($.parent.pos.x))/100*(-1)))
				pos_zb = (round(($.pos.z-($.parent.pos.z))/100*(-1)))
				pos_yb = (round(($.pos.y-($.parent.pos.y))/100))


				pos_string = (pos_x + " " + pos_z + " " + pos_y)
				output += pos_string

				pos_stringb = (pos_xb + " " + pos_zb + " " + pos_yb)
				outputb += pos_stringb

				
			)
			edt1.text = output
			edt2.text = outputb

		)

)--end btn2


on btn1 pressed do
(
		if(selection.count == 1)then
		(
			output = ""

			outputb = ""

			for obj in selection do
			(
				pos_x = (round(($.pos.x)/100))
				pos_z = (round(($.pos.z)/100))
				pos_y = (round(($.pos.y)/100*(-1)))

				pos_xb = (round(($.pos.x)/100*(-1)))
				pos_zb = (round(($.pos.z)/100*(-1)))
				pos_yb = (round(($.pos.y)/100))


				pos_string = (pos_x + " " + pos_z + " " + pos_y)
				output += pos_string

				pos_stringb = (pos_xb + " " + pos_zb + " " + pos_yb)
				outputb += pos_stringb

				
			)
			edt1.text = output
			edt2.text = outputb

		)
	if(selection.count == 0)then
(
	messagebox "You have to select one object!"
)
if(selection.count > 1)then
(
	messagebox "You have to select ONLY 1 object!"
)

)--end btn1





)--end utility
openUtility SLRR_Coordinates
