Luacasts for Light

This commit is contained in:
Sam 2014-01-21 22:01:11 +01:00
parent 9bd02ca8ba
commit 38c9b6b0b2
2 changed files with 27 additions and 0 deletions

View File

@ -143,3 +143,26 @@ bool luavalue_cast(int index, MarketData& data)
} }
return false; 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;
}

View File

@ -40,4 +40,8 @@ bool luavalue_cast(int index, Position& pos);
int push_luavalue(const MarketData& data); int push_luavalue(const MarketData& data);
bool luavalue_cast(int index, MarketData& data); bool luavalue_cast(int index, MarketData& data);
// light
int push_luavalue(const Light& light);
bool luavalue_cast(int index, Light& light);
#endif #endif