From 6b57cf07a6fd62a460c9178c64708dec5e0466fb Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sat, 5 Jan 2019 18:04:56 +0100 Subject: [PATCH] new mod 'techpack_warehouse' added tubelib_stairway renamed to techpack_stairway code maintenance --- README.md | 5 +- .../depends.txt | 0 .../description.txt | 0 .../init.lua | 226 +++++++------ techpack_stairway/mod.conf | 2 + .../textures/techpack_stairway_bottom.png | Bin .../textures/techpack_stairway_ladder.png | Bin .../textures/techpack_stairway_lattice.png | Bin .../textures/techpack_stairway_side.png | Bin .../textures/techpack_stairway_steps.png | Bin techpack_warehouse/box_copper.lua | 163 ++++++++++ techpack_warehouse/box_gold.lua | 163 ++++++++++ techpack_warehouse/box_steel.lua | 163 ++++++++++ techpack_warehouse/common.lua | 297 ++++++++++++++++++ techpack_warehouse/depends.txt | 3 + techpack_warehouse/description.txt | 2 + techpack_warehouse/init.lua | 20 ++ techpack_warehouse/mod.conf | 2 + .../textures/techpack_warehouse_arrow_inv.png | Bin 0 -> 219 bytes .../textures/techpack_warehouse_box_back.png | Bin 0 -> 436 bytes .../textures/techpack_warehouse_box_front.png | Bin 0 -> 486 bytes .../textures/techpack_warehouse_box_side.png | Bin 0 -> 493 bytes .../techpack_warehouse_filter_inv.png | Bin 0 -> 202 bytes .../textures/techpack_warehouse_input_inv.png | Bin 0 -> 206 bytes .../techpack_warehouse_inventory_inv.png | Bin 0 -> 181 bytes tubelib/distributor.lua | 25 +- tubelib/node_states.lua | 24 +- tubelib_addons1/autocrafter.lua | 41 ++- tubelib_addons1/fermenter.lua | 25 +- tubelib_addons1/grinder.lua | 30 +- tubelib_addons1/harvester.lua | 63 ++-- tubelib_addons1/liquidsampler.lua | 27 +- tubelib_addons1/quarry.lua | 41 ++- tubelib_addons1/reformer.lua | 25 +- tubelib_addons3/distributor.lua | 25 +- tubelib_addons3/pushing_chest.lua | 2 +- tubelib_stairway/mod.conf | 2 - 37 files changed, 1104 insertions(+), 272 deletions(-) rename {tubelib_stairway => techpack_stairway}/depends.txt (100%) rename {tubelib_stairway => techpack_stairway}/description.txt (100%) rename {tubelib_stairway => techpack_stairway}/init.lua (64%) create mode 100644 techpack_stairway/mod.conf rename tubelib_stairway/textures/tubelib_stairway_bottom.png => techpack_stairway/textures/techpack_stairway_bottom.png (100%) rename tubelib_stairway/textures/tubelib_stairway_ladder.png => techpack_stairway/textures/techpack_stairway_ladder.png (100%) rename tubelib_stairway/textures/tubelib_stairway_lattice.png => techpack_stairway/textures/techpack_stairway_lattice.png (100%) rename tubelib_stairway/textures/tubelib_stairway_side.png => techpack_stairway/textures/techpack_stairway_side.png (100%) rename tubelib_stairway/textures/tubelib_stairway_steps.png => techpack_stairway/textures/techpack_stairway_steps.png (100%) create mode 100644 techpack_warehouse/box_copper.lua create mode 100644 techpack_warehouse/box_gold.lua create mode 100644 techpack_warehouse/box_steel.lua create mode 100644 techpack_warehouse/common.lua create mode 100644 techpack_warehouse/depends.txt create mode 100644 techpack_warehouse/description.txt create mode 100644 techpack_warehouse/init.lua create mode 100644 techpack_warehouse/mod.conf create mode 100644 techpack_warehouse/textures/techpack_warehouse_arrow_inv.png create mode 100644 techpack_warehouse/textures/techpack_warehouse_box_back.png create mode 100644 techpack_warehouse/textures/techpack_warehouse_box_front.png create mode 100644 techpack_warehouse/textures/techpack_warehouse_box_side.png create mode 100644 techpack_warehouse/textures/techpack_warehouse_filter_inv.png create mode 100644 techpack_warehouse/textures/techpack_warehouse_input_inv.png create mode 100644 techpack_warehouse/textures/techpack_warehouse_inventory_inv.png delete mode 100644 tubelib_stairway/mod.conf diff --git a/README.md b/README.md index 504902a..c24368f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ - The Quarry now uses LVM techniques to go down up to 100 meter - Ladders, stairways, and bridges added (tubelib_stairway) for the machines - Industrial lamps +- TechPack Warehouse Boxes in steel, copper, and gold for your warehouse/stock ## New in v2 (from admins point of view) @@ -34,7 +35,8 @@ TechPack is a collection of following Mods: * tubelib_addons1, a Tubelib extension with mining, farming, and crafting nodes * tubelib_addons2, a Tubelib extension with control nodes * tubelib_addons3, a Tubelib extension with high performance nodes -* tubelib_stairway, Ladders, stairways, and bridges for your machines +* techpack_stairway, Ladders, stairways, and bridges for your machines +* techpack_warehouse, Warehouse Boxes in steel, copper, and gold * gravelsieve, a Mod to sieve ores from gravel. * smartline, a Mod with small and smart sensors, actors and controllers. * safer_lua, a subset of the language Lua for safe and secure Lua sandboxes @@ -83,6 +85,7 @@ TechPack provides: - a Signal Tower node showing machine states - a Display node for text outputs of the Controller - Metal ladders, stairways, and bridges +- Warehouse Boxes in steel, copper, and gold TechPack supports the following mods: diff --git a/tubelib_stairway/depends.txt b/techpack_stairway/depends.txt similarity index 100% rename from tubelib_stairway/depends.txt rename to techpack_stairway/depends.txt diff --git a/tubelib_stairway/description.txt b/techpack_stairway/description.txt similarity index 100% rename from tubelib_stairway/description.txt rename to techpack_stairway/description.txt diff --git a/tubelib_stairway/init.lua b/techpack_stairway/init.lua similarity index 64% rename from tubelib_stairway/init.lua rename to techpack_stairway/init.lua index d09d1be..eaeab8a 100644 --- a/tubelib_stairway/init.lua +++ b/techpack_stairway/init.lua @@ -1,9 +1,22 @@ -minetest.register_node("tubelib_stairway:grating", { - description = "Tubelib Grating", +--[[ + + TechPack Stairway + ================= + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + init.lua + +]]-- +minetest.register_node("techpack_stairway:grating", { + description = "TechPack Grating", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -29,12 +42,12 @@ minetest.register_node("tubelib_stairway:grating", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:handrail1", { - description = "Tubelib Handrail 1", +minetest.register_node("techpack_stairway:handrail1", { + description = "TechPack Handrail 1", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -60,12 +73,12 @@ minetest.register_node("tubelib_stairway:handrail1", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:handrail2", { - description = "Tubelib Handrail 2", +minetest.register_node("techpack_stairway:handrail2", { + description = "TechPack Handrail 2", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -93,12 +106,12 @@ minetest.register_node("tubelib_stairway:handrail2", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:handrail3", { - description = "Tubelib Handrail 3", +minetest.register_node("techpack_stairway:handrail3", { + description = "TechPack Handrail 3", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -126,12 +139,12 @@ minetest.register_node("tubelib_stairway:handrail3", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:handrail4", { - description = "Tubelib Handrail 4", +minetest.register_node("techpack_stairway:handrail4", { + description = "TechPack Handrail 4", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -161,12 +174,12 @@ minetest.register_node("tubelib_stairway:handrail4", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:bridge1", { - description = "Tubelib Bridge 1", +minetest.register_node("techpack_stairway:bridge1", { + description = "TechPack Bridge 1", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -193,12 +206,12 @@ minetest.register_node("tubelib_stairway:bridge1", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:bridge2", { - description = "Tubelib Bridge 2", +minetest.register_node("techpack_stairway:bridge2", { + description = "TechPack Bridge 2", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -226,12 +239,12 @@ minetest.register_node("tubelib_stairway:bridge2", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:bridge3", { - description = "Tubelib Bridge 3", +minetest.register_node("techpack_stairway:bridge3", { + description = "TechPack Bridge 3", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -259,12 +272,12 @@ minetest.register_node("tubelib_stairway:bridge3", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:bridge4", { - description = "Tubelib Bridge 4", +minetest.register_node("techpack_stairway:bridge4", { + description = "TechPack Bridge 4", tiles = { - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_bottom.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_bottom.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -293,12 +306,12 @@ minetest.register_node("tubelib_stairway:bridge4", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:stairway", { - description = "Tubelib Stairway", +minetest.register_node("techpack_stairway:stairway", { + description = "TechPack Stairway", tiles = { - 'tubelib_stairway_steps.png', - 'tubelib_stairway_steps.png', - 'tubelib_stairway_side.png', + 'techpack_stairway_steps.png', + 'techpack_stairway_steps.png', + 'techpack_stairway_side.png', }, drawtype = "nodebox", node_box = { @@ -331,12 +344,12 @@ minetest.register_node("tubelib_stairway:stairway", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:ladder1", { - description = "Tubelib Ladder 1", +minetest.register_node("techpack_stairway:ladder1", { + description = "TechPack Ladder 1", tiles = { - 'tubelib_stairway_steps.png', - 'tubelib_stairway_steps.png', - 'tubelib_stairway_ladder.png', + 'techpack_stairway_steps.png', + 'techpack_stairway_steps.png', + 'techpack_stairway_ladder.png', }, drawtype = "nodebox", node_box = { @@ -362,12 +375,12 @@ minetest.register_node("tubelib_stairway:ladder1", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:ladder2", { - description = "Tubelib Ladder 2", +minetest.register_node("techpack_stairway:ladder2", { + description = "TechPack Ladder 2", tiles = { - 'tubelib_stairway_steps.png', - 'tubelib_stairway_steps.png', - 'tubelib_stairway_ladder.png', + 'techpack_stairway_steps.png', + 'techpack_stairway_steps.png', + 'techpack_stairway_ladder.png', }, drawtype = "nodebox", node_box = { @@ -394,10 +407,10 @@ minetest.register_node("tubelib_stairway:ladder2", { sounds = default.node_sound_metal_defaults(), }) -minetest.register_node("tubelib_stairway:lattice", { - description = "Tubelib Lattice", +minetest.register_node("techpack_stairway:lattice", { + description = "TechPack Lattice", tiles = { - 'tubelib_stairway_lattice.png', + 'techpack_stairway_lattice.png', }, drawtype = "nodebox", node_box = { @@ -427,7 +440,7 @@ minetest.register_node("tubelib_stairway:lattice", { minetest.register_craft({ - output = "tubelib_stairway:grating 4", + output = "techpack_stairway:grating 4", recipe = { {"", "", ""}, {"dye:dark_grey", "", "default:coal_lump"}, @@ -436,7 +449,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "tubelib_stairway:handrail1 4", + output = "techpack_stairway:handrail1 4", recipe = { {"default:steel_ingot", "default:coal_lump", ""}, {"default:tin_ingot", "", ""}, @@ -445,7 +458,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "tubelib_stairway:stairway 2", + output = "techpack_stairway:stairway 2", recipe = { {"", "", "default:steel_ingot"}, {"dye:dark_grey", "default:tin_ingot", "default:coal_lump"}, @@ -454,7 +467,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "tubelib_stairway:ladder1 2", + output = "techpack_stairway:ladder1 2", recipe = { {"", "default:steel_ingot", ""}, {"dye:dark_grey", "default:tin_ingot", "default:coal_lump"}, @@ -463,7 +476,7 @@ minetest.register_craft({ }) minetest.register_craft({ - output = "tubelib_stairway:lattice 2", + output = "techpack_stairway:lattice 2", recipe = { {"default:steel_ingot", "", "default:steel_ingot"}, {"dye:dark_grey", "default:tin_ingot", "default:coal_lump"}, @@ -472,69 +485,84 @@ minetest.register_craft({ }) - minetest.register_craft({ - output = "tubelib_stairway:handrail2", + output = "techpack_stairway:handrail2", recipe = { {"", "", ""}, - {"tubelib_stairway:handrail1", "", "tubelib_stairway:handrail1"}, + {"techpack_stairway:handrail1", "", "techpack_stairway:handrail1"}, {"", "", ""}, }, }) minetest.register_craft({ - output = "tubelib_stairway:handrail3", + output = "techpack_stairway:handrail3", recipe = { - {"", "tubelib_stairway:handrail1", ""}, - {"tubelib_stairway:handrail1", "", ""}, + {"", "techpack_stairway:handrail1", ""}, + {"techpack_stairway:handrail1", "", ""}, {"", "", ""}, }, }) minetest.register_craft({ - output = "tubelib_stairway:handrail4", + output = "techpack_stairway:handrail4", recipe = { - {"", "tubelib_stairway:handrail1", ""}, - {"tubelib_stairway:handrail1", "", "tubelib_stairway:handrail1"}, + {"", "techpack_stairway:handrail1", ""}, + {"techpack_stairway:handrail1", "", "techpack_stairway:handrail1"}, {"", "", ""}, }, }) minetest.register_craft({ - output = "tubelib_stairway:bridge1", + output = "techpack_stairway:bridge1", recipe = { {"", "", ""}, - {"tubelib_stairway:handrail1", "tubelib_stairway:grating", ""}, + {"techpack_stairway:handrail1", "techpack_stairway:grating", ""}, {"", "", ""}, }, }) minetest.register_craft({ - output = "tubelib_stairway:bridge2", + output = "techpack_stairway:bridge2", recipe = { {"", "", ""}, - {"tubelib_stairway:handrail1", "tubelib_stairway:grating", "tubelib_stairway:handrail1"}, - {"", "", ""}, - }, -}) -minetest.register_craft({ - output = "tubelib_stairway:bridge3", - recipe = { - {"", "tubelib_stairway:handrail1", ""}, - {"tubelib_stairway:handrail1", "tubelib_stairway:grating", ""}, - {"", "", ""}, - }, -}) -minetest.register_craft({ - output = "tubelib_stairway:bridge4", - recipe = { - {"", "tubelib_stairway:handrail1", ""}, - {"tubelib_stairway:handrail1", "tubelib_stairway:grating", "tubelib_stairway:handrail1"}, + {"techpack_stairway:handrail1", "techpack_stairway:grating", "techpack_stairway:handrail1"}, {"", "", ""}, }, }) minetest.register_craft({ - output = "tubelib_stairway:ladder2", - recipe = {{"tubelib_stairway:ladder1"}}, + output = "techpack_stairway:bridge3", + recipe = { + {"", "techpack_stairway:handrail1", ""}, + {"techpack_stairway:handrail1", "techpack_stairway:grating", ""}, + {"", "", ""}, + }, }) + +minetest.register_craft({ + output = "techpack_stairway:bridge4", + recipe = { + {"", "techpack_stairway:handrail1", ""}, + {"techpack_stairway:handrail1", "techpack_stairway:grating", "techpack_stairway:handrail1"}, + {"", "", ""}, + }, +}) + +minetest.register_craft({ + output = "techpack_stairway:ladder2", + recipe = {{"techpack_stairway:ladder1"}}, +}) + +minetest.register_alias("tubelib_stairway:grating", "techpack_stairway:grating") +minetest.register_alias("tubelib_stairway:lattice", "techpack_stairway:lattice") +minetest.register_alias("tubelib_stairway:handrail1", "techpack_stairway:handrail1") +minetest.register_alias("tubelib_stairway:handrail2", "techpack_stairway:handrail3") +minetest.register_alias("tubelib_stairway:handrail3", "techpack_stairway:handrail4") +minetest.register_alias("tubelib_stairway:handrail4", "techpack_stairway:handrail5") +minetest.register_alias("tubelib_stairway:stairway", "techpack_stairway:stairway") +minetest.register_alias("tubelib_stairway:ladder1", "techpack_stairway:ladder1") +minetest.register_alias("tubelib_stairway:ladder2", "techpack_stairway:ladder2") +minetest.register_alias("tubelib_stairway:bridge1", "techpack_stairway:bridge1") +minetest.register_alias("tubelib_stairway:bridge2", "techpack_stairway:bridge2") +minetest.register_alias("tubelib_stairway:bridge3", "techpack_stairway:bridge3") +minetest.register_alias("tubelib_stairway:bridge4", "techpack_stairway:bridge4") diff --git a/techpack_stairway/mod.conf b/techpack_stairway/mod.conf new file mode 100644 index 0000000..73fbafe --- /dev/null +++ b/techpack_stairway/mod.conf @@ -0,0 +1,2 @@ +name=techpack_stairway + diff --git a/tubelib_stairway/textures/tubelib_stairway_bottom.png b/techpack_stairway/textures/techpack_stairway_bottom.png similarity index 100% rename from tubelib_stairway/textures/tubelib_stairway_bottom.png rename to techpack_stairway/textures/techpack_stairway_bottom.png diff --git a/tubelib_stairway/textures/tubelib_stairway_ladder.png b/techpack_stairway/textures/techpack_stairway_ladder.png similarity index 100% rename from tubelib_stairway/textures/tubelib_stairway_ladder.png rename to techpack_stairway/textures/techpack_stairway_ladder.png diff --git a/tubelib_stairway/textures/tubelib_stairway_lattice.png b/techpack_stairway/textures/techpack_stairway_lattice.png similarity index 100% rename from tubelib_stairway/textures/tubelib_stairway_lattice.png rename to techpack_stairway/textures/techpack_stairway_lattice.png diff --git a/tubelib_stairway/textures/tubelib_stairway_side.png b/techpack_stairway/textures/techpack_stairway_side.png similarity index 100% rename from tubelib_stairway/textures/tubelib_stairway_side.png rename to techpack_stairway/textures/techpack_stairway_side.png diff --git a/tubelib_stairway/textures/tubelib_stairway_steps.png b/techpack_stairway/textures/techpack_stairway_steps.png similarity index 100% rename from tubelib_stairway/textures/tubelib_stairway_steps.png rename to techpack_stairway/textures/techpack_stairway_steps.png diff --git a/techpack_warehouse/box_copper.lua b/techpack_warehouse/box_copper.lua new file mode 100644 index 0000000..1bb0f4f --- /dev/null +++ b/techpack_warehouse/box_copper.lua @@ -0,0 +1,163 @@ +--[[ + + TechPack Warehouse + ================== + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + box_copper.lua + +]]-- + +--- for lazy programmers +local S = function(pos) if pos then return minetest.pos_to_string(pos) end end +local P = minetest.string_to_pos +local M = minetest.get_meta +local wh = techpack_warehouse + +local NODE_NAME = "techpack_warehouse:box_copper" +local DESCRIPTION = "Warehouse Box Copper" +local INV_SIZE = 1200 +local BACKGROUND_IMG = "default_copper_block.png" + + +local Box = wh.Box:new({ + node_name = NODE_NAME, + description = DESCRIPTION, + inv_size = INV_SIZE, + background_img = BACKGROUND_IMG, +}) + +minetest.register_node(NODE_NAME, { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + return wh.after_place_node(Box, pos, placer, itemstack) + end, + on_receive_fields = function(pos, formname, fields, player) + wh.on_receive_fields(Box, pos, formname, fields, player) + end, + on_timer = function(pos,elapsed) + return wh.on_timer(Box, pos,elapsed) + end, + on_dig = function(pos, node, puncher, pointed_thing) + wh.on_dig(Box, pos, node, puncher, pointed_thing) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {choppy=2, cracky=2, crumbly=2}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node(NODE_NAME.."_active", { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles_active(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + return wh.after_place_node(Box, pos, placer, itemstack) + end, + on_receive_fields = function(pos, formname, fields, player) + wh.on_receive_fields(Box, pos, formname, fields, player) + end, + on_timer = function(pos,elapsed) + return wh.on_timer(Box, pos,elapsed) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {crumbly=0, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node(NODE_NAME.."_defect", { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles_defect(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + wh.after_place_node(Box, pos, placer, itemstack) + Box.State:defect(pos, M(pos)) + end, + on_dig = function(pos, node, puncher, pointed_thing) + wh.on_dig(Box, pos, node, puncher, pointed_thing) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +tubelib.register_node(NODE_NAME, + {NODE_NAME.."_active", NODE_NAME.."_defect"}, { + on_push_item = function(pos, side, item) + local meta = M(pos) + meta:set_string("push_dir", side) + local num = wh.numbers_to_shift(Box, meta, item) + if num then + item:set_count(num) + return tubelib.put_item(meta, "shift", item) + end + end, + on_pull_stack = function(pos, side) + return tubelib.get_stack(M(pos), "main") + end, + on_unpull_item = function(pos, side, item) + return tubelib.put_item(M(pos), "main", item) + end, + + on_recv_message = function(pos, topic, payload) + local resp = Box.State:on_receive_message(pos, topic, payload) + if resp then + return resp + else + return "unsupported" + end + end, + on_node_load = function(pos) + Box.State:on_node_load(pos) + end, + on_node_repair = function(pos) + return Box.State:on_node_repair(pos) + end, +}) + +minetest.register_craft({ + output = NODE_NAME, + recipe = { + {"default:copper_ingot", "tubelib:pusher", "default:copper_ingot"}, + {"default:copper_ingot", "tubelib_addons1:chest", "default:copper_ingot"}, + {"", "", ""}, + } +}) diff --git a/techpack_warehouse/box_gold.lua b/techpack_warehouse/box_gold.lua new file mode 100644 index 0000000..80c8c15 --- /dev/null +++ b/techpack_warehouse/box_gold.lua @@ -0,0 +1,163 @@ +--[[ + + TechPack Warehouse + ================== + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + box_gold.lua + +]]-- + +--- for lazy programmers +local S = function(pos) if pos then return minetest.pos_to_string(pos) end end +local P = minetest.string_to_pos +local M = minetest.get_meta +local wh = techpack_warehouse + +local NODE_NAME = "techpack_warehouse:box_gold" +local DESCRIPTION = "Warehouse Box Gold" +local INV_SIZE = 3600 +local BACKGROUND_IMG = "default_gold_block.png" + + +local Box = wh.Box:new({ + node_name = NODE_NAME, + description = DESCRIPTION, + inv_size = INV_SIZE, + background_img = BACKGROUND_IMG, +}) + +minetest.register_node(NODE_NAME, { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + return wh.after_place_node(Box, pos, placer, itemstack) + end, + on_receive_fields = function(pos, formname, fields, player) + wh.on_receive_fields(Box, pos, formname, fields, player) + end, + on_timer = function(pos,elapsed) + return wh.on_timer(Box, pos,elapsed) + end, + on_dig = function(pos, node, puncher, pointed_thing) + wh.on_dig(Box, pos, node, puncher, pointed_thing) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {choppy=2, cracky=2, crumbly=2}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node(NODE_NAME.."_active", { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles_active(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + return wh.after_place_node(Box, pos, placer, itemstack) + end, + on_receive_fields = function(pos, formname, fields, player) + wh.on_receive_fields(Box, pos, formname, fields, player) + end, + on_timer = function(pos,elapsed) + return wh.on_timer(Box, pos,elapsed) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {crumbly=0, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node(NODE_NAME.."_defect", { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles_defect(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + wh.after_place_node(Box, pos, placer, itemstack) + Box.State:defect(pos, M(pos)) + end, + on_dig = function(pos, node, puncher, pointed_thing) + wh.on_dig(Box, pos, node, puncher, pointed_thing) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +tubelib.register_node(NODE_NAME, + {NODE_NAME.."_active", NODE_NAME.."_defect"}, { + on_push_item = function(pos, side, item) + local meta = M(pos) + meta:set_string("push_dir", side) + local num = wh.numbers_to_shift(Box, meta, item) + if num then + item:set_count(num) + return tubelib.put_item(meta, "shift", item) + end + end, + on_pull_stack = function(pos, side) + return tubelib.get_stack(M(pos), "main") + end, + on_unpull_item = function(pos, side, item) + return tubelib.put_item(M(pos), "main", item) + end, + + on_recv_message = function(pos, topic, payload) + local resp = Box.State:on_receive_message(pos, topic, payload) + if resp then + return resp + else + return "unsupported" + end + end, + on_node_load = function(pos) + Box.State:on_node_load(pos) + end, + on_node_repair = function(pos) + return Box.State:on_node_repair(pos) + end, +}) + +minetest.register_craft({ + output = NODE_NAME, + recipe = { + {"default:gold_ingot", "tubelib:pusher", "default:gold_ingot"}, + {"default:gold_ingot", "tubelib_addons1:chest", "default:gold_ingot"}, + {"default:gold_ingot", "default:gold_ingot", "default:gold_ingot"}, + } +}) diff --git a/techpack_warehouse/box_steel.lua b/techpack_warehouse/box_steel.lua new file mode 100644 index 0000000..c4b91f4 --- /dev/null +++ b/techpack_warehouse/box_steel.lua @@ -0,0 +1,163 @@ +--[[ + + TechPack Warehouse + ================== + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + box_steel.lua + +]]-- + +--- for lazy programmers +local S = function(pos) if pos then return minetest.pos_to_string(pos) end end +local P = minetest.string_to_pos +local M = minetest.get_meta +local wh = techpack_warehouse + +local NODE_NAME = "techpack_warehouse:box_steel" +local DESCRIPTION = "Warehouse Box Steel" +local INV_SIZE = 400 +local BACKGROUND_IMG = "default_steel_block.png" + + +local Box = wh.Box:new({ + node_name = NODE_NAME, + description = DESCRIPTION, + inv_size = INV_SIZE, + background_img = BACKGROUND_IMG, +}) + +minetest.register_node(NODE_NAME, { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + return wh.after_place_node(Box, pos, placer, itemstack) + end, + on_receive_fields = function(pos, formname, fields, player) + wh.on_receive_fields(Box, pos, formname, fields, player) + end, + on_timer = function(pos,elapsed) + return wh.on_timer(Box, pos,elapsed) + end, + on_dig = function(pos, node, puncher, pointed_thing) + wh.on_dig(Box, pos, node, puncher, pointed_thing) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {choppy=2, cracky=2, crumbly=2}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node(NODE_NAME.."_active", { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles_active(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + return wh.after_place_node(Box, pos, placer, itemstack) + end, + on_receive_fields = function(pos, formname, fields, player) + wh.on_receive_fields(Box, pos, formname, fields, player) + end, + on_timer = function(pos,elapsed) + return wh.on_timer(Box, pos,elapsed) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {crumbly=0, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node(NODE_NAME.."_defect", { + description = DESCRIPTION.." (8 x "..INV_SIZE.." items)", + tiles = wh.tiles_defect(BACKGROUND_IMG), + + after_place_node = function(pos, placer, itemstack) + wh.after_place_node(Box, pos, placer, itemstack) + Box.State:defect(pos, M(pos)) + end, + on_dig = function(pos, node, puncher, pointed_thing) + wh.on_dig(Box, pos, node, puncher, pointed_thing) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + return wh.allow_metadata_inventory_put(Box, pos, listname, index, stack, player) + end, + on_metadata_inventory_put = wh.on_metadata_inventory_put, + allow_metadata_inventory_take = wh.allow_metadata_inventory_take, + allow_metadata_inventory_move = wh.allow_metadata_inventory_move, + + on_rotate = screwdriver.disallow, + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "facedir", + groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1}, + is_ground_content = false, + sounds = default.node_sound_metal_defaults(), +}) + +tubelib.register_node(NODE_NAME, + {NODE_NAME.."_active", NODE_NAME.."_defect"}, { + on_push_item = function(pos, side, item) + local meta = M(pos) + meta:set_string("push_dir", side) + local num = wh.numbers_to_shift(Box, meta, item) + if num then + item:set_count(num) + return tubelib.put_item(meta, "shift", item) + end + end, + on_pull_stack = function(pos, side) + return tubelib.get_stack(M(pos), "main") + end, + on_unpull_item = function(pos, side, item) + return tubelib.put_item(M(pos), "main", item) + end, + + on_recv_message = function(pos, topic, payload) + local resp = Box.State:on_receive_message(pos, topic, payload) + if resp then + return resp + else + return "unsupported" + end + end, + on_node_load = function(pos) + Box.State:on_node_load(pos) + end, + on_node_repair = function(pos) + return Box.State:on_node_repair(pos) + end, +}) + +minetest.register_craft({ + output = NODE_NAME, + recipe = { + {"default:steel_ingot", "tubelib:pusher", "default:steel_ingot"}, + {"", "tubelib_addons1:chest", ""}, + {"", "", ""}, + } +}) diff --git a/techpack_warehouse/common.lua b/techpack_warehouse/common.lua new file mode 100644 index 0000000..28dcbd7 --- /dev/null +++ b/techpack_warehouse/common.lua @@ -0,0 +1,297 @@ +--[[ + + TechPack Warehouse + ================== + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + common.lua + +]]-- + +--- for lazy programmers +local S = function(pos) if pos then return minetest.pos_to_string(pos) end end +local P = minetest.string_to_pos +local M = minetest.get_meta + +local STANDBY_TICKS = 4 +local COUNTDOWN_TICKS = 2 +local CYCLE_TIME = 2 + +local Cache = {} + +techpack_warehouse.Box = {} + +local function formspec(self, pos, meta) + return "size[10,9]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "image[0,0;1,1;techpack_warehouse_arrow_inv.png]".. + "list[context;shift;1,0;8,1;]".. + "image[9,0;1,1;techpack_warehouse_arrow_inv.png]".. + + "image[0,1.2;1,1;techpack_warehouse_filter_inv.png]".. + "list[context;filter;1,1.2;8,1;]".. + "image[9,1.2;1,1;techpack_warehouse_filter_inv.png]".. + + "image[0,2.4;1,1;techpack_warehouse_inventory_inv.png]".. + "list[context;main;1,2.4;8,1;]".. + "image[9,2.4;1,1;techpack_warehouse_inventory_inv.png]".. + + "image[0,3.6;1,1;techpack_warehouse_input_inv.png]".. + "list[context;input;1,3.6;8,1;]".. + "image[9,3.6;1,1;techpack_warehouse_input_inv.png]".. + + "image_button[9,5.3;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. + "list[current_player;main;0.5,5.3;8,4;]".. + "listring[context;shift]".. + "listring[current_player;main]".. + "listring[context;input]" +end + +local function move_to_main(pos, index) + local inv = M(pos):get_inventory() + local main_stack = inv:get_stack("main", index) + local inp_stack = inv:get_stack("input", index) + + local stack = ItemStack(inp_stack:get_name()) + stack:set_count(inp_stack:get_count() + main_stack:get_count()) + inp_stack:clear() + + inv:set_stack("main", index, stack) + inv:set_stack("input", index, inp_stack) +end + +function techpack_warehouse.tiles(background_img) + return { + -- up, down, right, left, back, front + 'tubelib_pusher1.png^tubelib_addons3_node_frame4.png', + 'tubelib_pusher1.png^tubelib_addons3_node_frame4.png', + background_img..'^techpack_warehouse_box_side.png', + background_img..'^techpack_warehouse_box_side.png', + background_img..'^techpack_warehouse_box_back.png', + background_img..'^techpack_warehouse_box_front.png', + } +end + +function techpack_warehouse.tiles_active(background_img) + return { + -- up, down, right, left, back, front + { + image = "tubelib_addons3_pusher_active.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 32, + aspect_h = 32, + length = 2.0, + }, + }, + { + image = "tubelib_addons3_pusher_active.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 32, + aspect_h = 32, + length = 2.0, + }, + }, + background_img..'^techpack_warehouse_box_side.png', + background_img..'^techpack_warehouse_box_side.png', + background_img..'^techpack_warehouse_box_back.png', + background_img..'^techpack_warehouse_box_front.png', + } +end + +function techpack_warehouse.tiles_defect(background_img) + return { + -- up, down, right, left, back, front + 'tubelib_pusher1.png^tubelib_addons3_node_frame4.png', + 'tubelib_pusher1.png^tubelib_addons3_node_frame4.png', + background_img..'^techpack_warehouse_box_side.png^tubelib_defect.png', + background_img..'^techpack_warehouse_box_side.png^tubelib_defect.png', + background_img..'^techpack_warehouse_box_back.png^tubelib_defect.png', + background_img..'^techpack_warehouse_box_front.png^tubelib_defect.png', + } +end + + + +function techpack_warehouse.Box:new(attr) + local o = { + node_name = attr.node_name, + description = attr.description, + inv_size = attr.inv_size, + background_img = attr.background_img, + } + o.State = tubelib.NodeStates:new({ + node_name_passive = attr.node_name, + node_name_active = attr.node_name.."_active", + node_name_defect = attr.node_name.."_defect", + infotext_name = attr.description, + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + has_item_meter = true, + aging_factor = 50, + formspec_func = formspec, + }) + setmetatable(o, self) + self.__index = self + return o +end + +function techpack_warehouse.numbers_to_shift(self, meta, item) + -- check cache + local number = meta:get_string("number") + local item_name = item:get_name() + if not Cache[number] then + local inv = meta:get_inventory() + Cache[number] = {} + for idx,items in ipairs(inv:get_list("filter")) do + Cache[number][idx] = items:get_name() + end + end + + -- determine number to shift + local num_items = item:get_count() + local inv_size = meta:get_int("inv_size") + local inv = meta:get_inventory() + + for idx, name in ipairs(Cache[number]) do + if item_name == name then + local stack_size = inv:get_stack("main", idx):get_count() + if stack_size == self.inv_size then -- full? + Cache[number][idx] = "" -- delete for searching + elseif (stack_size + num_items) > self.inv_size then -- limit will be reached? + inv:set_stack("main", idx, ItemStack({name = item_name, count = self.inv_size})) + Cache[number][idx] = "" -- delete for searching + -- search with the rest for further slots + num_items = num_items - (self.inv_size - stack_size) + else + inv:set_stack("main", idx, ItemStack({name = item_name, count = stack_size + num_items})) + return 0 + end + end + end + return num_items +end + +function techpack_warehouse.allow_metadata_inventory_put(self, pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + local inv = M(pos):get_inventory() + local main_stack = inv:get_stack("main", index) + local item_name = inv:get_stack("filter", index):get_name() + if listname == "input" and item_name == stack:get_name() then + return math.min(stack:get_count(), self.inv_size - main_stack:get_count()) + elseif listname == "filter" then + local number = M(pos):get_string("number") + Cache[number] = nil + return 1 + elseif listname == "shift" and item_name == main_stack:get_name() then + return stack:get_count() + end + return 0 +end + +function techpack_warehouse.on_metadata_inventory_put(pos, listname, index, stack, player) + if listname == "input" then + minetest.after(0.5, move_to_main, pos, index) + end +end + +function techpack_warehouse.allow_metadata_inventory_take(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + if listname == "main" then + local number = M(pos):get_string("number") + Cache[number] = nil + local inv = M(pos):get_inventory() + local list = inv:get_list("main") + local num = list[index]:get_count() + if num > 99 then + return 99 + else + return num + end + elseif listname == "filter" then + local number = M(pos):get_string("number") + Cache[number] = nil + return 1 + elseif listname == "shift" then + return stack:get_count() + end + return 0 +end + +function techpack_warehouse.allow_metadata_inventory_move(pos, listname, index, stack, player) + return 0 +end + +function techpack_warehouse.on_receive_fields(self, pos, formname, fields, player) + if minetest.is_protected(pos, player:get_player_name()) then + return + end + self.State:state_button_event(pos, fields) +end + +function techpack_warehouse.after_place_node(self, pos, placer, itemstack) + local meta = M(pos) + local number = tubelib.add_node(pos, self.node_name) + self.State:node_init(pos, number) + meta:set_string("player_name", placer:get_player_name()) + local inv = meta:get_inventory() + inv:set_size('shift', 8) + inv:set_size('filter', 8) + inv:set_size('main', 8) + inv:set_size('input', 8) +end + +function techpack_warehouse.on_timer(self, pos, elapsed) + local meta = M(pos) + local inv = meta:get_inventory() + if not inv:is_empty("shift") then + local number = meta:get_string("number") + local player_name = meta:get_string("player_name") + local offs = meta:get_int("offs") + local push_dir = meta:get_string("push_dir") or "R" + meta:set_int("offs", offs + 1) + for i = 0,7 do + local idx = ((i + offs) % 8) + 1 + local stack = inv:get_stack("shift", idx) + if stack:get_count() > 0 then + if tubelib.push_items(pos, push_dir, stack, player_name) then + -- The effort is needed here for the case the + -- pusher pushes into its own chest. + local num = stack:get_count() + stack = inv:get_stack("shift", idx) + stack:take_item(num) + inv:set_stack("shift", idx, stack) + self.State:keep_running(pos, meta, COUNTDOWN_TICKS) + break + else + self.State:blocked(pos, meta) + end + end + end + else + self.State:idle(pos, meta) + end + + return self.State:is_active(meta) +end + +function techpack_warehouse.on_dig(self, pos, node, puncher, pointed_thing) + local inv = M(pos):get_inventory() + if inv:is_empty("main") and inv:is_empty("shift") then + minetest.node_dig(pos, node, puncher, pointed_thing) + tubelib.remove_node(pos) + end +end diff --git a/techpack_warehouse/depends.txt b/techpack_warehouse/depends.txt new file mode 100644 index 0000000..81141c1 --- /dev/null +++ b/techpack_warehouse/depends.txt @@ -0,0 +1,3 @@ +tubelib +tubelib_addons3 + diff --git a/techpack_warehouse/description.txt b/techpack_warehouse/description.txt new file mode 100644 index 0000000..8c2eaac --- /dev/null +++ b/techpack_warehouse/description.txt @@ -0,0 +1,2 @@ +Warehouse boxes + diff --git a/techpack_warehouse/init.lua b/techpack_warehouse/init.lua new file mode 100644 index 0000000..2dac8a4 --- /dev/null +++ b/techpack_warehouse/init.lua @@ -0,0 +1,20 @@ +--[[ + + TechPack Warehouse + ================== + + Copyright (C) 2019 Joachim Stolberg + + LGPLv2.1+ + See LICENSE.txt for more information + + init.lua + +]]-- + +techpack_warehouse = {} + +dofile(minetest.get_modpath("techpack_warehouse") .. "/common.lua") +dofile(minetest.get_modpath("techpack_warehouse") .. "/box_steel.lua") +dofile(minetest.get_modpath("techpack_warehouse") .. "/box_copper.lua") +dofile(minetest.get_modpath("techpack_warehouse") .. "/box_gold.lua") diff --git a/techpack_warehouse/mod.conf b/techpack_warehouse/mod.conf new file mode 100644 index 0000000..d1c117a --- /dev/null +++ b/techpack_warehouse/mod.conf @@ -0,0 +1,2 @@ +name=techpack_warehouse + diff --git a/techpack_warehouse/textures/techpack_warehouse_arrow_inv.png b/techpack_warehouse/textures/techpack_warehouse_arrow_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..e2fdcb83cf6b45e948adbcae107d3411a638a96c GIT binary patch literal 219 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaP3?%1DUd;wlEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaMM1AIbUeKHFZI~I4Z+JErGvlftwk|4ie28U-i(m*N-JR*x37`TN&n2}-D z9FPTmo-U3d9M_W*8kku*mNG8fvLJ-HC5mBTn8S)t1s)b&fh@+Bs75E<#(-c67iZ_q zVXO@+r}8Dd^;TTw(-^>*;3cecbOG1KFcv4y1G4N4P4@Eq&s#KZ15IY|boFyt=akR{ E0B_|xNS%G}U;vjb? zhIQv;UIICs1s;*b3=G`DAk4@xYmNj^P%gkH#FdGO$tSb$!lm=KZe4%$p1&#KxL`OxJVQREsHRRvNzDzjjW^gim6g^56ZATmSIe?ox2r zay@6~Yg-w^)e}~&dp#vg{VPNI=M$IbPKha7mEPI-RY>OSyan}<7F{eUJGl=rud%mX z&{!opk?omzZ)2d2!0APIPBLk_N=RRx@$vMlFUeZaUN6Afj0)MPa+m+ zNBlkguPOM1-i3mF@P)Px#32;bRa{vGf6951U69E94oEQKA03=XMR7C;;0!(Rf z($vx2-P=1pJG{QTWP@00MMUPE#}h&AC3$0003! zNkl!lZueZuaV9@hV5c7MzlGXp2KL4rI&OcA}bg}v}ALCdCT%A!1!cW~r>#I`JnlBV2+ zgu^lbP1Zehk5f$(0)C(atAo|s2oyj^9+Ltv*OS@^Ar(<51byBnR8VgY=Zt6k{4RC) zPx#32;bRa{vGf6951U69E94oEQKA03=XMR7C>=159ag z00000007?J+|AC+)Yj8GK0E5{>AkSJ40f00eYWPE#}hL1<>to02JcP5arg*Pxy;3H7n8^J2YUR0_SatEw+n32XJ+yQIj2vrIa z1215am&@`~fJ^sr_Uv*NC|8*XWiF+>NP(XTpz^s2Ql(USV#40SckZ)Q8raNMAIR4Q zoGloXwgC6b7?d7@u!cYraDE#B2hcLim%gTk?tp)Ury9{)V2LxBxWMt1Eu*$}YO~=` z6?t*%z`o9_8YH#MJ8+o6vm#)a%Q%Xozi2l#CSeP11mftvCvbr)jh)kb0*6jvwTgSM z$ROxE8bBVJg6pwqiF<`6A!u8gF^z&+evciXvHP|qcqfm3F;cknapcjjJ~e350U!@O zYXUOS`>$~3?=;&Lad8_=9ZV4t{9Q{00000NkvXXu0mjfCK}6( literal 0 HcmV?d00001 diff --git a/techpack_warehouse/textures/techpack_warehouse_filter_inv.png b/techpack_warehouse/textures/techpack_warehouse_filter_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..7b99c932c6657619edbafb310f01be572e3dbb88 GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaP3?%1DUd;wlEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaMM1AIbUeKHFZI~I4Z+JErGvlftwk|4ie28U-i(m*N-JR*x37`TN&n2}-D z9FPUJo-U3d9M_W*8W`4wu6A;EPMDIBq0y1V^if7a!a;<2&ZQ{UDM<+rqC}+{7R(51 m6k)pBVx$llrFdn50|UdA7D=D_2;NGdK@6U*elF{r5}E)7060Ye literal 0 HcmV?d00001 diff --git a/techpack_warehouse/textures/techpack_warehouse_input_inv.png b/techpack_warehouse/textures/techpack_warehouse_input_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..e0df9fe1e939356f755f4a839015e24a7a611fe7 GIT binary patch literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaP3?%1DUd;wlEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaMM1AIbUeKHHXSM5*iSbRX9)e5AdB*-tA!Qt7BG?0n{kH}&M25w;xW@MN( z2V{Yxr;B3<$Mxid28N3l1UN*wo?16(hH)J2m@LE?sN}$Lg=3M6^8t};h8az#8m}%4 rj9MMG)*(Qn$icmZX)g0p1qOy~CVXq2W_%3+8ph!1>gTe~DWM4f97s7B literal 0 HcmV?d00001 diff --git a/techpack_warehouse/textures/techpack_warehouse_inventory_inv.png b/techpack_warehouse/textures/techpack_warehouse_inventory_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..721a8604082a0d3eb21c7aec24429d652bdd2de5 GIT binary patch literal 181 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaP3?%1DUd;wlEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaMM1AIbUeKHFZI~I4Z+JErGvlftwk|4ie28U-i(m*N-JR*x37`TN&n2}-D z9FPSXo-U3d9M_W*8kjC#xFEpN%JtzyW&?}q1Ca<0zloa5w{mfW9nj!lU`SOEE$08b Rz7D8|!PC{xWt~$(69BBgF&_W` literal 0 HcmV?d00001 diff --git a/tubelib/distributor.lua b/tubelib/distributor.lua index fa6e9a1..547ae6a 100644 --- a/tubelib/distributor.lua +++ b/tubelib/distributor.lua @@ -32,17 +32,7 @@ local COUNTDOWN_TICKS = 6 local STANDBY_TICKS = 4 local CYCLE_TIME = 2 -local State = tubelib.NodeStates:new({ - node_name_passive = "tubelib:distributor", - node_name_active = "tubelib:distributor_active", - node_name_defect = "tubelib:distributor_defect", - infotext_name = "Tubelib Distributor", - cycle_time = CYCLE_TIME, - standby_ticks = STANDBY_TICKS, - aging_factor = 10, -}) - -local function formspec(pos, meta) +local function formspec(self, pos, meta) local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false} return "size[10.5,8.5]".. default.gui_bg.. @@ -50,7 +40,7 @@ local function formspec(pos, meta) default.gui_slots.. "list[context;src;0,0;2,4;]".. "image[2,1.5;1,1;tubelib_gui_arrow.png]".. - "image_button[2,3;1,1;"..State:get_state_button_image(meta)..";state_button;]".. + "image_button[2,3;1,1;"..self:get_state_button_image(meta)..";state_button;]".. "checkbox[3,0;filter1;On;"..dump(filter[1]).."]".. "checkbox[3,1;filter2;On;"..dump(filter[2]).."]".. "checkbox[3,2;filter3;On;"..dump(filter[3]).."]".. @@ -68,7 +58,16 @@ local function formspec(pos, meta) "listring[current_player;main]" end -State:register_formspec_func(formspec) +local State = tubelib.NodeStates:new({ + node_name_passive = "tubelib:distributor", + node_name_active = "tubelib:distributor_active", + node_name_defect = "tubelib:distributor_defect", + infotext_name = "Tubelib Distributor", + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + aging_factor = 10, + formspec_func = formspec, +}) -- Return a key/value table with all items and the corresponding stack numbers local function invlist_content_as_kvlist(list) diff --git a/tubelib/node_states.lua b/tubelib/node_states.lua index 48b80e8..d9a0e31 100644 --- a/tubelib/node_states.lua +++ b/tubelib/node_states.lua @@ -94,6 +94,7 @@ function NodeStates:new(attr) start_condition_fullfilled = attr.start_condition_fullfilled or start_condition_fullfilled, on_start = attr.on_start, on_stop = attr.on_stop, + formspec_func = attr.formspec_func, } if attr.aging_factor then o.aging_level1 = attr.aging_factor * tubelib.machine_aging_value @@ -104,10 +105,6 @@ function NodeStates:new(attr) return o end -function NodeStates:register_formspec_func(func) - self.formspec_func = func -end - function NodeStates:node_init(pos, number) local meta = M(pos) meta:set_int("tubelib_state", STOPPED) @@ -122,7 +119,7 @@ function NodeStates:node_init(pos, number) meta:set_int("tubelib_aging", 0) end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end end @@ -143,7 +140,7 @@ function NodeStates:stop(pos, meta) meta:set_string("infotext", self.infotext_name.." "..number..": stopped") end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end minetest.get_node_timer(pos):stop() return true @@ -161,6 +158,7 @@ function NodeStates:start(pos, meta, called_from_on_timer) self.on_start(pos, meta, state) end meta:set_int("tubelib_state", RUNNING) + meta:set_int("tubelib_countdown", 4) if called_from_on_timer then -- timer has to be stopped once to be able to be restarted self.stop_timer = true @@ -175,7 +173,7 @@ function NodeStates:start(pos, meta, called_from_on_timer) meta:set_string("infotext", self.infotext_name.." "..number..": running") end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end minetest.get_node_timer(pos):start(self.cycle_time) return true @@ -198,7 +196,7 @@ function NodeStates:standby(pos, meta) meta:set_string("infotext", self.infotext_name.." "..number..": standby") end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks) return true @@ -222,7 +220,7 @@ function NodeStates:blocked(pos, meta) meta:set_string("infotext", self.infotext_name.." "..number..": blocked") end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks) return true @@ -243,7 +241,7 @@ function NodeStates:fault(pos, meta) meta:set_string("infotext", self.infotext_name.." "..number..": fault") end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end minetest.get_node_timer(pos):stop() return true @@ -263,7 +261,7 @@ function NodeStates:defect(pos, meta) meta:set_string("infotext", self.infotext_name.." "..number..": defect") end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end minetest.get_node_timer(pos):stop() return true @@ -408,7 +406,7 @@ function NodeStates:on_node_load(pos, not_start_timer) end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end end @@ -430,7 +428,7 @@ function NodeStates:on_node_repair(pos) meta:set_string("infotext", self.infotext_name.." "..number..": stopped") end if self.formspec_func then - meta:set_string("formspec", self.formspec_func(pos, meta)) + meta:set_string("formspec", self.formspec_func(self, pos, meta)) end return true end diff --git a/tubelib_addons1/autocrafter.lua b/tubelib_addons1/autocrafter.lua index b61d52a..73b8b06 100644 --- a/tubelib_addons1/autocrafter.lua +++ b/tubelib_addons1/autocrafter.lua @@ -24,6 +24,25 @@ local STANDBY_TICKS = 6 local COUNTDOWN_TICKS = 6 local CYCLE_TIME = 2 +local function formspec(self, pos, meta) + return "size[8,9.2]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "list[context;recipe;0,0;3,3;]".. + "image[2.8,1;1,1;tubelib_gui_arrow.png]".. + "list[context;output;3.5,1;1,1;]".. + "image_button[3.5,2;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. + "list[context;src;0,3.2;8,2;]".. + "list[context;dst;5,0;3,3;]".. + "list[current_player;main;0,5.4;8,4;]" .. + "listring[current_player;main]".. + "listring[context;src]" .. + "listring[current_player;main]".. + "listring[context;dst]" .. + "listring[current_player;main]" +end + local State = tubelib.NodeStates:new({ node_name_passive = "tubelib_addons1:autocrafter", node_name_active = "tubelib_addons1:autocrafter_active", @@ -40,29 +59,9 @@ local State = tubelib.NodeStates:new({ end return true end, + formspec_func = formspec, }) -local function formspec(pos, meta) - return "size[8,9.2]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - "list[context;recipe;0,0;3,3;]".. - "image[2.8,1;1,1;tubelib_gui_arrow.png]".. - "list[context;output;3.5,1;1,1;]".. - "image_button[3.5,2;1,1;".. State:get_state_button_image(meta) ..";state_button;]".. - "list[context;src;0,3.2;8,2;]".. - "list[context;dst;5,0;3,3;]".. - "list[current_player;main;0,5.4;8,4;]" .. - "listring[current_player;main]".. - "listring[context;src]" .. - "listring[current_player;main]".. - "listring[context;dst]" .. - "listring[current_player;main]" -end - -State:register_formspec_func(formspec) - local function count_index(invlist) local index = {} diff --git a/tubelib_addons1/fermenter.lua b/tubelib_addons1/fermenter.lua index 2ddb7f7..45f0974 100644 --- a/tubelib_addons1/fermenter.lua +++ b/tubelib_addons1/fermenter.lua @@ -24,17 +24,7 @@ local STANDBY_TICKS = 4 local COUNTDOWN_TICKS = 4 local CYCLE_TIME = 2 -local State = tubelib.NodeStates:new({ - node_name_passive = "tubelib_addons1:fermenter", - node_name_defect = "tubelib_addons1:fermenter_defect", - infotext_name = "Tubelib Fermenter", - cycle_time = CYCLE_TIME, - standby_ticks = STANDBY_TICKS, - has_item_meter = true, - aging_factor = 10, -}) - -local function formspec(pos, meta) +local function formspec(self, pos, meta) return "size[8,8]".. default.gui_bg.. default.gui_bg_img.. @@ -42,7 +32,7 @@ local function formspec(pos, meta) "list[context;src;0,0;3,3;]".. "item_image[0,0;1,1;default:leaves]".. "image[3.5,1;1,1;tubelib_gui_arrow.png]".. - "image_button[3.5,3;1,1;".. State:get_state_button_image(meta) ..";state_button;]".. + "image_button[3.5,3;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. "list[context;dst;5,0;3,3;]".. "item_image[5,0;1,1;tubelib_addons1:biogas]".. "list[current_player;main;0,4.3;8,4;]".. @@ -52,7 +42,16 @@ local function formspec(pos, meta) "listring[current_player;main]" end -State:register_formspec_func(formspec) +local State = tubelib.NodeStates:new({ + node_name_passive = "tubelib_addons1:fermenter", + node_name_defect = "tubelib_addons1:fermenter_defect", + infotext_name = "Tubelib Fermenter", + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + has_item_meter = true, + aging_factor = 10, + formspec_func = formspec, +}) local function is_leaves(name) return tubelib_addons1.FarmingNodes[name] ~= nil and diff --git a/tubelib_addons1/grinder.lua b/tubelib_addons1/grinder.lua index 67f4ab3..0fdfaf7 100644 --- a/tubelib_addons1/grinder.lua +++ b/tubelib_addons1/grinder.lua @@ -27,18 +27,7 @@ local CYCLE_TIME = 2 -- Grinder recipes local Recipes = {} -local State = tubelib.NodeStates:new({ - node_name_passive = "tubelib_addons1:grinder", - node_name_active = "tubelib_addons1:grinder_active", - node_name_defect = "tubelib_addons1:grinder_defect", - infotext_name = "Tubelib Grinder", - cycle_time = CYCLE_TIME, - standby_ticks = STANDBY_TICKS, - has_item_meter = true, - aging_factor = 10, -}) - -local function formspec(pos, meta) +local function formspec(self, pos, meta) return "size[8,8]".. default.gui_bg.. default.gui_bg_img.. @@ -46,7 +35,7 @@ local function formspec(pos, meta) "list[context;src;0,0;3,3;]".. "item_image[0,0;1,1;default:cobble]".. "image[3.5,1;1,1;tubelib_gui_arrow.png]".. - "image_button[3.5,2;1,1;".. State:get_state_button_image(meta) ..";state_button;]".. + "image_button[3.5,2;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. "list[context;dst;5,0;3,3;]".. "item_image[5,0;1,1;default:gravel]".. "list[current_player;main;0,4;8,4;]".. @@ -56,7 +45,17 @@ local function formspec(pos, meta) "listring[current_player;main]" end -State:register_formspec_func(formspec) +local State = tubelib.NodeStates:new({ + node_name_passive = "tubelib_addons1:grinder", + node_name_active = "tubelib_addons1:grinder_active", + node_name_defect = "tubelib_addons1:grinder_defect", + infotext_name = "Tubelib Grinder", + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + has_item_meter = true, + aging_factor = 10, + formspec_func = formspec, +}) local function allow_metadata_inventory_put(pos, listname, index, stack, player) if minetest.is_protected(pos, player:get_player_name()) then @@ -132,8 +131,7 @@ minetest.register_node("tubelib_addons1:grinder", { after_place_node = function(pos, placer) local number = tubelib.add_node(pos, "tubelib_addons1:grinder") State:node_init(pos, number) - local meta = M(pos) - local inv = meta:get_inventory() + local inv = M(pos):get_inventory() inv:set_size('src', 9) inv:set_size('dst', 9) end, diff --git a/tubelib_addons1/harvester.lua b/tubelib_addons1/harvester.lua index e976bf7..6fde659 100644 --- a/tubelib_addons1/harvester.lua +++ b/tubelib_addons1/harvester.lua @@ -39,6 +39,36 @@ local function working_start_pos(pos) return working_pos end +local Radius2Idx = {[4]=1 ,[6]=2, [8]=3, [10]=4, [12]=5, [14]=6, [16]=7} + +local function formspec(self, pos, meta) + -- some recalculations + local this = minetest.deserialize(meta:get_string("this")) + local endless = this.endless == 1 and "true" or "false" + local fuel = this.fuel * 100/BURNING_TIME + if self:get_state(meta) ~= tubelib.RUNNING then + fuel = 0 + end + local radius = Radius2Idx[this.radius] or 2 + + return "size[9,8]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "dropdown[0,0;1.5;radius;4,6,8,10,12,14,16;"..radius.."]".. + "label[1.6,0.2;Area radius]".. + "checkbox[0,1;endless;Run endless;"..endless.."]".. + "list[context;main;5,0;4,4;]".. + "list[context;fuel;1.5,3;1,1;]".. + "item_image[1.5,3;1,1;tubelib_addons1:biofuel]".. + "image[2.5,3;1,1;default_furnace_fire_bg.png^[lowpart:".. + fuel..":default_furnace_fire_fg.png]".. + "image_button[3.5,3;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. + "list[current_player;main;0.5,4.3;8,4;]".. + "listring[context;main]".. + "listring[current_player;main]" +end + local State = tubelib.NodeStates:new({ node_name_passive = "tubelib_addons1:harvester_base", node_name_defect = "tubelib_addons1:harvester_defect", @@ -53,10 +83,9 @@ local State = tubelib.NodeStates:new({ this.working_pos = working_start_pos(pos) meta:set_string("this", minetest.serialize(this)) end, + formspec_func = formspec, }) -local Radius2Idx = {[4]=1 ,[6]=2, [8]=3, [10]=4, [12]=5, [14]=6, [16]=7} - local function gen_working_steps() -- Working steps like a snail shell from inner to outer local t = {} @@ -81,36 +110,6 @@ end local WorkingSteps = gen_working_steps() -local function formspec(pos, meta) - -- some recalculations - local this = minetest.deserialize(meta:get_string("this")) - local endless = this.endless == 1 and "true" or "false" - local fuel = this.fuel * 100/BURNING_TIME - if State:get_state(meta) ~= tubelib.RUNNING then - fuel = 0 - end - local radius = Radius2Idx[this.radius] or 2 - - return "size[9,8]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - "dropdown[0,0;1.5;radius;4,6,8,10,12,14,16;"..radius.."]".. - "label[1.6,0.2;Area radius]".. - "checkbox[0,1;endless;Run endless;"..endless.."]".. - "list[context;main;5,0;4,4;]".. - "list[context;fuel;1.5,3;1,1;]".. - "item_image[1.5,3;1,1;tubelib_addons1:biofuel]".. - "image[2.5,3;1,1;default_furnace_fire_bg.png^[lowpart:".. - fuel..":default_furnace_fire_fg.png]".. - "image_button[3.5,3;1,1;".. State:get_state_button_image(meta) ..";state_button;]".. - "list[current_player;main;0.5,4.3;8,4;]".. - "listring[context;main]".. - "listring[current_player;main]" -end - -State:register_formspec_func(formspec) - local function allow_metadata_inventory_put(pos, listname, index, stack, player) if minetest.is_protected(pos, player:get_player_name()) then return 0 diff --git a/tubelib_addons1/liquidsampler.lua b/tubelib_addons1/liquidsampler.lua index 695349a..9c25f85 100644 --- a/tubelib_addons1/liquidsampler.lua +++ b/tubelib_addons1/liquidsampler.lua @@ -21,18 +21,7 @@ local STANDBY_TICKS = 4 local COUNTDOWN_TICKS = 2 local CYCLE_TIME = 8 -local State = tubelib.NodeStates:new({ - node_name_passive = "tubelib_addons1:liquidsampler", - node_name_active = "tubelib_addons1:liquidsampler_active", - node_name_defect = "tubelib_addons1:liquidsampler_defect", - infotext_name = "Liquid Sampler", - cycle_time = CYCLE_TIME, - standby_ticks = STANDBY_TICKS, - has_item_meter = true, - aging_factor = 8, -}) - -local function formspec(pos, meta) +local function formspec(self, pos, meta) return "size[9,8.5]".. default.gui_bg.. default.gui_bg_img.. @@ -40,7 +29,7 @@ local function formspec(pos, meta) "list[context;src;0,0;1,4;]".. "image[0,0;1,1;bucket.png]".. "image[1,1;1,1;tubelib_gui_arrow.png]".. - "image_button[1,3;1,1;".. State:get_state_button_image(meta) ..";state_button;]".. + "image_button[1,3;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. "list[context;dst;2,0;7,4;]".. "list[current_player;main;0.5,4.5;8,4;]".. "listring[current_player;main]".. @@ -50,7 +39,17 @@ local function formspec(pos, meta) "listring[current_player;main]" end -State:register_formspec_func(formspec) +local State = tubelib.NodeStates:new({ + node_name_passive = "tubelib_addons1:liquidsampler", + node_name_active = "tubelib_addons1:liquidsampler_active", + node_name_defect = "tubelib_addons1:liquidsampler_defect", + infotext_name = "Liquid Sampler", + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + has_item_meter = true, + aging_factor = 8, + formspec_func = formspec, +}) local function get_pos(pos, facedir, side) local offs = {F=0, R=1, B=2, L=3, D=4, U=5} diff --git a/tubelib_addons1/quarry.lua b/tubelib_addons1/quarry.lua index 7e37c83..af4bab8 100644 --- a/tubelib_addons1/quarry.lua +++ b/tubelib_addons1/quarry.lua @@ -35,31 +35,14 @@ local Depth2Idx = {[1]=1 ,[2]=2, [3]=3, [5]=4, [10]=5, [15]=6, [20]=7, [25]=8, [ local Level2Idx = {[2]=1, [1]=2, [0]=3, [-1]=4, [-2]=5, [-3]=6, [-5]=7, [-10]=8, [-15]=9, [-20]=10} -local State = tubelib.NodeStates:new({ - node_name_passive = "tubelib_addons1:quarry", - node_name_active = "tubelib_addons1:quarry_active", - node_name_defect = "tubelib_addons1:quarry_defect", - infotext_name = "Tubelib Quarry", - cycle_time = CYCLE_TIME, - standby_ticks = STANDBY_TICKS, - has_item_meter = true, - aging_factor = 12, - on_stop = function(pos, meta, oldstate) - if oldstate == tubelib.RUNNING then - meta:set_int("idx", 1) -- restart from the beginning - meta:set_string("quarry_pos", nil) - end - end, -}) - -local function formspec(pos, meta) +local function formspec(self, pos, meta) local depth = meta:get_int("max_levels") or 1 local start_level = meta:get_int("start_level") or 1 local endless = meta:get_int("endless") or 0 local fuel = meta:get_int("fuel") or 0 -- some recalculations endless = endless == 1 and "true" or "false" - if State:get_state(meta) ~= tubelib.RUNNING then + if self:get_state(meta) ~= tubelib.RUNNING then fuel = fuel * 100/BURNING_TIME else fuel = 0 @@ -79,13 +62,29 @@ local function formspec(pos, meta) "item_image[1.5,3;1,1;tubelib_addons1:biofuel]".. "image[2.5,3;1,1;default_furnace_fire_bg.png^[lowpart:".. fuel..":default_furnace_fire_fg.png]".. - "image_button[3.5,3;1,1;".. State:get_state_button_image(meta) ..";state_button;]".. + "image_button[3.5,3;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. "list[current_player;main;0.5,4.3;8,4;]".. "listring[context;main]".. "listring[current_player;main]" end -State:register_formspec_func(formspec) +local State = tubelib.NodeStates:new({ + node_name_passive = "tubelib_addons1:quarry", + node_name_active = "tubelib_addons1:quarry_active", + node_name_defect = "tubelib_addons1:quarry_defect", + infotext_name = "Tubelib Quarry", + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + has_item_meter = true, + aging_factor = 12, + on_stop = function(pos, meta, oldstate) + if oldstate == tubelib.RUNNING then + meta:set_int("idx", 1) -- restart from the beginning + meta:set_string("quarry_pos", nil) + end + end, + formspec_func = formspec, +}) local function get_pos(pos, facedir, side, steps) facedir = (facedir + Side2Facedir[side]) % 4 diff --git a/tubelib_addons1/reformer.lua b/tubelib_addons1/reformer.lua index d4fd3b3..2d18237 100644 --- a/tubelib_addons1/reformer.lua +++ b/tubelib_addons1/reformer.lua @@ -24,17 +24,7 @@ local STANDBY_TICKS = 4 local COUNTDOWN_TICKS = 4 local CYCLE_TIME = 2 -local State = tubelib.NodeStates:new({ - node_name_passive = "tubelib_addons1:reformer", - node_name_defect = "tubelib_addons1:reformer_defect", - infotext_name = "Tubelib Reformer", - cycle_time = CYCLE_TIME, - standby_ticks = STANDBY_TICKS, - has_item_meter = true, - aging_factor = 10, -}) - -local function formspec(pos, meta) +local function formspec(self, pos, meta) return "size[8,8]".. default.gui_bg.. default.gui_bg_img.. @@ -42,7 +32,7 @@ local function formspec(pos, meta) "list[context;src;0,0;3,3;]".. "item_image[0,0;1,1;tubelib_addons1:biogas]".. "image[3.5,1;1,1;tubelib_gui_arrow.png]".. - "image_button[3.5,3;1,1;".. State:get_state_button_image(meta) ..";state_button;]".. + "image_button[3.5,3;1,1;".. self:get_state_button_image(meta) ..";state_button;]".. "list[context;dst;5,0;3,3;]".. "item_image[5,0;1,1;tubelib_addons1:biofuel]".. "list[current_player;main;0,4.3;8,4;]".. @@ -52,7 +42,16 @@ local function formspec(pos, meta) "listring[current_player;main]" end -State:register_formspec_func(formspec) +local State = tubelib.NodeStates:new({ + node_name_passive = "tubelib_addons1:reformer", + node_name_defect = "tubelib_addons1:reformer_defect", + infotext_name = "Tubelib Reformer", + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + has_item_meter = true, + aging_factor = 10, + formspec_func = formspec, +}) local function allow_metadata_inventory_put(pos, listname, index, stack, player) if minetest.is_protected(pos, player:get_player_name()) then diff --git a/tubelib_addons3/distributor.lua b/tubelib_addons3/distributor.lua index bb32413..4e7911d 100644 --- a/tubelib_addons3/distributor.lua +++ b/tubelib_addons3/distributor.lua @@ -25,17 +25,7 @@ local COUNTDOWN_TICKS = 6 local STANDBY_TICKS = 4 local CYCLE_TIME = 2 -local State = tubelib.NodeStates:new({ - node_name_passive = "tubelib_addons3:distributor", - node_name_active = "tubelib_addons3:distributor_active", - node_name_defect = "tubelib_addons3:distributor_defect", - infotext_name = "HighPerf Distributor", - cycle_time = CYCLE_TIME, - standby_ticks = STANDBY_TICKS, - aging_factor = 50, -}) - -local function formspec(pos, meta) +local function formspec(self, pos, meta) local filter = minetest.deserialize(meta:get_string("filter")) return "size[10.5,8.5]".. default.gui_bg.. @@ -43,7 +33,7 @@ local function formspec(pos, meta) default.gui_slots.. "list[context;src;0,0;2,4;]".. "image[2,1.5;1,1;tubelib_gui_arrow.png]".. - "image_button[2,3;1,1;"..State:get_state_button_image(meta)..";state_button;]".. + "image_button[2,3;1,1;"..self:get_state_button_image(meta)..";state_button;]".. "checkbox[3,0;filter1;On;"..dump(filter[1]).."]".. "checkbox[3,1;filter2;On;"..dump(filter[2]).."]".. "checkbox[3,2;filter3;On;"..dump(filter[3]).."]".. @@ -61,7 +51,16 @@ local function formspec(pos, meta) "listring[current_player;main]" end -State:register_formspec_func(formspec) +local State = tubelib.NodeStates:new({ + node_name_passive = "tubelib_addons3:distributor", + node_name_active = "tubelib_addons3:distributor_active", + node_name_defect = "tubelib_addons3:distributor_defect", + infotext_name = "HighPerf Distributor", + cycle_time = CYCLE_TIME, + standby_ticks = STANDBY_TICKS, + aging_factor = 50, + formspec_func = formspec, +}) -- Return the total number of list entries local function invlist_num_entries(list) diff --git a/tubelib_addons3/pushing_chest.lua b/tubelib_addons3/pushing_chest.lua index 5afcfb7..161b5c1 100644 --- a/tubelib_addons3/pushing_chest.lua +++ b/tubelib_addons3/pushing_chest.lua @@ -239,7 +239,7 @@ minetest.register_node("tubelib_addons3:pushing_chest_defect", { paramtype = "light", sunlight_propagates = true, paramtype2 = "facedir", - groups = {choppy=2, cracky=2, crumbly=2}, + groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1}, is_ground_content = false, sounds = default.node_sound_wood_defaults(), }) diff --git a/tubelib_stairway/mod.conf b/tubelib_stairway/mod.conf deleted file mode 100644 index e3d8579..0000000 --- a/tubelib_stairway/mod.conf +++ /dev/null @@ -1,2 +0,0 @@ -name=tubelib_stairway -