int ObjectRef::l_get_clouds(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); if (!player) return 0; const CloudParams &cloud_params = player->getCloudParams(); lua_newtable(L); lua_pushnumber(L, cloud_params.density); lua_setfield(L, -2, "density"); push_ARGB8(L, cloud_params.color_bright); lua_setfield(L, -2, "color"); push_ARGB8(L, cloud_params.color_ambient); lua_setfield(L, -2, "ambient"); lua_pushnumber(L, cloud_params.height); lua_setfield(L, -2, "height"); lua_pushnumber(L, cloud_params.thickness); lua_setfield(L, -2, "thickness"); lua_newtable(L); lua_pushnumber(L, cloud_params.speed.X); lua_setfield(L, -2, "x"); lua_pushnumber(L, cloud_params.speed.Y); lua_setfield(L, -2, "y"); lua_setfield(L, -2, "speed"); return 1; }
// get_sky(self) int ObjectRef::l_get_sky(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); if (player == NULL) return 0; video::SColor bgcolor(255, 255, 255, 255); std::string type; std::vector<std::string> params; bool clouds; player->getSky(&bgcolor, &type, ¶ms, &clouds); type = type.empty() ? "regular" : type; push_ARGB8(L, bgcolor); lua_pushlstring(L, type.c_str(), type.size()); lua_newtable(L); s16 i = 1; for (const std::string ¶m : params) { lua_pushlstring(L, param.c_str(), param.size()); lua_rawseti(L, -2, i++); } lua_pushboolean(L, clouds); return 4; }
// get_sky(self) int ObjectRef::l_get_sky(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); Player *player = getplayer(ref); if (player == NULL) return 0; video::SColor bgcolor(255, 255, 255, 255); std::string type; std::vector<std::string> params; player->getSky(&bgcolor, &type, ¶ms); type = type == "" ? "regular" : type; push_ARGB8(L, bgcolor); lua_pushlstring(L, type.c_str(), type.size()); lua_newtable(L); s16 i = 1; for (std::vector<std::string>::iterator it = params.begin(); it != params.end(); ++it) { lua_pushlstring(L, it->c_str(), it->size()); lua_rawseti(L, -2, i); i++; } return 3; }
void push_object_properties(lua_State *L, ObjectProperties *prop) { lua_newtable(L); lua_pushnumber(L, prop->hp_max); lua_setfield(L, -2, "hp_max"); lua_pushboolean(L, prop->physical); lua_setfield(L, -2, "physical"); lua_pushboolean(L, prop->collideWithObjects); lua_setfield(L, -2, "collide_with_objects"); lua_pushnumber(L, prop->weight); lua_setfield(L, -2, "weight"); push_aabb3f(L, prop->collisionbox); lua_setfield(L, -2, "collisionbox"); lua_pushlstring(L, prop->visual.c_str(), prop->visual.size()); lua_setfield(L, -2, "visual"); lua_pushlstring(L, prop->mesh.c_str(), prop->mesh.size()); lua_setfield(L, -2, "mesh"); push_v2f(L, prop->visual_size); lua_setfield(L, -2, "visual_size"); lua_newtable(L); u16 i = 1; for (std::vector<std::string>::iterator it = prop->textures.begin(); it != prop->textures.end(); ++it) { lua_pushlstring(L, it->c_str(), it->size()); lua_rawseti(L, -2, i); } lua_setfield(L, -2, "textures"); lua_newtable(L); i = 1; for (std::vector<video::SColor>::iterator it = prop->colors.begin(); it != prop->colors.end(); ++it) { push_ARGB8(L, *it); lua_rawseti(L, -2, i); } lua_setfield(L, -2, "colors"); push_v2s16(L, prop->spritediv); lua_setfield(L, -2, "spritediv"); push_v2s16(L, prop->initial_sprite_basepos); lua_setfield(L, -2, "initial_sprite_basepos"); lua_pushboolean(L, prop->is_visible); lua_setfield(L, -2, "is_visible"); lua_pushboolean(L, prop->makes_footstep_sound); lua_setfield(L, -2, "makes_footstep_sound"); lua_pushnumber(L, prop->automatic_rotate); lua_setfield(L, -2, "automatic_rotate"); lua_pushnumber(L, prop->stepheight / BS); lua_setfield(L, -2, "stepheight"); if (prop->automatic_face_movement_dir) lua_pushnumber(L, prop->automatic_face_movement_dir_offset); else lua_pushboolean(L, false); lua_setfield(L, -2, "automatic_face_movement_dir"); }
// 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; }
// get_nametag_attributes(self) int ObjectRef::l_get_nametag_attributes(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); if (co == NULL) return 0; ObjectProperties *prop = co->accessObjectProperties(); if (!prop) return 0; video::SColor color = prop->nametag_color; lua_newtable(L); push_ARGB8(L, color); lua_setfield(L, -2, "color"); lua_pushstring(L, prop->nametag.c_str()); lua_setfield(L, -2, "text"); return 1; }