add bucket-lite mod

master
daret 2020-11-14 23:49:28 +01:00
parent 8548721306
commit ac132116b4
7 changed files with 232 additions and 341 deletions

View File

@ -1,3 +1,8 @@
Work in Progress
- ADD bucket-lite mod - liquid from bucket lows only 1 block
-------------------------------------------------
Work in Progress 0.3 [11.11.2020]
- hbsprint update - repairs error if damage is disabled and try to sprint

View File

@ -64,7 +64,7 @@ origin git@github.com:minetest-mods/ts_doors.git (fetch)
Mod: buildings/ts_doors
origin git@gitlab.com:daretmavi/bucket-lite.git (fetch)
* master c159492 [origin/master] Readme update - dynamic_liquid description
* master 31d9189 [origin/master] Merge branch 'devel' into 'master'
Mod: environment/bucket-lite
origin https://github.com/minetest-mods/dynamic_liquid (fetch)

View File

@ -0,0 +1,18 @@
Ver. 2.0 [14.11.2020]
Settings added (settingtypes.txt)
- bucket_water_flowing_range (Default = 1)
- bucket_lava_flowing_range (Default = 1)
Code cleanup, global names defined
- Liquid_name - all use liquid names
.water - all water like names
.lava - all lava like names
- bucket
- bucket names definitions
- bucket material defined
--------------------------------------------------
Ver. 1.0 [10.11.2020]
Fist release

View File

@ -7,16 +7,28 @@ Fork of **Minetest Game mod: bucket**
- only one bucket for all water types
- flowing is only one block to prevent flooding with one bucket
- If "bucket water" gets in contact with normal water or river water, then the bucket water changes to this type.
- If "bucket lava" gets in contact with water, or default lava, the bucket lava changes to default type - this can result in lava flooging. Just don't mess up with lava :)
- If "bucket lava" gets in contact with water, or default lava, the bucket lava changes to default type - this can result in lava flooding. Just don't mess up with lava :)
**Working with other mods:**
**dynamic_liquid** - actually works, it creates obsidian easily (good enough)
- If you want full support, some changes are needen:
- If you want full support, some changes are needed:
- see my fork https://github.com/daretmavi/dynamic_liquid (no warranty, I just tried some changes)
**Screenshots:**
This is default behavior:
![Image](screenshot_old_river_water.png)
![Image](screenshot_old_water.png)
![Image](screenshot_old_lava.png)
River water is ok, but normal water and lava can create real flood ... from one bucket. It's crazy.
This mod changes it to just one block
![Image](screenshot_new.png)
Minetest: https://www.minetest.net/
-----

View File

@ -1,237 +1,146 @@
--
--
-- Load support for MT game translation.
local S = minetest.get_translator("bucket")
-- Default Liquid Namespace
Liquid_name = {}
Liquid_name.water = {}
Liquid_name.lava = {}
-- Default water and lava
Liquid_name.water.source = "default:water_source"
Liquid_name.water.flowing = "default:water_flowing"
Liquid_name.water.river_source = "default:river_water_source"
Liquid_name.water.river_flowing = "default:river_water_flowing"
Liquid_name.lava.source = "default:lava_source"
Liquid_name.lava.flowing = "default:lava_flowing"
--bucket waret and lava
Liquid_name.water.bucket_source = "bucket:bucket_water_source"
Liquid_name.water.bucket_flowing = "bucket:bucket_water_flowing"
Liquid_name.lava.bucket_source = "bucket:bucket_lava_source"
Liquid_name.lava.bucket_flowing = "bucket:bucket_lava_flowing"
--Bucket river water not used (not needed yet)
--Liquid_name.water.bucket_river_source = "bucket:bucket_river_water_source"
--Liquid_name.water.bucket_river_flowing = "bucket:bucket_river_water_flowing"
-- Liquid flowing range definitions (Default)
local bucket_water_range = 1
local bucket_lava_range = 1
-- load settingtypes
bucket_water_range = minetest.settings:get("bucket_water_flowing_range") or bucket_water_range
bucket_lava_range = minetest.settings:get("bucket_lava_flowing_range") or bucket_lava_range
-- Registred nodes according to aliases
local water_source_def = minetest.deserialize(minetest.serialize(minetest.registered_nodes[Liquid_name.water.source]))
local water_flowing_def = minetest.deserialize(minetest.serialize(minetest.registered_nodes[Liquid_name.water.flowing]))
local lava_source_def = minetest.deserialize(minetest.serialize(minetest.registered_nodes[Liquid_name.lava.source]))
local lava_flowing_def = minetest.deserialize(minetest.serialize(minetest.registered_nodes[Liquid_name.lava.flowing]))
-- NEW liquid definitions "bucket" liquid
minetest.register_node("bucket:bucket_water_source", {
description = S("Bucket Water Source"),
drawtype = "liquid",
waving = 3,
tiles = {
{
name = "default_water_source_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
{
name = "default_water_source_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
},
alpha = 191,
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_renewable = false,
liquid_alternative_flowing = "bucket:bucket_water_flowing",
liquid_alternative_source = "bucket:bucket_water_source",
liquid_viscosity = 1,
post_effect_color = {a = 103, r = 30, g = 60, b = 90},
groups = {water = 3, liquid = 3, cools_lava = 1},
sounds = default.node_sound_water_defaults(),
})
minetest.register_node(Liquid_name.water.bucket_source, water_source_def)
minetest.override_item(Liquid_name.water.bucket_source, {
description = S("Bucket Water Source"),
liquid_alternative_flowing = Liquid_name.water.bucket_flowing,
liquid_alternative_source = Liquid_name.water.bucket_source,
})
minetest.register_node("bucket:bucket_water_flowing", {
minetest.register_node(Liquid_name.water.bucket_flowing, water_flowing_def)
minetest.override_item(Liquid_name.water.bucket_flowing, {
description = S("Flowing Bucket Water"),
drawtype = "flowingliquid",
tiles = {"default_river_water.png"},
special_tiles = {
{
name = "default_water_flowing_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.5,
},
},
{
name = "default_water_flowing_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.5,
},
},
},
alpha = 160,
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "bucket:bucket_water_flowing",
liquid_alternative_source = "bucket:bucket_water_source",
liquid_viscosity = 1,
liquid_renewable = false,
liquid_range = 1,
post_effect_color = {a = 103, r = 30, g = 76, b = 90},
groups = {water = 3, liquid = 3, not_in_creative_inventory = 1,
cools_lava = 1},
sounds = default.node_sound_water_defaults(),
})
liquid_alternative_flowing = Liquid_name.water.bucket_flowing,
liquid_alternative_source = Liquid_name.water.bucket_source,
liquid_range = bucket_water_range,
})
minetest.register_node("bucket:bucket_lava_source", {
minetest.register_node(Liquid_name.lava.bucket_source, lava_source_def)
minetest.override_item(Liquid_name.lava.bucket_source, {
description = S("Bucket Lava Source"),
drawtype = "liquid",
tiles = {
{
name = "default_lava_source_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0,
},
},
{
name = "default_lava_source_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0,
},
},
},
paramtype = "light",
light_source = default.LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "bucket:bucket_lava_flowing",
liquid_alternative_source = "bucket:bucket_lava_source",
liquid_viscosity = 7,
liquid_renewable = false,
damage_per_second = 4 * 2,
post_effect_color = {a = 191, r = 255, g = 64, b = 0},
groups = {lava = 3, liquid = 2, igniter = 1},
liquid_alternative_flowing = Liquid_name.lava.bucket_flowing,
liquid_alternative_source = Liquid_name.lava.bucket_source,
})
minetest.register_node("bucket:bucket_lava_flowing", {
description = S("Flowing Bucket Lava"),
drawtype = "flowingliquid",
tiles = {"default_lava.png"},
special_tiles = {
{
name = "default_lava_flowing_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.3,
},
},
{
name = "default_lava_flowing_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.3,
},
},
},
paramtype = "light",
paramtype2 = "flowingliquid",
light_source = default.LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "bucket:bucket_lava_flowing",
liquid_alternative_source = "bucket:bucket_lava_source",
liquid_viscosity = 7,
liquid_renewable = false,
damage_per_second = 4 * 2,
post_effect_color = {a = 191, r = 255, g = 64, b = 0},
groups = {lava = 3, liquid = 2, igniter = 1,
not_in_creative_inventory = 1},
liquid_range = 1,
minetest.register_node(Liquid_name.lava.bucket_flowing, lava_flowing_def)
minetest.override_item(Liquid_name.lava.bucket_flowing, {
description = S("Bucket Lava Source"),
liquid_alternative_flowing = Liquid_name.lava.bucket_flowing,
liquid_alternative_source = Liquid_name.lava.bucket_source,
liquid_range = bucket_lava_range,
})
-- Change Bucket Water to normal "default:water_source" on contact with it
minetest.register_abm({
nodenames = {"bucket:bucket_water_source"},
neighbors = {"default:water_source", "default:water_flowing"},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = "default:water_source"})
end
})
-- Change Bucket Water to normal "default:river_water_source" on contact with it
-- Change Bucket Water to normal "water_source" on contact with it
minetest.register_abm({
nodenames = {"bucket:bucket_water_source"},
neighbors = {"default:river_water_source", "default:river_water_flowing"},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = "default:river_water_source"})
end
})
nodenames = {Liquid_name.water.bucket_source},
neighbors = {Liquid_name.water.source,
Liquid_name.water.flowing},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = Liquid_name.water.source})
end
})
--
minetest.register_abm({
nodenames = {Liquid_name.water.bucket_flowing},
neighbors = {Liquid_name.water.source,
Liquid_name.water.flowing},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = Liquid_name.water.flowing})
end
})
-- Change Bucket Water to normal "river_water_source" on contact with it
minetest.register_abm({
nodenames = {Liquid_name.water.bucket_source},
neighbors = {Liquid_name.water.river_source,
Liquid_name.water.river_flowing},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = Liquid_name.water.river_source})
end
})
-- Change Bucket Lava to normal on contact with lava or water
minetest.register_abm({
nodenames = {"bucket:bucket_lava_source"},
neighbors = {"default:lava_source", "default:lava_flowing", "default:water_source", "default:water_flowing", "default:river_water_source", "default:river_water_flowing", "bucket:bucket_water_source", "bucket:bucket_water_flowing"},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = "default:lava_source"})
end
})
nodenames = {Liquid_name.lava.bucket_source},
neighbors = {Liquid_name.lava.source,
Liquid_name.lava.flowing,
Liquid_name.water.source,
Liquid_name.water.flowing,
Liquid_name.water.river_source,
Liquid_name.water.river_flowing,
Liquid_name.water.bucket_source,
Liquid_name.water.bucket_flowing},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = Liquid_name.lava.source})
end
})
-- Bucket flowing Lava to normal on contact with lava or water
minetest.register_abm({
nodenames = {"bucket:bucket_lava_flowing"},
neighbors = {"default:lava_source", "default:lava_flowing", "default:water_source", "default:water_flowing", "default:river_water_source", "default:river_water_flowing", "bucket:bucket_water_source"},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = "default:lava_flowing"})
end
})
nodenames = {Liquid_name.lava.bucket_flowing},
neighbors = {Liquid_name.lava.source,
Liquid_name.lava.flowing,
Liquid_name.water.source,
Liquid_name.water.flowing,
Liquid_name.water.river_source,
Liquid_name.water.river_flowing,
Liquid_name.water.bucket_source},
interval = 1.0, -- Run every 1 second
chance = 1, -- Select every 1 nod
action = function(pos, node, active_object_count, active_object_count_wider)
local pos = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(pos, {name = Liquid_name.lava.flowing})
end
})

View File

@ -4,23 +4,32 @@
-- Load support for MT game translation.
local S = minetest.get_translator("bucket")
-- bucket item definitions
bucket = {}
minetest.register_alias("bucket", "bucket:bucket_empty")
minetest.register_alias("bucket_water", "bucket:bucket_water")
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
bucket.material = "default:steel_ingot"
bucket.empty = "bucket:bucket_empty"
bucket.water = "bucket:bucket_water_uni"
bucket.lava = "bucket:bucket_lava_uni"
bucket.liquids = {}
-- Bucket aliases
minetest.register_alias("bucket", bucket.empty)
minetest.register_alias("bucket_water", bucket.water)
minetest.register_alias("bucket_lava", bucket.lava)
-- define bucket liquids and Liquid_name
dofile(minetest.get_modpath("bucket") .. "/bucket_liquids.lua")
minetest.register_craft({
output = "bucket:bucket_empty 1",
output = bucket.empty.." 1",
recipe = {
{"default:steel_ingot", "", "default:steel_ingot"},
{"", "default:steel_ingot", ""},
{bucket.material, "", bucket.material},
{"", bucket.material, ""},
}
})
bucket = {}
bucket.liquids = {}
local function check_protection(pos, name, text)
if minetest.is_protected(pos, name) then
@ -46,6 +55,9 @@ end
-- source neighbour, even if defined as 'liquid_renewable = false'.
-- Needed to avoid creating holes in sloping rivers.
-- This function can be called from any mod (that depends on bucket).
-- this is function from original bucket
-- for compatibility, if used by another mod. (not tested)
function bucket.register_liquid(source, flowing, itemname, inventory_image, name,
groups, force_renew)
bucket.liquids[source] = {
@ -110,84 +122,14 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name
end
minetest.set_node(lpos, {name = source})
return ItemStack("bucket:bucket_empty")
return ItemStack(bucket.empty)
end
})
end
end
function bucket.register_bucket_liquid(source, flowing, itemname, inventory_image, name,
groups, force_renew)
bucket.liquids[source] = {
source = source,
flowing = flowing,
itemname = itemname,
force_renew = force_renew,
}
bucket.liquids[flowing] = bucket.liquids[source]
-- item only for bucket with "bucket" liquid
if itemname == "bucket:bucket_water_uni" or itemname == "bucket:bucket_lava_uni" then
minetest.register_craftitem(itemname, {
description = name,
inventory_image = inventory_image,
stack_max = 1,
liquids_pointable = true,
groups = groups,
on_place = function(itemstack, user, pointed_thing)
-- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
local node = minetest.get_node_or_nil(pointed_thing.under)
local ndef = node and minetest.registered_nodes[node.name]
-- Call on_rightclick if the pointed node defines it
if ndef and ndef.on_rightclick and
not (user and user:is_player() and
user:get_player_control().sneak) then
return ndef.on_rightclick(
pointed_thing.under,
node, user,
itemstack)
end
local lpos
-- Check if pointing to a buildable node
if ndef and ndef.buildable_to then
-- buildable; replace the node
lpos = pointed_thing.under
else
-- not buildable to; place the liquid above
-- check if the node above can be replaced
lpos = pointed_thing.above
node = minetest.get_node_or_nil(lpos)
local above_ndef = node and minetest.registered_nodes[node.name]
if not above_ndef or not above_ndef.buildable_to then
-- do not remove the bucket with the liquid
return itemstack
end
end
if check_protection(lpos, user
and user:get_player_name()
or "", "place "..source) then
return
end
minetest.set_node(lpos, {name = source})
return ItemStack("bucket:bucket_empty")
end
})
end
end
minetest.register_craftitem("bucket:bucket_empty", {
minetest.register_craftitem(bucket.empty, {
description = S("Empty Bucket"),
inventory_image = "bucket.png",
groups = {tool = 1},
@ -208,28 +150,27 @@ minetest.register_craftitem("bucket:bucket_empty", {
if liquiddef ~= nil
and liquiddef.itemname ~= nil
and node.name == liquiddef.source then
if check_protection(pointed_thing.under,
user:get_player_name(),
"take ".. node.name) then
return
end
if check_protection(pointed_thing.under,
user:get_player_name(),
"take ".. node.name) then
return
end
-- default set to return filled bucket
local giving_back
-- according to source (liquid type) assign bucket with "bucket" liquid
local giving_back={
["default:lava_source"]="bucket:bucket_lava_uni",
["bucket:bucket_lava_source"]="bucket:bucket_lava_uni",
["bucket:bucket_water_source"]="bucket:bucket_water_uni",
["default:water_source"]="bucket:bucket_water_uni",
["default:river_water_source"]="bucket:bucket_water_uni",
[Liquid_name.lava.source]=bucket.lava,
[Liquid_name.water.source]=bucket.water,
[Liquid_name.water.river_source ]=bucket.water,
[Liquid_name.lava.bucket_source]=bucket.lava,
[Liquid_name.water.bucket_source]=bucket.water,
}
-- giving_back from original bucket
if giving_back[liquiddef.source] == nil then
giving_back[liquiddef.source]=liquiddef.itemname
end
-- check if holding more than 1 empty bucket
if item_count > 1 then
@ -244,7 +185,7 @@ minetest.register_craftitem("bucket:bucket_empty", {
end
-- set to return empty buckets minus 1
giving_back[liquiddef.source] = "bucket:bucket_empty "..tostring(item_count-1)
giving_back[liquiddef.source] = bucket.empty.." "..tostring(item_count-1)
end
@ -272,10 +213,11 @@ minetest.register_craftitem("bucket:bucket_empty", {
-- original bucket - to take the original liquit sources
bucket.register_bucket_liquid(
"default:water_source",
"default:water_flowing",
"bucket:bucket_water",
-- uses new bucket uni
bucket.register_liquid(
Liquid_name.water.source,
Liquid_name.water.flowing,
bucket.water,
"bucket_water.png",
S("Water Bucket"),
{tool = 1, water_bucket = 1}
@ -287,20 +229,20 @@ bucket.register_bucket_liquid(
-- River water source is instead made renewable by the 'force renew' option
-- used here.
bucket.register_bucket_liquid(
"default:river_water_source",
"default:river_water_flowing",
"bucket:bucket_river_water",
bucket.register_liquid(
Liquid_name.water.river_source ,
Liquid_name.water.river_flowing,
bucket.water,
"bucket_river_water.png",
S("River Water Bucket"),
{tool = 1, water_bucket = 1},
true
)
bucket.register_bucket_liquid(
"default:lava_source",
"default:lava_flowing",
"bucket:bucket_lava",
bucket.register_liquid(
Liquid_name.lava.source,
Liquid_name.lava.flowing,
bucket.lava,
"bucket_lava.png",
S("Lava Bucket"),
{tool = 1}
@ -309,20 +251,20 @@ bucket.register_bucket_liquid(
-- Unified bucket
-- every bucket will be change to this
bucket.register_bucket_liquid(
"bucket:bucket_water_source",
"bucket:bucket_water_flowing",
"bucket:bucket_water_uni",
bucket.register_liquid(
Liquid_name.water.bucket_source,
Liquid_name.water.bucket_flowing,
bucket.water,
"bucket_water.png",
S("Water Bucket"),
{tool = 1, water_bucket = 1},
false
)
bucket.register_bucket_liquid(
"bucket:bucket_lava_source",
"bucket:bucket_lava_flowing",
"bucket:bucket_lava_uni",
bucket.register_liquid(
Liquid_name.lava.bucket_source,
Liquid_name.lava.bucket_flowing,
bucket.lava,
"bucket_lava.png",
S("Lava Bucket"),
{tool = 1}
@ -332,21 +274,21 @@ bucket.register_bucket_liquid(
minetest.register_craft({
type = "fuel",
recipe = "bucket:bucket_lava",
recipe = bucket.lava,
burntime = 60,
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
replacements = {{bucket.lava, bucket.empty}},
})
-- Register buckets as dungeon loot
if minetest.global_exists("dungeon_loot") then
dungeon_loot.register({
{name = "bucket:bucket_empty", chance = 0.55},
{name = bucket.empty, chance = 0.55},
-- water in deserts/ice or above ground, lava otherwise
{name = "bucket:bucket_water", chance = 0.45,
{name = bucket.water, chance = 0.45,
types = {"sandstone", "desert", "ice"}},
{name = "bucket:bucket_water", chance = 0.45, y = {0, 32768},
{name = bucket.water, chance = 0.45, y = {0, 32768},
types = {"normal"}},
{name = "bucket:bucket_lava", chance = 0.45, y = {-32768, -1},
{name = bucket.lava, chance = 0.45, y = {-32768, -1},
types = {"normal"}},
})
end

View File

@ -0,0 +1,5 @@
# How far will water from bucket flow
bucket_water_flowing_range (Bucket water flowing range) int 1
# How far will lava from bucket flow
bucket_lava_flowing_range (Bucket lava flowing range) int 1