From 38c9b6b0b2ef2d15f1570be64dadd8d60f5ce82b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 21 Jan 2014 22:01:11 +0100 Subject: [PATCH] Luacasts for Light --- src/client/luavaluecasts.cpp | 23 +++++++++++++++++++++++ src/client/luavaluecasts.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/client/luavaluecasts.cpp b/src/client/luavaluecasts.cpp index 42103568..a98087e1 100644 --- a/src/client/luavaluecasts.cpp +++ b/src/client/luavaluecasts.cpp @@ -143,3 +143,26 @@ bool luavalue_cast(int index, MarketData& data) } return false; } + +int push_luavalue(const Light& light) +{ + g_lua.createTable(0, 2); + g_lua.pushInteger(light.color); + g_lua.setField("color"); + g_lua.pushInteger(light.intensity); + g_lua.setField("intensity"); + return 1; +} + + +bool luavalue_cast(int index, Light& light) +{ + if(g_lua.isTable(index)) { + g_lua.getField("color", index); + light.color = g_lua.popInteger(); + g_lua.getField("intensity", index); + light.intensity = g_lua.popInteger(); + return true; + } + return false; +} diff --git a/src/client/luavaluecasts.h b/src/client/luavaluecasts.h index 3851a54c..867c94bb 100644 --- a/src/client/luavaluecasts.h +++ b/src/client/luavaluecasts.h @@ -40,4 +40,8 @@ bool luavalue_cast(int index, Position& pos); int push_luavalue(const MarketData& data); bool luavalue_cast(int index, MarketData& data); +// light +int push_luavalue(const Light& light); +bool luavalue_cast(int index, Light& light); + #endif