Esempio n. 1
0
RemotePlayer *ObjectRef::getplayer(ObjectRef *ref)
{
	PlayerSAO *playersao = getplayersao(ref);
	if (playersao == NULL)
		return NULL;
	return playersao->getPlayer();
}
Esempio n. 2
0
// get_look_yaw2(self)
int ObjectRef::l_get_look_horizontal(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	// Do it
	lua_pushnumber(L, co->getRadRotation().Y);
	return 1;
}
Esempio n. 3
0
// get_meta(self, attribute)
int ObjectRef::l_get_meta(lua_State *L)
{
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO *co = getplayersao(ref);
	if (co == NULL)
		return 0;

	PlayerMetaRef::create(L, &co->getMeta());
	return 1;
}
Esempio n. 4
0
// get_look_pitch2(self)
int ObjectRef::l_get_look_vertical(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	// Do it
	lua_pushnumber(L, co->getRadLookPitch());
	return 1;
}
Esempio n. 5
0
// set_look_yaw(self, radians)
int ObjectRef::l_set_look_yaw(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	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;
}
Esempio n. 6
0
// set_look_vertical(self, radians)
int ObjectRef::l_set_look_vertical(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	float pitch = readParam<float>(L, 2) * core::RADTODEG;
	// Do it
	co->setLookPitchAndSend(pitch);
	return 1;
}
Esempio n. 7
0
// set_look_horizontal(self, radians)
int ObjectRef::l_set_look_horizontal(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	float yaw = readParam<float>(L, 2) * core::RADTODEG;
	// Do it
	co->setPlayerYawAndSend(yaw);
	return 1;
}
Esempio n. 8
0
// set_breath(self, breath)
int ObjectRef::l_set_breath(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	u16 breath = luaL_checknumber(L, 2);
	co->setBreath(breath);

	return 0;
}
Esempio n. 9
0
// get_breath(self)
int ObjectRef::l_get_breath(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	// Do it
	u16 breath = co->getBreath();
	lua_pushinteger (L, breath);
	return 1;
}
Esempio n. 10
0
// get_look_dir(self)
int ObjectRef::l_get_look_dir(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	// Do it
	float pitch = co->getRadPitchDep();
	float yaw = co->getRadYawDep();
	v3f v(cos(pitch)*cos(yaw), sin(pitch), cos(pitch)*sin(yaw));
	push_v3f(L, v);
	return 1;
}
Esempio n. 11
0
// DEPRECATED
// get_look_yaw(self)
int ObjectRef::l_get_look_yaw(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;

	log_deprecated(L,
		"Deprecated call to get_look_yaw, use get_look_horizontal instead");

	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	// Do it
	lua_pushnumber(L, co->getRadYawDep());
	return 1;
}
Esempio n. 12
0
// DEPRECATED
// set_look_pitch(self, radians)
int ObjectRef::l_set_look_pitch(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;

	log_deprecated(L,
		"Deprecated call to set_look_pitch, use set_look_vertical instead.");

	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->setPitchAndSend(pitch);
	return 1;
}
Esempio n. 13
0
// DEPRECATED
// set_look_yaw(self, radians)
int ObjectRef::l_set_look_yaw(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;

	log_deprecated(L,
		"Deprecated call to set_look_yaw, use set_look_horizontal instead.");

	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->setYawAndSend(yaw);
	return 1;
}
Esempio n. 14
0
// set_breath(self, breath)
int ObjectRef::l_set_breath(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) return 0;
	u16 breath = luaL_checknumber(L, 2);
	// Do it
	co->setBreath(breath);

	// If the object is a player sent the breath to client
	if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
			getServer(L)->SendPlayerBreath(((PlayerSAO*)co)->getPeerID());

	return 0;
}
Esempio n. 15
0
// get_nametag_attributes(self)
int ObjectRef::l_get_nametag_attributes(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO *playersao = getplayersao(ref);
	if (playersao == NULL)
		return 0;

	video::SColor color = playersao->getNametagColor();

	lua_newtable(L);
	push_ARGB8(L, color);
	lua_setfield(L, -2, "color");

	return 1;
}
Esempio n. 16
0
// set_attribute(self, attribute, value)
int ObjectRef::l_set_attribute(lua_State *L)
{
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) {
		return 0;
	}

	std::string attr = luaL_checkstring(L, 2);
	if (lua_isnil(L, 3)) {
		co->removeExtendedAttribute(attr);
	} else {
		std::string value = luaL_checkstring(L, 3);
		co->setExtendedAttribute(attr, value);
	}
	return 1;
}
Esempio n. 17
0
// get_attribute(self, attribute)
int ObjectRef::l_get_attribute(lua_State *L)
{
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL) {
		return 0;
	}

	std::string attr = luaL_checkstring(L, 2);

	std::string value = "";
	if (co->getExtendedAttribute(attr, &value)) {
		lua_pushstring(L, value.c_str());
		return 1;
	}

	return 0;
}
Esempio n. 18
0
// set_nametag_attributes(self, attributes)
int ObjectRef::l_set_nametag_attributes(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO *playersao = getplayersao(ref);
	if (playersao == NULL)
		return 0;

	lua_getfield(L, 2, "color");
	if (!lua_isnil(L, -1)) {
		video::SColor color = playersao->getNametagColor();
		if (!read_color(L, -1, &color))
			return 0;
		playersao->setNametagColor(color);
	}

	lua_pushboolean(L, true);
	return 1;
}
Esempio n. 19
0
// set_attribute(self, attribute, value)
int ObjectRef::l_set_attribute(lua_State *L)
{
	log_deprecated(L,
		"Deprecated call to set_attribute, use MetaDataRef methods instead.");

	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL)
		return 0;

	std::string attr = luaL_checkstring(L, 2);
	if (lua_isnil(L, 3)) {
		co->getMeta().removeString(attr);
	} else {
		std::string value = luaL_checkstring(L, 3);
		co->getMeta().setString(attr, value);
	}
	return 1;
}
Esempio n. 20
0
// setvelocity(self, {x=num, y=num, z=num})
int ObjectRef::l_setvelocity(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);

	v3f pos = checkFloatPos(L, 2);

	PlayerSAO* ps = getplayersao(ref);
	if (ps) {
		ps->addSpeed(pos);
		return 0;
	}

	LuaEntitySAO *co = getluaobject(ref);
	if (co == NULL) return 0;
	// Do it
	co->setVelocity(pos);
	return 0;
}
Esempio n. 21
0
// get_attribute(self, attribute)
int ObjectRef::l_get_attribute(lua_State *L)
{
	log_deprecated(L,
		"Deprecated call to get_attribute, use MetaDataRef methods instead.");

	ObjectRef *ref = checkobject(L, 1);
	PlayerSAO* co = getplayersao(ref);
	if (co == NULL)
		return 0;

	std::string attr = luaL_checkstring(L, 2);

	std::string value;
	if (co->getMeta().getStringToRef(attr, value)) {
		lua_pushstring(L, value.c_str());
		return 1;
	}

	return 0;
}
Esempio n. 22
0
// getvelocity(self)
int ObjectRef::l_getvelocity(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	ObjectRef *ref = checkobject(L, 1);

	{
		PlayerSAO* co = getplayersao(ref);
		if (co) {
			v3f v = co->getPlayer()->getSpeed();
			pushFloatPos(L, v);
			return 1;
		}
	}

	LuaEntitySAO *co = getluaobject(ref);
	if (co == NULL) return 0;
	// Do it
	v3f v = co->getVelocity();
	pushFloatPos(L, v);
	return 1;
}