Fix no-power issues for several machines, fix grinder recipe bug
parent
600c12dc88
commit
62be5cf818
|
@ -380,6 +380,9 @@ local tubing = {
|
|||
on_recv_message = function(pos, src, topic, payload)
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
|
|
|
@ -478,7 +478,6 @@ local tubing = {
|
|||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
|
|
|
@ -204,6 +204,9 @@ local tubing = {
|
|||
on_recv_message = function(pos, src, topic, payload)
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
|
|
|
@ -129,6 +129,15 @@ local function get_random_gravel_ore()
|
|||
end
|
||||
end
|
||||
|
||||
local function remove_objects(pos)
|
||||
for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
local lua_entity = object:get_luaentity()
|
||||
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
|
||||
object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function washing(pos, crd, nvm, inv)
|
||||
-- for testing purposes
|
||||
if inv:contains_item("src", ItemStack("default:stick")) then
|
||||
|
@ -163,7 +172,6 @@ local function keep_running(pos, elapsed)
|
|||
local crd = CRD(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
washing(pos, crd, nvm, inv)
|
||||
return crd.State:is_active(nvm)
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
|
@ -240,6 +248,10 @@ local tubing = {
|
|||
on_recv_message = function(pos, src, topic, payload)
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
remove_objects({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
|
@ -321,26 +333,6 @@ function techage.add_rinser_recipe(recipe)
|
|||
end
|
||||
end
|
||||
|
||||
local function remove_objects(pos)
|
||||
for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
local lua_entity = object:get_luaentity()
|
||||
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
|
||||
object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "[techage] Rinser update",
|
||||
name = "techage:rinser_update",
|
||||
nodenames = {"techage:ta2_rinser_act", "techage:ta3_rinser_act"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
remove_objects({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
techage.add_rinser_recipe({input="techage:sieved_gravel", output="techage:usmium_nuggets", probability=30})
|
||||
techage.add_rinser_recipe({input="techage:sieved_gravel", output="default:copper_lump", probability=15})
|
||||
|
||||
|
|
|
@ -175,6 +175,9 @@ local tubing = {
|
|||
on_recv_message = function(pos, src, topic, payload)
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
|
|
|
@ -73,10 +73,22 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function src_to_dst(src_stack, idx, num_items, inv, dst_name)
|
||||
local taken = src_stack:take_item(num_items)
|
||||
local output = ItemStack(dst_name)
|
||||
-- Grinder normaly handles 'num_items' per cycle. 'num_items' is node stage dependent.
|
||||
-- But if 'inp_num' > 1 (wheat recipes), use 'inp_num' and produce one output item.
|
||||
local function src_to_dst(src_stack, idx, num_items, inp_num, inv, dst_name, num_input)
|
||||
local taken, output
|
||||
if inp_num > 1 then
|
||||
if src_stack:get_count() >= inp_num then
|
||||
taken = src_stack:take_item(inp_num)
|
||||
output = ItemStack(dst_name)
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
taken = src_stack:take_item(num_items)
|
||||
output = ItemStack(dst_name)
|
||||
output:set_count(output:get_count() * taken:get_count())
|
||||
end
|
||||
if inv:room_for_item("dst", output) then
|
||||
inv:set_stack("src", idx, src_stack)
|
||||
inv:add_item("dst", output)
|
||||
|
@ -91,7 +103,8 @@ local function grinding(pos, crd, nvm, inv)
|
|||
if not stack:is_empty() then
|
||||
local name = stack:get_name()
|
||||
if Recipes[name] then
|
||||
if src_to_dst(stack, idx, crd.num_items, inv, Recipes[name]) then
|
||||
local recipe = Recipes[name]
|
||||
if src_to_dst(stack, idx, crd.num_items, recipe.inp_num, inv, recipe.output) then
|
||||
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||
else
|
||||
crd.State:blocked(pos, nvm)
|
||||
|
@ -186,6 +199,9 @@ local tubing = {
|
|||
on_recv_message = function(pos, src, topic, payload)
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
|
@ -264,7 +280,9 @@ if minetest.global_exists("unified_inventory") then
|
|||
end
|
||||
|
||||
function techage.add_grinder_recipe(recipe)
|
||||
Recipes[recipe.input] = recipe.output
|
||||
local name, num = unpack(string.split(recipe.input, " ", false, 1))
|
||||
Recipes[name] = {input = name,inp_num = tonumber(num) or 1, output = recipe.output}
|
||||
|
||||
if minetest.global_exists("unified_inventory") then
|
||||
recipe.items = {recipe.input}
|
||||
recipe.type = "grinding"
|
||||
|
|
|
@ -368,13 +368,8 @@ local tubing = {
|
|||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos, node)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if nvm.techage_state == techage.RUNNING then
|
||||
play_sound(pos)
|
||||
else
|
||||
stop_sound(pos)
|
||||
end
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
|
@ -231,6 +231,9 @@ local tubing = {
|
|||
on_recv_message = function(pos, src, topic, payload)
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local _, _, node_name_ta4 =
|
||||
|
|
|
@ -242,6 +242,9 @@ local tubing = {
|
|||
on_recv_message = function(pos, src, topic, payload)
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
CRD(pos).State:on_node_load(pos)
|
||||
end,
|
||||
}
|
||||
|
||||
local _, node_name_ta3, node_name_ta4 =
|
||||
|
|
|
@ -471,9 +471,15 @@ function NodeStates:on_receive_message(pos, topic, payload)
|
|||
end
|
||||
end
|
||||
|
||||
-- repair corrupt node data
|
||||
-- restart timer
|
||||
function NodeStates:on_node_load(pos)
|
||||
-- tbd
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local state = nvm.techage_state or STOPPED
|
||||
if state == RUNNING then
|
||||
minetest.get_node_timer(pos):start(self.cycle_time)
|
||||
elseif state < FAULT then
|
||||
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("techage:defect_dummy", {
|
||||
|
|
Loading…
Reference in New Issue