add in basic bottles mod, limit shelfs to there respective items

This commit is contained in:
wsor 2021-04-21 19:13:13 -04:00
parent a8d556ab5c
commit 4e1df91bda
30 changed files with 70 additions and 2 deletions

11
mods/fl_bottles/README Normal file
View File

@ -0,0 +1,11 @@
wsor(aka wsor4035)(CC BY-SA 3.0)
dervived from Thomas-S under same license
farlands_bottle_empty.png
wsor(aka wsor4035)(CC BY-SA 3.0)
derived from D00Med under same license who
derived from Thomas-S under same license
all other farlands_bottle_*.png
D00Med(CC BY-SA 3.0)
farlands_bubble*.png

48
mods/fl_bottles/init.lua Normal file
View File

@ -0,0 +1,48 @@
minetest.register_craftitem("fl_bottles:water", {
description = "bottle with water",
inventory_image = "farlands_bottle_blue.png",
groups = {bottle = 1, vessel = 1},
})
minetest.register_craftitem("fl_bottles:river_water", {
description = "bottle with river water",
inventory_image = "farlands_bottle_aqua.png",
groups = {bottle = 1, vessel = 1},
})
minetest.register_craftitem("fl_bottles:bottle", {
description = "empty bottle",
inventory_image = "farlands_bottle_empty.png",
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
local node = minetest.get_node(pointed_thing.under)
local node_def = minetest.registered_nodes[node.name]
if user and not user:get_player_control().sneak then
if node_def.on_rightclick then
return node_def.on_rightclick(pointed_thing.under, node, user, itemstack)
end
end
if node_def._bottle_item == nil then
return itemstack
else
if user:get_wielded_item():get_count() > 1 then
local inv = user:get_inventory()
if inv:room_for_item("main", {name=node_def._bottle_item}) then
inv:add_item("main", node_def._bottle_item)
else
local pos = user:get_pos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, node_def._bottle_item)
end
itemstack:take_item()
return itemstack
end
return ItemStack(node_def._bottle_item)
end
end,
groups = {bottle = 1, vessel = 1},
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

View File

@ -51,6 +51,7 @@ minetest.register_node(":fl_terrain:water_source", {
liquid_viscosity = 1,
post_effect_color = {a = 103, r = 30, g = 60, b = 90},
groups = {water = 3, liquid = 3, cools_lava = 1},
_bottle_item = "fl_bottles:water",
})
minetest.register_node(":fl_terrain:water_flowing", {
@ -144,6 +145,7 @@ minetest.register_node(":fl_terrain:river_water_source", {
liquid_range = 2,
post_effect_color = {a = 103, r = 30, g = 76, b = 90},
groups = {water = 3, liquid = 3, cools_lava = 1},
_bottle_item = "fl_bottles:river_water",
})
minetest.register_node(":fl_terrain:river_water_flowing", {

View File

@ -95,8 +95,6 @@ minetest.register_node("fl_storage:wood_chest", {
end,
})
--add allow_metadata_inventory_put = function(pos, listname, index, stack, player)
-- to limit for vessels and books type shelfs
local function shelf_nodes(name)
local overlays = {"book", "empty", "multi", "vessel"}
@ -184,6 +182,15 @@ local function shelf_nodes(name)
local shelf_formspec = table.concat(formspec, "")
minetest.show_formspec(clicker:get_player_name(), "fl_wildlife:trader_formspec", shelf_formspec)
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if overlay == "vessel" or overlay == "book" then
if minetest.get_item_group(stack:get_name(), overlay) ~= 0 then
return stack:get_count()
end
return 0
end
return stack:get_count()
end,
on_dig = function(pos, node, digger)
local inv = minetest.get_inventory({type="node", pos=pos})
for _, item in ipairs(inv:get_list("main")) do