working pattern example

This commit is contained in:
BuckarooBanzay 2020-06-16 19:46:06 +02:00
parent 866637b8a4
commit f5128886f8
2 changed files with 17 additions and 15 deletions

@ -123,7 +123,7 @@ function digibuilder.digiline_effector(pos, _, channel, msg)
digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, { digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, {
pos = msg.pos, pos = msg.pos,
error = true, error = true,
message = "place node is unknown: '" .. msg.name .. "'" message = "place node is unknown: '" .. (msg.name or "<empty>") .. "'"
}) })
return return
end end
@ -156,12 +156,12 @@ function digibuilder.digiline_effector(pos, _, channel, msg)
end end
-- place node inworld -- place node inworld
minetest.place_node(absolute_pos, place_node) minetest.log("action", "[digibuilder] " .. owner .. " places node '" ..
place_node.name .. "' at " ..
minetest.pos_to_string(absolute_pos)
)
if enable_param2 then minetest.set_node(absolute_pos, place_node)
-- add param2 info
minetest.swap_node(absolute_pos, place_node)
end
digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, { digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, {
pos = msg.pos, pos = msg.pos,

@ -2,7 +2,7 @@
-- pattern, starting at -x/-z -- pattern, starting at -x/-z
local data = { local data = {
-- x >> -- x >>
"sdsd", "sdsdsd",
"dsds" "dsds"
-- z \/ -- z \/
} }
@ -13,9 +13,9 @@ local nodes = {
} }
-- coordinate offsets -- coordinate offsets
local x_offset = -10 local x_offset = -5
local y_offset = 1 local y_offset = 2
local z_offset = -10 local z_offset = -5
-- initial start -- initial start
if event.type == "program" then if event.type == "program" then
@ -26,13 +26,13 @@ end
-- timer interrupt -- timer interrupt
if event.type == "interrupt" then if event.type == "interrupt" then
local line = data[mem.line] local line = data[mem.line]
if not line then if not line then
-- done -- done
return return
end end
local char = line:sub(mem.pos, 1) local char = line:sub(mem.pos, mem.pos)
if char == "" then if char == "" then
-- next line -- next line
mem.line = mem.line + 1 mem.line = mem.line + 1
@ -46,16 +46,18 @@ if event.type == "interrupt" then
pos = { x=x_offset+mem.pos-1, y=y_offset, z=z_offset+mem.line-1 }, pos = { x=x_offset+mem.pos-1, y=y_offset, z=z_offset+mem.line-1 },
name = nodes[char] name = nodes[char]
}) })
end end
-- callback from digibuilder node -- callback from digibuilder node
if event.type == "digiline" and event.channel == "digibuilder" then if event.type == "digiline" and event.channel == "digibuilder" then
if event.error then if event.error then
-- error state -- error state
error(event.message) error(event.message)
return
end end
-- next command -- next command
mem.line = mem.line + 1 mem.pos = mem.pos + 1
interrupt(1) interrupt(1)
end end