|
|
@@ -28,8 +28,8 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|
|
#include "LuaEnvironment.h"
|
|
|
#include "World.h"
|
|
|
#include "Gui.h"
|
|
|
-#include "Device.h"
|
|
|
-#include "LuaSystem.h"
|
|
|
+#include "TempAllocator.h"
|
|
|
+#include "Array.h"
|
|
|
|
|
|
namespace crown
|
|
|
{
|
|
|
@@ -74,6 +74,29 @@ static int world_num_units(lua_State* L)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+static int world_units(lua_State* L)
|
|
|
+{
|
|
|
+ LuaStack stack(L);
|
|
|
+
|
|
|
+ World* world = stack.get_world(1);
|
|
|
+
|
|
|
+ TempAllocator1024 alloc;
|
|
|
+ Array<UnitId> all_units(alloc);
|
|
|
+
|
|
|
+ world->units(all_units);
|
|
|
+
|
|
|
+ stack.push_table();
|
|
|
+ for (uint32_t i = 0; i < array::size(all_units); i++)
|
|
|
+ {
|
|
|
+ stack.push_key_begin((int32_t) i + 1);
|
|
|
+ stack.push_unit(world->lookup_unit(all_units[i]));
|
|
|
+ stack.push_key_end();
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
static int world_play_sound(lua_State* L)
|
|
|
{
|
|
|
@@ -255,6 +278,7 @@ void load_world(LuaEnvironment& env)
|
|
|
env.load_module_function("World", "spawn_unit", world_spawn_unit);
|
|
|
env.load_module_function("World", "destroy_unit", world_destroy_unit);
|
|
|
env.load_module_function("World", "num_units", world_num_units);
|
|
|
+ env.load_module_function("World", "units", world_units);
|
|
|
|
|
|
env.load_module_function("World", "play_sound", world_play_sound);
|
|
|
env.load_module_function("World", "stop_sound", world_stop_sound);
|