add Digtron duplicator block

This commit is contained in:
FaceDeer 2017-10-22 19:50:11 -06:00
parent ae0a24b19b
commit 1224a34615
5 changed files with 296 additions and 42 deletions

@ -207,6 +207,11 @@ end
---------------------------------------------------------------------
digtron.doc.duplicator_longdesc = S("A device for duplicating an adjacent Digtron using parts from its inventory.")
digtron.doc.duplicator_usagehelp = S("Place the duplicator block adjacent to a Digtron, and then fill the duplicator's inventory with enough parts to recreate the adjacent Digtron. Then place an empty Digtron crate at the duplicator's output (the side with the black \"+\") and click the \"Duplicate\" button in the duplicator's right-click GUI. If enough parts are available the Digtron will be duplicated and packed into the crate, along with all of its programming but with empty inventories.")
---------------------------------------------------------------------
digtron.doc.structure_longdesc = S("Structural component for a Digtron array")
digtron.doc.structure_usagehelp = S("These blocks allow otherwise-disconnected sections of digtron blocks to be linked together. They are not usually necessary for simple diggers but more elaborate builder arrays might have builder blocks that can't be placed directly adjacent to other digtron blocks and these blocks can serve to keep them connected to the controller."
.."\n\n"..

@ -59,6 +59,7 @@ dofile( digtron_modpath .. "/nodes/node_controllers.lua" ) -- controllers
dofile( digtron_modpath .. "/nodes/node_axle.lua" ) -- Rotation controller
dofile( digtron_modpath .. "/nodes/node_crate.lua" ) -- Digtron portability support
dofile( digtron_modpath .. "/nodes/node_item_ejector.lua" ) -- ejects non-building, non-fuel items from inventories
dofile( digtron_modpath .. "/nodes/node_duplicator.lua" ) -- constructs copies of existing Digtrons
--Technic
dofile( digtron_modpath .. "/nodes/node_battery_holder.lua" ) -- holds rechargeable batteries from the technic mod

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-21 22:27-0600\n"
"POT-Creation-Date: 2017-10-22 19:49-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -746,11 +746,27 @@ msgid ""
msgstr ""
#: doc.lua:210
msgid "Structural component for a Digtron array"
msgid ""
"A device for duplicating an adjacent Digtron using parts from its inventory."
msgstr ""
#: doc.lua:211
msgid ""
"Place the duplicator block adjacent to a Digtron, and then fill the "
"duplicator's inventory with enough parts to recreate the adjacent Digtron. "
"Then place an empty Digtron crate at the duplicator's output (the side with "
"the black \"+\") and click the \"Duplicate\" button in the duplicator's "
"right-click GUI. If enough parts are available the Digtron will be "
"duplicated and packed into the crate, along with all of its programming but "
"with empty inventories."
msgstr ""
#: doc.lua:215
msgid "Structural component for a Digtron array"
msgstr ""
#: doc.lua:216
msgid ""
"These blocks allow otherwise-disconnected sections of digtron blocks to be "
"linked together. They are not usually necessary for simple diggers but more "
"elaborate builder arrays might have builder blocks that can't be placed "
@ -764,11 +780,11 @@ msgid ""
"you ride your mighty mechanical leviathan through the landscape."
msgstr ""
#: doc.lua:217
#: doc.lua:222
msgid "Digtron light source"
msgstr ""
#: doc.lua:218
#: doc.lua:223
msgid ""
"A light source that moves along with the digging machine. Convenient if "
"you're digging a tunnel that you don't intend to outfit with torches or "
@ -776,53 +792,53 @@ msgid ""
"protective lens tends to get grimy while burrowing through the earth."
msgstr ""
#: doc.lua:220
#: doc.lua:225
msgid "Digtron panel"
msgstr ""
#: doc.lua:221
#: doc.lua:226
msgid ""
"A structural panel that can be made part of a Digtron to provide shelter for "
"an operator, keep sand out of the Digtron's innards, or just to look cool."
msgstr ""
#: doc.lua:223
#: doc.lua:228
msgid "Digtron edge panel"
msgstr ""
#: doc.lua:224
#: doc.lua:229
msgid ""
"A pair of structural panels that can be made part of a Digtron to provide "
"shelter for an operator, keep sand out of the Digtron's innards, or just to "
"look cool."
msgstr ""
#: doc.lua:226
#: doc.lua:231
msgid "Digtron corner panel"
msgstr ""
#: doc.lua:227
#: doc.lua:232
msgid ""
"A trio of structural panels that can be made part of a Digtron to provide "
"shelter for an operator, keep sand out of the Digtron's innards, or just to "
"look cool."
msgstr ""
#: doc.lua:231
#: doc.lua:236
msgid "Digtron"
msgstr ""
#: doc.lua:232
#: doc.lua:237
msgid ""
"The Digtron system is a set of blocks used to construct tunnel-boring and "
"construction machines."
msgstr ""
#: doc.lua:239
#: doc.lua:244
msgid "Summary"
msgstr ""
#: doc.lua:240
#: doc.lua:245
msgid ""
"Digtron blocks can be used to construct highly customizable and modular "
"tunnel-boring machines, bridge-builders, road-pavers, wall-o-matics, and "
@ -844,11 +860,11 @@ msgid ""
"edges and corners don't count."
msgstr ""
#: doc.lua:253
#: doc.lua:258
msgid "Concepts"
msgstr ""
#: doc.lua:255
#: doc.lua:260
msgid ""
"Several general concepts are important when building more sophisticated "
"diggers.\n"
@ -887,11 +903,11 @@ msgid ""
"when moving in any direction."
msgstr ""
#: doc.lua:269
#: doc.lua:274
msgid "Audio cues"
msgstr ""
#: doc.lua:271
#: doc.lua:276
msgid ""
"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 "
@ -937,11 +953,11 @@ msgid ""
"caution when opening the door to clear the obstruction."
msgstr ""
#: doc.lua:289
#: doc.lua:294
msgid "Tips and Tricks"
msgstr ""
#: doc.lua:291
#: doc.lua:296
msgid ""
"To more easily visualize the operation of a Digtron, imagine that its cycle "
"of operation follows these steps in order:\n"
@ -1096,16 +1112,18 @@ msgstr ""
#: nodes\node_builders.lua:39
#: nodes\node_controllers.lua:106
#: nodes\node_crate.lua:80
#: nodes\node_crate.lua:87
#: nodes\node_diggers.lua:42
#: nodes\node_duplicator.lua:22
#: nodes\node_item_ejector.lua:17
msgid "Help"
msgstr ""
#: nodes\node_builders.lua:40
#: nodes\node_controllers.lua:107
#: nodes\node_crate.lua:81
#: nodes\node_crate.lua:88
#: nodes\node_diggers.lua:43
#: nodes\node_duplicator.lua:23
#: nodes\node_item_ejector.lua:18
msgid "Show documentation about this block"
msgstr ""
@ -1212,65 +1230,71 @@ msgstr ""
msgid "Digtron can't be packaged, it contains protected blocks"
msgstr ""
#: nodes\node_crate.lua:60
#: nodes\node_crate.lua:61
#: nodes\node_crate.lua:32
msgid "No Digtron components adjacent to package"
msgstr ""
#: nodes\node_crate.lua:67
#: nodes\node_crate.lua:68
#: nodes\node_duplicator.lua:172
#: nodes\node_duplicator.lua:173
msgid "Crated Digtron"
msgstr ""
#: nodes\node_crate.lua:73
#: nodes\node_crate.lua:88
#: nodes\node_crate.lua:80
#: nodes\node_crate.lua:95
msgid "Digtron Name"
msgstr ""
#: nodes\node_crate.lua:74
#: nodes\node_crate.lua:89
#: nodes\node_crate.lua:81
#: nodes\node_crate.lua:96
msgid ""
"Save\n"
"Title"
msgstr ""
#: nodes\node_crate.lua:75
#: nodes\node_crate.lua:90
#: nodes\node_crate.lua:82
#: nodes\node_crate.lua:97
msgid "Saves the title of this Digtron"
msgstr ""
#: nodes\node_crate.lua:76
#: nodes\node_crate.lua:91
#: nodes\node_crate.lua:83
#: nodes\node_crate.lua:98
msgid ""
"Show\n"
"Blocks"
msgstr ""
#: nodes\node_crate.lua:77
#: nodes\node_crate.lua:92
#: nodes\node_crate.lua:84
#: nodes\node_crate.lua:99
msgid "Shows which blocks the packed Digtron will occupy if unpacked"
msgstr ""
#: nodes\node_crate.lua:78
#: nodes\node_crate.lua:93
#: nodes\node_crate.lua:85
#: nodes\node_crate.lua:100
msgid "Unpack"
msgstr ""
#: nodes\node_crate.lua:79
#: nodes\node_crate.lua:94
#: nodes\node_crate.lua:86
#: nodes\node_crate.lua:101
msgid "Attempts to unpack the Digtron on this location"
msgstr ""
#: nodes\node_crate.lua:103
#: nodes\node_crate.lua:110
msgid "Digtron Crate (Loaded)"
msgstr ""
#: nodes\node_crate.lua:138
#: nodes\node_crate.lua:145
msgid ""
"Unable to read layout from crate metadata, regrettably this Digtron may be "
"corrupted or lost."
msgstr ""
#: nodes\node_crate.lua:169
#: nodes\node_crate.lua:176
msgid "Unable to deploy Digtron due to protected blocks in target area"
msgstr ""
#: nodes\node_crate.lua:175
#: nodes\node_crate.lua:182
msgid "Unable to deploy Digtron due to obstruction in target area"
msgstr ""
@ -1313,6 +1337,43 @@ msgstr ""
msgid "Digtron Dual Soft Material Digger Head"
msgstr ""
#: nodes\node_duplicator.lua:10
msgid "Digtron components"
msgstr ""
#: nodes\node_duplicator.lua:17
msgid "Duplicate"
msgstr ""
#: nodes\node_duplicator.lua:18
msgid ""
"Puts a copy of the adjacent Digtron into an empty crate\n"
"located at the output side of the duplicator,\n"
"using components from the duplicator's inventory."
msgstr ""
#: nodes\node_duplicator.lua:27
msgid "Digtron Duplicator"
msgstr ""
#: nodes\node_duplicator.lua:99
msgid "Needs an empty crate in output position to store duplicate"
msgstr ""
#: nodes\node_duplicator.lua:107
msgid "Digtron can't be duplicated, it contains protected blocks"
msgstr ""
#: nodes\node_duplicator.lua:113
msgid "No Digtron components adjacent to duplicate"
msgstr ""
#: nodes\node_duplicator.lua:135
msgid ""
"Duplicator requires:\n"
"@1"
msgstr ""
#: nodes\node_item_ejector.lua:27
msgid "Eject into world"
msgstr ""

178
nodes/node_duplicator.lua Normal file

@ -0,0 +1,178 @@
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
local inventory_formspec_string =
"size[9,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;" .. S("Digtron components") .. "]" ..
"list[current_name;main;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)..
"button_exit[8,3.5;1,1;duplicate;"..S("Duplicate").."]" ..
"tooltip[duplicate;" .. S("Puts a copy of the adjacent Digtron into an empty crate\nlocated at the output side of the duplicator,\nusing components from the duplicator's inventory.") .. "]"
if minetest.get_modpath("doc") then
inventory_formspec_string = inventory_formspec_string ..
"button_exit[8,4.5;1,1;help;"..S("Help").."]" ..
"tooltip[help;" .. S("Show documentation about this block") .. "]"
end
minetest.register_node("digtron:duplicator", {
description = S("Digtron Duplicator"),
_doc_items_longdesc = digtron.doc.duplicator_longdesc,
_doc_items_usagehelp = digtron.doc.duplicator_usagehelp,
groups = {cracky = 3, oddly_breakable_by_hand=3},
sounds = digtron.metal_sounds,
tiles = {"digtron_plate.png^(digtron_axel_side.png^[transformR90)",
"digtron_plate.png^(digtron_axel_side.png^[transformR270)",
"digtron_plate.png^digtron_axel_side.png",
"digtron_plate.png^(digtron_axel_side.png^[transformR180)",
"digtron_plate.png^digtron_builder.png",
"digtron_plate.png",
},
paramtype = "light",
paramtype2= "facedir",
is_ground_content = false,
drawtype="nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, 0.3125, 0.3125, 0.5, 0.5, 0.5}, -- FrontFrame_top
{-0.5, -0.5, 0.3125, 0.5, -0.3125, 0.5}, -- FrontFrame_bottom
{0.3125, -0.3125, 0.3125, 0.5, 0.3125, 0.5}, -- FrontFrame_right
{-0.5, -0.3125, 0.3125, -0.3125, 0.3125, 0.5}, -- FrontFrame_left
{-0.0625, -0.3125, 0.3125, 0.0625, 0.3125, 0.375}, -- frontcross_vertical
{-0.3125, -0.0625, 0.3125, 0.3125, 0.0625, 0.375}, -- frontcross_horizontal
{-0.4375, -0.4375, -0.4375, 0.4375, 0.4375, 0.3125}, -- Body
{-0.5, -0.3125, -0.5, -0.3125, 0.3125, -0.3125}, -- backframe_vertical
{0.3125, -0.3125, -0.5, 0.5, 0.3125, -0.3125}, -- backframe_left
{-0.5, 0.3125, -0.5, 0.5, 0.5, -0.3125}, -- backframe_top
{-0.5, -0.5, -0.5, 0.5, -0.3125, -0.3125}, -- backframe_bottom
{-0.0625, -0.0625, -0.5625, 0.0625, 0.0625, -0.4375}, -- back_probe
},
},
selection_box = {
type = "regular"
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", inventory_formspec_string)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.get_item_group(stack:get_name(), "digtron") > 0 then
return stack:get_count()
else
return 0
end
end,
on_receive_fields = function(pos, formname, fields, sender)
if fields.help then
minetest.after(0.5, doc.show_entry, sender:get_player_name(), "nodes", "digtron:duplicator", true)
end
if fields.duplicate then
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local target_pos = vector.add(pos, minetest.facedir_to_dir(node.param2))
local target_node = minetest.get_node(target_pos)
if target_node.name ~= "digtron:empty_crate" then
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", S("Needs an empty crate in output position to store duplicate"))
return
end
local layout = DigtronLayout.create(pos, sender)
if layout.contains_protected_node then
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", S("Digtron can't be duplicated, it contains protected blocks"))
return
end
if #layout.all == 1 then
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
meta:set_string("infotext", S("No Digtron components adjacent to duplicate"))
return
end
layout.all[1] = {node={name="digtron:empty_crate"}, meta={fields = {}, inventory = {}}, pos={x=pos.x, y=pos.y, z=pos.z}} -- replace the duplicator's image with the empty crate image
-- count required nodes, skipping node 1 since it's the crate and we already know it's present in-world
local required_count = {}
for i = 2, #layout.all do
local nodename = layout.all[i].node.name
required_count[nodename] = (required_count[nodename] or 0) + 1
end
-- check that there's enough in the duplicator's inventory
local unsatisfied = {}
for name, count in pairs(required_count) do
if not inv:contains_item("main", ItemStack({name=name, count=count})) then
table.insert(unsatisfied, tostring(count) .. " " .. minetest.registered_nodes[name].description)
end
end
if #unsatisfied > 0 then
minetest.sound_play("dingding", {gain=1.0, pos=pos}) -- Insufficient inventory
meta:set_string("infotext", S("Duplicator requires:\n@1", table.concat(unsatisfied, "\n")))
return
end
meta:set_string("infotext", "") -- clear infotext, we're good to go.
-- deduct nodes from duplicator inventory
for name, count in pairs(required_count) do
inv:remove_item("main", ItemStack({name=name, count=count}))
end
-- clear inventories of image's nodes
for _, node_image in pairs(layout.inventories) do
local main_inventory = node_image.meta.inventory.main
for index, _ in pairs(main_inventory) do
main_inventory[index] = ItemStack(nil)
end
end
for _, node_image in pairs(layout.fuelstores) do
local fuel_inventory = node_image.meta.inventory.fuel
for index, _ in pairs(fuel_inventory) do
fuel_inventory[index] = ItemStack(nil)
end
end
for _, node_image in pairs(layout.battery_holders) do
local battery_inventory = node_image.meta.inventory.batteries
for index, _ in pairs(battery_inventory) do
battery_inventory[index] = ItemStack(nil)
end
end
-- replace empty crate with loaded crate and write image to its metadata
local layout_string = layout:serialize()
minetest.set_node(target_pos, {name="digtron:loaded_crate", param1=node.param1, param2=node.param2})
local target_meta = minetest.get_meta(target_pos)
target_meta:set_string("crated_layout", layout_string)
target_meta:set_string("title", S("Crated Digtron"))
target_meta:set_string("infotext", S("Crated Digtron"))
minetest.sound_play("machine1", {gain=1.0, pos=pos})
end
end,
})

@ -147,6 +147,15 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "digtron:duplicator",
recipe = {
{"default:mese_crystal","default:mese_crystal","default:mese_crystal"},
{"default:chest","digtron:digtron_core","default:chest"},
{"default:mese_crystal","default:mese_crystal","default:mese_crystal"}
}
})
minetest.register_craft({
output = "digtron:inventory_ejector",
recipe = {