mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-03-20 19:10:39 +01:00
Scanner: Add output rules in proper places and a couple of minor cleanups and changes.
This commit is contained in:
parent
f40fe54e3c
commit
d7586ed76d
@ -111,6 +111,15 @@ local function update_watermarks(pos, meta)
|
|||||||
meta:set_int("high", high)
|
meta:set_int("high", high)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function update_state(pos, node, state)
|
||||||
|
mesecon.setstate(pos, node, state)
|
||||||
|
if state == "on" then
|
||||||
|
mesecon.receptor_on(pos, scanner_get_output_rules(node))
|
||||||
|
else
|
||||||
|
mesecon.receptor_off(pos, scanner_get_output_rules(node))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function on_receive_fields(pos, form_name, fields, sender)
|
local function on_receive_fields(pos, form_name, fields, sender)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if fields.inventory then
|
if fields.inventory then
|
||||||
@ -146,14 +155,6 @@ local function on_receive_fields(pos, form_name, fields, sender)
|
|||||||
update_watermarks(pos, meta)
|
update_watermarks(pos, meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_receptor(pos, output, rules)
|
|
||||||
if output then
|
|
||||||
mesecon.receptor_on(pos, rules)
|
|
||||||
else
|
|
||||||
mesecon.receptor_off(pos, rules)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local boxes = {
|
local boxes = {
|
||||||
{ -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }, -- the bottom slab
|
{ -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }, -- the bottom slab
|
||||||
{ -7/16, -7/16, -4/16, 4/16, -4/16, 4/16 }, -- the "box"
|
{ -7/16, -7/16, -4/16, 4/16, -4/16, 4/16 }, -- the "box"
|
||||||
@ -164,10 +165,10 @@ mesecon.register_node("mesecons_scanner:mesecon_scanner", {
|
|||||||
paramtype2="facedir",
|
paramtype2="facedir",
|
||||||
description = "Inventory scanner",
|
description = "Inventory scanner",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = false,
|
||||||
inventory_image = "mesecons_scanner_preview.png",
|
inventory_image = "mesecons_scanner_preview.png",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
wield_image = "mesecons_scanner_preview.png",
|
wield_image = "mesecons_scanner_top_off.png",
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
@ -180,7 +181,7 @@ mesecon.register_node("mesecons_scanner:mesecon_scanner", {
|
|||||||
},
|
},
|
||||||
after_dig_node = function (pos, node)
|
after_dig_node = function (pos, node)
|
||||||
mesecon.do_cooldown(pos)
|
mesecon.do_cooldown(pos)
|
||||||
mesecon.receptor_off(pos, output_rules)
|
mesecon.receptor_off(pos, scanner_get_output_rules(node))
|
||||||
end,
|
end,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -236,16 +237,16 @@ mesecon.register_node("mesecons_scanner:mesecon_scanner", {
|
|||||||
end
|
end
|
||||||
meta:set_int("current", count)
|
meta:set_int("current", count)
|
||||||
|
|
||||||
-- Update node
|
-- Do update if output changed
|
||||||
local output_string = (output and "on") or "off"
|
|
||||||
set_receptor(pos, output, {scanner_get_output_rules(node)})
|
|
||||||
mesecon.setstate(pos, node, output_string)
|
|
||||||
|
|
||||||
-- Save the new state
|
|
||||||
meta:set_string("output", output_string)
|
|
||||||
|
|
||||||
-- Send digiline message on change
|
|
||||||
if old_output ~= output then
|
if old_output ~= output then
|
||||||
|
-- Update node
|
||||||
|
local output_string = (output and "on") or "off"
|
||||||
|
update_state(pos, node, output_string)
|
||||||
|
|
||||||
|
-- Save the new state
|
||||||
|
meta:set_string("output", output_string)
|
||||||
|
|
||||||
|
-- Send digiline message
|
||||||
if digilines_enabled and meta:get_string("channel") ~= "" then
|
if digilines_enabled and meta:get_string("channel") ~= "" then
|
||||||
digilines.receptor_send(pos, digilines.rules.default,
|
digilines.receptor_send(pos, digilines.rules.default,
|
||||||
meta:get_string("channel"),
|
meta:get_string("channel"),
|
||||||
@ -317,7 +318,10 @@ mesecon.register_node("mesecons_scanner:mesecon_scanner", {
|
|||||||
-- back
|
-- back
|
||||||
"mesecons_scanner_left_off.png",
|
"mesecons_scanner_left_off.png",
|
||||||
},
|
},
|
||||||
mesecons = { receptor = { state = mesecon.state.off } }
|
mesecons = { receptor = {
|
||||||
|
state = mesecon.state.off,
|
||||||
|
rules = scanner_get_output_rules,
|
||||||
|
} }
|
||||||
},{
|
},{
|
||||||
groups = { dig_immediate=2, not_in_creative_inventory=1 },
|
groups = { dig_immediate=2, not_in_creative_inventory=1 },
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -328,7 +332,10 @@ mesecon.register_node("mesecons_scanner:mesecon_scanner", {
|
|||||||
"mesecons_scanner_right_on.png",
|
"mesecons_scanner_right_on.png",
|
||||||
"mesecons_scanner_left_on.png",
|
"mesecons_scanner_left_on.png",
|
||||||
},
|
},
|
||||||
mesecons = { receptor = { state = mesecon.state.off } }
|
mesecons = { receptor = {
|
||||||
|
state = mesecon.state.on,
|
||||||
|
rules = scanner_get_output_rules,
|
||||||
|
} }
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user