New mod tubelib_stairway added,

further bug fixes and improvements
This commit is contained in:
Joachim Stolberg 2018-12-29 21:02:23 +01:00
parent c5f8e29f10
commit 667739acfe
17 changed files with 343 additions and 66 deletions

@ -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)**

@ -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)

@ -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,
},
{

@ -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",
},
{

@ -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,

@ -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)

@ -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

@ -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 = {} -- {<item:name> = 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 = {} -- {<item:name> = 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",

@ -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)

@ -0,0 +1,2 @@
default

@ -0,0 +1,2 @@
Simple stairways and bridges for your machines.

283
tubelib_stairway/init.lua Normal file

@ -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"}},
})

@ -0,0 +1,2 @@
name=tubelib_stairway

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B