mirror of
https://github.com/BenjieFiftysix/sponge.git
synced 2025-01-19 19:11:26 +01:00
Add configuration options, with changed default behaviour
This commit is contained in:
parent
457de1e214
commit
a3ae65833f
12
README.md
12
README.md
@ -17,3 +17,15 @@ This will cause them to become soggy, so to use them again they have to be cooke
|
||||
* If sponges have cleared more than 3 nodes of liquid, they become soggy sponges.
|
||||
* Removing a sponge or soggy sponge will turn a 9x9x9 cube of air-like nodes back into air, as long as they are not in the area of another sponge.
|
||||
*(Air-like nodes can be removed in protection by removing a sponge outside the protection, they are not meant to be permanent)*
|
||||
|
||||
### Options:
|
||||
**Replace air nodes**: boolean, default true
|
||||
Causes sponges not to replace air with water blocking airlike nodes. Disabling this may cause unusual behaviour with flowing water.
|
||||
|
||||
**Group list**: list, default: water
|
||||
List of group names as group1,group2,... (common groups are water, liquid and lava)
|
||||
See "Group list type" (sponge_group_list_type) for the behaviour of this list.
|
||||
|
||||
**Group list type**: multi-choice, default whitelist_source
|
||||
If the groups in the group list should be treated as a whitelist or blacklist for removing liquids.
|
||||
The *_source variants will remove all flowing liquids regardless of the list.
|
||||
|
61
init.lua
61
init.lua
@ -15,10 +15,26 @@ removing a sponge or soggy sponge will turn a 9x9x9 cube of air-like nodes back
|
||||
(air-like nodes can be removed in protection by removing a sponge outside the protection, they are not meant to be permanent)
|
||||
]]--
|
||||
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local area = 4 -- The "radius" (of the cube) to clear water
|
||||
local keep_dry = 3 -- The maximum amount of water cleared where the sponge doesn't turn soggy
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
-- Load configurable options
|
||||
local replace_air_nodes = minetest.settings:get_bool("sponge_replace_air_nodes", true)
|
||||
local group_list = minetest.settings:get("sponge_group_list", false) or "water"
|
||||
local group_list_type = minetest.settings:get("sponge_group_list_type") or "whitelist_source"
|
||||
|
||||
-- returns true if groups contains anything in list
|
||||
local compare_groups = function(list, groups)
|
||||
for group in list:gmatch("([^,]+)") do
|
||||
if groups[group] and groups[group] > 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- called by after_destruct()
|
||||
@ -71,17 +87,46 @@ local construct = function(pos, placer, itemstack, pointed_thing)
|
||||
for x = pos.x-area, pos.x+area do
|
||||
for y = pos.y-area, pos.y+area do
|
||||
for z = pos.z-area, pos.z+area do
|
||||
local p = {x=x, y=y, z=z}
|
||||
|
||||
local n = minetest.get_node({x=x, y=y, z=z}).name
|
||||
local n = minetest.get_node(p).name
|
||||
local def = minetest.registered_nodes[n]
|
||||
if def ~= nil and (n == "air" or def["drawtype"] == "liquid" or def["drawtype"] == "flowingliquid") then
|
||||
local p = {x=x, y=y, z=z}
|
||||
if not minetest.is_protected(p, playername) then
|
||||
if n ~= "air" then
|
||||
count = count + 1 -- counting liquids
|
||||
local replace = false
|
||||
if def == nil or minetest.is_protected(p, playername) then
|
||||
-- replace = false
|
||||
elseif replace_air_nodes and n == "air" then
|
||||
replace = true
|
||||
elseif def["drawtype"] == "flowingliquid" then
|
||||
if group_list_type == "whitelist" then
|
||||
if compare_groups(group_list, def.groups or {}) then
|
||||
replace = true
|
||||
end
|
||||
minetest.set_node(p, {name=modname..":liquid_stop"})
|
||||
elseif group_list_type == "blacklist" then
|
||||
if not compare_groups(group_list, def.groups or {}) then
|
||||
replace = true
|
||||
end
|
||||
else
|
||||
replace = true
|
||||
end
|
||||
elseif def["drawtype"] == "liquid" then
|
||||
if group_list_type == "whitelist" or group_list_type == "whitelist_source" then
|
||||
if compare_groups(group_list, def.groups or {}) then
|
||||
replace = true
|
||||
end
|
||||
elseif group_list_type == "blacklist" or group_list_type == "blacklist_source" then
|
||||
if not compare_groups(group_list, def.groups or {}) then
|
||||
replace = true
|
||||
end
|
||||
else
|
||||
replace = true
|
||||
end
|
||||
end
|
||||
|
||||
if replace then
|
||||
if n ~= "air" then
|
||||
count = count + 1 -- counting liquids
|
||||
end
|
||||
minetest.set_node(p, {name=modname..":liquid_stop"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
10
settingtypes.txt
Normal file
10
settingtypes.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Causes sponges not to replace air with water blocking airlike nodes. Disabling this may cause unusual behaviour with flowing water.
|
||||
sponge_replace_air_nodes (Replace air nodes) bool true
|
||||
|
||||
# List of group names as group1,group2,... (common groups are water, liquid and lava)
|
||||
# See "Group list type" (sponge_group_list_type) for the behaviour of this list.
|
||||
sponge_group_list (Group list) string water
|
||||
|
||||
# If the groups in the group list should be treated as a whitelist or blacklist for removing liquids.
|
||||
# The *_source variants will remove all flowing liquids regardless of the list.
|
||||
sponge_group_list_type (Group list type) enum whitelist_source whitelist,whitelist_source,blacklist,blacklist_source,ignored
|
Loading…
Reference in New Issue
Block a user