Page 1 of 1
All Unit Position
Posted: 08 Oct 2011, 14:32
by Von66341
Hey!
Is there a way I can get the position of all units?
Say for example, 5 mins into the game, i want to collect all unit position and log it in a txt file.
Thanks.
Re: All Unit Position
Posted: 08 Oct 2011, 15:15
by knorke
Spring.GetAllUnits
Spring.GetUnitPosition
collect all unit position and log it in a txt file
maybe it looking at the widget of this is helpfull:
http://springrts.com/phpbb/viewtopic.ph ... 1&start=62
Re: All Unit Position
Posted: 08 Oct 2011, 16:57
by Von66341
The link says: File does not exist on our server
Re: All Unit Position
Posted: 12 Oct 2011, 10:05
by knorke
down file is down.
try something like that:
Code: Select all
function widget:GameFrame(frame)
if (frame==5*60*30) then--5 minutes
myfile = io.open ("bla.txt", "w")
if (myfile== nil) then
Spring.Echo ("could not open file for writing!")
return
end
for _,unitID in ipairs(Spring.GetAllUnits ()) do
x,y,z=Spring.GetUnitPosition (unitID)
text = "unit " .. unitID .. " is at " .. ":"..x ..":".. y.. ":".. z
myfile:write (text .. "\n")
end
myfile:flush()
myfile:close()
end
end