diff --git a/README.md b/README.md index 38a9f7b..4c1a56a 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,9 @@ **For your world use the stable release ![v1.16](https://github.com/joe7575/techpack/releases/tag/v1.16)** -## Planned for v2 -- switch to library tubelib2 -- introduce a new machine state model -- add new machine state "defect" -- add a tubelib Repair Kit for defect blocks -- Forceload block as part of tubelib -- support for intllib -- optionally disable the cobble/ore generation - - -## Current state +## Current v2 state - Switch to tubelib2 is done (not fully tested). -- Pusher, Distributor, and Grinder already support the new state 'defect'. +- Almost all machines already support the new state 'defect'. - The Repair Kit is available and can be used to repair defect machines. - The mod 'basic_materials' is now needed for some new recipes. - Due to server crashes I can happen that all loaded nodes loose their timers. Therefore, all "timed" nodes got an "on_node_load" function, which is used to restart the timer. @@ -26,12 +16,12 @@ The cobble generation produces Basalt Stone which can be crafted to Basalt Stone Blocks and Basalt Stone Bricks - Quarry now uses LVM techniques to go down up to 100 meter - settingtypes introduced with the following settings: tubelib_max_num_forceload_blocks, tubelib_basalt_stone_enabled, tubelib_machine_aging_value +- Ladders, stairways, and bridges (tubelib_stairway) ## To Do - adapt API.md - revise Wiki -- expand controllers by the state defect @@ -53,7 +43,7 @@ TechPack is a collection of following Mods: * safer_lua, a subset of the language Lua for safe and secure Lua sandboxes * SaferLua Controller - a controller to be programmed in LUA * lcdlib - a display lib used by smartline - +* tubelib_stairway - Ladders, stairways, and bridges for machines **A TechPack Tutorial is available as ![Wiki](https://github.com/joe7575/techpack/wiki)** diff --git a/gravelsieve/init.lua b/gravelsieve/init.lua index 9d4aaad..59a804f 100644 --- a/gravelsieve/init.lua +++ b/gravelsieve/init.lua @@ -53,8 +53,8 @@ local PROBABILITY_FACTOR = 3 local AGING_LEVEL1 = nil local AGING_LEVEL2 = nil if minetest.get_modpath("tubelib") and tubelib ~= nil then - AGING_LEVEL1 = 1 * tubelib.machine_aging_value - AGING_LEVEL2 = 3 * tubelib.machine_aging_value + AGING_LEVEL1 = 10 * tubelib.machine_aging_value + AGING_LEVEL2 = 30 * tubelib.machine_aging_value end -- Ore probability table (1/n) diff --git a/smartline/commands.lua b/smartline/commands.lua index ba78d25..4c054bb 100644 --- a/smartline/commands.lua +++ b/smartline/commands.lua @@ -256,7 +256,7 @@ smartline.register_condition("pusher", { type = "textlist", name = "value", label = "is", - choices = "stopped,running,standby,blocked,fault,false", + choices = "stopped,running,standby,blocked,fault,defect,false", default = 1, }, { diff --git a/smartline/icta/commands.lua b/smartline/icta/commands.lua index 945ae4c..58e4265 100644 --- a/smartline/icta/commands.lua +++ b/smartline/icta/commands.lua @@ -163,7 +163,7 @@ smartline.icta_register_condition("state", { type = "textlist", name = "value", label = "", - choices = "stopped,running,standby,blocked,fault", + choices = "stopped,running,standby,blocked,defect,fault,never", default = "stopped", }, { diff --git a/tubelib/distributor.lua b/tubelib/distributor.lua index d5cb2ec..a170c6a 100644 --- a/tubelib/distributor.lua +++ b/tubelib/distributor.lua @@ -446,9 +446,9 @@ minetest.register_node("tubelib:distributor_defect", { meta:set_string("item_counter", minetest.serialize({red=0, green=0, blue=0, yellow=0})) State:defect(pos, meta) end, - + on_receive_fields = on_receive_fields, - + allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_move = allow_metadata_inventory_move, diff --git a/tubelib_addons1/liquidsampler.lua b/tubelib_addons1/liquidsampler.lua index 8b91016..34983d6 100644 --- a/tubelib_addons1/liquidsampler.lua +++ b/tubelib_addons1/liquidsampler.lua @@ -138,7 +138,7 @@ minetest.register_node("tubelib_addons1:liquidsampler", { }, after_place_node = function(pos, placer) - local number = tubelib.add_node(pos, "tubelib_addons1:grinder") + local number = tubelib.add_node(pos, "ttubelib_addons1:liquidsampler") State:node_init(pos, number) local meta = M(pos) local node = minetest.get_node(pos) diff --git a/tubelib_addons1/pusher_fast.lua b/tubelib_addons1/pusher_fast.lua index 7d9343a..31a68fe 100644 --- a/tubelib_addons1/pusher_fast.lua +++ b/tubelib_addons1/pusher_fast.lua @@ -46,16 +46,16 @@ local State = tubelib.NodeStates:new({ cycle_time = CYCLE_TIME, standby_ticks = STANDBY_TICKS, has_item_meter = true, - aging_factor = 10, + aging_factor = 30, }) local function pushing(pos, meta) local player_name = meta:get_string("player_name") - local items = tubelib.pull_items(pos, "L", player_name) -- <<=== tubelib + local items = tubelib.pull_items(pos, "L", player_name) if items ~= nil then - if tubelib.push_items(pos, "R", items, player_name) == false then -- <<=== tubelib + if tubelib.push_items(pos, "R", items, player_name) == false then -- place item back - tubelib.unpull_items(pos, "L", items, player_name) -- <<=== tubelib + tubelib.unpull_items(pos, "L", items, player_name) State:blocked(pos, meta) return end @@ -86,7 +86,7 @@ minetest.register_node("tubelib_addons1:pusher_fast", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) meta:set_string("player_name", placer:get_player_name()) - local number = tubelib.add_node(pos, "tubelib_addons1:pusher_fast") -- <<=== tubelib + local number = tubelib.add_node(pos, "tubelib_addons1:pusher_fast") State:node_init(pos, number) end, @@ -97,7 +97,7 @@ minetest.register_node("tubelib_addons1:pusher_fast", { end, after_dig_node = function(pos, oldnode, oldmetadata, digger) - tubelib.remove_node(pos) -- <<=== tubelib + tubelib.remove_node(pos) State:after_dig_node(pos, oldnode, oldmetadata, digger) end, @@ -194,13 +194,13 @@ minetest.register_node("tubelib_addons1:pusher_fast_defect", { after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) meta:set_string("player_name", placer:get_player_name()) - local number = tubelib.add_node(pos, "tubelib_addons1:pusher") -- <<=== tubelib + local number = tubelib.add_node(pos, "tubelib_addons1:pusher_fast") State:node_init(pos, number) State:defect(pos, meta) end, after_dig_node = function(pos) - tubelib.remove_node(pos) -- <<=== tubelib + tubelib.remove_node(pos) end, on_timer = keep_running, @@ -224,7 +224,6 @@ minetest.register_craft({ }, }) ---------------------------------------------------------------- tubelib tubelib.register_node("tubelib_addons1:pusher_fast", {"tubelib_addons1:pusher_fast_active", "tubelib_addons1:pusher_fast_defect"}, { on_pull_item = nil, -- pusher has no inventory @@ -247,4 +246,3 @@ tubelib.register_node("tubelib_addons1:pusher_fast", return State:on_node_repair(pos) end, }) ---------------------------------------------------------------- tubelib diff --git a/tubelib_addons3/distributor.lua b/tubelib_addons3/distributor.lua index e0bd072..8dd3783 100644 --- a/tubelib_addons3/distributor.lua +++ b/tubelib_addons3/distributor.lua @@ -3,7 +3,7 @@ Tubelib Addons 3 ================ - Copyright (C) 2018 Joachim Stolberg + Copyright (C) 2018-2019 Joachim Stolberg LGPLv2.1+ See LICENSE.txt for more information @@ -111,6 +111,38 @@ local function random_list_elem(list) end end +local Side2Color = {B="red", L="green", F="blue", R="yellow"} +local SlotColors = {"red", "green", "blue", "yellow"} +local Num2Ascii = {"B", "L", "F", "R"} +local FilterCache = {} -- local cache for filter settings + +local function filter_settings(pos) + local hash = minetest.hash_node_position(pos) + local meta = M(pos) + local inv = meta:get_inventory() + local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false} + local kvFilterItemNames = {} -- { = side,...} + local OpenPorts = {} -- {side, ...} + + -- collect all filter settings + for idx,slot in ipairs(SlotColors) do + local side = Num2Ascii[idx] + if filter[idx] == true then + local list = inv:get_list(slot) + local filter = invlist_entries_as_list(list) + AddToTbl(kvFilterItemNames, filter, side) + if not next(filter) then + OpenPorts[#OpenPorts + 1] = side + end + end + end + + FilterCache[hash] = { + kvFilterItemNames = kvFilterItemNames, + OpenPorts = OpenPorts, + } +end + local function allow_metadata_inventory_put(pos, listname, index, stack, player) local meta = M(pos) local inv = meta:get_inventory() @@ -146,38 +178,6 @@ local function allow_metadata_inventory_move(pos, from_list, from_index, to_list return allow_metadata_inventory_put(pos, to_list, to_index, stack, player) end -local Side2Color = {B="red", L="green", F="blue", R="yellow"} -local SlotColors = {"red", "green", "blue", "yellow"} -local Num2Ascii = {"B", "L", "F", "R"} -local FilterCache = {} -- local cache for filter settings - -local function filter_settings(pos) - local hash = minetest.hash_node_position(pos) - local meta = M(pos) - local inv = meta:get_inventory() - local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false} - local kvFilterItemNames = {} -- { = side,...} - local OpenPorts = {} -- {side, ...} - - -- collect all filter settings - for idx,slot in ipairs(SlotColors) do - local side = Num2Ascii[idx] - if filter[idx] == true then - local list = inv:get_list(slot) - local filter = invlist_entries_as_list(list) - AddToTbl(kvFilterItemNames, filter, side) - if not next(filter) then - OpenPorts[#OpenPorts + 1] = side - end - end - end - - FilterCache[hash] = { - kvFilterItemNames = kvFilterItemNames, - OpenPorts = OpenPorts, - } -end - -- move items to the output slots local function distributing(pos, meta) local player_name = meta:get_string("player_name") @@ -438,7 +438,7 @@ minetest.register_node("tubelib_addons3:distributor_defect", { allow_metadata_inventory_move = allow_metadata_inventory_move, on_rotate = screwdriver.disallow, - + paramtype = "light", sunlight_propagates = true, paramtype2 = "facedir", diff --git a/tubelib_addons3/pusher.lua b/tubelib_addons3/pusher.lua index 14b2c41..0d9ec33 100644 --- a/tubelib_addons3/pusher.lua +++ b/tubelib_addons3/pusher.lua @@ -31,7 +31,7 @@ local State = tubelib.NodeStates:new({ cycle_time = CYCLE_TIME, standby_ticks = STANDBY_TICKS, has_item_meter = true, - aging_factor = 10, + aging_factor = 60, }) local function pushing(pos, meta) diff --git a/tubelib_stairway/depends.txt b/tubelib_stairway/depends.txt new file mode 100644 index 0000000..3a7daa1 --- /dev/null +++ b/tubelib_stairway/depends.txt @@ -0,0 +1,2 @@ +default + diff --git a/tubelib_stairway/description.txt b/tubelib_stairway/description.txt new file mode 100644 index 0000000..1769ea4 --- /dev/null +++ b/tubelib_stairway/description.txt @@ -0,0 +1,2 @@ +Simple stairways and bridges for your machines. + diff --git a/tubelib_stairway/init.lua b/tubelib_stairway/init.lua new file mode 100644 index 0000000..2e2fa50 --- /dev/null +++ b/tubelib_stairway/init.lua @@ -0,0 +1,283 @@ +minetest.register_node("tubelib_stairway:bridge1", { + description = "Tubelib Bridge 1", + tiles = { + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_side.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + { 15/32, -17/32, -17/32, 17/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, -15/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, 17/32, -14/32, 17/32} + }, + }, + + selection_box = { + type = "fixed", + fixed = { + {-16/32, -16/32, -16/32, 16/32, -14/32, 16/32}, + }, + }, + + --climbable = true, + paramtype2 = "facedir", + paramtype = "light", + sunlight_propagates = true, + use_texture_alpha = true, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node("tubelib_stairway:bridge2", { + description = "Tubelib Bridge 2", + tiles = { + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_side.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-17/32, -17/32, -17/32, -15/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, 17/32, -14/32, 17/32} + }, + }, + + selection_box = { + type = "fixed", + fixed = { + {-16/32, -16/32, -16/32, 16/32, -14/32, 16/32}, + }, + }, + + --climbable = true, + paramtype2 = "facedir", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node("tubelib_stairway:bridge3", { + description = "Tubelib Bridge 3", + tiles = { + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_side.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-17/32, -17/32, 15/32, 17/32, 17/32, 17/32}, + { 15/32, -17/32, -17/32, 17/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, -15/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, 17/32, -14/32, 17/32} + }, + }, + + selection_box = { + type = "fixed", + fixed = { + {-16/32, -16/32, -16/32, 16/32, -14/32, 16/32}, + }, + }, + + --climbable = true, + paramtype2 = "facedir", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node("tubelib_stairway:bridge4", { + description = "Tubelib Bridge 4", + tiles = { + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_bottom.png', + 'tubelib_stairway_side.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-17/32, -17/32, 15/32, 17/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, -15/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, 17/32, -14/32, 17/32} + }, + }, + + selection_box = { + type = "fixed", + fixed = { + {-16/32, -16/32, -16/32, 16/32, -14/32, 16/32}, + }, + }, + + --climbable = true, + paramtype2 = "facedir", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_metal_defaults(), +}) +minetest.register_node("tubelib_stairway:stairway", { + description = "Tubelib Stairway", + tiles = { + 'tubelib_stairway_steps.png', + 'tubelib_stairway_steps.png', + 'tubelib_stairway_side.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + { 15/32, -1/32, -1/32, 17/32, 49/32, 17/32}, + {-17/32, -1/32, -1/32, -15/32, 49/32, 17/32}, + {-17/32, -1/32, -1/32, 17/32, 1/32, 17/32}, + + { 15/32, -17/32, -17/32, 17/32, 33/32, 1/32}, + {-17/32, -17/32, -17/32, -15/32, 33/32, 1/32}, + {-17/32, -17/32, -17/32, 17/32, -15/32, 1/32}, + }, + }, + + selection_box = { + type = "fixed", + fixed = { + {-17/32, -1/32, -1/32, 17/32, 1/32, 17/32}, + {-17/32, -17/32, -17/32, 17/32, -15/32, 1/32}, + }, + }, + + --climbable = true, + paramtype2 = "facedir", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node("tubelib_stairway:ladder1", { + description = "Tubelib Ladder 1", + tiles = { + 'tubelib_stairway_steps.png', + 'tubelib_stairway_steps.png', + 'tubelib_stairway_ladder.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-17/32, -17/32, 15/32, 17/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, -15/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, 17/32, 17/32, -15/32}, + { 15/32, -17/32, -17/32, 17/32, 17/32, 17/32}, + }, + }, + selection_box = { + type = "fixed", + fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16}, + }, + + climbable = true, + paramtype2 = "facedir", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_node("tubelib_stairway:ladder2", { + description = "Tubelib Ladder 2", + tiles = { + 'tubelib_stairway_steps.png', + 'tubelib_stairway_steps.png', + 'tubelib_stairway_ladder.png', + }, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-17/32, -17/32, 15/32, 17/32, 17/32, 17/32}, + {-17/32, -17/32, -17/32, -15/32, 17/32, 17/32}, + --{-17/32, -17/32, -17/32, 17/32, 17/32, -15/32}, + { 15/32, -17/32, -17/32, 17/32, 17/32, 17/32}, + }, + }, + + selection_box = { + type = "fixed", + fixed = {-8/16, -8/16, -8/16, 8/16, 8/16, 8/16}, + }, + + climbable = true, + paramtype2 = "facedir", + paramtype = "light", + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_metal_defaults(), +}) + +minetest.register_craft({ + output = "tubelib_stairway:bridge1", + recipe = { + {"", "", ""}, + {"dye:dark_grey", "", "default:coal_lump"}, + {"default:steel_ingot", "default:tin_ingot", "default:steel_ingot"}, + }, +}) + +minetest.register_craft({ + output = "tubelib_stairway:bridge3", + recipe = { + {"", "", ""}, + {"default:coal_lump", "", "dye:dark_grey"}, + {"default:steel_ingot", "default:tin_ingot", "default:steel_ingot"}, + }, +}) + +minetest.register_craft({ + output = "tubelib_stairway:stairway", + recipe = { + {"", "", "default:steel_ingot"}, + {"dye:dark_grey", "default:tin_ingot", "default:coal_lump"}, + {"default:steel_ingot", "", ""}, + }, +}) + +minetest.register_craft({ + output = "tubelib_stairway:ladder1", + recipe = { + {"", "default:steel_ingot", ""}, + {"dye:dark_grey", "default:tin_ingot", "default:coal_lump"}, + {"", "default:steel_ingot", ""}, + }, +}) + +minetest.register_craft({ + output = "tubelib_stairway:ladder2", + recipe = {{"tubelib_stairway:ladder1"}}, +}) + +minetest.register_craft({ + output = "tubelib_stairway:bridge2", + recipe = {{"tubelib_stairway:bridge1"}}, +}) + +minetest.register_craft({ + output = "tubelib_stairway:bridge4", + recipe = {{"tubelib_stairway:bridge3"}}, +}) diff --git a/tubelib_stairway/mod.conf b/tubelib_stairway/mod.conf new file mode 100644 index 0000000..e3d8579 --- /dev/null +++ b/tubelib_stairway/mod.conf @@ -0,0 +1,2 @@ +name=tubelib_stairway + diff --git a/tubelib_stairway/textures/tubelib_stairway_bottom.png b/tubelib_stairway/textures/tubelib_stairway_bottom.png new file mode 100644 index 0000000..d806d42 Binary files /dev/null and b/tubelib_stairway/textures/tubelib_stairway_bottom.png differ diff --git a/tubelib_stairway/textures/tubelib_stairway_grating.png b/tubelib_stairway/textures/tubelib_stairway_grating.png new file mode 100644 index 0000000..6a0776e Binary files /dev/null and b/tubelib_stairway/textures/tubelib_stairway_grating.png differ diff --git a/tubelib_stairway/textures/tubelib_stairway_ladder.png b/tubelib_stairway/textures/tubelib_stairway_ladder.png new file mode 100644 index 0000000..68a61e9 Binary files /dev/null and b/tubelib_stairway/textures/tubelib_stairway_ladder.png differ diff --git a/tubelib_stairway/textures/tubelib_stairway_steps.png b/tubelib_stairway/textures/tubelib_stairway_steps.png new file mode 100644 index 0000000..4c75c7a Binary files /dev/null and b/tubelib_stairway/textures/tubelib_stairway_steps.png differ