diff options
-rw-r--r-- | builtin/client/cheats/init.lua | 1 | ||||
-rw-r--r-- | builtin/client/cheats/render.lua | 12 | ||||
-rw-r--r-- | builtin/client/register.lua | 1 | ||||
-rw-r--r-- | builtin/settingtypes.txt | 2 | ||||
-rw-r--r-- | doc/client_lua_api.txt | 6 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 1 | ||||
-rw-r--r-- | src/network/clientpackethandler.cpp | 5 | ||||
-rw-r--r-- | src/script/common/c_content.cpp | 51 | ||||
-rw-r--r-- | src/script/common/c_content.h | 1 | ||||
-rw-r--r-- | src/script/cpp_api/s_client.cpp | 37 | ||||
-rw-r--r-- | src/script/cpp_api/s_client.h | 2 |
11 files changed, 101 insertions, 18 deletions
diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 31657e9ed..30c3fe208 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -39,6 +39,7 @@ core.cheats = { ["PlayerTracers"] = "enable_player_tracers", ["NodeESP"] = "enable_node_esp", ["NodeTracers"] = "enable_node_tracers", + ["NoWeather"] = "noweather", }, ["World"] = { ["FastDig"] = "fastdig", diff --git a/builtin/client/cheats/render.lua b/builtin/client/cheats/render.lua index 6402246f3..dc3f71247 100644 --- a/builtin/client/cheats/render.lua +++ b/builtin/client/cheats/render.lua @@ -1,2 +1,14 @@ core.register_list_command("xray", "Configure X-Ray", "xray_nodes") core.register_list_command("search", "Configure NodeESP", "node_esp_nodes") + +core.register_on_spawn_particle(function(particle) + if core.settings:get_bool("noweather") and particle.texture:sub(1, 12) == "weather_pack" then + return true + end +end) + +core.register_on_play_sound(function(sound) + if core.settings:get_bool("noweather") and sound.name == "weather_rain" then + return true + end +end) diff --git a/builtin/client/register.lua b/builtin/client/register.lua index 03dc41f71..669ef134e 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -104,3 +104,4 @@ core.registered_on_modchannel_signal, core.register_on_modchannel_signal = make_ core.registered_on_inventory_open, core.register_on_inventory_open = make_registration() core.registered_on_recieve_physics_override, core.register_on_recieve_physics_override = make_registration() core.registered_on_play_sound, core.register_on_play_sound = make_registration() +core.registered_on_spawn_particle, core.register_on_spawn_particle = make_registration() diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index b66ac3538..45f20a99d 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2366,3 +2366,5 @@ enable_node_tracers (NodeTracers) bool false entity_esp_color (EntityESP Color) v3f 255, 255, 255 player_esp_color (PlayerESP Color) v3f 0, 255, 0 + +noweather (NoWeather) bool false diff --git a/doc/client_lua_api.txt b/doc/client_lua_api.txt index 9ce553ca1..5618c7a6f 100644 --- a/doc/client_lua_api.txt +++ b/doc/client_lua_api.txt @@ -755,10 +755,14 @@ Call these functions only at load time! * Called when recieving physics_override from server * Newest functions are called first * If any function returns true, the physics override does not change -* `minetest.register_on_sound_play(function(SimpleSoundSpec))` +* `minetest.register_on_play_sound(function(SimpleSoundSpec))` * Called when recieving a play sound command from server * Newest functions are called first * If any function returns true, the sound does not play +* `minetest.register_on_spawn_partice(function(particle definition))` + * Called when recieving a spawn particle command from server + * Newest functions are called first + * If any function returns true, the particel does not spawn ### Setting-related * `minetest.settings`: Settings object containing all of the settings from the diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 141070003..bcf5012a9 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -146,6 +146,7 @@ void set_default_settings(Settings *settings) settings->setDefault("enable_node_tracers", "false"); settings->setDefault("entity_esp_color", "(255, 255, 255)"); settings->setDefault("player_esp_color", "(0, 255, 0)"); + settings->setDefault("noweather", "false"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index c39586f2c..55f85571d 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -988,9 +988,8 @@ void Client::handleCommand_SpawnParticle(NetworkPacket* pkt) event->type = CE_SPAWN_PARTICLE; event->spawn_particle = new ParticleParameters(p); - if (g_settings->getBool("log_particles")) { - std::cout << p.pos.X << " " << p.pos.Y << " " << p.pos.Z << std::endl; - } + if (m_mods_loaded && m_script->on_spawn_particle(*event->spawn_particle)) + return; m_client_event_queue.push(event); } diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 04f4c335c..72361bdb5 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1325,20 +1325,6 @@ void push_inventory(lua_State *L, Inventory *inventory) } /******************************************************************************/ -void push_inventory_list(lua_State *L, Inventory *inv, const char *name) -{ - InventoryList *invlist = inv->getList(name); - if(invlist == NULL){ - lua_pushnil(L); - return; - } - std::vector<ItemStack> items; - for(u32 i=0; i<invlist->getSize(); i++) - items.push_back(invlist->getItem(i)); - push_items(L, items); -} - -/******************************************************************************/ void read_inventory_list(lua_State *L, int tableindex, Inventory *inv, const char *name, Server* srv, int forcesize) { @@ -1367,6 +1353,19 @@ void read_inventory_list(lua_State *L, int tableindex, } } +void push_inventory_list(lua_State *L, Inventory *inv, const char *name) +{ + InventoryList *invlist = inv->getList(name); + if(invlist == NULL){ + lua_pushnil(L); + return; + } + std::vector<ItemStack> items; + for(u32 i=0; i<invlist->getSize(); i++) + items.push_back(invlist->getItem(i)); + push_items(L, items); +} + /******************************************************************************/ struct TileAnimationParams read_animation_definition(lua_State *L, int index) { @@ -1402,6 +1401,29 @@ struct TileAnimationParams read_animation_definition(lua_State *L, int index) return anim; } +void push_animation_definition(lua_State *L, struct TileAnimationParams anim) +{ + switch (anim.type) { + case TAT_NONE: + lua_pushnil(L); + break; + case TAT_VERTICAL_FRAMES: + lua_newtable(L); + setstringfield(L, -1, "type", "vertical_frames"); + setfloatfield(L, -1, "aspect_w", anim.vertical_frames.aspect_w); + setfloatfield(L, -1, "aspect_h", anim.vertical_frames.aspect_h); + setfloatfield(L, -1, "length", anim.vertical_frames.length); + break; + case TAT_SHEET_2D: + lua_newtable(L); + setstringfield(L, -1, "type", "sheet_2d"); + setintfield(L, -1, "frames_w", anim.sheet_2d.frames_w); + setintfield(L, -1, "frames_h", anim.sheet_2d.frames_h); + setintfield(L, -1, "frame_length", anim.sheet_2d.frame_length); + break; + } +} + /******************************************************************************/ ToolCapabilities read_tool_capabilities( lua_State *L, int table) @@ -2103,6 +2125,7 @@ void push_collision_move_result(lua_State *L, const collisionMoveResult &res) /**/ } +/******************************************************************************/ void push_physics_override(lua_State *L, float speed, float jump, float gravity, bool sneak, bool sneak_glitch, bool new_move) { lua_createtable(L, 0, 6); diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h index 08c74c292..10b77a116 100644 --- a/src/script/common/c_content.h +++ b/src/script/common/c_content.h @@ -98,6 +98,7 @@ void push_hit_params (lua_State *L, ItemStack read_item (lua_State *L, int index, IItemDefManager *idef); struct TileAnimationParams read_animation_definition(lua_State *L, int index); +void push_animation_definition(lua_State *L, struct TileAnimationParams anim); ToolCapabilities read_tool_capabilities (lua_State *L, int table); void push_tool_capabilities (lua_State *L, diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index cf7df5b5d..200a449ee 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -253,6 +253,43 @@ bool ScriptApiClient::on_play_sound(SimpleSoundSpec spec) return readParam<bool>(L, -1); } +bool ScriptApiClient::on_spawn_particle(struct ParticleParameters param) +{ + SCRIPTAPI_PRECHECKHEADER + + // Get core.registered_on_play_sound + + lua_getglobal(L, "core"); + lua_getfield(L, -1, "registered_on_spawn_particle"); + + // Push data + lua_newtable(L); + push_v3f(L, param.pos); + lua_setfield(L, -2, "pos"); + push_v3f(L, param.vel); + lua_setfield(L, -2, "velocity"); + push_v3f(L, param.acc); + lua_setfield(L, -2, "acceleration"); + setfloatfield(L, -1, "expirationtime", param.expirationtime); + setboolfield(L, -1, "collisiondetection", param.collisiondetection); + setboolfield(L, -1, "collision_removal", param.collision_removal); + setboolfield(L, -1, "object_collision", param.object_collision); + setboolfield(L, -1, "vertical", param.vertical); + push_animation_definition(L, param.animation); + lua_setfield(L, -2, "animation"); + setstringfield(L, -1, "texture", param.texture); + setintfield(L, -1, "glow", param.glow); + if (param.node.getContent() != CONTENT_IGNORE) { + pushnode(L, param.node, getGameDef()->ndef()); + lua_setfield(L, -2, "node"); + } + setintfield(L, -1, "node_tile", param.node_tile); + + // Call functions + runCallbacks(1, RUN_CALLBACKS_MODE_OR); + return readParam<bool>(L, -1); +} + bool ScriptApiClient::on_inventory_open(Inventory *inventory) { SCRIPTAPI_PRECHECKHEADER diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h index 8db253d56..ff1c473ae 100644 --- a/src/script/cpp_api/s_client.h +++ b/src/script/cpp_api/s_client.h @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/string.h" #include "util/pointedthing.h" #include "lua_api/l_item.h" +#include "particles.h" #ifdef _CRT_MSVCP_CURRENT #include <cstdint> @@ -59,6 +60,7 @@ public: bool on_item_use(const ItemStack &item, const PointedThing &pointed); bool on_recieve_physics_override(float override_speed, float override_jump, float override_gravity, bool sneak, bool sneak_glitch, bool new_move); bool on_play_sound(SimpleSoundSpec spec); + bool on_spawn_particle(struct ParticleParameters param); bool on_inventory_open(Inventory *inventory); void open_enderchest(); |