Rename ObjectRef methods to be consistent and predictable

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

View File

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

View File

@ -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)

View File

@ -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

View File

@ -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)