mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 07:13:48 +01:00
bug fixes and improvements
This commit is contained in:
parent
021f5c450c
commit
48ca13d05d
@ -36,6 +36,7 @@
|
||||
2018-01-02 V1.07 * changed to registered ores
|
||||
2018-02-09 V1.08 * Pipeworks support added, bugfix for issue #7
|
||||
2018-12-28 V1.09 * Ore probability calculation changed (thanks to obl3pplifp)
|
||||
tubelib aging added
|
||||
]]--
|
||||
|
||||
gravelsieve = {
|
||||
@ -48,6 +49,14 @@ gravelsieve.ore_rarity = tonumber(minetest.setting_get("gravelsieve_ore_rarity")
|
||||
-- Increase the probability over the natural occurrence
|
||||
local PROBABILITY_FACTOR = 3
|
||||
|
||||
-- tubelib aging feature
|
||||
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
|
||||
end
|
||||
|
||||
-- Ore probability table (1/n)
|
||||
gravelsieve.ore_probability = {
|
||||
}
|
||||
@ -139,6 +148,17 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function aging(pos, meta)
|
||||
if AGING_LEVEL1 then
|
||||
local cnt = meta:get_int("tubelib_aging") + 1
|
||||
meta:set_int("tubelib_aging", cnt)
|
||||
if cnt > AGING_LEVEL1 and math.random(AGING_LEVEL2) == 1 then
|
||||
minetest.get_node_timer(pos):stop()
|
||||
minetest.swap_node(pos, {name = "gravelsieve:sieve_defect"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- handle the sieve animation
|
||||
local function swap_node(pos, meta, start)
|
||||
local node = minetest.get_node(pos)
|
||||
@ -212,8 +232,10 @@ local function sieve_node_timer(pos, elapsed)
|
||||
local gravel_sieved = ItemStack("gravelsieve:sieved_gravel")
|
||||
|
||||
if move_src2dst(meta, pos, inv, gravel) then
|
||||
aging(pos, meta)
|
||||
return true
|
||||
elseif move_src2dst(meta, pos, inv, gravel_sieved) then
|
||||
aging(pos, meta)
|
||||
return true
|
||||
else
|
||||
minetest.get_node_timer(pos):stop()
|
||||
@ -405,11 +427,67 @@ end
|
||||
-- Optional adaption to tubelib
|
||||
------------------------------------------------------------------------
|
||||
if minetest.global_exists("tubelib") then
|
||||
minetest.register_node("gravelsieve:sieve_defect", {
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"gravelsieve_top.png",
|
||||
"gravelsieve_gravel.png",
|
||||
"gravelsieve_auto_sieve.png^tubelib_defect.png",
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, -8/16, -8/16, 8/16, 4/16, -6/16 },
|
||||
{ -8/16, -8/16, 6/16, 8/16, 4/16, 8/16 },
|
||||
{ -8/16, -8/16, -8/16, -6/16, 4/16, 8/16 },
|
||||
{ 6/16, -8/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
{ -6/16, -2/16, -6/16, 6/16, 2/16, 6/16 },
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, 4/16, 8/16 },
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("idx", 0) -- for the 4 sieve phases
|
||||
meta:set_int("gravel_cnt", 0) -- counter to switch between gravel and sieved gravel
|
||||
meta:set_string("node_name", "gravelsieve:auto_sieve")
|
||||
meta:set_string("formspec", sieve_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 1)
|
||||
inv:set_size('dst', 16)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Gravel Sieve")
|
||||
end,
|
||||
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||
end
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {choppy=2, cracky=1, not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
tubelib.register_node("gravelsieve:auto_sieve3",
|
||||
{
|
||||
"gravelsieve:auto_sieve0",
|
||||
"gravelsieve:auto_sieve1",
|
||||
"gravelsieve:auto_sieve2",
|
||||
"gravelsieve:sieve_defect",
|
||||
},
|
||||
{
|
||||
on_pull_item = function(pos, side)
|
||||
@ -428,6 +506,18 @@ if minetest.global_exists("tubelib") then
|
||||
on_node_load = function(pos)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
end,
|
||||
on_node_repair = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("tubelib_aging", 0)
|
||||
meta:set_int("idx", 2)
|
||||
meta:set_string("node_name", "gravelsieve:auto_sieve")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('src', 1)
|
||||
inv:set_size('dst', 16)
|
||||
swap_node(pos, meta, false)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
return true
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ local State = tubelib.NodeStates:new({
|
||||
})
|
||||
|
||||
local function formspec(pos, meta)
|
||||
local filter = minetest.deserialize(meta:get_string("filter"))
|
||||
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
|
||||
return "size[10.5,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
|
@ -404,6 +404,10 @@ function NodeStates:on_node_load(pos)
|
||||
elseif state == BLOCKED then
|
||||
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
|
||||
end
|
||||
|
||||
if self.formspec_func then
|
||||
meta:set_string("formspec", self.formspec_func(pos, meta))
|
||||
end
|
||||
end
|
||||
|
||||
-- Repair of defect (feature!) nodes
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Maximim number of Forceload Blocks per player (default 10)
|
||||
tubelib_max_num_forceload_blocks (max number of Forceload Blocks) int 10
|
||||
# Maximim number of Forceload Blocks per player (default 12)
|
||||
tubelib_max_num_forceload_blocks (max number of Forceload Blocks) int 12
|
||||
|
||||
# Enable Basalt Stone (and disable ore generation via cobble generator)
|
||||
tubelib_basalt_stone_enabled (Basalt Stone enabled) bool true
|
||||
|
@ -42,7 +42,7 @@ end
|
||||
local State = tubelib.NodeStates:new({
|
||||
node_name_passive = "tubelib_addons1:harvester_base",
|
||||
node_name_defect = "tubelib_addons1:harvester_defect",
|
||||
infotext_name = "Tubelib Fermenter",
|
||||
infotext_name = "Tubelib Harvester",
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
has_item_meter = true,
|
||||
@ -283,18 +283,18 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
radius = tonumber(fields.radius)
|
||||
end
|
||||
if radius ~= this.radius then
|
||||
State:stop(pos, meta)
|
||||
this.radius = radius
|
||||
this.max = (radius*2 + 1) * (radius*2 + 1)
|
||||
meta:set_string("this", minetest.serialize(this))
|
||||
State:stop(pos, meta)
|
||||
end
|
||||
|
||||
if fields.endless ~= nil then
|
||||
this.endless = fields.endless == "true" and 1 or 0
|
||||
end
|
||||
meta:set_string("this", minetest.serialize(this))
|
||||
|
||||
State:state_button_event(pos, fields)
|
||||
|
||||
meta:set_string("this", minetest.serialize(this))
|
||||
end
|
||||
|
||||
minetest.register_node("tubelib_addons1:harvester_base", {
|
||||
|
@ -238,8 +238,8 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
end
|
||||
if max_levels ~= meta:get_int("max_levels") then
|
||||
meta:set_string("quarry_pos", nil) -- reset the quarry
|
||||
State:stop(pos, meta)
|
||||
meta:set_int("max_levels", max_levels)
|
||||
State:stop(pos, meta)
|
||||
end
|
||||
|
||||
local start_level = meta:get_int("start_level") or 0
|
||||
@ -248,8 +248,8 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
end
|
||||
if start_level ~= meta:get_int("start_level") then
|
||||
meta:set_string("quarry_pos", nil) -- reset the quarry
|
||||
State:stop(pos, meta)
|
||||
meta:set_int("start_level", start_level)
|
||||
State:stop(pos, meta)
|
||||
end
|
||||
|
||||
local endless = meta:get_int("endless") or 0
|
||||
@ -370,7 +370,17 @@ minetest.register_node("tubelib_addons1:quarry_defect", {
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = M(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('main', 16)
|
||||
inv:set_size('fuel', 1)
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:quarry")
|
||||
local facedir = minetest.dir_to_facedir(placer:get_look_dir(), false)
|
||||
meta:set_int("facedir", facedir)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_int("endless", 0)
|
||||
meta:set_int("curr_level", -1)
|
||||
meta:set_int("max_levels", 1)
|
||||
State:node_init(pos, number)
|
||||
State:defect(pos, M(pos))
|
||||
end,
|
||||
|
@ -200,14 +200,13 @@ tubelib.register_node("tubelib_addons3:pushing_chest", {}, {
|
||||
end,
|
||||
on_pull_item = function(pos, side)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local item = tubelib.get_item(meta, "main")
|
||||
-- check if one remaining item is left
|
||||
if meta:get_inventory():contains_item("main", item) then
|
||||
return item
|
||||
else
|
||||
-- don't remove the last item (recipe)
|
||||
tubelib.put_item(meta, "main", item)
|
||||
return nil
|
||||
local items = tubelib.get_num_items(meta, "main", 2)
|
||||
if items then
|
||||
-- return only one
|
||||
items:set_count(1)
|
||||
-- don't remove the potentally last item (recipe)
|
||||
tubelib.put_item(meta, "main", items)
|
||||
return items
|
||||
end
|
||||
end,
|
||||
on_push_item = function(pos, side, item)
|
||||
|
Loading…
Reference in New Issue
Block a user