diff options
author | rubenwardy <rubenwardy@gmail.com> | 2017-01-16 13:08:59 +0000 |
---|---|---|
committer | rubenwardy <rubenwardy@gmail.com> | 2017-01-16 15:34:44 +0000 |
commit | 63c892eedfe21cbca2e2369d28e5e4d4e62ca1bd (patch) | |
tree | 60aaef50af7a091d1f549c37bffbe81485b2111c /src/script/lua_api | |
parent | f3bd4c405df6bce64b7a98789d825eeac9c279b2 (diff) | |
download | minetest-63c892eedfe21cbca2e2369d28e5e4d4e62ca1bd.tar.gz minetest-63c892eedfe21cbca2e2369d28e5e4d4e62ca1bd.tar.bz2 minetest-63c892eedfe21cbca2e2369d28e5e4d4e62ca1bd.zip |
Rename ObjectRef methods to be consistent and predictable
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_internal.h | 1 | ||||
-rw-r--r-- | src/script/lua_api/l_object.cpp | 66 | ||||
-rw-r--r-- | src/script/lua_api/l_object.h | 44 |
3 files changed, 56 insertions, 55 deletions
diff --git a/src/script/lua_api/l_internal.h b/src/script/lua_api/l_internal.h index 456c8fcce..c610dc5a3 100644 --- a/src/script/lua_api/l_internal.h +++ b/src/script/lua_api/l_internal.h @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common/c_internal.h" #define luamethod(class, name) {#name, class::l_##name} +#define luamethod_aliased(class, name, alias) {#name, class::l_##name}, {#alias, class::l_##name} #define API_FCT(name) registerFunction(L, #name, l_##name,top) #define ASYNC_API_FCT(name) engine.registerFunction(#name, l_##name) diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 506e56df9..dd29208c5 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -150,9 +150,9 @@ int ObjectRef::l_remove(lua_State *L) return 0; } -// getpos(self) +// get_pos(self) // returns: {x=num, y=num, z=num} -int ObjectRef::l_getpos(lua_State *L) +int ObjectRef::l_get_pos(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -169,8 +169,8 @@ int ObjectRef::l_getpos(lua_State *L) return 1; } -// setpos(self, pos) -int ObjectRef::l_setpos(lua_State *L) +// set_pos(self, pos) +int ObjectRef::l_set_pos(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -184,8 +184,8 @@ int ObjectRef::l_setpos(lua_State *L) return 0; } -// moveto(self, pos, continuous=false) -int ObjectRef::l_moveto(lua_State *L) +// move_to(self, pos, continuous=false) +int ObjectRef::l_move_to(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -821,8 +821,8 @@ int ObjectRef::l_get_nametag_attributes(lua_State *L) /* LuaEntitySAO-only */ -// setvelocity(self, {x=num, y=num, z=num}) -int ObjectRef::l_setvelocity(lua_State *L) +// set_velocity(self, {x=num, y=num, z=num}) +int ObjectRef::l_set_velocity(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -834,8 +834,8 @@ int ObjectRef::l_setvelocity(lua_State *L) return 0; } -// getvelocity(self) -int ObjectRef::l_getvelocity(lua_State *L) +// get_velocity(self) +int ObjectRef::l_get_velocity(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -847,8 +847,8 @@ int ObjectRef::l_getvelocity(lua_State *L) return 1; } -// setacceleration(self, {x=num, y=num, z=num}) -int ObjectRef::l_setacceleration(lua_State *L) +// set_acceleration(self, {x=num, y=num, z=num}) +int ObjectRef::l_set_acceleration(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -861,8 +861,8 @@ int ObjectRef::l_setacceleration(lua_State *L) return 0; } -// getacceleration(self) -int ObjectRef::l_getacceleration(lua_State *L) +// get_acceleration(self) +int ObjectRef::l_get_acceleration(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -874,8 +874,8 @@ int ObjectRef::l_getacceleration(lua_State *L) return 1; } -// setyaw(self, radians) -int ObjectRef::l_setyaw(lua_State *L) +// set_yaw(self, radians) +int ObjectRef::l_set_yaw(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -887,8 +887,8 @@ int ObjectRef::l_setyaw(lua_State *L) return 0; } -// getyaw(self) -int ObjectRef::l_getyaw(lua_State *L) +// get_yaw(self) +int ObjectRef::l_get_yaw(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -900,8 +900,8 @@ int ObjectRef::l_getyaw(lua_State *L) return 1; } -// settexturemod(self, mod) -int ObjectRef::l_settexturemod(lua_State *L) +// set_texture_mod(self, mod) +int ObjectRef::l_set_texture_mod(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -913,9 +913,9 @@ int ObjectRef::l_settexturemod(lua_State *L) return 0; } -// setsprite(self, p={x=0,y=0}, num_frames=1, framelength=0.2, +// set_sprite(self, p={x=0,y=0}, num_frames=1, framelength=0.2, // select_horiz_by_yawpitch=false) -int ObjectRef::l_setsprite(lua_State *L) +int ObjectRef::l_set_sprite(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); @@ -1774,9 +1774,9 @@ const char ObjectRef::className[] = "ObjectRef"; const luaL_reg ObjectRef::methods[] = { // ServerActiveObject luamethod(ObjectRef, remove), - luamethod(ObjectRef, getpos), - luamethod(ObjectRef, setpos), - luamethod(ObjectRef, moveto), + luamethod_aliased(ObjectRef, get_pos, getpos), + luamethod_aliased(ObjectRef, set_pos, setpos), + luamethod_aliased(ObjectRef, move_to, moveto), luamethod(ObjectRef, punch), luamethod(ObjectRef, right_click), luamethod(ObjectRef, set_hp), @@ -1800,14 +1800,14 @@ const luaL_reg ObjectRef::methods[] = { luamethod(ObjectRef, set_nametag_attributes), luamethod(ObjectRef, get_nametag_attributes), // LuaEntitySAO-only - luamethod(ObjectRef, setvelocity), - luamethod(ObjectRef, getvelocity), - luamethod(ObjectRef, setacceleration), - luamethod(ObjectRef, getacceleration), - luamethod(ObjectRef, setyaw), - luamethod(ObjectRef, getyaw), - luamethod(ObjectRef, settexturemod), - luamethod(ObjectRef, setsprite), + luamethod_aliased(ObjectRef, set_velocity, setvelocity), + luamethod_aliased(ObjectRef, get_velocity, getvelocity), + luamethod_aliased(ObjectRef, set_acceleration, setacceleration), + luamethod_aliased(ObjectRef, get_acceleration, getacceleration), + luamethod_aliased(ObjectRef, set_yaw, setyaw), + luamethod_aliased(ObjectRef, get_yaw, getyaw), + luamethod_aliased(ObjectRef, set_texture_mod, set_texturemod), + luamethod_aliased(ObjectRef, set_sprite, setsprite), luamethod(ObjectRef, get_entity_name), luamethod(ObjectRef, get_luaentity), // Player-only diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index 09f10e417..06b1bb79b 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -57,15 +57,15 @@ private: // remove(self) static int l_remove(lua_State *L); - // getpos(self) + // get_pos(self) // returns: {x=num, y=num, z=num} - static int l_getpos(lua_State *L); + static int l_get_pos(lua_State *L); - // setpos(self, pos) - static int l_setpos(lua_State *L); + // set_pos(self, pos) + static int l_set_pos(lua_State *L); - // moveto(self, pos, continuous=false) - static int l_moveto(lua_State *L); + // move_to(self, pos, continuous=false) + static int l_move_to(lua_State *L); // punch(self, puncher, time_from_last_punch, tool_capabilities, dir) static int l_punch(lua_State *L); @@ -143,30 +143,30 @@ private: /* LuaEntitySAO-only */ - // setvelocity(self, {x=num, y=num, z=num}) - static int l_setvelocity(lua_State *L); + // set_velocity(self, {x=num, y=num, z=num}) + static int l_set_velocity(lua_State *L); - // getvelocity(self) - static int l_getvelocity(lua_State *L); + // get_velocity(self) + static int l_get_velocity(lua_State *L); - // setacceleration(self, {x=num, y=num, z=num}) - static int l_setacceleration(lua_State *L); + // set_acceleration(self, {x=num, y=num, z=num}) + static int l_set_acceleration(lua_State *L); - // getacceleration(self) - static int l_getacceleration(lua_State *L); + // get_acceleration(self) + static int l_get_acceleration(lua_State *L); - // setyaw(self, radians) - static int l_setyaw(lua_State *L); + // set_yaw(self, radians) + static int l_set_yaw(lua_State *L); - // getyaw(self) - static int l_getyaw(lua_State *L); + // get_yaw(self) + static int l_get_yaw(lua_State *L); - // settexturemod(self, mod) - static int l_settexturemod(lua_State *L); + // set_texture_mod(self, mod) + static int l_set_texture_mod(lua_State *L); - // setsprite(self, p={x=0,y=0}, num_frames=1, framelength=0.2, + // set_sprite(self, p={x=0,y=0}, num_frames=1, framelength=0.2, // select_horiz_by_yawpitch=false) - static int l_setsprite(lua_State *L); + static int l_set_sprite(lua_State *L); // DEPRECATED // get_entity_name(self) |