Changed sand digger to a more generic soft material digger, added more sophisticated traction, made structure climbable, added infotexts

This commit is contained in:
FaceDeer 2016-12-31 21:19:52 -07:00
parent 70803f1f44
commit 68e0ca21c6
6 changed files with 55 additions and 23 deletions

@ -52,13 +52,15 @@ Facing of a digger head is significant; it will excavate material from the node
Digger heads can have a period and offset defined if you want them to punch regularly-spaced holes. Note that diggers aimed forward should generally always have a period of 1, otherwise the digging machine may be unable to move.
Sand Digger Head
Soft Material Digger Head
----------------
This specialized digger head is designed to excavate only loose material such as sand or gravel. It has no period/offset settings; it will always attempt to dig sand when it's present in its target node. It leaves all other types of nodes alone. (in technical terms, this digger digs nodes belonging to the "falling_node" group)
This specialized digger head is designed to excavate only softer material such as sand or gravel. It has no period/offset settings; it will always attempt to dig sand when it's present in its target node. It leaves all other types of nodes alone. (in technical terms, this digger digs nodes belonging to the "crumbly", "choppy", "snappy", "oddly_diggable_by_hand" and "fleshy" groups)
The intended purpose of this digger is to be aimed at the ceiling or walls of a tunnel being dug, making spaces to allow shoring nodes to be inserted into unstable roofs but leaving the wall alone if it's composed of a more stable material.
It can also serve as part of a lawnmower or tree-harvester.
Builder Head
------------
@ -71,14 +73,18 @@ Inventory Module
Inventory modules have the same capacity as a chest. They're used both for storing the products of the digger heads and as the source of materials used by the builder heads. A digging machine whose builder heads are laying down cobble can automatically self-replenish in this way, but note that an inventory module is still required as buffer space even if the digger heads produced everything needed by the builder heads in a given cycle.
Inventory modules are not required for a digging-only machine. If there's not enough storage space to hold the materials produced by the digging heads, the excess material will be ejected out the back of the control node. They're handy for accumulating ores and other building materials, though.
Inventory modules are not required for a digging-only machine. If there's not enough storage space to hold the materials produced by the digging heads the excess material will be ejected out the back of the control node. They're handy for accumulating ores and other building materials, though.
Digging machines can have multiple inventory modules added to expand their capacity.
Structural Module
-----------------
These nodes allow otherwise-disconnected sections of builder machines to be linked together. You can also use them to build a platform to stand on as you ride your mighty mechanical leviathan through the landscape.
These nodes allow otherwise-disconnected sections of digtron nodes to be linked together. They are not usually necessary for simple diggers but more elaborate builder arrays might have builder nodes that can't be placed directly adjacent to other digtron nodes and these nodes can serve to keep them connected to the controller.
They may also be used for providing additional traction if your digtron array is very tall compared to the terrain surface that it's touching.
You can also use them decoratively, or to build a platform to stand on as you ride your mighty mechanical leviathan through the landscape.
Digtron Lamp
------------
@ -88,11 +94,11 @@ A light source that moves along with the digging machine. Convenient if you're d
What Do These Noises Mean?
==========================
When a digging machine is unable to complete a cycle it will make one of several noises to indicate what the problem is.
When a digging machine is unable to complete a cycle it will make one of several noises to indicate what the problem is. It will also set its mouseover text to explain what went wrong.
Squealing traction wheels indicates a mobility problem. If the squealing is accompanied by a buzzer, the digging machine has encountered an obstruction it can't dig through. This could be a protected region (the digging machine has only the priviledges of the player triggering it), a chest containing items, or perhaps the digger was incorrectly designed and can't dug the correctly sized and shaped cavity for it to move forward into. There are many possibilities.
Squealing traction wheels indicates a mobility problem. If the squealing is accompanied by a buzzer, the digging machine has encountered an obstruction it can't dig through. This could be a protected region (the digging machine has only the priviledges of the player triggering it), a chest containing items, or perhaps the digger was incorrectly designed and can't dig the correctly sized and shaped cavity for it to move forward into. There are many possibilities.
Squealing traction wheels with no accompanying buzzer indicates that the digging machine has no solid adjacent nodes to push off of. Tunnel boring machines cannot fly or swim, not even through lava, and they don't dig fast enough to "catch sick air" when they emerge from a cliffside. If you wish to cross a chasm you'll need to ensure that there are builder heads placing a solid surface as you go.
Squealing traction wheels with no accompanying buzzer indicates that the digging machine doesn't have enough solid adjacent nodes to push off of. Tunnel boring machines cannot fly or swim, not even through lava, and they don't dig fast enough to "catch sick air" when they emerge from a cliffside. If you wish to cross a chasm you'll need to ensure that there are builder heads placing a solid surface as you go. If you've built a very tall digtron with a small surface footprint you may need to improve its traction by adding structural modules that touch the ground.
A ringing bell indicates that there are insufficient materials in inventory to supply all the builder heads for this cycle.

@ -9,6 +9,7 @@ dofile( minetest.get_modpath( "digtron" ) .. "/node_controllers.lua" ) -- contro
dofile( minetest.get_modpath( "digtron" ) .."/recipes.lua" )
digtron.refractory = 1.0 -- How long a digtron waits between cycles.
digtron.traction_factor = 3.0 -- How many digtron nodes can be moved for each adjacent solid node that the digtron has traction against
-- digtron group numbers:
-- 1 - generic digtron node, nothing special is done with these. They're just dragged along.
@ -17,6 +18,16 @@ digtron.refractory = 1.0 -- How long a digtron waits between cycles.
-- 4 - builder head, has a "test_build" and "execute_build" method in its definition
minetest.register_lbm({
name = "digtron:sand_digger_upgrade",
nodenames = {"digtron:sand_digger"},
action = function(pos, node)
local meta = minetest.get_meta(pos)
local offset = meta:get_string("offset")
local period = meta:get_string("period")
minetest.set_node(pos, {name = "digtron:soft_digger",
param2 = node.param2})
meta:set_string("offset", offset)
meta:set_string("period", period)
end
})

@ -45,12 +45,14 @@ minetest.register_node("digtron:controller", {
if layout.all == nil then
-- get_all_digtron_neighbours returns nil if the digtron array touches unloaded nodes, too dangerous to do anything in that situation. Abort.
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", "Digtron is adjacent to unloaded nodes.")
return
end
if layout.traction == false then
if layout.traction * digtron.traction_factor < table.getn(layout.all) then
-- digtrons can't fly
minetest.sound_play("squeal", {gain=1.0, pos=pos})
meta:set_string("infotext", string.format("Digtron has %d nodes but only enough traction to move %d nodes.", table.getn(layout.all), layout.traction * digtron.traction_factor))
return
end
@ -103,6 +105,7 @@ minetest.register_node("digtron:controller", {
)
minetest.sound_play("squeal", {gain=1.0, pos=pos})
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", "Digtron is obstructed.")
return --Abort, don't dig and don't build.
end
@ -145,8 +148,10 @@ minetest.register_node("digtron:controller", {
)
if test_build_return == 1 then
minetest.sound_play("honk", {gain=0.5, pos=pos}) -- A builder is not configured
meta:set_string("infotext", "Digtron connected to at least one builder node that hasn't had an output material assigned.")
elseif test_build_return == 2 then
minetest.sound_play("dingding", {gain=1.0, pos=pos}) -- Insufficient inventory
meta:set_string("infotext", "Digtron has insufficient materials in inventory to execute all build operations.")
end
return --Abort, don't dig and don't build.
end
@ -192,7 +197,7 @@ minetest.register_node("digtron:controller", {
local targetdef = minetest.registered_nodes[target.name]
if targetdef.execute_build ~= nil then
--using the old location of the controller as fallback so that any leftovers land with the rest of the digger output. Not that there should be any.
can_build = targetdef.execute_build(location, clicker, layout.inventories, layout.protected, nodes_dug, controlling_coordinate, oldpos)
can_build = can_build and targetdef.execute_build(location, clicker, layout.inventories, layout.protected, nodes_dug, controlling_coordinate, oldpos)
else
minetest.log(string.format("%s has builder group but is missing execute_build method! This is an error in mod programming, file a bug.", targetdef.name))
end
@ -201,6 +206,7 @@ minetest.register_node("digtron:controller", {
-- We weren't able to detect this build failure ahead of time, so make a big noise now. This is strange, shouldn't happen often.
minetest.sound_play("dingding", {gain=1.0, pos=pos})
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", "Digtron unexpectedly failed to execute a build operation.")
end
-- finally, dig out any nodes remaining to be dug. Some of these will have had their flag revoked because
@ -250,12 +256,14 @@ minetest.register_node("digtron:pusher", {
if layout.all == nil then
-- get_all_digtron_neighbours returns nil if the digtron array touches unloaded nodes, too dangerous to do anything in that situation. Abort.
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", "Digtron is adjacent to unloaded nodes.")
return
end
if layout.traction == false then
if layout.traction * digtron.traction_factor < table.getn(layout.all) then
-- digtrons can't fly
minetest.sound_play("squeal", {gain=1.0, pos=pos})
meta:set_string("infotext", string.format("Digtron has %d nodes but only enough traction to move %d nodes.", table.getn(layout.all), layout.traction * digtron.traction_factor))
return
end
@ -276,7 +284,7 @@ minetest.register_node("digtron:pusher", {
if not can_move then
-- mark this node as waiting, will clear this flag in digtron.refractory seconds
minetest.get_meta(pos):set_string("waiting", "true")
meta:set_string("waiting", "true")
minetest.after(digtron.refractory,
function (pos)
minetest.get_meta(pos):set_string("waiting", nil)
@ -284,6 +292,7 @@ minetest.register_node("digtron:pusher", {
)
minetest.sound_play("squeal", {gain=1.0, pos=pos})
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", "Digtron is obstructed.")
return --Abort
end

@ -92,10 +92,10 @@ minetest.register_node("digtron:digger", {
})
-- A special-purpose digger to deal with stuff like sand and gravel in the ceiling. It always digs (no periodicity or offset), but it only digs falling_block nodes
minetest.register_node("digtron:sand_digger", {
description = "Sand Digger Head",
minetest.register_node("digtron:soft_digger", {
description = "Soft Material Digger Head",
groups = {cracky = 3, stone = 1, digtron = 3},
drop = 'digtron:sand_digger',
drop = 'digtron:soft_digger',
paramtype = "light",
paramtype2= 'facedir',
@ -138,7 +138,11 @@ minetest.register_node("digtron:sand_digger", {
end
local target_node = minetest.get_node(digpos)
if minetest.get_item_group(target_node.name, "falling_node") ~= 0 then
if minetest.get_item_group(target_node.name, "crumbly") ~= 0 or
minetest.get_item_group(target_node.name, "choppy") ~= 0 or
minetest.get_item_group(target_node.name, "snappy") ~= 0 or
minetest.get_item_group(target_node.name, "oddly_breakable_by_hand") ~= 0 or
minetest.get_item_group(target_node.name, "fleshy") ~= 0 then
return digtron.mark_diggable(digpos, nodes_dug)
end

@ -5,6 +5,8 @@ minetest.register_node("digtron:structure", {
drop = 'digtron:structure',
tiles = {"digtron_plate.png"},
drawtype = "nodebox",
climbable = true,
walkable = false,
paramtype = "light",
node_box = {
type = "fixed",

@ -90,13 +90,13 @@ digtron.move_node = function(pos, newpos)
end
digtron.get_all_digtron_neighbours = function(pos, player)
-- returns table containing a list of all digtron node locations, lists of special digtron node types, a table of the coordinate extents of the digtron array, a Pointset of protected nodes, and a bool to determine if the array is adjacent to non-digtron nodes (for traction)
-- returns table containing a list of all digtron node locations, lists of special digtron node types, a table of the coordinate extents of the digtron array, a Pointset of protected nodes, and a number to determine how many adjacent solid non-digtron nodes there are (for traction)
--minetest.debug(string.format("digtron search started at component %d %d %d", pos.x, pos.y, pos.z))
local layout = {}
--initialize. We're assuming that the start position is a controller digtron, should be a safe assumption since only the controller node should call this
layout.traction = false
layout.traction = 0
layout.all = {}
layout.inventories = {}
layout.diggers = {}
@ -176,9 +176,9 @@ digtron.get_all_digtron_neighbours = function(pos, player)
to_test:set_if_not_in(tested, testpos.x, testpos.y - 1, testpos.z, true)
to_test:set_if_not_in(tested, testpos.x, testpos.y, testpos.z + 1, true)
to_test:set_if_not_in(tested, testpos.x, testpos.y, testpos.z - 1, true)
elseif not layout.traction and minetest.registered_nodes[node.name].buildable_to ~= true then
-- Tracks whether the digtron is hovering in mid-air. If any part of the digtron array touches something solid, it can move.
layout.traction = true
elseif minetest.registered_nodes[node.name].buildable_to ~= true then
-- Tracks whether the digtron is hovering in mid-air. If any part of the digtron array touches something solid it gains traction.
layout.traction = layout.traction + 1
end
testpos, _ = to_test:pop()