adding output location visualizer entities for the build heads.

This commit is contained in:
FaceDeer 2017-01-02 16:05:48 -07:00
parent 5ba5b76ba7
commit ec1ee19893
6 changed files with 94 additions and 2 deletions

@ -68,6 +68,8 @@ Builder Head
A builder head is the most complex component of this system. It has period and offset properties, and also an inventory slot where you "program" it by placing an example of the node type that you want it to build. Only a single item is needed here, any additional items in this inventory stack will be shunted into the digger's general inventory (or ejected from the control node if there's no space for it).
When the "Save & Show" button is clicked the properties for period and offset will be saved, and markers will briefly be shown to indicate where the nearest spots corresponding to those values are. The builder will build its output at those locations provided it is moving along the matching axis.
The "output" side of a builder is the side with a black crosshair on it.
Builders also have a "facing" setting. If you haven't memorized the meaning of the 24 facing values yet, builder heads have a helpful "Read & Save" button to fill this value in for you. Simply build a temporary instance of the node in the output location in front of the builder, adjust it to the orientation you want using the screwdriver tool, and then when you click the "Read & Save" button the node's facing will be read and saved.
@ -190,3 +192,11 @@ Pusher controller:
[ , coal , ]
[coal, core , coal]
[ , coal , ]
Tips and tricks
===============
If you're building a repeating pattern of nodes, your periodicity should be one larger than your largest offset. For example, if you've laid out builders to create a set of spiral stairs and the offsets are from 0 to 11, you'll want to use periodicity 12.
A good way to program a set of builders is to build a complete example of the structure you want them to create, then place builders against the structure and have them "read" all of its facings. This also lets you more easily visualize the tricks that might be needed to allow the digtron to pass through the structure as it's being built.

51
entities.lua Normal file

@ -0,0 +1,51 @@
minetest.register_entity("digtron:marker", {
initial_properties = {
visual = "cube",
visual_size = {x=1.1, y=1.1},
textures = {"digtron_marker_side.png","digtron_marker_side.png","digtron_marker.png","digtron_marker.png","digtron_marker_side.png","digtron_marker_side.png"},
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
physical = false,
},
on_activate = function(self, staticdata)
minetest.after(5.0,
function(self)
self.object:remove()
end,
self)
end,
on_rightclick=function(self, clicker)
self.object:remove()
end,
on_punch = function(self, hitter)
self.object:remove()
end,
})
minetest.register_entity("digtron:marker_vertical", {
initial_properties = {
visual = "cube",
visual_size = {x=1.1, y=1.1},
textures = {"digtron_marker.png","digtron_marker.png","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90"},
collisionbox = {-0.55, -0.55, -0.55, 0.55, 0.55, 0.55},
physical = false,
},
on_activate = function(self, staticdata)
minetest.after(5.0,
function(self)
self.object:remove()
end,
self)
end,
on_rightclick=function(self, clicker)
self.object:remove()
end,
on_punch = function(self, hitter)
self.object:remove()
end,
})

@ -1,5 +1,6 @@
dofile( minetest.get_modpath( "digtron" ) .. "/util.lua" )
dofile( minetest.get_modpath( "digtron" ) .. "/pointset.lua" )
dofile( minetest.get_modpath( "digtron" ) .. "/entities.lua" )
dofile( minetest.get_modpath( "digtron" ) .. "/node_misc.lua" ) -- contains inventory and structure nodes
dofile( minetest.get_modpath( "digtron" ) .. "/node_diggers.lua" ) -- contains all diggers

@ -52,7 +52,7 @@ minetest.register_node("digtron:builder", {
"tooltip[period;Builder will build once every n steps. These steps are globally aligned, so all builders with the same period and offset will build on the same location.]" ..
"field[3.5,0.8;1,0.1;offset;Offset;${offset}]" ..
"tooltip[offset;Offsets the start of periodicity counting by this amount. For example, a builder with period 2 and offset 0 builds every even-numbered node and one with period 2 and offset 1 builds every odd-numbered node.]" ..
"button_exit[4.2,0.5;1,0.1;set;Save]" ..
"button_exit[4.2,0.5;1,0.1;set;Save &\nShow]" ..
"tooltip[set;Saves settings]" ..
"field[5.7,0.8;1,0.1;build_facing;Facing;${build_facing}]" ..
"tooltip[build_facing;Value from 0-23. Not all node types make use of this. Use the 'Read & Save' button to copy the facing of the node currently in the builder output location]" ..
@ -83,7 +83,37 @@ minetest.register_node("digtron:builder", {
meta:set_int("offset", math.floor(tonumber(fields.offset)))
end
if fields.read then
if fields.set then
local buildpos = digtron.find_new_pos(pos, minetest.get_node(pos).param2)
local offset_mod_period = math.abs(offset%period)
local x_pos = math.floor(buildpos.x/period)*period - offset_mod_period
minetest.add_entity({x=x_pos, y=buildpos.y, z=buildpos.z}, "digtron:marker")
if x_pos >= buildpos.x then
minetest.add_entity({x=x_pos - period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
end
if x_pos <= buildpos.x then
minetest.add_entity({x=x_pos + period, y=buildpos.y, z=buildpos.z}, "digtron:marker")
end
local y_pos = math.floor(buildpos.y/period)*period - offset_mod_period
minetest.add_entity({x=buildpos.x, y=y_pos, z=buildpos.z}, "digtron:marker_vertical")
if y_pos >= buildpos.y then
minetest.add_entity({x=buildpos.x, y=y_pos - period, z=buildpos.z}, "digtron:marker_vertical")
end
if y_pos <= buildpos.y then
minetest.add_entity({x=buildpos.x, y=y_pos + period, z=buildpos.z}, "digtron:marker_vertical")
end
local z_pos = math.floor(buildpos.z/period)*period - offset_mod_period
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos}, "digtron:marker"):setyaw(1.5708)
if z_pos >= buildpos.z then
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos - period}, "digtron:marker"):setyaw(1.5708)
end
if z_pos <= buildpos.z then
minetest.add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker"):setyaw(1.5708)
end
elseif fields.read then
local meta = minetest.get_meta(pos)
local facing = minetest.get_node(pos).param2
local buildpos = digtron.find_new_pos(pos, facing)

BIN
textures/digtron_marker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B