mirror of
https://github.com/joe7575/techpack.git
synced 2024-08-20 13:14:12 +02:00
pushing_chest converted to new states
This commit is contained in:
parent
667739acfe
commit
4ff98d47d4
@ -299,14 +299,15 @@ end
|
|||||||
-- To be called after successful node action to raise the timer
|
-- To be called after successful node action to raise the timer
|
||||||
-- and keep the node in state RUNNING
|
-- and keep the node in state RUNNING
|
||||||
function NodeStates:keep_running(pos, meta, val, num_items)
|
function NodeStates:keep_running(pos, meta, val, num_items)
|
||||||
|
num_items = num_items or 1
|
||||||
-- set to RUNNING if not already done
|
-- set to RUNNING if not already done
|
||||||
self:start(pos, meta, true)
|
self:start(pos, meta, true)
|
||||||
meta:set_int("tubelib_countdown", val)
|
meta:set_int("tubelib_countdown", val)
|
||||||
meta:set_int("tubelib_item_meter", meta:get_int("tubelib_item_meter") + (num_items or 1))
|
meta:set_int("tubelib_item_meter", meta:get_int("tubelib_item_meter") + (num_items or 1))
|
||||||
if self.aging_level1 then
|
if self.aging_level1 then
|
||||||
local cnt = meta:get_int("tubelib_aging") + (num_items or 1)
|
local cnt = meta:get_int("tubelib_aging") + num_items
|
||||||
meta:set_int("tubelib_aging", cnt)
|
meta:set_int("tubelib_aging", cnt)
|
||||||
if cnt > (self.aging_level1) and math.random(self.aging_level2) == 1 then
|
if cnt > (self.aging_level1) and math.random(self.aging_level2/num_items) == 1 then
|
||||||
self:defect(pos, meta)
|
self:defect(pos, meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
-- tubelib aging feature
|
||||||
|
local AGING_LEVEL1 = 80 * tubelib.machine_aging_value
|
||||||
|
local AGING_LEVEL2 = 240 * tubelib.machine_aging_value
|
||||||
|
|
||||||
local Cache = {}
|
local Cache = {}
|
||||||
|
|
||||||
@ -45,6 +48,17 @@ local function allow_metadata_inventory_move(pos, from_list, from_index, to_list
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function aging(pos, meta, num)
|
||||||
|
local cnt = meta:get_int("tubelib_aging") + num
|
||||||
|
meta:set_int("tubelib_aging", cnt)
|
||||||
|
if cnt > AGING_LEVEL1 and math.random(AGING_LEVEL2/num) == 1 then
|
||||||
|
minetest.get_node_timer(pos):stop()
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
node.name = "tubelib_addons3:pushing_chest_defect"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function set_state(meta, state)
|
local function set_state(meta, state)
|
||||||
local number = meta:get_string("number")
|
local number = meta:get_string("number")
|
||||||
meta:set_string("infotext", "HighPerf Pushing Chest "..number..": "..state)
|
meta:set_string("infotext", "HighPerf Pushing Chest "..number..": "..state)
|
||||||
@ -83,6 +97,7 @@ local function shift_items(pos, elapsed)
|
|||||||
stack = inv:get_stack("shift", idx)
|
stack = inv:get_stack("shift", idx)
|
||||||
stack:take_item(num)
|
stack:take_item(num)
|
||||||
inv:set_stack("shift", idx, stack)
|
inv:set_stack("shift", idx, stack)
|
||||||
|
aging(pos, meta, num)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
set_state(meta, "blocked")
|
set_state(meta, "blocked")
|
||||||
@ -174,6 +189,61 @@ minetest.register_node("tubelib_addons3:pushing_chest", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("tubelib_addons3:pushing_chest_defect", {
|
||||||
|
description = "HighPerf Pushing Chest",
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
'tubelib_pusher1.png^tubelib_addons3_node_frame4.png',
|
||||||
|
'tubelib_addons3_chest_bottom.png',
|
||||||
|
"tubelib_addons3_chest_out.png^tubelib_defect.png",
|
||||||
|
"tubelib_addons3_chest_side.png^tubelib_defect.png",
|
||||||
|
"tubelib_addons3_chest_side.png^tubelib_defect.png",
|
||||||
|
"tubelib_addons3_chest_front.png^tubelib_defect.png",
|
||||||
|
},
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size('main', 32)
|
||||||
|
inv:set_size('shift', 8)
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local number = tubelib.add_node(pos, "tubelib_addons3:pushing_chest")
|
||||||
|
meta:set_string("player_name", placer:get_player_name())
|
||||||
|
meta:set_string("number", number)
|
||||||
|
meta:set_string("formspec", formspec())
|
||||||
|
set_state(meta, "empty")
|
||||||
|
end,
|
||||||
|
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:is_empty("main") and inv:is_empty("shift")
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_dig = function(pos, node, puncher, pointed_thing)
|
||||||
|
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||||
|
end,
|
||||||
|
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||||
|
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||||
|
allow_metadata_inventory_move = 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_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "tubelib_addons3:pushing_chest",
|
output = "tubelib_addons3:pushing_chest",
|
||||||
@ -184,7 +254,8 @@ minetest.register_craft({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
tubelib.register_node("tubelib_addons3:pushing_chest", {}, {
|
tubelib.register_node("tubelib_addons3:pushing_chest",
|
||||||
|
{"tubelib_addons3:pushing_chest_defect"}, {
|
||||||
on_recv_message = function(pos, topic, payload)
|
on_recv_message = function(pos, topic, payload)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if topic == "state" then
|
if topic == "state" then
|
||||||
@ -234,4 +305,17 @@ tubelib.register_node("tubelib_addons3:pushing_chest", {}, {
|
|||||||
on_node_load = function(pos)
|
on_node_load = function(pos)
|
||||||
minetest.get_node_timer(pos):start(2)
|
minetest.get_node_timer(pos):start(2)
|
||||||
end,
|
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("formspec", formspec())
|
||||||
|
set_state(meta, "empty")
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
node.name = "tubelib_addons3:pushing_chest"
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
minetest.get_node_timer(pos):start(2)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
@ -11,7 +11,7 @@ minetest.register_node("tubelib_stairway:bridge1", {
|
|||||||
fixed = {
|
fixed = {
|
||||||
{ 15/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, -17/32, -15/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}
|
{-17/32, -15/32, -17/32, 17/32, -14/32, 17/32}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ minetest.register_node("tubelib_stairway:bridge2", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-17/32, -17/32, -17/32, -15/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}
|
{-17/32, -15/32, -17/32, 17/32, -14/32, 17/32}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ minetest.register_node("tubelib_stairway:bridge3", {
|
|||||||
{-17/32, -17/32, 15/32, 17/32, 17/32, 17/32},
|
{-17/32, -17/32, 15/32, 17/32, 17/32, 17/32},
|
||||||
{ 15/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, -17/32, -15/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}
|
{-17/32, -15/32, -17/32, 17/32, -14/32, 17/32}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ minetest.register_node("tubelib_stairway:bridge4", {
|
|||||||
fixed = {
|
fixed = {
|
||||||
{-17/32, -17/32, 15/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, -15/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}
|
{-17/32, -15/32, -17/32, 17/32, -14/32, 17/32}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
BIN
tubelib_stairway/textures/tubelib_stairway_side.png
Normal file
BIN
tubelib_stairway/textures/tubelib_stairway_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 326 B |
Loading…
Reference in New Issue
Block a user