summaryrefslogtreecommitdiff
path: root/nodes
diff options
context:
space:
mode:
authorFaceDeer <FaceDeer@users.noreply.github.com>2017-10-10 19:01:28 -0600
committerGitHub <noreply@github.com>2017-10-10 19:01:28 -0600
commitf10d46d3796d390e5ac5036c8bed93c69926c1c5 (patch)
treed22294496193285738f330ab84e8bf9be6738e83 /nodes
parent19a0f193ad37ddf48741b93eb48aa9f973c7df55 (diff)
parent6290e57d8fde124647ec1cd74373217582f4ec86 (diff)
Merge pull request #12 from h-v-smacker/technic-RE-batteries
Support for RE batteries for fuel
Diffstat (limited to 'nodes')
-rw-r--r--nodes/node_battery_holder.lua219
-rw-r--r--nodes/node_diggers.lua2
-rw-r--r--nodes/node_storage.lua4
-rw-r--r--nodes/recipes.lua9
4 files changed, 231 insertions, 3 deletions
diff --git a/nodes/node_battery_holder.lua b/nodes/node_battery_holder.lua
new file mode 100644
index 0000000..d29e021
--- /dev/null
+++ b/nodes/node_battery_holder.lua
@@ -0,0 +1,219 @@
+-- internationalization boilerplate
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
+
+-- Battery storage. Controller node draws electrical power from here.
+-- Note that batttery boxes are digtron group 7.
+
+local battery_holder_formspec =
+ "size[8,9.3]" ..
+ default.gui_bg ..
+ default.gui_bg_img ..
+ default.gui_slots ..
+ "label[0,0;" .. S("Batteries") .. "]" ..
+ "list[current_name;batteries;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;batteries]" ..
+ "listring[current_player;main]" ..
+ default.get_hotbar_bg(0,5.15)
+
+
+minetest.register_node("digtron:battery_holder", {
+ description = S("Digtron Battery Holder"),
+ _doc_items_longdesc = digtron.doc.battery_holder_longdesc,
+ _doc_items_usagehelp = digtron.doc.battery_holder_usagehelp,
+ _digtron_formspec = battery_holder_formspec,
+ groups = {cracky = 3, oddly_breakable_by_hand = 3, digtron = 7, tubedevice = 1, tubedevice_receiver = 1},
+ drop = "digtron:battery_holder",
+ sounds = digtron.metal_sounds,
+ paramtype2= "facedir",
+ drawtype = "nodebox",
+ paramtype = "light",
+ is_ground_content = false,
+ tiles = {
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ },
+
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec", battery_holder_formspec)
+ local inv = meta:get_inventory()
+ inv:set_size("batteries", 8*4)
+ end,
+
+ -- Only allow RE batteries to be placed in the inventory
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ if listname == "batteries" then
+ local node_name = stack:get_name()
+
+ -- Only allow RE batteries from technic mode
+ if node_name == "technic:battery" then
+ local meta = stack:get_metadata()
+ local md = minetest.deserialize(meta)
+ -- And specifically if they hold any charge
+ -- Disregard empty batteries, the player should know better
+ if md.charge > 0 then
+ return stack:get_count()
+ else
+ return 0
+ end
+
+ else
+ return 0
+ end
+ end
+ return 0
+ end,
+
+
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:is_empty("batteries")
+ end,
+
+ -- Pipeworks compatibility
+ -- Because who wouldn't send batteries through pipes if he could?
+ -----------------------------------------------------------------
+
+ tube = (function() if minetest.get_modpath("pipeworks") then return {
+ insert_object = function(pos, node, stack, direction)
+ if minetest.get_craft_result({method="batteries", width=1, items={stack}}).time ~= 0 then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("batteries", stack)
+ end
+ return stack
+ end,
+ can_insert = function(pos, node, stack, direction)
+ if minetest.get_craft_result({method="batteries", width=1, items={stack}}).time ~= 0 then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:room_for_item("batteries", stack)
+ end
+ return false
+ end,
+ input_inventory = "batteries",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ } end end)(),
+
+ after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
+ after_dig_node = (function() if minetest.get_modpath("pipeworks")then return pipeworks.after_dig end end)()
+})
+
+
+
+
+----------------------------- previous version below
+
+--[[
+
+
+minetest.register_node("digtron:battery_holder", {
+ description = S("Digtron Battery Holder"),
+ _doc_items_longdesc = digtron.doc.batteryholder_longdesc,
+ _doc_items_usagehelp = digtron.doc.batteryholder_usagehelp,
+ groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 7, tubedevice = 1, tubedevice_receiver = 1},
+ drop = "digtron:battery_holder",
+ sounds = digtron.metal_sounds,
+ paramtype2= "facedir",
+ drawtype = "nodebox",
+ paramtype = "light",
+ is_ground_content = false,
+ tiles = {
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ "digtron_plate.png^digtron_crossbrace.png^digtron_battery.png^digtron_storage.png",
+ },
+
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec",
+ "size[8,9.3]" ..
+ default.gui_bg ..
+ default.gui_bg_img ..
+ default.gui_slots ..
+ "label[0,0;" .. S("Batteries") .. "]" ..
+ "list[current_name;batteries;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;batteries]" ..
+ "listring[current_player;main]" ..
+ default.get_hotbar_bg(0,5.15)
+ )
+ local inv = meta:get_inventory()
+ inv:set_size("batteries", 8*4)
+ end,
+
+ -- Only allow RE batteries to be placed in the inventory
+ allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+ if listname == "batteries" then
+ local node_name = stack:get_name()
+
+ -- Only allow RE batteries from technic mode
+ if node_name == "technic:battery" then
+ local meta = stack:get_metadata()
+-- minetest.chat_send_all(minetest.serialize(meta))
+ local md = minetest.deserialize(meta)
+ minetest.chat_send_all("Battery has charge: "..md.charge)
+ -- And specifically if they hold any charge
+ if md.charge > 0 then
+ return stack:get_count()
+ else
+ return 0
+ end
+
+ else
+ return 0
+ end
+ end
+ return 0
+ end,
+
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:is_empty("batteries")
+ end,
+
+
+ -- Pipeworks compatibility
+ ----------------------------------------------------------------
+
+ tube = (function() if minetest.get_modpath("pipeworks") then return {
+ insert_object = function(pos, node, stack, direction)
+ local node_name = stack:get_name()
+ if node_name == "technic:battery" then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:add_item("batteries", stack)
+ end
+ return stack
+ end,
+ can_insert = function(pos, node, stack, direction)
+ local node_name = stack:get_name()
+ if node_name == "technic:battery" then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ return inv:room_for_item("batteries", stack)
+ end
+ return false
+ end,
+ input_inventory = "batteries",
+ connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
+ } end end)(),
+
+ after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
+ after_dig_node = (function() if minetest.get_modpath("pipeworks")then return pipeworks.after_dig end end)()
+})
+]]
diff --git a/nodes/node_diggers.lua b/nodes/node_diggers.lua
index bf48f71..e1daff3 100644
--- a/nodes/node_diggers.lua
+++ b/nodes/node_diggers.lua
@@ -205,7 +205,7 @@ minetest.register_node("digtron:soft_digger", {
sounds = digtron.metal_sounds,
paramtype = "light",
paramtype2= "facedir",
- is_ground_content = false,
+ is_ground_content = false,
drawtype="nodebox",
node_box = {
type = "fixed",
diff --git a/nodes/node_storage.lua b/nodes/node_storage.lua
index 56d19aa..fccf28a 100644
--- a/nodes/node_storage.lua
+++ b/nodes/node_storage.lua
@@ -21,7 +21,7 @@ local inventory_formspec =
minetest.register_node("digtron:inventory", {
description = S("Digtron Inventory Storage"),
_doc_items_longdesc = digtron.doc.inventory_longdesc,
- _doc_items_usagehelp = digtron.doc.inventory_usagehelp,
+ _doc_items_usagehelp = digtron.doc.inventory_usagehelp,
_digtron_formspec = inventory_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:inventory",
@@ -92,7 +92,7 @@ local fuelstore_formspec =
minetest.register_node("digtron:fuelstore", {
description = S("Digtron Fuel Storage"),
_doc_items_longdesc = digtron.doc.fuelstore_longdesc,
- _doc_items_usagehelp = digtron.doc.fuelstore_usagehelp,
+ _doc_items_usagehelp = digtron.doc.fuelstore_usagehelp,
_digtron_formspec = fuelstore_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:fuelstore",
diff --git a/nodes/recipes.lua b/nodes/recipes.lua
index 9895971..00cf0d7 100644
--- a/nodes/recipes.lua
+++ b/nodes/recipes.lua
@@ -91,6 +91,15 @@ minetest.register_craft({
})
minetest.register_craft({
+ output = "digtron:battery_holder",
+ recipe = {
+ {"","default:chest",""},
+ {"","digtron:digtron_core",""},
+ {"","default:steel_ingot",""}
+ }
+})
+
+minetest.register_craft({
output = "digtron:combined_storage",
recipe = {
{"","default:furnace",""},