Notifications
Clear all

[Closed] Anyone have a script that writes objects positions to a file?

Writes every objects position in the scene relative to 0,0,0 to a file?

I’m coding a weather system for our project, and barely have time to spare. This would be much appreciated.

Thanks!!

6 Replies
global objectList = createFile "c:/temp/objectList.txt"

for obj in $* do
(
	print (obj.name + " - " + obj.pos + "
") to:objectList
)

That should work. I can’t test it out at the moment, wcs would be casting the obj.pos as a string.

for obj in $* do

This is bad. Instead, a better option would be to use the keyword “objects” which is dynamic and contains all objects in the scene.

for obj in objects do

Is better.

also, using print and then a “
” will give you two new lines for each line. Better is:

format “% – %
” obj.name obj.pos to:objectList

and then you want to close the file with:

close objectList

giving:


global objectList = createFile "c:/temp/objectList.txt"
for obj in objects do
	format "% - %
" obj.name obj.pos to:objectList	
close objectList

Can this get shorter?


  (
  	local fs = createFile "c:/temp/objectList.txt"
  	for o in objects do format "% - %
" o.name o.pos to:fs
  	close fs
  )
  

Heh, more than I could ever ask for. Thank you.

I’ve changed the thread title so that people know what it is. Please keep your thread titles descriptive.