mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-22 22:02:32 +01:00
Update LV grinder code
This commit is contained in:
parent
86f39a0d96
commit
a2aef2a7af
@ -197,7 +197,7 @@ minetest.register_node("technic:grinder", {
|
|||||||
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
|
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
|
||||||
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
|
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
groups = {cracky=2},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
technic_power_machine=1,
|
technic_power_machine=1,
|
||||||
@ -214,11 +214,9 @@ minetest.register_node("technic:grinder", {
|
|||||||
meta:set_float("internal_EU_buffer_size", 5000)
|
meta:set_float("internal_EU_buffer_size", 5000)
|
||||||
meta:set_string("formspec", grinder_formspec)
|
meta:set_string("formspec", grinder_formspec)
|
||||||
meta:set_float("grind_time", 0)
|
meta:set_float("grind_time", 0)
|
||||||
|
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("src", 1)
|
inv:set_size("src", 1)
|
||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
|
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.env:get_meta(pos);
|
local meta = minetest.env:get_meta(pos);
|
||||||
@ -229,14 +227,33 @@ minetest.register_node("technic:grinder", {
|
|||||||
if not inv:is_empty("dst") then
|
if not inv:is_empty("dst") then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("technic:grinder_active", {
|
||||||
|
description = "Grinder",
|
||||||
|
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
|
||||||
|
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=2,not_in_creative_inventory=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.env:get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if not inv:is_empty("src") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if not inv:is_empty("dst") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"technic:grinder"},
|
nodenames = {"technic:grinder","technic:grinder_active"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
@ -258,12 +275,7 @@ minetest.register_abm({
|
|||||||
"list[current_player;main;0,5;8,4;]"
|
"list[current_player;main;0,5;8,4;]"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
-- local grinder_on = meta:get_float("grinder_on")
|
|
||||||
|
|
||||||
local srclist = inv:get_list("src")
|
local srclist = inv:get_list("src")
|
||||||
if inv:is_empty("src") then meta:set_float("grinder_on",0) end
|
if inv:is_empty("src") then meta:set_float("grinder_on",0) end
|
||||||
|
|
||||||
@ -294,12 +306,19 @@ minetest.register_abm({
|
|||||||
local grinded=nil
|
local grinded=nil
|
||||||
if not inv:is_empty("src") then
|
if not inv:is_empty("src") then
|
||||||
grinded = get_grinded_item (inv:get_stack("src", 1))
|
grinded = get_grinded_item (inv:get_stack("src", 1))
|
||||||
if grinded then meta:set_float("grinder_on",1) end
|
if grinded then
|
||||||
|
meta:set_float("grinder_on",1)
|
||||||
|
hacky_swap_node(pos,"technic:grinder_active")
|
||||||
|
meta:set_string("infotext", "Grinder Active")
|
||||||
grind_time=4
|
grind_time=4
|
||||||
meta:set_float("grind_time",grind_time)
|
meta:set_float("grind_time",grind_time)
|
||||||
meta:set_float("src_time", 0)
|
meta:set_float("src_time", 0)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
hacky_swap_node(pos,"technic:grinder")
|
||||||
|
meta:set_string("infotext", "Grinder Inactive")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
@ -317,3 +336,4 @@ return nil
|
|||||||
end
|
end
|
||||||
|
|
||||||
register_LV_machine ("technic:grinder","RE")
|
register_LV_machine ("technic:grinder","RE")
|
||||||
|
register_LV_machine ("technic:grinder_active","RE")
|
||||||
|
Loading…
Reference in New Issue
Block a user