Rename ObjectRef methods to be consistent and predictable

This commit is contained in:
rubenwardy 2017-01-16 13:08:59 +00:00
parent f3bd4c405d
commit 63c892eedf
4 changed files with 67 additions and 66 deletions

@ -2788,9 +2788,9 @@ This is basically a reference to a C++ `ServerActiveObject`
#### Methods #### Methods
* `remove()`: remove object (after returning from Lua) * `remove()`: remove object (after returning from Lua)
* Note: Doesn't work on players, use minetest.kick_player instead * Note: Doesn't work on players, use minetest.kick_player instead
* `getpos()`: returns `{x=num, y=num, z=num}` * `get_pos()`: returns `{x=num, y=num, z=num}`
* `setpos(pos)`; `pos`=`{x=num, y=num, z=num}` * `set_pos(pos)`; `pos`=`{x=num, y=num, z=num}`
* `moveto(pos, continuous=false)`: interpolated move * `move_to(pos, continuous=false)`: interpolated move
* `punch(puncher, time_from_last_punch, tool_capabilities, direction)` * `punch(puncher, time_from_last_punch, tool_capabilities, direction)`
* `puncher` = another `ObjectRef`, * `puncher` = another `ObjectRef`,
* `time_from_last_punch` = time since last punch action of the puncher * `time_from_last_punch` = time since last punch action of the puncher
@ -2836,14 +2836,14 @@ This is basically a reference to a C++ `ServerActiveObject`
} }
##### LuaEntitySAO-only (no-op for other objects) ##### LuaEntitySAO-only (no-op for other objects)
* `setvelocity({x=num, y=num, z=num})` * `set_velocity({x=num, y=num, z=num})`
* `getvelocity()`: returns `{x=num, y=num, z=num}` * `get_velocity()`: returns `{x=num, y=num, z=num}`
* `setacceleration({x=num, y=num, z=num})` * `set_acceleration({x=num, y=num, z=num})`
* `getacceleration()`: returns `{x=num, y=num, z=num}` * `get_acceleration()`: returns `{x=num, y=num, z=num}`
* `setyaw(radians)` * `set_yaw(radians)`
* `getyaw()`: returns number in radians * `get_yaw()`: returns number in radians
* `settexturemod(mod)` * `set_texture_mod(mod)`
* `setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2, * `set_sprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
select_horiz_by_yawpitch=false)` select_horiz_by_yawpitch=false)`
* Select sprite from spritesheet with optional animation and DM-style * Select sprite from spritesheet with optional animation and DM-style
texture selection based on yaw relative to camera texture selection based on yaw relative to camera

@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/c_internal.h" #include "common/c_internal.h"
#define luamethod(class, name) {#name, class::l_##name} #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 API_FCT(name) registerFunction(L, #name, l_##name,top)
#define ASYNC_API_FCT(name) engine.registerFunction(#name, l_##name) #define ASYNC_API_FCT(name) engine.registerFunction(#name, l_##name)

@ -150,9 +150,9 @@ int ObjectRef::l_remove(lua_State *L)
return 0; return 0;
} }
// getpos(self) // get_pos(self)
// returns: {x=num, y=num, z=num} // 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; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -169,8 +169,8 @@ int ObjectRef::l_getpos(lua_State *L)
return 1; return 1;
} }
// setpos(self, pos) // set_pos(self, pos)
int ObjectRef::l_setpos(lua_State *L) int ObjectRef::l_set_pos(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -184,8 +184,8 @@ int ObjectRef::l_setpos(lua_State *L)
return 0; return 0;
} }
// moveto(self, pos, continuous=false) // move_to(self, pos, continuous=false)
int ObjectRef::l_moveto(lua_State *L) int ObjectRef::l_move_to(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -821,8 +821,8 @@ int ObjectRef::l_get_nametag_attributes(lua_State *L)
/* LuaEntitySAO-only */ /* LuaEntitySAO-only */
// setvelocity(self, {x=num, y=num, z=num}) // set_velocity(self, {x=num, y=num, z=num})
int ObjectRef::l_setvelocity(lua_State *L) int ObjectRef::l_set_velocity(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -834,8 +834,8 @@ int ObjectRef::l_setvelocity(lua_State *L)
return 0; return 0;
} }
// getvelocity(self) // get_velocity(self)
int ObjectRef::l_getvelocity(lua_State *L) int ObjectRef::l_get_velocity(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -847,8 +847,8 @@ int ObjectRef::l_getvelocity(lua_State *L)
return 1; return 1;
} }
// setacceleration(self, {x=num, y=num, z=num}) // set_acceleration(self, {x=num, y=num, z=num})
int ObjectRef::l_setacceleration(lua_State *L) int ObjectRef::l_set_acceleration(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -861,8 +861,8 @@ int ObjectRef::l_setacceleration(lua_State *L)
return 0; return 0;
} }
// getacceleration(self) // get_acceleration(self)
int ObjectRef::l_getacceleration(lua_State *L) int ObjectRef::l_get_acceleration(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -874,8 +874,8 @@ int ObjectRef::l_getacceleration(lua_State *L)
return 1; return 1;
} }
// setyaw(self, radians) // set_yaw(self, radians)
int ObjectRef::l_setyaw(lua_State *L) int ObjectRef::l_set_yaw(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -887,8 +887,8 @@ int ObjectRef::l_setyaw(lua_State *L)
return 0; return 0;
} }
// getyaw(self) // get_yaw(self)
int ObjectRef::l_getyaw(lua_State *L) int ObjectRef::l_get_yaw(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -900,8 +900,8 @@ int ObjectRef::l_getyaw(lua_State *L)
return 1; return 1;
} }
// settexturemod(self, mod) // set_texture_mod(self, mod)
int ObjectRef::l_settexturemod(lua_State *L) int ObjectRef::l_set_texture_mod(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -913,9 +913,9 @@ int ObjectRef::l_settexturemod(lua_State *L)
return 0; 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) // select_horiz_by_yawpitch=false)
int ObjectRef::l_setsprite(lua_State *L) int ObjectRef::l_set_sprite(lua_State *L)
{ {
NO_MAP_LOCK_REQUIRED; NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1); ObjectRef *ref = checkobject(L, 1);
@ -1774,9 +1774,9 @@ const char ObjectRef::className[] = "ObjectRef";
const luaL_reg ObjectRef::methods[] = { const luaL_reg ObjectRef::methods[] = {
// ServerActiveObject // ServerActiveObject
luamethod(ObjectRef, remove), luamethod(ObjectRef, remove),
luamethod(ObjectRef, getpos), luamethod_aliased(ObjectRef, get_pos, getpos),
luamethod(ObjectRef, setpos), luamethod_aliased(ObjectRef, set_pos, setpos),
luamethod(ObjectRef, moveto), luamethod_aliased(ObjectRef, move_to, moveto),
luamethod(ObjectRef, punch), luamethod(ObjectRef, punch),
luamethod(ObjectRef, right_click), luamethod(ObjectRef, right_click),
luamethod(ObjectRef, set_hp), luamethod(ObjectRef, set_hp),
@ -1800,14 +1800,14 @@ const luaL_reg ObjectRef::methods[] = {
luamethod(ObjectRef, set_nametag_attributes), luamethod(ObjectRef, set_nametag_attributes),
luamethod(ObjectRef, get_nametag_attributes), luamethod(ObjectRef, get_nametag_attributes),
// LuaEntitySAO-only // LuaEntitySAO-only
luamethod(ObjectRef, setvelocity), luamethod_aliased(ObjectRef, set_velocity, setvelocity),
luamethod(ObjectRef, getvelocity), luamethod_aliased(ObjectRef, get_velocity, getvelocity),
luamethod(ObjectRef, setacceleration), luamethod_aliased(ObjectRef, set_acceleration, setacceleration),
luamethod(ObjectRef, getacceleration), luamethod_aliased(ObjectRef, get_acceleration, getacceleration),
luamethod(ObjectRef, setyaw), luamethod_aliased(ObjectRef, set_yaw, setyaw),
luamethod(ObjectRef, getyaw), luamethod_aliased(ObjectRef, get_yaw, getyaw),
luamethod(ObjectRef, settexturemod), luamethod_aliased(ObjectRef, set_texture_mod, set_texturemod),
luamethod(ObjectRef, setsprite), luamethod_aliased(ObjectRef, set_sprite, setsprite),
luamethod(ObjectRef, get_entity_name), luamethod(ObjectRef, get_entity_name),
luamethod(ObjectRef, get_luaentity), luamethod(ObjectRef, get_luaentity),
// Player-only // Player-only

@ -57,15 +57,15 @@ private:
// remove(self) // remove(self)
static int l_remove(lua_State *L); static int l_remove(lua_State *L);
// getpos(self) // get_pos(self)
// returns: {x=num, y=num, z=num} // 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) // set_pos(self, pos)
static int l_setpos(lua_State *L); static int l_set_pos(lua_State *L);
// moveto(self, pos, continuous=false) // move_to(self, pos, continuous=false)
static int l_moveto(lua_State *L); static int l_move_to(lua_State *L);
// punch(self, puncher, time_from_last_punch, tool_capabilities, dir) // punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
static int l_punch(lua_State *L); static int l_punch(lua_State *L);
@ -143,30 +143,30 @@ private:
/* LuaEntitySAO-only */ /* LuaEntitySAO-only */
// setvelocity(self, {x=num, y=num, z=num}) // set_velocity(self, {x=num, y=num, z=num})
static int l_setvelocity(lua_State *L); static int l_set_velocity(lua_State *L);
// getvelocity(self) // get_velocity(self)
static int l_getvelocity(lua_State *L); static int l_get_velocity(lua_State *L);
// setacceleration(self, {x=num, y=num, z=num}) // set_acceleration(self, {x=num, y=num, z=num})
static int l_setacceleration(lua_State *L); static int l_set_acceleration(lua_State *L);
// getacceleration(self) // get_acceleration(self)
static int l_getacceleration(lua_State *L); static int l_get_acceleration(lua_State *L);
// setyaw(self, radians) // set_yaw(self, radians)
static int l_setyaw(lua_State *L); static int l_set_yaw(lua_State *L);
// getyaw(self) // get_yaw(self)
static int l_getyaw(lua_State *L); static int l_get_yaw(lua_State *L);
// settexturemod(self, mod) // set_texture_mod(self, mod)
static int l_settexturemod(lua_State *L); 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) // select_horiz_by_yawpitch=false)
static int l_setsprite(lua_State *L); static int l_set_sprite(lua_State *L);
// DEPRECATED // DEPRECATED
// get_entity_name(self) // get_entity_name(self)