-- - set_hp(hp): set number of hitpoints (2 * number of hearts)
-- LuaEntitySAO-only: (no-op for other objects)
-- - setvelocity({x=num, y=num, z=num})
+-- - getvelocity() -> {x=num, y=num, z=num}
-- - setacceleration({x=num, y=num, z=num})
-- - getacceleration() -> {x=num, y=num, z=num}
+-- - setyaw(radians)
+-- - getyaw() -> radians
-- - settexturemod(mod)
-- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
-- - select_horiz_by_yawpitch=false)
float getMinimumSavedMovement();
/* LuaEntitySAO-specific */
void setVelocity(v3f velocity);
+ v3f getVelocity();
void setAcceleration(v3f acceleration);
v3f getAcceleration();
+ void setYaw(float yaw);
+ float getYaw();
void setTextureMod(const std::string &mod);
void setSprite(v2s16 p, int num_frames, float framelength,
bool select_horiz_by_yawpitch);
return 0;
}
+ // getvelocity(self)
+ static int l_getvelocity(lua_State *L)
+ {
+ ObjectRef *ref = checkobject(L, 1);
+ LuaEntitySAO *co = getluaobject(ref);
+ if(co == NULL) return 0;
+ // Do it
+ v3f v = co->getVelocity();
+ pushFloatPos(L, v);
+ return 1;
+ }
+
// setacceleration(self, {x=num, y=num, z=num})
static int l_setacceleration(lua_State *L)
{
return 1;
}
+ // setyaw(self, radians)
+ static int l_setyaw(lua_State *L)
+ {
+ ObjectRef *ref = checkobject(L, 1);
+ LuaEntitySAO *co = getluaobject(ref);
+ if(co == NULL) return 0;
+ // pos
+ float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
+ // Do it
+ co->setYaw(yaw);
+ return 0;
+ }
+
+ // getyaw(self)
+ static int l_getyaw(lua_State *L)
+ {
+ ObjectRef *ref = checkobject(L, 1);
+ LuaEntitySAO *co = getluaobject(ref);
+ if(co == NULL) return 0;
+ // Do it
+ float yaw = co->getYaw() * core::DEGTORAD;
+ lua_pushnumber(L, yaw);
+ return 1;
+ }
+
// settexturemod(self, mod)
static int l_settexturemod(lua_State *L)
{
method(ObjectRef, get_hp),
// LuaEntitySAO-only
method(ObjectRef, setvelocity),
+ method(ObjectRef, getvelocity),
method(ObjectRef, setacceleration),
method(ObjectRef, getacceleration),
+ method(ObjectRef, setyaw),
+ method(ObjectRef, getyaw),
method(ObjectRef, settexturemod),
method(ObjectRef, setsprite),
method(ObjectRef, get_entity_name),