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.
All Unit Position
Moderator: Moderators
Re: All Unit Position
Spring.GetAllUnits
Spring.GetUnitPosition
http://springrts.com/phpbb/viewtopic.ph ... 1&start=62
Spring.GetUnitPosition
maybe it looking at the widget of this is helpfull:collect all unit position and log it in a txt file
http://springrts.com/phpbb/viewtopic.ph ... 1&start=62
Re: All Unit Position
The link says: File does not exist on our server
Re: All Unit Position
down file is down.
try something like that:
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