MegaGlest Forum
Modding and game content creation => Maps, tilesets and scenarios => Topic started by: wciow on 9 August 2009, 09:04:30
-
Can anyone write a Lua function which checks a specified cell to see if there is a unit on it and returns the units faction?
Just one catch . . .
You can't use any unit id to specify a unit.
If anyone knows how to do this please tell me.
-
You mean something like?:
factionId isCellOccupied(Vec2i)
Or more like?:
factionId unitOnCell(unitType, Vec2i)
-
Maybe you can go through all units and test their positions ( with lua )...
But some units are bigger than one cell coordinate.
-
Maybe you can go through all units and test their positions ( with lua )...
But some units are bigger than one cell coordinate.
Yep, this would be the only way to do it currently. You'd need to record every unit created, storing their IDs in a table, then loop over it testing the position of every unit... pretty intensive processing to be doing with LUA. (and the size problem... if you really wanted it to be single cell accurate).
-
OK thanks guys.
I had an idea similar to Silnarm's but also realised that it would take way too much cpu.
I suppose its another thing to add to the long todo list.