40 lines
1.1 KiB
Lua
Raw Normal View History

-- CC0/Unlicense Emilia 2020
-- Optimizes stuff.
-- texture is a prefix
2021-01-26 04:13:43 +01:00
local function remove_ents(texture)
2021-01-21 11:41:32 +01:00
if not minetest.localplayer then return end
local obj = minetest.localplayer.get_nearby_objects(10000)
for i, v in ipairs(obj) do
-- CAOs with water/lava textures are droplets
2021-01-26 04:13:43 +01:00
--minetest.log("ERROR",v:get_item_textures())
if v:get_item_textures():find("^" .. texture) then
v:set_visible(false)
v:remove_from_scene(true)
end
end
end
2021-01-26 04:13:43 +01:00
core.register_on_spawn_particle(function(particle)
if minetest.settings:get_bool("noparticles") then return true end
end)
local epoch = os.clock()
minetest.register_globalstep(function()
if os.clock() > epoch + 1 then
if minetest.settings:get_bool("optimize_water_drops") then
2021-01-26 04:13:43 +01:00
remove_ents("default_water_source")
end
epoch = os.clock()
end
end)
2021-01-26 04:13:43 +01:00
minetest.register_cheat("NoParticles", "Render", "noparticles")
minetest.register_cheat("NoDroplets", "Render", "optimize_water_drops")
minetest.register_cheat("NoHearts", "Render", "optimize_hearts")