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, {
pos = msg.pos,
error = true,
message = "place node is unknown: '" .. msg.name .. "'"
message = "place node is unknown: '" .. (msg.name or "<empty>") .. "'"
})
return
end
@ -156,12 +156,12 @@ function digibuilder.digiline_effector(pos, _, channel, msg)
end
-- 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
-- add param2 info
minetest.swap_node(absolute_pos, place_node)
end
minetest.set_node(absolute_pos, place_node)
digilines.receptor_send(pos, digibuilder.digiline_rules, set_channel, {
pos = msg.pos,

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