- get_look_dir(): get camera direction as a unit vector
- get_look_pitch(): pitch in radians
- get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
+- set_look_pitch(radians): sets look pitch
+- set_look_yaw(radians): sets look yaw
- set_inventory_formspec(formspec)
^ Redefine player's inventory form
^ Should usually be called in on_joinplayer
m_moved = true;
}
+void PlayerSAO::setYaw(float yaw)
+{
+ m_player->setYaw(yaw);
+ // Force change on client
+ m_moved = true;
+}
+
+void PlayerSAO::setPitch(float pitch)
+{
+ m_player->setPitch(pitch);
+ // Force change on client
+ m_moved = true;
+}
+
int PlayerSAO::punch(v3f dir,
const ToolCapabilities *toolcap,
ServerActiveObject *puncher,
#include "scriptapi_entity.h"
#include "scriptapi_common.h"
-
/*
ObjectRef
*/
return 1;
}
+// set_look_pitch(self, radians)
+int ObjectRef::l_set_look_pitch(lua_State *L)
+{
+ ObjectRef *ref = checkobject(L, 1);
+ PlayerSAO* co = getplayersao(ref);
+ if(co == NULL) return 0;
+ float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
+ // Do it
+ co->setPitch(pitch);
+ return 1;
+}
+
+// set_look_yaw(self, radians)
+int ObjectRef::l_set_look_yaw(lua_State *L)
+{
+ ObjectRef *ref = checkobject(L, 1);
+ PlayerSAO* co = getplayersao(ref);
+ if(co == NULL) return 0;
+ float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
+ // Do it
+ co->setYaw(yaw);
+ return 1;
+}
+
// set_inventory_formspec(self, formspec)
int ObjectRef::l_set_inventory_formspec(lua_State *L)
{
luamethod(ObjectRef, get_look_dir),
luamethod(ObjectRef, get_look_pitch),
luamethod(ObjectRef, get_look_yaw),
+ luamethod(ObjectRef, set_look_yaw),
+ luamethod(ObjectRef, set_look_pitch),
luamethod(ObjectRef, set_inventory_formspec),
luamethod(ObjectRef, get_inventory_formspec),
luamethod(ObjectRef, get_player_control),
/*
-Minetest-c55
+Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
// get_look_yaw(self)
static int l_get_look_yaw(lua_State *L);
+ // set_look_pitch(self, radians)
+ static int l_set_look_pitch(lua_State *L);
+
+ // set_look_yaw(self, radians)
+ static int l_set_look_yaw(lua_State *L);
+
// set_inventory_formspec(self, formspec)
static int l_set_inventory_formspec(lua_State *L);