3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "lua_api/l_object.h"
21 #include "lua_api/l_internal.h"
22 #include "lua_api/l_inventory.h"
23 #include "lua_api/l_item.h"
24 #include "common/c_converter.h"
25 #include "common/c_content.h"
28 #include "serverobject.h"
29 #include "content_sao.h"
32 #include "scripting_game.h"
34 #define GET_ENV_PTR ServerEnvironment* env = \
35 dynamic_cast<ServerEnvironment*>(getEnv(L)); \
36 if (env == NULL) return 0
38 struct EnumString es_HudElementType[] =
40 {HUD_ELEM_IMAGE, "image"},
41 {HUD_ELEM_TEXT, "text"},
42 {HUD_ELEM_STATBAR, "statbar"},
43 {HUD_ELEM_INVENTORY, "inventory"},
44 {HUD_ELEM_WAYPOINT, "waypoint"},
48 struct EnumString es_HudElementStat[] =
50 {HUD_STAT_POS, "position"},
51 {HUD_STAT_POS, "pos"}, /* Deprecated, only for compatibility's sake */
52 {HUD_STAT_NAME, "name"},
53 {HUD_STAT_SCALE, "scale"},
54 {HUD_STAT_TEXT, "text"},
55 {HUD_STAT_NUMBER, "number"},
56 {HUD_STAT_ITEM, "item"},
57 {HUD_STAT_DIR, "direction"},
58 {HUD_STAT_ALIGN, "alignment"},
59 {HUD_STAT_OFFSET, "offset"},
60 {HUD_STAT_WORLD_POS, "world_pos"},
64 struct EnumString es_HudBuiltinElement[] =
66 {HUD_FLAG_HOTBAR_VISIBLE, "hotbar"},
67 {HUD_FLAG_HEALTHBAR_VISIBLE, "healthbar"},
68 {HUD_FLAG_CROSSHAIR_VISIBLE, "crosshair"},
69 {HUD_FLAG_WIELDITEM_VISIBLE, "wielditem"},
70 {HUD_FLAG_BREATHBAR_VISIBLE, "breathbar"},
79 ObjectRef* ObjectRef::checkobject(lua_State *L, int narg)
81 luaL_checktype(L, narg, LUA_TUSERDATA);
82 void *ud = luaL_checkudata(L, narg, className);
83 if(!ud) luaL_typerror(L, narg, className);
84 return *(ObjectRef**)ud; // unbox pointer
87 ServerActiveObject* ObjectRef::getobject(ObjectRef *ref)
89 ServerActiveObject *co = ref->m_object;
93 LuaEntitySAO* ObjectRef::getluaobject(ObjectRef *ref)
95 ServerActiveObject *obj = getobject(ref);
98 if(obj->getType() != ACTIVEOBJECT_TYPE_LUAENTITY)
100 return (LuaEntitySAO*)obj;
103 PlayerSAO* ObjectRef::getplayersao(ObjectRef *ref)
105 ServerActiveObject *obj = getobject(ref);
108 if(obj->getType() != ACTIVEOBJECT_TYPE_PLAYER)
110 return (PlayerSAO*)obj;
113 Player* ObjectRef::getplayer(ObjectRef *ref)
115 PlayerSAO *playersao = getplayersao(ref);
116 if(playersao == NULL)
118 return playersao->getPlayer();
121 // Exported functions
124 int ObjectRef::gc_object(lua_State *L) {
125 ObjectRef *o = *(ObjectRef **)(lua_touserdata(L, 1));
126 //infostream<<"ObjectRef::gc_object: o="<<o<<std::endl;
132 int ObjectRef::l_remove(lua_State *L)
134 NO_MAP_LOCK_REQUIRED;
135 ObjectRef *ref = checkobject(L, 1);
136 ServerActiveObject *co = getobject(ref);
137 if(co == NULL) return 0;
138 if(co->getType() == ACTIVEOBJECT_TYPE_PLAYER) return 0;
139 verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
140 co->m_removed = true;
145 // returns: {x=num, y=num, z=num}
146 int ObjectRef::l_getpos(lua_State *L)
148 NO_MAP_LOCK_REQUIRED;
149 ObjectRef *ref = checkobject(L, 1);
150 ServerActiveObject *co = getobject(ref);
151 if(co == NULL) return 0;
152 v3f pos = co->getBasePosition() / BS;
154 lua_pushnumber(L, pos.X);
155 lua_setfield(L, -2, "x");
156 lua_pushnumber(L, pos.Y);
157 lua_setfield(L, -2, "y");
158 lua_pushnumber(L, pos.Z);
159 lua_setfield(L, -2, "z");
164 int ObjectRef::l_setpos(lua_State *L)
166 NO_MAP_LOCK_REQUIRED;
167 ObjectRef *ref = checkobject(L, 1);
168 //LuaEntitySAO *co = getluaobject(ref);
169 ServerActiveObject *co = getobject(ref);
170 if(co == NULL) return 0;
172 v3f pos = checkFloatPos(L, 2);
178 // moveto(self, pos, continuous=false)
179 int ObjectRef::l_moveto(lua_State *L)
181 NO_MAP_LOCK_REQUIRED;
182 ObjectRef *ref = checkobject(L, 1);
183 //LuaEntitySAO *co = getluaobject(ref);
184 ServerActiveObject *co = getobject(ref);
185 if(co == NULL) return 0;
187 v3f pos = checkFloatPos(L, 2);
189 bool continuous = lua_toboolean(L, 3);
191 co->moveTo(pos, continuous);
195 // punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
196 int ObjectRef::l_punch(lua_State *L)
198 NO_MAP_LOCK_REQUIRED;
199 ObjectRef *ref = checkobject(L, 1);
200 ObjectRef *puncher_ref = checkobject(L, 2);
201 ServerActiveObject *co = getobject(ref);
202 ServerActiveObject *puncher = getobject(puncher_ref);
203 if(co == NULL) return 0;
204 if(puncher == NULL) return 0;
206 if(lua_type(L, 5) != LUA_TTABLE)
207 dir = co->getBasePosition() - puncher->getBasePosition();
209 dir = read_v3f(L, 5);
210 float time_from_last_punch = 1000000;
211 if(lua_isnumber(L, 3))
212 time_from_last_punch = lua_tonumber(L, 3);
213 ToolCapabilities toolcap = read_tool_capabilities(L, 4);
216 s16 src_original_hp = co->getHP();
217 s16 dst_origin_hp = puncher->getHP();
220 co->punch(dir, &toolcap, puncher, time_from_last_punch);
222 // If the punched is a player, and its HP changed
223 if (src_original_hp != co->getHP() &&
224 co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
225 getServer(L)->SendPlayerHPOrDie(((PlayerSAO*)co)->getPeerID(),
229 // If the puncher is a player, and its HP changed
230 if (dst_origin_hp != puncher->getHP() &&
231 puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
232 getServer(L)->SendPlayerHPOrDie(((PlayerSAO*)puncher)->getPeerID(),
233 puncher->getHP() == 0);
238 // right_click(self, clicker); clicker = an another ObjectRef
239 int ObjectRef::l_right_click(lua_State *L)
241 NO_MAP_LOCK_REQUIRED;
242 ObjectRef *ref = checkobject(L, 1);
243 ObjectRef *ref2 = checkobject(L, 2);
244 ServerActiveObject *co = getobject(ref);
245 ServerActiveObject *co2 = getobject(ref2);
246 if(co == NULL) return 0;
247 if(co2 == NULL) return 0;
254 // hp = number of hitpoints (2 * number of hearts)
256 int ObjectRef::l_set_hp(lua_State *L)
258 NO_MAP_LOCK_REQUIRED;
259 ObjectRef *ref = checkobject(L, 1);
260 luaL_checknumber(L, 2);
261 ServerActiveObject *co = getobject(ref);
262 if(co == NULL) return 0;
263 int hp = lua_tonumber(L, 2);
264 /*infostream<<"ObjectRef::l_set_hp(): id="<<co->getId()
265 <<" hp="<<hp<<std::endl;*/
268 if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
269 getServer(L)->SendPlayerHPOrDie(((PlayerSAO*)co)->getPeerID(), co->getHP() == 0);
276 // returns: number of hitpoints (2 * number of hearts)
277 // 0 if not applicable to this type of object
278 int ObjectRef::l_get_hp(lua_State *L)
280 NO_MAP_LOCK_REQUIRED;
281 ObjectRef *ref = checkobject(L, 1);
282 ServerActiveObject *co = getobject(ref);
285 lua_pushnumber(L, 1);
288 int hp = co->getHP();
289 /*infostream<<"ObjectRef::l_get_hp(): id="<<co->getId()
290 <<" hp="<<hp<<std::endl;*/
292 lua_pushnumber(L, hp);
296 // get_inventory(self)
297 int ObjectRef::l_get_inventory(lua_State *L)
299 NO_MAP_LOCK_REQUIRED;
300 ObjectRef *ref = checkobject(L, 1);
301 ServerActiveObject *co = getobject(ref);
302 if(co == NULL) return 0;
304 InventoryLocation loc = co->getInventoryLocation();
305 if(getServer(L)->getInventory(loc) != NULL)
306 InvRef::create(L, loc);
308 lua_pushnil(L); // An object may have no inventory (nil)
312 // get_wield_list(self)
313 int ObjectRef::l_get_wield_list(lua_State *L)
315 NO_MAP_LOCK_REQUIRED;
316 ObjectRef *ref = checkobject(L, 1);
317 ServerActiveObject *co = getobject(ref);
318 if(co == NULL) return 0;
320 lua_pushstring(L, co->getWieldList().c_str());
324 // get_wield_index(self)
325 int ObjectRef::l_get_wield_index(lua_State *L)
327 NO_MAP_LOCK_REQUIRED;
328 ObjectRef *ref = checkobject(L, 1);
329 ServerActiveObject *co = getobject(ref);
330 if(co == NULL) return 0;
332 lua_pushinteger(L, co->getWieldIndex() + 1);
336 // get_wielded_item(self)
337 int ObjectRef::l_get_wielded_item(lua_State *L)
339 NO_MAP_LOCK_REQUIRED;
340 ObjectRef *ref = checkobject(L, 1);
341 ServerActiveObject *co = getobject(ref);
344 LuaItemStack::create(L, ItemStack());
348 LuaItemStack::create(L, co->getWieldedItem());
352 // set_wielded_item(self, itemstack or itemstring or table or nil)
353 int ObjectRef::l_set_wielded_item(lua_State *L)
355 NO_MAP_LOCK_REQUIRED;
356 ObjectRef *ref = checkobject(L, 1);
357 ServerActiveObject *co = getobject(ref);
358 if(co == NULL) return 0;
360 ItemStack item = read_item(L, 2, getServer(L));
361 bool success = co->setWieldedItem(item);
362 if (success && co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
363 getServer(L)->SendInventory(((PlayerSAO*)co));
365 lua_pushboolean(L, success);
369 // set_armor_groups(self, groups)
370 int ObjectRef::l_set_armor_groups(lua_State *L)
372 NO_MAP_LOCK_REQUIRED;
373 ObjectRef *ref = checkobject(L, 1);
374 ServerActiveObject *co = getobject(ref);
375 if(co == NULL) return 0;
377 ItemGroupList groups;
378 read_groups(L, 2, groups);
379 co->setArmorGroups(groups);
383 // get_armor_groups(self)
384 int ObjectRef::l_get_armor_groups(lua_State *L)
386 NO_MAP_LOCK_REQUIRED;
387 ObjectRef *ref = checkobject(L, 1);
388 ServerActiveObject *co = getobject(ref);
392 ItemGroupList groups = co->getArmorGroups();
393 push_groups(L, groups);
397 // set_physics_override(self, physics_override_speed, physics_override_jump,
398 // physics_override_gravity, sneak, sneak_glitch)
399 int ObjectRef::l_set_physics_override(lua_State *L)
401 ObjectRef *ref = checkobject(L, 1);
402 PlayerSAO *co = (PlayerSAO *) getobject(ref);
403 if(co == NULL) return 0;
405 if (lua_istable(L, 2)) {
406 co->m_physics_override_speed = getfloatfield_default(L, 2, "speed", co->m_physics_override_speed);
407 co->m_physics_override_jump = getfloatfield_default(L, 2, "jump", co->m_physics_override_jump);
408 co->m_physics_override_gravity = getfloatfield_default(L, 2, "gravity", co->m_physics_override_gravity);
409 co->m_physics_override_sneak = getboolfield_default(L, 2, "sneak", co->m_physics_override_sneak);
410 co->m_physics_override_sneak_glitch = getboolfield_default(L, 2, "sneak_glitch", co->m_physics_override_sneak_glitch);
411 co->m_physics_override_sent = false;
413 // old, non-table format
414 if(!lua_isnil(L, 2)){
415 co->m_physics_override_speed = lua_tonumber(L, 2);
416 co->m_physics_override_sent = false;
418 if(!lua_isnil(L, 3)){
419 co->m_physics_override_jump = lua_tonumber(L, 3);
420 co->m_physics_override_sent = false;
422 if(!lua_isnil(L, 4)){
423 co->m_physics_override_gravity = lua_tonumber(L, 4);
424 co->m_physics_override_sent = false;
430 // get_physics_override(self)
431 int ObjectRef::l_get_physics_override(lua_State *L)
433 ObjectRef *ref = checkobject(L, 1);
434 PlayerSAO *co = (PlayerSAO *)getobject(ref);
439 lua_pushnumber(L, co->m_physics_override_speed);
440 lua_setfield(L, -2, "speed");
441 lua_pushnumber(L, co->m_physics_override_jump);
442 lua_setfield(L, -2, "jump");
443 lua_pushnumber(L, co->m_physics_override_gravity);
444 lua_setfield(L, -2, "gravity");
445 lua_pushboolean(L, co->m_physics_override_sneak);
446 lua_setfield(L, -2, "sneak");
447 lua_pushboolean(L, co->m_physics_override_sneak_glitch);
448 lua_setfield(L, -2, "sneak_glitch");
452 // set_animation(self, frame_range, frame_speed, frame_blend, frame_loop)
453 int ObjectRef::l_set_animation(lua_State *L)
455 NO_MAP_LOCK_REQUIRED;
456 ObjectRef *ref = checkobject(L, 1);
457 ServerActiveObject *co = getobject(ref);
458 if(co == NULL) return 0;
460 v2f frames = v2f(1, 1);
462 frames = read_v2f(L, 2);
463 float frame_speed = 15;
465 frame_speed = lua_tonumber(L, 3);
466 float frame_blend = 0;
468 frame_blend = lua_tonumber(L, 4);
469 bool frame_loop = true;
470 if(lua_isboolean(L, 5))
471 frame_loop = lua_toboolean(L, 5);
472 co->setAnimation(frames, frame_speed, frame_blend, frame_loop);
476 // get_animation(self)
477 int ObjectRef::l_get_animation(lua_State *L)
479 NO_MAP_LOCK_REQUIRED;
480 ObjectRef *ref = checkobject(L, 1);
481 ServerActiveObject *co = getobject(ref);
485 v2f frames = v2f(1,1);
486 float frame_speed = 15;
487 float frame_blend = 0;
488 bool frame_loop = true;
489 co->getAnimation(&frames, &frame_speed, &frame_blend, &frame_loop);
492 lua_pushnumber(L, frame_speed);
493 lua_pushnumber(L, frame_blend);
494 lua_pushboolean(L, frame_loop);
498 // set_local_animation(self, {stand/idle}, {walk}, {dig}, {walk+dig}, frame_speed)
499 int ObjectRef::l_set_local_animation(lua_State *L)
501 //NO_MAP_LOCK_REQUIRED;
502 ObjectRef *ref = checkobject(L, 1);
503 Player *player = getplayer(ref);
508 for (int i=0;i<4;i++) {
509 if(!lua_isnil(L, 2+1))
510 frames[i] = read_v2s32(L, 2+i);
512 float frame_speed = 30;
514 frame_speed = lua_tonumber(L, 6);
516 if (!getServer(L)->setLocalPlayerAnimations(player, frames, frame_speed))
519 lua_pushboolean(L, true);
523 // get_local_animation(self)
524 int ObjectRef::l_get_local_animation(lua_State *L)
526 //NO_MAP_LOCK_REQUIRED
527 ObjectRef *ref = checkobject(L, 1);
528 Player *player = getplayer(ref);
534 player->getLocalAnimations(frames, &frame_speed);
536 for (int i = 0; i < 4; i++) {
537 push_v2s32(L, frames[i]);
540 lua_pushnumber(L, frame_speed);
544 // set_eye_offset(self, v3f first pv, v3f third pv)
545 int ObjectRef::l_set_eye_offset(lua_State *L)
547 //NO_MAP_LOCK_REQUIRED;
548 ObjectRef *ref = checkobject(L, 1);
549 Player *player = getplayer(ref);
553 v3f offset_first = v3f(0, 0, 0);
554 v3f offset_third = v3f(0, 0, 0);
557 offset_first = read_v3f(L, 2);
559 offset_third = read_v3f(L, 3);
561 // Prevent abuse of offset values (keep player always visible)
562 offset_third.X = rangelim(offset_third.X,-10,10);
563 offset_third.Z = rangelim(offset_third.Z,-5,5);
564 /* TODO: if possible: improve the camera colision detetion to allow Y <= -1.5) */
565 offset_third.Y = rangelim(offset_third.Y,-10,15); //1.5*BS
567 if (!getServer(L)->setPlayerEyeOffset(player, offset_first, offset_third))
570 lua_pushboolean(L, true);
574 // get_eye_offset(self)
575 int ObjectRef::l_get_eye_offset(lua_State *L)
577 //NO_MAP_LOCK_REQUIRED;
578 ObjectRef *ref = checkobject(L, 1);
579 Player *player = getplayer(ref);
583 push_v3f(L, player->eye_offset_first);
584 push_v3f(L, player->eye_offset_third);
588 // set_bone_position(self, std::string bone, v3f position, v3f rotation)
589 int ObjectRef::l_set_bone_position(lua_State *L)
591 NO_MAP_LOCK_REQUIRED;
592 ObjectRef *ref = checkobject(L, 1);
593 ServerActiveObject *co = getobject(ref);
594 if(co == NULL) return 0;
596 std::string bone = "";
598 bone = lua_tostring(L, 2);
599 v3f position = v3f(0, 0, 0);
601 position = read_v3f(L, 3);
602 v3f rotation = v3f(0, 0, 0);
604 rotation = read_v3f(L, 4);
605 co->setBonePosition(bone, position, rotation);
609 // get_bone_position(self, bone)
610 int ObjectRef::l_get_bone_position(lua_State *L)
612 NO_MAP_LOCK_REQUIRED;
613 ObjectRef *ref = checkobject(L, 1);
614 ServerActiveObject *co = getobject(ref);
618 std::string bone = "";
620 bone = lua_tostring(L, 2);
622 v3f position = v3f(0, 0, 0);
623 v3f rotation = v3f(0, 0, 0);
624 co->getBonePosition(bone, &position, &rotation);
626 push_v3f(L, position);
627 push_v3f(L, rotation);
631 // set_attach(self, parent, bone, position, rotation)
632 int ObjectRef::l_set_attach(lua_State *L)
634 NO_MAP_LOCK_REQUIRED;
635 ObjectRef *ref = checkobject(L, 1);
636 ObjectRef *parent_ref = checkobject(L, 2);
637 ServerActiveObject *co = getobject(ref);
638 ServerActiveObject *parent = getobject(parent_ref);
639 if(co == NULL) return 0;
640 if(parent == NULL) return 0;
642 std::string bone = "";
644 bone = lua_tostring(L, 3);
645 v3f position = v3f(0, 0, 0);
647 position = read_v3f(L, 4);
648 v3f rotation = v3f(0, 0, 0);
650 rotation = read_v3f(L, 5);
651 co->setAttachment(parent->getId(), bone, position, rotation);
656 int ObjectRef::l_get_attach(lua_State *L)
658 NO_MAP_LOCK_REQUIRED;
661 ObjectRef *ref = checkobject(L, 1);
662 ServerActiveObject *co = getobject(ref);
668 std::string bone = "";
669 v3f position = v3f(0, 0, 0);
670 v3f rotation = v3f(0, 0, 0);
671 co->getAttachment(&parent_id, &bone, &position, &rotation);
674 ServerActiveObject *parent = env->getActiveObject(parent_id);
676 getScriptApiBase(L)->objectrefGetOrCreate(L, parent);
677 lua_pushlstring(L, bone.c_str(), bone.size());
678 push_v3f(L, position);
679 push_v3f(L, rotation);
684 int ObjectRef::l_set_detach(lua_State *L)
686 NO_MAP_LOCK_REQUIRED;
687 ObjectRef *ref = checkobject(L, 1);
688 ServerActiveObject *co = getobject(ref);
689 if(co == NULL) return 0;
691 co->setAttachment(0, "", v3f(0,0,0), v3f(0,0,0));
695 // set_properties(self, properties)
696 int ObjectRef::l_set_properties(lua_State *L)
698 NO_MAP_LOCK_REQUIRED;
699 ObjectRef *ref = checkobject(L, 1);
700 ServerActiveObject *co = getobject(ref);
701 if(co == NULL) return 0;
702 ObjectProperties *prop = co->accessObjectProperties();
705 read_object_properties(L, 2, prop);
706 co->notifyObjectPropertiesModified();
710 // get_properties(self)
711 int ObjectRef::l_get_properties(lua_State *L)
713 NO_MAP_LOCK_REQUIRED;
714 ObjectRef *ref = checkobject(L, 1);
715 ServerActiveObject *co = getobject(ref);
718 ObjectProperties *prop = co->accessObjectProperties();
721 push_object_properties(L, prop);
726 int ObjectRef::l_is_player(lua_State *L)
728 NO_MAP_LOCK_REQUIRED;
729 ObjectRef *ref = checkobject(L, 1);
730 Player *player = getplayer(ref);
731 lua_pushboolean(L, (player != NULL));
735 /* LuaEntitySAO-only */
737 // setvelocity(self, {x=num, y=num, z=num})
738 int ObjectRef::l_setvelocity(lua_State *L)
740 NO_MAP_LOCK_REQUIRED;
741 ObjectRef *ref = checkobject(L, 1);
742 LuaEntitySAO *co = getluaobject(ref);
743 if(co == NULL) return 0;
744 v3f pos = checkFloatPos(L, 2);
746 co->setVelocity(pos);
751 int ObjectRef::l_getvelocity(lua_State *L)
753 NO_MAP_LOCK_REQUIRED;
754 ObjectRef *ref = checkobject(L, 1);
755 LuaEntitySAO *co = getluaobject(ref);
756 if(co == NULL) return 0;
758 v3f v = co->getVelocity();
763 // setacceleration(self, {x=num, y=num, z=num})
764 int ObjectRef::l_setacceleration(lua_State *L)
766 NO_MAP_LOCK_REQUIRED;
767 ObjectRef *ref = checkobject(L, 1);
768 LuaEntitySAO *co = getluaobject(ref);
769 if(co == NULL) return 0;
771 v3f pos = checkFloatPos(L, 2);
773 co->setAcceleration(pos);
777 // getacceleration(self)
778 int ObjectRef::l_getacceleration(lua_State *L)
780 NO_MAP_LOCK_REQUIRED;
781 ObjectRef *ref = checkobject(L, 1);
782 LuaEntitySAO *co = getluaobject(ref);
783 if(co == NULL) return 0;
785 v3f v = co->getAcceleration();
790 // setyaw(self, radians)
791 int ObjectRef::l_setyaw(lua_State *L)
793 NO_MAP_LOCK_REQUIRED;
794 ObjectRef *ref = checkobject(L, 1);
795 LuaEntitySAO *co = getluaobject(ref);
796 if(co == NULL) return 0;
797 float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
804 int ObjectRef::l_getyaw(lua_State *L)
806 NO_MAP_LOCK_REQUIRED;
807 ObjectRef *ref = checkobject(L, 1);
808 LuaEntitySAO *co = getluaobject(ref);
809 if(co == NULL) return 0;
811 float yaw = co->getYaw() * core::DEGTORAD;
812 lua_pushnumber(L, yaw);
816 // settexturemod(self, mod)
817 int ObjectRef::l_settexturemod(lua_State *L)
819 NO_MAP_LOCK_REQUIRED;
820 ObjectRef *ref = checkobject(L, 1);
821 LuaEntitySAO *co = getluaobject(ref);
822 if(co == NULL) return 0;
824 std::string mod = luaL_checkstring(L, 2);
825 co->setTextureMod(mod);
829 // setsprite(self, p={x=0,y=0}, num_frames=1, framelength=0.2,
830 // select_horiz_by_yawpitch=false)
831 int ObjectRef::l_setsprite(lua_State *L)
833 NO_MAP_LOCK_REQUIRED;
834 ObjectRef *ref = checkobject(L, 1);
835 LuaEntitySAO *co = getluaobject(ref);
836 if(co == NULL) return 0;
840 p = read_v2s16(L, 2);
843 num_frames = lua_tonumber(L, 3);
844 float framelength = 0.2;
846 framelength = lua_tonumber(L, 4);
847 bool select_horiz_by_yawpitch = false;
849 select_horiz_by_yawpitch = lua_toboolean(L, 5);
850 co->setSprite(p, num_frames, framelength, select_horiz_by_yawpitch);
855 // get_entity_name(self)
856 int ObjectRef::l_get_entity_name(lua_State *L)
858 NO_MAP_LOCK_REQUIRED;
859 ObjectRef *ref = checkobject(L, 1);
860 LuaEntitySAO *co = getluaobject(ref);
861 log_deprecated(L,"Deprecated call to \"get_entity_name");
862 if(co == NULL) return 0;
864 std::string name = co->getName();
865 lua_pushstring(L, name.c_str());
869 // get_luaentity(self)
870 int ObjectRef::l_get_luaentity(lua_State *L)
872 NO_MAP_LOCK_REQUIRED;
873 ObjectRef *ref = checkobject(L, 1);
874 LuaEntitySAO *co = getluaobject(ref);
875 if(co == NULL) return 0;
877 luaentity_get(L, co->getId());
883 // is_player_connected(self)
884 int ObjectRef::l_is_player_connected(lua_State *L)
886 NO_MAP_LOCK_REQUIRED;
887 ObjectRef *ref = checkobject(L, 1);
888 Player *player = getplayer(ref);
889 lua_pushboolean(L, (player != NULL && player->peer_id != 0));
893 // get_player_name(self)
894 int ObjectRef::l_get_player_name(lua_State *L)
896 NO_MAP_LOCK_REQUIRED;
897 ObjectRef *ref = checkobject(L, 1);
898 Player *player = getplayer(ref);
900 lua_pushlstring(L, "", 0);
904 lua_pushstring(L, player->getName());
908 // get_look_dir(self)
909 int ObjectRef::l_get_look_dir(lua_State *L)
911 NO_MAP_LOCK_REQUIRED;
912 ObjectRef *ref = checkobject(L, 1);
913 Player *player = getplayer(ref);
914 if(player == NULL) return 0;
916 float pitch = player->getRadPitch();
917 float yaw = player->getRadYaw();
918 v3f v(cos(pitch)*cos(yaw), sin(pitch), cos(pitch)*sin(yaw));
923 // get_look_pitch(self)
924 int ObjectRef::l_get_look_pitch(lua_State *L)
926 NO_MAP_LOCK_REQUIRED;
927 ObjectRef *ref = checkobject(L, 1);
928 Player *player = getplayer(ref);
929 if(player == NULL) return 0;
931 lua_pushnumber(L, player->getRadPitch());
935 // get_look_yaw(self)
936 int ObjectRef::l_get_look_yaw(lua_State *L)
938 NO_MAP_LOCK_REQUIRED;
939 ObjectRef *ref = checkobject(L, 1);
940 Player *player = getplayer(ref);
941 if(player == NULL) return 0;
943 lua_pushnumber(L, player->getRadYaw());
947 // set_look_pitch(self, radians)
948 int ObjectRef::l_set_look_pitch(lua_State *L)
950 NO_MAP_LOCK_REQUIRED;
951 ObjectRef *ref = checkobject(L, 1);
952 PlayerSAO* co = getplayersao(ref);
953 if(co == NULL) return 0;
954 float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
960 // set_look_yaw(self, radians)
961 int ObjectRef::l_set_look_yaw(lua_State *L)
963 NO_MAP_LOCK_REQUIRED;
964 ObjectRef *ref = checkobject(L, 1);
965 PlayerSAO* co = getplayersao(ref);
966 if(co == NULL) return 0;
967 float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
973 // set_breath(self, breath)
974 int ObjectRef::l_set_breath(lua_State *L)
976 NO_MAP_LOCK_REQUIRED;
977 ObjectRef *ref = checkobject(L, 1);
978 PlayerSAO* co = getplayersao(ref);
979 if(co == NULL) return 0;
980 u16 breath = luaL_checknumber(L, 2);
982 co->setBreath(breath);
984 // If the object is a player sent the breath to client
985 if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
986 getServer(L)->SendPlayerBreath(((PlayerSAO*)co)->getPeerID());
992 int ObjectRef::l_get_breath(lua_State *L)
994 NO_MAP_LOCK_REQUIRED;
995 ObjectRef *ref = checkobject(L, 1);
996 PlayerSAO* co = getplayersao(ref);
997 if(co == NULL) return 0;
999 u16 breath = co->getBreath();
1000 lua_pushinteger (L, breath);
1004 // set_inventory_formspec(self, formspec)
1005 int ObjectRef::l_set_inventory_formspec(lua_State *L)
1007 NO_MAP_LOCK_REQUIRED;
1008 ObjectRef *ref = checkobject(L, 1);
1009 Player *player = getplayer(ref);
1010 if(player == NULL) return 0;
1011 std::string formspec = luaL_checkstring(L, 2);
1013 player->inventory_formspec = formspec;
1014 getServer(L)->reportInventoryFormspecModified(player->getName());
1015 lua_pushboolean(L, true);
1019 // get_inventory_formspec(self) -> formspec
1020 int ObjectRef::l_get_inventory_formspec(lua_State *L)
1022 NO_MAP_LOCK_REQUIRED;
1023 ObjectRef *ref = checkobject(L, 1);
1024 Player *player = getplayer(ref);
1025 if(player == NULL) return 0;
1027 std::string formspec = player->inventory_formspec;
1028 lua_pushlstring(L, formspec.c_str(), formspec.size());
1032 // get_player_control(self)
1033 int ObjectRef::l_get_player_control(lua_State *L)
1035 NO_MAP_LOCK_REQUIRED;
1036 ObjectRef *ref = checkobject(L, 1);
1037 Player *player = getplayer(ref);
1039 lua_pushlstring(L, "", 0);
1043 PlayerControl control = player->getPlayerControl();
1045 lua_pushboolean(L, control.up);
1046 lua_setfield(L, -2, "up");
1047 lua_pushboolean(L, control.down);
1048 lua_setfield(L, -2, "down");
1049 lua_pushboolean(L, control.left);
1050 lua_setfield(L, -2, "left");
1051 lua_pushboolean(L, control.right);
1052 lua_setfield(L, -2, "right");
1053 lua_pushboolean(L, control.jump);
1054 lua_setfield(L, -2, "jump");
1055 lua_pushboolean(L, control.aux1);
1056 lua_setfield(L, -2, "aux1");
1057 lua_pushboolean(L, control.sneak);
1058 lua_setfield(L, -2, "sneak");
1059 lua_pushboolean(L, control.LMB);
1060 lua_setfield(L, -2, "LMB");
1061 lua_pushboolean(L, control.RMB);
1062 lua_setfield(L, -2, "RMB");
1066 // get_player_control_bits(self)
1067 int ObjectRef::l_get_player_control_bits(lua_State *L)
1069 NO_MAP_LOCK_REQUIRED;
1070 ObjectRef *ref = checkobject(L, 1);
1071 Player *player = getplayer(ref);
1073 lua_pushlstring(L, "", 0);
1077 lua_pushnumber(L, player->keyPressed);
1081 // hud_add(self, form)
1082 int ObjectRef::l_hud_add(lua_State *L)
1084 ObjectRef *ref = checkobject(L, 1);
1085 Player *player = getplayer(ref);
1089 HudElement *elem = new HudElement;
1091 elem->type = (HudElementType)getenumfield(L, 2, "hud_elem_type",
1092 es_HudElementType, HUD_ELEM_TEXT);
1094 lua_getfield(L, 2, "position");
1095 elem->pos = lua_istable(L, -1) ? read_v2f(L, -1) : v2f();
1098 lua_getfield(L, 2, "scale");
1099 elem->scale = lua_istable(L, -1) ? read_v2f(L, -1) : v2f();
1102 lua_getfield(L, 2, "size");
1103 elem->size = lua_istable(L, -1) ? read_v2s32(L, -1) : v2s32();
1106 elem->name = getstringfield_default(L, 2, "name", "");
1107 elem->text = getstringfield_default(L, 2, "text", "");
1108 elem->number = getintfield_default(L, 2, "number", 0);
1109 elem->item = getintfield_default(L, 2, "item", 0);
1110 elem->dir = getintfield_default(L, 2, "direction", 0);
1112 // Deprecated, only for compatibility's sake
1114 elem->dir = getintfield_default(L, 2, "dir", 0);
1116 lua_getfield(L, 2, "alignment");
1117 elem->align = lua_istable(L, -1) ? read_v2f(L, -1) : v2f();
1120 lua_getfield(L, 2, "offset");
1121 elem->offset = lua_istable(L, -1) ? read_v2f(L, -1) : v2f();
1124 lua_getfield(L, 2, "world_pos");
1125 elem->world_pos = lua_istable(L, -1) ? read_v3f(L, -1) : v3f();
1128 /* check for known deprecated element usage */
1129 if ((elem->type == HUD_ELEM_STATBAR) && (elem->size == v2s32())) {
1130 log_deprecated(L,"Deprecated usage of statbar without size!");
1133 u32 id = getServer(L)->hudAdd(player, elem);
1134 if (id == (u32)-1) {
1139 lua_pushnumber(L, id);
1143 // hud_remove(self, id)
1144 int ObjectRef::l_hud_remove(lua_State *L)
1146 ObjectRef *ref = checkobject(L, 1);
1147 Player *player = getplayer(ref);
1152 if (!lua_isnil(L, 2))
1153 id = lua_tonumber(L, 2);
1155 if (!getServer(L)->hudRemove(player, id))
1158 lua_pushboolean(L, true);
1162 // hud_change(self, id, stat, data)
1163 int ObjectRef::l_hud_change(lua_State *L)
1165 ObjectRef *ref = checkobject(L, 1);
1166 Player *player = getplayer(ref);
1170 u32 id = lua_isnumber(L, 2) ? lua_tonumber(L, 2) : -1;
1172 HudElement *e = player->getHud(id);
1176 HudElementStat stat = HUD_STAT_NUMBER;
1177 if (lua_isstring(L, 3)) {
1179 std::string statstr = lua_tostring(L, 3);
1180 stat = string_to_enum(es_HudElementStat, statint, statstr) ?
1181 (HudElementStat)statint : HUD_STAT_NUMBER;
1187 e->pos = read_v2f(L, 4);
1191 e->name = luaL_checkstring(L, 4);
1194 case HUD_STAT_SCALE:
1195 e->scale = read_v2f(L, 4);
1199 e->text = luaL_checkstring(L, 4);
1202 case HUD_STAT_NUMBER:
1203 e->number = luaL_checknumber(L, 4);
1207 e->item = luaL_checknumber(L, 4);
1211 e->dir = luaL_checknumber(L, 4);
1214 case HUD_STAT_ALIGN:
1215 e->align = read_v2f(L, 4);
1218 case HUD_STAT_OFFSET:
1219 e->offset = read_v2f(L, 4);
1222 case HUD_STAT_WORLD_POS:
1223 e->world_pos = read_v3f(L, 4);
1224 value = &e->world_pos;
1227 e->size = read_v2s32(L, 4);
1232 getServer(L)->hudChange(player, id, stat, value);
1234 lua_pushboolean(L, true);
1238 // hud_get(self, id)
1239 int ObjectRef::l_hud_get(lua_State *L)
1241 ObjectRef *ref = checkobject(L, 1);
1242 Player *player = getplayer(ref);
1246 u32 id = lua_tonumber(L, -1);
1248 HudElement *e = player->getHud(id);
1254 lua_pushstring(L, es_HudElementType[(u8)e->type].str);
1255 lua_setfield(L, -2, "type");
1257 push_v2f(L, e->pos);
1258 lua_setfield(L, -2, "position");
1260 lua_pushstring(L, e->name.c_str());
1261 lua_setfield(L, -2, "name");
1263 push_v2f(L, e->scale);
1264 lua_setfield(L, -2, "scale");
1266 lua_pushstring(L, e->text.c_str());
1267 lua_setfield(L, -2, "text");
1269 lua_pushnumber(L, e->number);
1270 lua_setfield(L, -2, "number");
1272 lua_pushnumber(L, e->item);
1273 lua_setfield(L, -2, "item");
1275 lua_pushnumber(L, e->dir);
1276 lua_setfield(L, -2, "direction");
1278 // Deprecated, only for compatibility's sake
1279 lua_pushnumber(L, e->dir);
1280 lua_setfield(L, -2, "dir");
1282 push_v3f(L, e->world_pos);
1283 lua_setfield(L, -2, "world_pos");
1288 // hud_set_flags(self, flags)
1289 int ObjectRef::l_hud_set_flags(lua_State *L)
1291 ObjectRef *ref = checkobject(L, 1);
1292 Player *player = getplayer(ref);
1300 const EnumString *esp = es_HudBuiltinElement;
1301 for (int i = 0; esp[i].str; i++) {
1302 if (getboolfield(L, 2, esp[i].str, flag)) {
1303 flags |= esp[i].num * flag;
1307 if (!getServer(L)->hudSetFlags(player, flags, mask))
1310 lua_pushboolean(L, true);
1314 int ObjectRef::l_hud_get_flags(lua_State *L)
1316 ObjectRef *ref = checkobject(L, 1);
1317 Player *player = getplayer(ref);
1322 lua_pushboolean(L, player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE);
1323 lua_setfield(L, -2, "hotbar");
1324 lua_pushboolean(L, player->hud_flags & HUD_FLAG_HEALTHBAR_VISIBLE);
1325 lua_setfield(L, -2, "healthbar");
1326 lua_pushboolean(L, player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE);
1327 lua_setfield(L, -2, "crosshair");
1328 lua_pushboolean(L, player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE);
1329 lua_setfield(L, -2, "wielditem");
1330 lua_pushboolean(L, player->hud_flags & HUD_FLAG_BREATHBAR_VISIBLE);
1331 lua_setfield(L, -2, "breathbar");
1336 // hud_set_hotbar_itemcount(self, hotbar_itemcount)
1337 int ObjectRef::l_hud_set_hotbar_itemcount(lua_State *L)
1339 ObjectRef *ref = checkobject(L, 1);
1340 Player *player = getplayer(ref);
1344 s32 hotbar_itemcount = lua_tonumber(L, 2);
1346 if (!getServer(L)->hudSetHotbarItemcount(player, hotbar_itemcount))
1349 lua_pushboolean(L, true);
1353 // hud_get_hotbar_itemcount(self)
1354 int ObjectRef::l_hud_get_hotbar_itemcount(lua_State *L)
1356 ObjectRef *ref = checkobject(L, 1);
1357 Player *player = getplayer(ref);
1361 s32 hotbar_itemcount = getServer(L)->hudGetHotbarItemcount(player);
1363 lua_pushnumber(L, hotbar_itemcount);
1367 // hud_set_hotbar_image(self, name)
1368 int ObjectRef::l_hud_set_hotbar_image(lua_State *L)
1370 ObjectRef *ref = checkobject(L, 1);
1371 Player *player = getplayer(ref);
1375 std::string name = lua_tostring(L, 2);
1377 getServer(L)->hudSetHotbarImage(player, name);
1381 // hud_get_hotbar_image(self)
1382 int ObjectRef::l_hud_get_hotbar_image(lua_State *L)
1384 ObjectRef *ref = checkobject(L, 1);
1385 Player *player = getplayer(ref);
1389 std::string name = getServer(L)->hudGetHotbarImage(player);
1390 lua_pushlstring(L, name.c_str(), name.size());
1394 // hud_set_hotbar_selected_image(self, name)
1395 int ObjectRef::l_hud_set_hotbar_selected_image(lua_State *L)
1397 ObjectRef *ref = checkobject(L, 1);
1398 Player *player = getplayer(ref);
1402 std::string name = lua_tostring(L, 2);
1404 getServer(L)->hudSetHotbarSelectedImage(player, name);
1408 // hud_get_hotbar_selected_image(self)
1409 int ObjectRef::l_hud_get_hotbar_selected_image(lua_State *L)
1411 ObjectRef *ref = checkobject(L, 1);
1412 Player *player = getplayer(ref);
1416 std::string name = getServer(L)->hudGetHotbarSelectedImage(player);
1417 lua_pushlstring(L, name.c_str(), name.size());
1421 // set_sky(self, bgcolor, type, list)
1422 int ObjectRef::l_set_sky(lua_State *L)
1424 ObjectRef *ref = checkobject(L, 1);
1425 Player *player = getplayer(ref);
1429 video::SColor bgcolor(255,255,255,255);
1430 read_color(L, 2, &bgcolor);
1432 std::string type = luaL_checkstring(L, 3);
1434 std::vector<std::string> params;
1435 if (lua_istable(L, 4)) {
1436 int table = lua_gettop(L);
1438 while (lua_next(L, table) != 0) {
1439 // key at index -2 and value at index -1
1440 if (lua_isstring(L, -1))
1441 params.push_back(lua_tostring(L, -1));
1443 params.push_back("");
1444 // removes value, keeps key for next iteration
1449 if (type == "skybox" && params.size() != 6)
1450 throw LuaError("skybox expects 6 textures");
1452 if (!getServer(L)->setSky(player, bgcolor, type, params))
1455 lua_pushboolean(L, true);
1460 int ObjectRef::l_get_sky(lua_State *L)
1462 ObjectRef *ref = checkobject(L, 1);
1463 Player *player = getplayer(ref);
1466 video::SColor bgcolor(255, 255, 255, 255);
1468 std::vector<std::string> params;
1470 player->getSky(&bgcolor, &type, ¶ms);
1471 type = type == "" ? "regular" : type;
1473 push_ARGB8(L, bgcolor);
1474 lua_pushlstring(L, type.c_str(), type.size());
1477 for (std::vector<std::string>::iterator it = params.begin();
1478 it != params.end(); ++it) {
1479 lua_pushlstring(L, it->c_str(), it->size());
1480 lua_rawseti(L, -2, i);
1486 // override_day_night_ratio(self, brightness=0...1)
1487 int ObjectRef::l_override_day_night_ratio(lua_State *L)
1489 ObjectRef *ref = checkobject(L, 1);
1490 Player *player = getplayer(ref);
1494 bool do_override = false;
1496 if (!lua_isnil(L, 2)){
1498 ratio = luaL_checknumber(L, 2);
1501 if (!getServer(L)->overrideDayNightRatio(player, do_override, ratio))
1504 lua_pushboolean(L, true);
1508 // get_day_night_ratio(self)
1509 int ObjectRef::l_get_day_night_ratio(lua_State *L)
1511 ObjectRef *ref = checkobject(L, 1);
1512 Player *player = getplayer(ref);
1518 player->getDayNightRatio(&do_override, &ratio);
1521 lua_pushnumber(L, ratio);
1528 // set_nametag_attributes(self, attributes)
1529 int ObjectRef::l_set_nametag_attributes(lua_State *L)
1531 NO_MAP_LOCK_REQUIRED;
1532 ObjectRef *ref = checkobject(L, 1);
1533 PlayerSAO *playersao = getplayersao(ref);
1534 if (playersao == NULL)
1537 lua_getfield(L, 2, "color");
1538 if (!lua_isnil(L, -1)) {
1539 video::SColor color = playersao->getNametagColor();
1540 if (!read_color(L, -1, &color))
1542 playersao->setNametagColor(color);
1545 lua_pushboolean(L, true);
1549 // get_nametag_attributes(self)
1550 int ObjectRef::l_get_nametag_attributes(lua_State *L)
1552 NO_MAP_LOCK_REQUIRED;
1553 ObjectRef *ref = checkobject(L, 1);
1554 PlayerSAO *playersao = getplayersao(ref);
1555 if (playersao == NULL)
1558 video::SColor color = playersao->getNametagColor();
1561 push_ARGB8(L, color);
1562 lua_setfield(L, -2, "color");
1567 ObjectRef::ObjectRef(ServerActiveObject *object):
1570 //infostream<<"ObjectRef created for id="<<m_object->getId()<<std::endl;
1573 ObjectRef::~ObjectRef()
1576 infostream<<"ObjectRef destructing for id="
1577 <<m_object->getId()<<std::endl;
1579 infostream<<"ObjectRef destructing for id=unknown"<<std::endl;*/
1582 // Creates an ObjectRef and leaves it on top of stack
1583 // Not callable from Lua; all references are created on the C side.
1584 void ObjectRef::create(lua_State *L, ServerActiveObject *object)
1586 ObjectRef *o = new ObjectRef(object);
1587 //infostream<<"ObjectRef::create: o="<<o<<std::endl;
1588 *(void **)(lua_newuserdata(L, sizeof(void *))) = o;
1589 luaL_getmetatable(L, className);
1590 lua_setmetatable(L, -2);
1593 void ObjectRef::set_null(lua_State *L)
1595 ObjectRef *o = checkobject(L, -1);
1599 void ObjectRef::Register(lua_State *L)
1602 int methodtable = lua_gettop(L);
1603 luaL_newmetatable(L, className);
1604 int metatable = lua_gettop(L);
1606 lua_pushliteral(L, "__metatable");
1607 lua_pushvalue(L, methodtable);
1608 lua_settable(L, metatable); // hide metatable from Lua getmetatable()
1610 lua_pushliteral(L, "__index");
1611 lua_pushvalue(L, methodtable);
1612 lua_settable(L, metatable);
1614 lua_pushliteral(L, "__gc");
1615 lua_pushcfunction(L, gc_object);
1616 lua_settable(L, metatable);
1618 lua_pop(L, 1); // drop metatable
1620 luaL_openlib(L, 0, methods, 0); // fill methodtable
1621 lua_pop(L, 1); // drop methodtable
1623 // Cannot be created from Lua
1624 //lua_register(L, className, create_object);
1627 const char ObjectRef::className[] = "ObjectRef";
1628 const luaL_reg ObjectRef::methods[] = {
1629 // ServerActiveObject
1630 luamethod(ObjectRef, remove),
1631 luamethod(ObjectRef, getpos),
1632 luamethod(ObjectRef, setpos),
1633 luamethod(ObjectRef, moveto),
1634 luamethod(ObjectRef, punch),
1635 luamethod(ObjectRef, right_click),
1636 luamethod(ObjectRef, set_hp),
1637 luamethod(ObjectRef, get_hp),
1638 luamethod(ObjectRef, get_inventory),
1639 luamethod(ObjectRef, get_wield_list),
1640 luamethod(ObjectRef, get_wield_index),
1641 luamethod(ObjectRef, get_wielded_item),
1642 luamethod(ObjectRef, set_wielded_item),
1643 luamethod(ObjectRef, set_armor_groups),
1644 luamethod(ObjectRef, get_armor_groups),
1645 luamethod(ObjectRef, set_animation),
1646 luamethod(ObjectRef, get_animation),
1647 luamethod(ObjectRef, set_bone_position),
1648 luamethod(ObjectRef, get_bone_position),
1649 luamethod(ObjectRef, set_attach),
1650 luamethod(ObjectRef, get_attach),
1651 luamethod(ObjectRef, set_detach),
1652 luamethod(ObjectRef, set_properties),
1653 luamethod(ObjectRef, get_properties),
1654 // LuaEntitySAO-only
1655 luamethod(ObjectRef, setvelocity),
1656 luamethod(ObjectRef, getvelocity),
1657 luamethod(ObjectRef, setacceleration),
1658 luamethod(ObjectRef, getacceleration),
1659 luamethod(ObjectRef, setyaw),
1660 luamethod(ObjectRef, getyaw),
1661 luamethod(ObjectRef, settexturemod),
1662 luamethod(ObjectRef, setsprite),
1663 luamethod(ObjectRef, get_entity_name),
1664 luamethod(ObjectRef, get_luaentity),
1666 luamethod(ObjectRef, is_player),
1667 luamethod(ObjectRef, is_player_connected),
1668 luamethod(ObjectRef, get_player_name),
1669 luamethod(ObjectRef, get_look_dir),
1670 luamethod(ObjectRef, get_look_pitch),
1671 luamethod(ObjectRef, get_look_yaw),
1672 luamethod(ObjectRef, set_look_yaw),
1673 luamethod(ObjectRef, set_look_pitch),
1674 luamethod(ObjectRef, get_breath),
1675 luamethod(ObjectRef, set_breath),
1676 luamethod(ObjectRef, set_inventory_formspec),
1677 luamethod(ObjectRef, get_inventory_formspec),
1678 luamethod(ObjectRef, get_player_control),
1679 luamethod(ObjectRef, get_player_control_bits),
1680 luamethod(ObjectRef, set_physics_override),
1681 luamethod(ObjectRef, get_physics_override),
1682 luamethod(ObjectRef, hud_add),
1683 luamethod(ObjectRef, hud_remove),
1684 luamethod(ObjectRef, hud_change),
1685 luamethod(ObjectRef, hud_get),
1686 luamethod(ObjectRef, hud_set_flags),
1687 luamethod(ObjectRef, hud_get_flags),
1688 luamethod(ObjectRef, hud_set_hotbar_itemcount),
1689 luamethod(ObjectRef, hud_get_hotbar_itemcount),
1690 luamethod(ObjectRef, hud_set_hotbar_image),
1691 luamethod(ObjectRef, hud_get_hotbar_image),
1692 luamethod(ObjectRef, hud_set_hotbar_selected_image),
1693 luamethod(ObjectRef, hud_get_hotbar_selected_image),
1694 luamethod(ObjectRef, set_sky),
1695 luamethod(ObjectRef, get_sky),
1696 luamethod(ObjectRef, override_day_night_ratio),
1697 luamethod(ObjectRef, get_day_night_ratio),
1698 luamethod(ObjectRef, set_local_animation),
1699 luamethod(ObjectRef, get_local_animation),
1700 luamethod(ObjectRef, set_eye_offset),
1701 luamethod(ObjectRef, get_eye_offset),
1702 luamethod(ObjectRef, set_nametag_attributes),
1703 luamethod(ObjectRef, get_nametag_attributes),