mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 15:23:43 +01:00
Merge pull request #46 from BlockySurvival/master
merge fork from BlockySurvival back to base
This commit is contained in:
commit
74ec940932
@ -91,6 +91,41 @@ local function calculate_probability(item)
|
||||
item.clust_scarcity / (item.clust_num_ores * ((ymax - ymin) / y_spread))
|
||||
end
|
||||
|
||||
local function pairs_by_values(t, f)
|
||||
if not f then
|
||||
f = function(a, b) return a < b end
|
||||
end
|
||||
local s = {}
|
||||
for k, v in pairs(t) do
|
||||
table.insert(s, {k, v})
|
||||
end
|
||||
table.sort(s, function(a, b)
|
||||
return f(a[2], b[2])
|
||||
end)
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
local v = s[i]
|
||||
if v then
|
||||
return unpack(v)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function parse_drop(drop)
|
||||
local d, count = drop:match("^%s*(%S+)%s+(%d+)%s*$")
|
||||
if d and count then
|
||||
return d, count
|
||||
end
|
||||
d, count = drop:match("%s*craft%s+\"?([^%s\"]+)\"?%s+(%d+)%s*")
|
||||
if d and count then
|
||||
return d, count
|
||||
end
|
||||
return drop, 1
|
||||
end
|
||||
|
||||
-- collect all registered ores and calculate the probability
|
||||
local function add_ores()
|
||||
for _,item in pairs(minetest.registered_ores) do
|
||||
@ -104,7 +139,10 @@ local function add_ores()
|
||||
and item.clust_scarcity ~= nil and item.clust_scarcity > 0
|
||||
and item.clust_num_ores ~= nil and item.clust_num_ores > 0
|
||||
and item.y_max ~= nil and item.y_min ~= nil then
|
||||
local probability = calculate_probability(item)
|
||||
local count
|
||||
drop, count = parse_drop(drop)
|
||||
|
||||
local probability = calculate_probability(item) / count
|
||||
if probability > 0 then
|
||||
local cur_probability = gravelsieve.ore_probability[drop]
|
||||
if cur_probability then
|
||||
@ -116,12 +154,13 @@ local function add_ores()
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.log("action", "[gravelsieve] ore probabilties:")
|
||||
local overall_probability = 0.0
|
||||
for name,probability in pairs(gravelsieve.ore_probability) do
|
||||
minetest.log("info", ("[gravelsieve] %-32s %.02f"):format(name, probability))
|
||||
for name,probability in pairs_by_values(gravelsieve.ore_probability) do
|
||||
minetest.log("action", ("[gravelsieve] %-32s: 1 / %.02f"):format(name, probability))
|
||||
overall_probability = overall_probability + 1.0/probability
|
||||
end
|
||||
minetest.log("info", ("[gravelsieve] Overall probability %f"):format(overall_probability))
|
||||
minetest.log("action", ("[gravelsieve] Overall probability %f"):format(overall_probability))
|
||||
end
|
||||
|
||||
minetest.after(1, add_ores)
|
||||
|
1
modpack.conf
Normal file
1
modpack.conf
Normal file
@ -0,0 +1 @@
|
||||
name = techpack
|
@ -1,2 +1,3 @@
|
||||
name=techpack_stairway
|
||||
|
||||
description=Simple stairways and bridges for your machines.
|
||||
depends=default
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
|
||||
common.lua
|
||||
|
||||
]]--
|
||||
@ -36,24 +36,24 @@ local function formspec(self, pos, meta)
|
||||
"list[context;shift;1,0;7,1;]"..
|
||||
"image_button[9,0;1,1;techpack_warehouse_arrow_inv.png;shift;;true;false;]"..
|
||||
"image_button[8,0;1,1;".. self:get_state_button_image(meta) ..";state_button;]"..
|
||||
|
||||
|
||||
"image_button[0,1.4;1,1;techpack_warehouse_filter_inv.png;filter;;true;false;]"..
|
||||
"list[context;filter;1,1.4;8,1;]"..
|
||||
"image_button[9,1.4;1,1;techpack_warehouse_filter_inv.png;filter;;true;false;]"..
|
||||
|
||||
|
||||
"image_button[0,2.5;1,1;techpack_warehouse_inventory_inv.png;storage;;true;false;]"..
|
||||
"list[context;main;1,2.5;8,1;]"..
|
||||
"image_button[9,2.5;1,1;techpack_warehouse_inventory_inv.png;storage;;true;false;]"..
|
||||
|
||||
|
||||
"image_button[0,3.6;1,1;techpack_warehouse_input_inv.png;input;;true;false;]"..
|
||||
"list[context;input;1,3.6;8,1;]"..
|
||||
"image_button[9,3.6;1,1;techpack_warehouse_input_inv.png;input;;true;false;]"..
|
||||
|
||||
|
||||
"tooltip[shift;Pass-through storage for unconfigured items (turn on/off)]"..
|
||||
"tooltip[filter;Filter: To configure the 8 storages]"..
|
||||
"tooltip[storage;Storage: All items will be stored here]"..
|
||||
"tooltip[input;Input: Put items will be moved to the storage, if configured]"..
|
||||
|
||||
|
||||
"list[current_player;main;1,5.3;8,4;]"..
|
||||
"listring[context;shift]"..
|
||||
"listring[current_player;main]"..
|
||||
@ -64,12 +64,12 @@ 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)
|
||||
|
||||
|
||||
if inp_stack:get_name() ~= "" then
|
||||
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
|
||||
@ -178,12 +178,12 @@ function techpack_warehouse.numbers_to_shift(self, meta, item)
|
||||
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()
|
||||
@ -206,6 +206,10 @@ 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
|
||||
elseif stack:get_wear() ~= 0 then
|
||||
return 0
|
||||
elseif stack:get_stack_max() == 1 then
|
||||
return 0
|
||||
end
|
||||
local inv = M(pos):get_inventory()
|
||||
local main_stack = inv:get_stack("main", index)
|
||||
@ -275,7 +279,7 @@ function techpack_warehouse.after_place_node(self, pos, placer, itemstack)
|
||||
inv:set_size('main', 8)
|
||||
inv:set_size('input', 8)
|
||||
end
|
||||
|
||||
|
||||
function techpack_warehouse.on_timer(self, pos, elapsed)
|
||||
if tubelib.data_not_corrupted(pos) then
|
||||
local meta = M(pos)
|
||||
@ -292,7 +296,7 @@ function techpack_warehouse.on_timer(self, pos, elapsed)
|
||||
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
|
||||
-- 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)
|
||||
@ -308,12 +312,12 @@ function techpack_warehouse.on_timer(self, pos, elapsed)
|
||||
else
|
||||
self.State:idle(pos, meta)
|
||||
end
|
||||
|
||||
|
||||
return self.State:is_active(meta)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function techpack_warehouse.can_dig(self, pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
return inv:is_empty("main") and inv:is_empty("shift")
|
||||
|
@ -1,2 +1,3 @@
|
||||
name=techpack_warehouse
|
||||
|
||||
description=Warehouse boxes
|
||||
depends=tubelib,tubelib_addons1
|
||||
|
@ -96,7 +96,7 @@ end)
|
||||
minetest.after(60*59, update_mod_storage)
|
||||
|
||||
-- Key2Number will be generated at runtine
|
||||
local Key2Number = {}
|
||||
local Key2Number = {}
|
||||
|
||||
local Name2Name = {} -- translation table
|
||||
|
||||
@ -206,11 +206,12 @@ local function get_dest_node(pos, side)
|
||||
local _,node = Tube:get_node(pos)
|
||||
local dir = side_to_dir(side, node.param2)
|
||||
local spos, sdir = Tube:get_connected_node_pos(pos, dir)
|
||||
if not (spos and sdir) then return end
|
||||
_,node = Tube:get_node(spos)
|
||||
local out_side = dir_to_side(tubelib2.Turn180Deg[sdir], node.param2)
|
||||
return spos, out_side, Name2Name[node.name] or node.name
|
||||
return spos, out_side, Name2Name[node.name] or node.name
|
||||
end
|
||||
|
||||
|
||||
local function item_handling_node(name)
|
||||
local node_def = name and tubelib_NodeDef[name]
|
||||
if node_def then
|
||||
@ -221,7 +222,7 @@ end
|
||||
-------------------------------------------------------------------
|
||||
-- API helper functions
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
-- Check the given list of numbers.
|
||||
-- Returns true if number(s) is/are valid and point to real nodes.
|
||||
function tubelib.check_numbers(numbers)
|
||||
@ -234,7 +235,7 @@ function tubelib.check_numbers(numbers)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Function returns { pos, name } for the node on the given position number.
|
||||
function tubelib.get_node_info(dest_num)
|
||||
@ -242,7 +243,7 @@ function tubelib.get_node_info(dest_num)
|
||||
return Number2Pos[dest_num]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Function returns the node number from the given position or
|
||||
-- nil, if no node number for this position is assigned.
|
||||
@ -256,14 +257,14 @@ function tubelib.get_node_number(pos)
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Function is used for available nodes with lost numbers, only.
|
||||
function tubelib.get_new_number(pos, name)
|
||||
-- store position
|
||||
-- store position
|
||||
local number = get_number(pos)
|
||||
Number2Pos[number] = {
|
||||
pos = pos,
|
||||
pos = pos,
|
||||
name = name,
|
||||
}
|
||||
return number
|
||||
@ -293,7 +294,7 @@ end
|
||||
-------------------------------------------------------------------
|
||||
-- Node construction/destruction functions
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
-- Add node to the tubelib lists.
|
||||
-- Function determines and returns the node position number,
|
||||
-- needed for message communication.
|
||||
@ -301,10 +302,10 @@ function tubelib.add_node(pos, name)
|
||||
if item_handling_node(name) then
|
||||
Tube:after_place_node(pos)
|
||||
end
|
||||
-- store position
|
||||
-- store position
|
||||
local number = get_number(pos)
|
||||
Number2Pos[number] = {
|
||||
pos = pos,
|
||||
pos = pos,
|
||||
name = name,
|
||||
}
|
||||
return number
|
||||
@ -317,7 +318,7 @@ function tubelib.remove_node(pos)
|
||||
if Number2Pos[number] then
|
||||
name = Number2Pos[number].name
|
||||
Number2Pos[number] = {
|
||||
pos = pos,
|
||||
pos = pos,
|
||||
name = nil,
|
||||
time = minetest.get_day_count() -- used for reservation timeout
|
||||
}
|
||||
@ -352,11 +353,11 @@ function tubelib.register_node(name, add_names, node_definition)
|
||||
for _,n in ipairs(add_names) do
|
||||
Name2Name[n] = name
|
||||
end
|
||||
if node_definition.on_pull_item or node_definition.on_push_item or
|
||||
if node_definition.on_pull_item or node_definition.on_push_item or
|
||||
node_definition.is_pusher then
|
||||
Tube:add_secondary_node_names({name})
|
||||
Tube:add_secondary_node_names(add_names)
|
||||
|
||||
|
||||
tubelib.KnownNodes[name] = true
|
||||
for _,n in ipairs(add_names) do
|
||||
tubelib.KnownNodes[n] = true
|
||||
@ -387,7 +388,7 @@ function tubelib.send_message(numbers, placer_name, clicker_name, topic, payload
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function tubelib.send_request(number, topic, payload)
|
||||
if Number2Pos[number] and Number2Pos[number].name then
|
||||
@ -397,7 +398,7 @@ function tubelib.send_request(number, topic, payload)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- for defect nodes
|
||||
function tubelib.repair_node(pos)
|
||||
@ -426,10 +427,10 @@ function tubelib.push_items(pos, side, items, player_name)
|
||||
local npos, nside, name = get_dest_node(pos, side)
|
||||
if npos == nil then return end
|
||||
if tubelib_NodeDef[name] and tubelib_NodeDef[name].on_push_item then
|
||||
return tubelib_NodeDef[name].on_push_item(npos, nside, items, player_name)
|
||||
return tubelib_NodeDef[name].on_push_item(npos, nside, items, player_name)
|
||||
elseif name == "air" then
|
||||
minetest.add_item(npos, items)
|
||||
return true
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -442,7 +443,7 @@ function tubelib.unpull_items(pos, side, items, player_name)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function tubelib.pull_stack(pos, side, player_name)
|
||||
local npos, nside, name = get_dest_node(pos, side)
|
||||
if npos == nil then return end
|
||||
@ -493,7 +494,7 @@ function tubelib.get_this_item(meta, listname, list_number, num_items)
|
||||
if inv:is_empty(listname) then
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
if num_items == nil then num_items = 1 end
|
||||
local items = inv:get_stack(listname, list_number)
|
||||
if items:get_count() > 0 then
|
||||
@ -548,7 +549,7 @@ function tubelib.get_stack(meta, listname)
|
||||
taken:set_count(taken:get_count() + 1)
|
||||
return taken
|
||||
end
|
||||
return item
|
||||
return item
|
||||
end
|
||||
|
||||
-- Return "full", "loaded", or "empty" depending
|
||||
@ -567,7 +568,7 @@ function tubelib.fuelstate(meta, listname, item)
|
||||
return "loaded"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Return "full", "loaded", or "empty" depending
|
||||
-- on the inventory load.
|
||||
-- Full is returned, when no empty stack is available.
|
||||
@ -682,8 +683,8 @@ local function data_maintenance()
|
||||
end
|
||||
minetest.log("info", "[Tubelib] Data base shrank from "..cnt1.." to "..cnt2.." nodes")
|
||||
minetest.log("info", "[Tubelib] Data maintenance finished")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
generate_Key2Number()
|
||||
|
||||
-- maintain data after 2 seconds
|
||||
|
@ -13,6 +13,15 @@ minetest.register_node("tubelib:defect_dummy", {
|
||||
is_ground_content = false,
|
||||
})
|
||||
|
||||
local reported_machines = {}
|
||||
local function report(pos)
|
||||
reported_machines[minetest.pos_to_string(pos)] = true
|
||||
end
|
||||
local function already_reported(pos)
|
||||
local key = minetest.pos_to_string(pos)
|
||||
return reported_machines[key]
|
||||
end
|
||||
|
||||
|
||||
function tubelib.data_not_corrupted(pos)
|
||||
if minetest.pos_to_string(pos) ~= minetest.get_meta(pos):get_string("my_pos") then
|
||||
@ -29,23 +38,27 @@ function tubelib.data_not_corrupted(pos)
|
||||
number = meta:get_string("own_number")
|
||||
end
|
||||
if number == "" then
|
||||
tubelib.remove_node(pos)
|
||||
minetest.set_node(pos, {name = "tubelib:defect_dummy"})
|
||||
meta:from_table(nil)
|
||||
return false
|
||||
if not already_reported(pos) then
|
||||
minetest.log('error', ('[tubelib] machine @ %s has no number'):format(minetest.pos_to_string(pos)))
|
||||
report(pos)
|
||||
end
|
||||
end
|
||||
-- node moved?
|
||||
local info = tubelib.get_node_info(number)
|
||||
if not info or not vector.equals(info.pos, pos) then
|
||||
if not already_reported(pos) then
|
||||
if not info then
|
||||
minetest.log('error', ('[tubelib] machine @ %s has no info'):format(minetest.pos_to_string(pos)))
|
||||
else
|
||||
minetest.log('error', ('[tubelib] machine @ %s thinks it is at %s'):format(minetest.pos_to_string(pos), minetest.pos_to_string(info.pos)))
|
||||
end
|
||||
report(pos)
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
number = tubelib.get_new_number(pos, node.name)
|
||||
meta:set_string("tubelib_number", number)
|
||||
-- tubelib.remove_node(pos)
|
||||
-- minetest.set_node(pos, {name = "tubelib:defect_dummy"})
|
||||
-- meta:from_table(nil)
|
||||
-- return false
|
||||
end
|
||||
minetest.get_meta(pos):get_string("my_pos", minetest.pos_to_string(pos))
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -72,7 +72,7 @@ local State = tubelib.NodeStates:new({
|
||||
-- Return a key/value table with all items and the corresponding stack numbers
|
||||
local function invlist_content_as_kvlist(list)
|
||||
local res = {}
|
||||
for idx,items in ipairs(list) do
|
||||
for idx,items in ipairs(list or {}) do
|
||||
local name = items:get_name()
|
||||
if name ~= "" then
|
||||
res[name] = idx
|
||||
|
@ -1 +1,3 @@
|
||||
name=tubelib
|
||||
description=Tubes Mod with message communication interface as basis for further technique Mods.
|
||||
depends=default,tubelib2,basic_materials
|
||||
|
@ -1,8 +1,10 @@
|
||||
tubelib
|
||||
default
|
||||
bucket
|
||||
stairs?
|
||||
moreores?
|
||||
farming?
|
||||
ethereal?
|
||||
farming?
|
||||
moreores?
|
||||
moretrees?
|
||||
skytest?
|
||||
stairs?
|
||||
unified_inventory?
|
||||
|
@ -9,7 +9,7 @@
|
||||
See LICENSE.txt for more information
|
||||
|
||||
detector.lua:
|
||||
|
||||
|
||||
]]--
|
||||
|
||||
|
||||
@ -75,11 +75,11 @@ minetest.register_node("tubelib_addons1:detector", {
|
||||
"button_exit[2,2;3,1;exit;Save]")
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
tubelib.remove_node(pos)
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
@ -108,7 +108,7 @@ minetest.register_node("tubelib_addons1:detector_active", {
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
tubelib.remove_node(pos)
|
||||
end,
|
||||
|
||||
|
||||
paramtype = "light",
|
||||
light_source = 2,
|
||||
sunlight_propagates = true,
|
||||
@ -140,5 +140,5 @@ tubelib.register_node("tubelib_addons1:detector", {"tubelib_addons1:detector_act
|
||||
return false
|
||||
end,
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
|
||||
fermenter.lua
|
||||
|
||||
|
||||
The Fermenter converts 3 leave items of any kind into one Bio Gas item,
|
||||
needed by the Reformer to produce Bio Fuel.
|
||||
|
||||
@ -97,7 +97,8 @@ local function place_top(pos, facedir, placer)
|
||||
return false
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name ~= "air" then
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if not def or not def.buildable_to then
|
||||
return false
|
||||
end
|
||||
minetest.add_node(pos, {name="tubelib_addons1:fermenter_top", param2=facedir})
|
||||
@ -107,13 +108,13 @@ end
|
||||
local function convert_leaves_to_biogas(pos, meta)
|
||||
local inv = meta:get_inventory()
|
||||
local biogas = ItemStack("tubelib_addons1:biogas")
|
||||
|
||||
|
||||
-- Not enough output space?
|
||||
if not inv:room_for_item("dst", biogas) then
|
||||
State:blocked(pos, meta)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
-- take NUM_LEAVES items
|
||||
local items = {}
|
||||
for i = 1, NUM_LEAVES do
|
||||
@ -128,14 +129,14 @@ local function convert_leaves_to_biogas(pos, meta)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- put result into dst inventory
|
||||
if #items == NUM_LEAVES then
|
||||
inv:add_item("dst", biogas)
|
||||
State:keep_running(pos, meta, COUNTDOWN_TICKS)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
-- put leaves back to src inventory
|
||||
for i = 1, #items do
|
||||
inv:add_item("src", items[i])
|
||||
@ -176,22 +177,24 @@ minetest.register_node("tubelib_addons1:fermenter", {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, 24/16, 8/16 },
|
||||
},
|
||||
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = M(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 9)
|
||||
inv:set_size('dst', 9)
|
||||
end,
|
||||
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
||||
State:node_init(pos, number)
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
minetest.chat_send_player(placer:get_player_name(), "Fermenter will not fit there")
|
||||
return true
|
||||
end
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
||||
State:node_init(pos, number)
|
||||
end,
|
||||
|
||||
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
||||
@ -208,7 +211,7 @@ minetest.register_node("tubelib_addons1:fermenter", {
|
||||
tubelib.remove_node(pos)
|
||||
State:after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = keep_running,
|
||||
on_receive_fields = on_receive_fields,
|
||||
@ -242,23 +245,25 @@ minetest.register_node("tubelib_addons1:fermenter_defect", {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, 24/16, 8/16 },
|
||||
},
|
||||
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = M(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 9)
|
||||
inv:set_size('dst', 9)
|
||||
end,
|
||||
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
||||
State:node_init(pos, number)
|
||||
State:defect(pos, M(pos))
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
minetest.chat_send_player(placer:get_player_name(), "Fermenter will not fit there")
|
||||
return true
|
||||
end
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:fermenter")
|
||||
State:node_init(pos, number)
|
||||
State:defect(pos, M(pos))
|
||||
end,
|
||||
|
||||
-- the fermenter needs 'on_dig' to be able to remove the upper node
|
||||
@ -274,7 +279,7 @@ minetest.register_node("tubelib_addons1:fermenter_defect", {
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
tubelib.remove_node(pos)
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
@ -327,14 +332,14 @@ if minetest.global_exists("unified_inventory") then
|
||||
height = 2,
|
||||
})
|
||||
unified_inventory.register_craft({
|
||||
items = {"group:leaves", "group:leaves"},
|
||||
output = "tubelib_addons1:biogas",
|
||||
items = {"group:leaves", "group:leaves"},
|
||||
output = "tubelib_addons1:biogas",
|
||||
type = "fermenting"
|
||||
})
|
||||
unified_inventory.register_craft({
|
||||
items = {"tubelib_addons1:biogas", "tubelib_addons1:biogas",
|
||||
"tubelib_addons1:biogas", "tubelib_addons1:biogas"},
|
||||
output = "tubelib_addons1:biofuel",
|
||||
items = {"tubelib_addons1:biogas", "tubelib_addons1:biogas",
|
||||
"tubelib_addons1:biogas", "tubelib_addons1:biogas"},
|
||||
output = "tubelib_addons1:biofuel",
|
||||
type = "reforming"
|
||||
})
|
||||
end
|
||||
@ -373,4 +378,4 @@ tubelib.register_node("tubelib_addons1:fermenter", {"tubelib_addons1:fermenter_d
|
||||
on_node_repair = function(pos)
|
||||
return State:on_node_repair(pos)
|
||||
end,
|
||||
})
|
||||
})
|
||||
|
@ -1 +1,4 @@
|
||||
name=tubelib_addons1
|
||||
description=Tubelib Extension with Mining, Farming, and Crafting nodes
|
||||
depends=tubelib,default,bucket
|
||||
optional_depends=ethereal,farming,moreores,moretrees,skytest,stairs,unified_inventory
|
||||
|
@ -9,10 +9,10 @@
|
||||
See LICENSE.txt for more information
|
||||
|
||||
reformer.lua
|
||||
|
||||
|
||||
The Reformer converts 4 Bio Gas items into one Bio Fuel item,
|
||||
needed by Harvester and Quarry.
|
||||
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
@ -91,7 +91,8 @@ local function place_top(pos, facedir, placer)
|
||||
return false
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name ~= "air" then
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if not def or not def.buildable_to then
|
||||
return false
|
||||
end
|
||||
minetest.add_node(pos, {name="tubelib_addons1:reformer_top", param2=facedir})
|
||||
@ -172,24 +173,26 @@ minetest.register_node("tubelib_addons1:reformer", {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, 24/16, 8/16 },
|
||||
},
|
||||
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = M(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 9)
|
||||
inv:set_size('dst', 9)
|
||||
end,
|
||||
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
||||
State:node_init(pos, number)
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
minetest.chat_send_player(placer:get_player_name(), "Reformer will not fit there")
|
||||
return true
|
||||
end
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
||||
State:node_init(pos, number)
|
||||
end,
|
||||
|
||||
|
||||
-- the reformer needs 'on_dig' to be able to remove the upper node
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
local meta = M(pos)
|
||||
@ -199,12 +202,12 @@ minetest.register_node("tubelib_addons1:reformer", {
|
||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
tubelib.remove_node(pos)
|
||||
State:after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
on_timer = keep_running,
|
||||
on_receive_fields = on_receive_fields,
|
||||
@ -238,23 +241,25 @@ minetest.register_node("tubelib_addons1:reformer_defect", {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, 24/16, 8/16 },
|
||||
},
|
||||
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = M(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 9)
|
||||
inv:set_size('dst', 9)
|
||||
end,
|
||||
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) == false then
|
||||
if place_top({x=pos.x, y=pos.y+1, z=pos.z}, facedir, placer) then
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
||||
State:node_init(pos, number)
|
||||
State:defect(pos, M(pos))
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
minetest.chat_send_player(placer:get_player_name(), "Reformer will not fit there")
|
||||
return true
|
||||
end
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:reformer")
|
||||
State:node_init(pos, number)
|
||||
State:defect(pos, M(pos))
|
||||
end,
|
||||
|
||||
-- the reformer needs 'on_dig' to be able to remove the upper node
|
||||
@ -266,11 +271,11 @@ minetest.register_node("tubelib_addons1:reformer_defect", {
|
||||
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
tubelib.remove_node(pos)
|
||||
end,
|
||||
|
||||
|
||||
on_rotate = screwdriver.disallow,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
@ -351,4 +356,4 @@ tubelib.register_node("tubelib_addons1:reformer", {"tubelib_addons1:reformer_def
|
||||
on_node_repair = function(pos)
|
||||
return State:on_node_repair(pos)
|
||||
end,
|
||||
})
|
||||
})
|
||||
|
@ -1 +1,4 @@
|
||||
name=tubelib_addons2
|
||||
description=Tubelib Extension for switching/controlling tasks
|
||||
depends=default,tubelib,basic_materials
|
||||
optional_depends=mesecons,unifieddyes
|
||||
|
@ -1 +1,3 @@
|
||||
name=tubelib_addons3
|
||||
description=Tubelib Extension with High Performance nodes
|
||||
depends=tubelib,tubelib_addons1,default
|
||||
|
Loading…
Reference in New Issue
Block a user