From 4e44c4b33a35fcaa22d26ef1b5fc82275ef6216d Mon Sep 17 00:00:00 2001 From: "nielsbreu@gmail.com" Date: Thu, 9 May 2013 14:32:27 +0000 Subject: function SpawnItemPickups is now exported to Lua. Lua is able to create a Items object. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1463 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Bindings.cpp | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++ source/Bindings.h | 4 ++ source/Item.h | 2 + source/World.h | 8 ++- 4 files changed, 179 insertions(+), 1 deletion(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index fb9e6e265..a07ec6b95 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -1,6 +1,10 @@ /* ** Lua binding: AllToLua +<<<<<<< .mine +** Generated automatically by tolua++-1.0.92 on 05/09/13 14:14:47. +======= ** Generated automatically by tolua++-1.0.92 on 05/08/13 11:35:08. +>>>>>>> .r1462 */ #ifndef __cplusplus @@ -85,6 +89,21 @@ static int tolua_collect_cPickup (lua_State* tolua_S) return 0; } +<<<<<<< .mine +static int tolua_collect_cItems (lua_State* tolua_S) +======= +static int tolua_collect_cChestEntity (lua_State* tolua_S) +>>>>>>> .r1462 +{ +<<<<<<< .mine + cItems* self = (cItems*) tolua_tousertype(tolua_S,1,0); +======= + cChestEntity* self = (cChestEntity*) tolua_tousertype(tolua_S,1,0); +>>>>>>> .r1462 + Mtolua_delete(self); + return 0; +} + static int tolua_collect_cChestEntity (lua_State* tolua_S) { cChestEntity* self = (cChestEntity*) tolua_tousertype(tolua_S,1,0); @@ -11333,6 +11352,87 @@ tolua_lerror: } #endif //#ifndef TOLUA_DISABLE +/* method: SpawnItemPickups of class cWorld */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SpawnItemPickups00 +static int tolua_AllToLua_cWorld_SpawnItemPickups00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItems",0,&tolua_err)) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,1,&tolua_err) || + !tolua_isnoobj(tolua_S,7,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0); + const cItems* a_Pickups = ((const cItems*) tolua_tousertype(tolua_S,2,0)); + double a_BlockX = ((double) tolua_tonumber(tolua_S,3,0)); + double a_BlockY = ((double) tolua_tonumber(tolua_S,4,0)); + double a_BlockZ = ((double) tolua_tonumber(tolua_S,5,0)); + double a_FlyAwaySpeed = ((double) tolua_tonumber(tolua_S,6,1.0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SpawnItemPickups'", NULL); +#endif + { + self->SpawnItemPickups(*a_Pickups,a_BlockX,a_BlockY,a_BlockZ,a_FlyAwaySpeed); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SpawnItemPickups'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SpawnItemPickups of class cWorld */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_SpawnItemPickups01 +static int tolua_AllToLua_cWorld_SpawnItemPickups01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItems",0,&tolua_err)) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,0,&tolua_err) || + !tolua_isnumber(tolua_S,8,0,&tolua_err) || + !tolua_isnoobj(tolua_S,9,&tolua_err) + ) + goto tolua_lerror; + else + { + cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0); + const cItems* a_Pickups = ((const cItems*) tolua_tousertype(tolua_S,2,0)); + double a_BlockX = ((double) tolua_tonumber(tolua_S,3,0)); + double a_BlockY = ((double) tolua_tonumber(tolua_S,4,0)); + double a_BlockZ = ((double) tolua_tonumber(tolua_S,5,0)); + double a_SpeedX = ((double) tolua_tonumber(tolua_S,6,0)); + double a_SpeedY = ((double) tolua_tonumber(tolua_S,7,0)); + double a_SpeedZ = ((double) tolua_tonumber(tolua_S,8,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SpawnItemPickups'", NULL); +#endif + { + self->SpawnItemPickups(*a_Pickups,a_BlockX,a_BlockY,a_BlockZ,a_SpeedX,a_SpeedY,a_SpeedZ); + } + } + return 0; +tolua_lerror: + return tolua_AllToLua_cWorld_SpawnItemPickups00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + /* method: DigBlock of class cWorld */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_DigBlock00 static int tolua_AllToLua_cWorld_DigBlock00(lua_State* tolua_S) @@ -13418,6 +13518,63 @@ static int tolua_set_cItem_m_ItemDamage(lua_State* tolua_S) } #endif //#ifndef TOLUA_DISABLE +/* method: new of class cItems */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cItems_new00 +static int tolua_AllToLua_cItems_new00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"cItems",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + cItems* tolua_ret = (cItems*) Mtolua_new((cItems)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItems"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class cItems */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cItems_new00_local +static int tolua_AllToLua_cItems_new00_local(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"cItems",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + cItems* tolua_ret = (cItems*) Mtolua_new((cItems)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"cItems"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + /* method: Get of class cItems */ #ifndef TOLUA_DISABLE_tolua_AllToLua_cItems_Get00 static int tolua_AllToLua_cItems_Get00(lua_State* tolua_S) @@ -24851,6 +25008,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"GetBlock",tolua_AllToLua_cWorld_GetBlock01); tolua_function(tolua_S,"GetBlockMeta",tolua_AllToLua_cWorld_GetBlockMeta01); tolua_function(tolua_S,"SetBlockMeta",tolua_AllToLua_cWorld_SetBlockMeta01); + tolua_function(tolua_S,"SpawnItemPickups",tolua_AllToLua_cWorld_SpawnItemPickups00); + tolua_function(tolua_S,"SpawnItemPickups",tolua_AllToLua_cWorld_SpawnItemPickups01); tolua_function(tolua_S,"DigBlock",tolua_AllToLua_cWorld_DigBlock00); tolua_function(tolua_S,"SendBlockTo",tolua_AllToLua_cWorld_SendBlockTo00); tolua_function(tolua_S,"GetSpawnX",tolua_AllToLua_cWorld_GetSpawnX00); @@ -24924,8 +25083,15 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_variable(tolua_S,"m_ItemCount",tolua_get_cItem_m_ItemCount,tolua_set_cItem_m_ItemCount); tolua_variable(tolua_S,"m_ItemDamage",tolua_get_cItem_m_ItemDamage,tolua_set_cItem_m_ItemDamage); tolua_endmodule(tolua_S); + #ifdef __cplusplus + tolua_cclass(tolua_S,"cItems","cItems","",tolua_collect_cItems); + #else tolua_cclass(tolua_S,"cItems","cItems","",NULL); + #endif tolua_beginmodule(tolua_S,"cItems"); + tolua_function(tolua_S,"new",tolua_AllToLua_cItems_new00); + tolua_function(tolua_S,"new_local",tolua_AllToLua_cItems_new00_local); + tolua_function(tolua_S,".call",tolua_AllToLua_cItems_new00_local); tolua_function(tolua_S,"Get",tolua_AllToLua_cItems_Get00); tolua_function(tolua_S,"Set",tolua_AllToLua_cItems_Set00); tolua_function(tolua_S,"Add",tolua_AllToLua_cItems_Add00); diff --git a/source/Bindings.h b/source/Bindings.h index e80650e8b..1965974d1 100644 --- a/source/Bindings.h +++ b/source/Bindings.h @@ -1,6 +1,10 @@ /* ** Lua binding: AllToLua +<<<<<<< .mine +** Generated automatically by tolua++-1.0.92 on 05/09/13 14:14:48. +======= ** Generated automatically by tolua++-1.0.92 on 05/08/13 11:35:08. +>>>>>>> .r1462 */ /* Exported function */ diff --git a/source/Item.h b/source/Item.h index fb3999f9e..b80eb132b 100644 --- a/source/Item.h +++ b/source/Item.h @@ -99,6 +99,8 @@ class cItems // tolua_export { // tolua_export public: // tolua_begin + /// Need a Lua-accessible constructor + cItems(void) {} cItem & Get (int a_Idx) {return at(a_Idx); } void Set (int a_Idx, const cItem & a_Item) {at(a_Idx) = a_Item; } void Add (const cItem & a_Item) {push_back(a_Item); } diff --git a/source/World.h b/source/World.h index c3aa0c25c..8f096fa38 100644 --- a/source/World.h +++ b/source/World.h @@ -301,11 +301,17 @@ public: bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes); /// Spawns item pickups for each item in the list. May compress pickups if too many entities: + + // tolua_begin void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0); + // tolua_end /// Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified: - void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ); + // tolua_begin + void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ); + // tolua_end + /// Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType void ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_FilterBlockType); -- cgit v1.2.3