various tidies and tweaks to technic support

master
FaceDeer 2017-10-10 20:33:56 -06:00
parent f10d46d379
commit 06a2ba85e3
7 changed files with 65 additions and 179 deletions

46
doc.lua
View File

@ -4,6 +4,14 @@ if not minetest.get_modpath("doc") then
return
end
local coal_fuel = minetest.get_craft_result({method="fuel", width=1, items={"default:coal_lump"}}).time
local dig_stone_count = coal_fuel/digtron.config.dig_cost_cracky
local dig_dirt_count = coal_fuel/digtron.config.dig_cost_crumbly
local dig_wood_count = coal_fuel/digtron.config.dig_cost_choppy
local build_count = coal_fuel/digtron.config.build_cost
local battery_ratio = (10000/digtron.config.power_ratio) / coal_fuel
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
@ -51,16 +59,18 @@ if pipeworks_enabled then
S("Inventory modules are compatible with Pipeworks blocks. When a Digtron moves one of the inventory modules adjacent to a pipe it will automatically hook up to it, and disconnect again when it moves on.")
end
local standard_fuel_doc = S("When a control unit is triggered, it will tally up how much fuel is required for the next cycle and then burn items from the fuel hopper until a sufficient amount of heat has been generated to power the operation. Any leftover heat will be retained by the control unit for use in the next cycle; this is the \"heat remaining in controller furnace\". This means you don't have to worry too much about what kinds of fuel you put in the fuel store, none will be wasted (unless you dig away a control unit with some heat remaining in it, that heat does get wasted)."
.."\n\n"..
"By using one lump of coal as fuel a digtron can:\n"..
"\tBuild @1 blocks\n"..
"\tDig @2 stone blocks\n"..
"\tDig @3 wood blocks\n"..
"\tDig @4 dirt or sand blocks", math.floor(build_count), math.floor(dig_stone_count), math.floor(dig_wood_count), math.floor(dig_dirt_count))
digtron.doc.fuelstore_longdesc = S("Stores fuel to run a Digtron")
digtron.doc.fuelstore_usagehelp = S("Digtrons have an appetite. Build operations and dig operations require a certain amount of fuel, and that fuel comes from fuel hopper modules. Note that movement does not require fuel, only digging and building."
.."\n\n"..
"When a control unit is triggered, it will tally up how much fuel is required for the next cycle and then burn items from the fuel hopper until a sufficient amount of heat has been generated to power the operation. Any leftover heat will be retained by the control unit for use in the next cycle; this is the \"heat remaining in controller furnace\". This means you don't have to worry too much about what kinds of fuel you put in the hopper, none will be wasted (unless you dig away a control unit with some heat remaining in it, that heat does get wasted)."
.."\n\n"..
"The fuel costs for digging and building can be configured in the init.lua file. By default using one lump of coal as fuel a digtron can:\n"..
"\tBuild 40 blocks\n"..
"\tDig 40 stone blocks\n"..
"\tDig 60 wood blocks\n"..
"\tDig 80 dirt or sand blocks")
digtron.doc.fuelstore_usagehelp = S("Digtrons have an appetite. Build operations and dig operations require a certain amount of fuel, and that fuel comes from fuel store modules. Note that movement does not require fuel, only digging and building.")
.."\n\n".. standard_fuel_doc
if hoppers_enabled then
digtron.doc.fuelstore_usagehelp = digtron.doc.fuelstore_usagehelp
@ -76,26 +86,26 @@ end
-- Battery holders
digtron.doc.batteryholder_longdesc = S("Holds RE batteries to run a Digtron")
digtron.doc.batteryholder_usagehelp = S("Digtrons have an appetite, and it can be satisfied by electricity as well. Build operations and dig operations require a certain amount of power, and that power comes from the batteries place in the holder. Note that movement does not consume charge, only digging and building."
digtron.doc.battery_holder_longdesc = S("Holds RE batteries to run a Digtron")
digtron.doc.battery_holder_usagehelp = S("Digtrons have an appetite, and it can be satisfied by electricity as well. Build operations and dig operations require a certain amount of power, and that power comes from the batteries place in the holder. Note that movement does not consume charge, only digging and building."
.."\n\n"..
"When a control unit is triggered, it will tally up how much power is required for the next cycle and then discharge the batteries in the battery holder until a sufficient amount of heat has been generated to power the operation. Any leftover heat will be retained by the control unit for use in the next cycle; this is the \"heat remaining in controller furnace\". Thus no power is wasted (unless you dig away a control unit with some heat remaining in it, that heat does get wasted), and the discharged batteries can be taken away to be recharged."
.."\n\n"..
"The fuel costs for digging and building can be configured in the init.lua file. By default using one lump of coal as fuel a digtron can:\n"..
"\tBuild 40 blocks\n"..
"\tDig 40 stone blocks\n"..
"\tDig 60 wood blocks\n"..
"\tDig 80 dirt or sand blocks")
"One fully charged battery can:\n"..
"\tBuild @1 blocks\n"..
"\tDig @2 stone blocks\n"..
"\tDig @3 wood blocks\n"..
"\tDig @4 dirt or sand blocks", math.floor(build_count*battery_ratio), math.floor(dig_stone_count*battery_ratio), math.floor(dig_wood_count*battery_ratio), math.floor(dig_dirt_count*battery_ratio))
if pipeworks_enabled then
digtron.doc.batteryholder_usagehelp = digtron.doc.batteryholder_usagehelp
digtron.doc.battery_holder_usagehelp = digtron.doc.battery_holder_usagehelp
.."\n\n"..
S("Fuel modules are compatible with Pipeworks blocks. When a Digtron moves one of the inventory modules adjacent to a pipe it will automatically hook up to it, and disconnect again when it moves on.")
end
digtron.doc.combined_storage_longdesc = S("Stores fuel for a Digtron and also has an inventory for building materials")
digtron.doc.combined_storage_usagehelp = S("For smaller jobs the two dedicated modules may simply be too much of a good thing, wasting precious Digtron space to give unneeded capacity. The combined storage module is the best of both worlds, splitting its internal space between building material inventory and fuel storage. It has 3/4 building material capacity and 1/4 fuel storage capacity.")
digtron.doc.combined_storage_usagehelp = S("For smaller jobs the two dedicated modules may simply be too much of a good thing, wasting precious Digtron space to give unneeded capacity. The combined storage module is the best of both worlds, splitting its internal space between building material inventory and fuel storage. It has 3/4 building material capacity and 1/4 fuel storage capacity.") .. "\n\n" .. standard_fuel_doc
if hoppers_enabled then
digtron.doc.combined_storage_usagehelp = digtron.doc.combined_storage_usagehelp

View File

@ -20,12 +20,19 @@ local battery_holder_formspec =
default.get_hotbar_bg(0,5.15)
local holder_groups = {cracky = 3, oddly_breakable_by_hand = 3, digtron = 7, tubedevice = 1, tubedevice_receiver = 1}
if not minetest.get_modpath("technic") then
-- if technic isn't installed there's no point in offering battery holders.
-- leave them registered, though, in case technic is being removed from an existing server.
holder_groups.not_in_creative_inventory = 1
end
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},
groups = holder_groups,
drop = "digtron:battery_holder",
sounds = digtron.metal_sounds,
paramtype2= "facedir",
@ -53,13 +60,13 @@ minetest.register_node("digtron:battery_holder", {
if listname == "batteries" then
local node_name = stack:get_name()
-- Only allow RE batteries from technic mode
-- Only allow RE batteries from technic mod
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
if md and md.charge > 0 then
return stack:get_count()
else
return 0
@ -85,15 +92,16 @@ minetest.register_node("digtron:battery_holder", {
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
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:add_item("batteries", 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 = 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 and md.charge > 0 then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:room_for_item("batteries", stack)
@ -106,114 +114,4 @@ minetest.register_node("digtron:battery_holder", {
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)()
})
]]
})

View File

@ -75,7 +75,6 @@ minetest.register_node("digtron:digger", {
description = S("Digtron Digger Head"),
_doc_items_longdesc = digtron.doc.digger_longdesc,
_doc_items_usagehelp = digtron.doc.digger_usagehelp,
_digtron_formspec = intermittent_formspec,
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 3},
drop = "digtron:digger",
sounds = digtron.metal_sounds,

View File

@ -90,14 +90,17 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "digtron:battery_holder",
recipe = {
{"","default:chest",""},
{"","digtron:digtron_core",""},
{"","default:steel_ingot",""}
}
})
if minetest.get_modpath("technic") then
-- no need for this recipe if technic is not installed, avoid cluttering crafting guides
minetest.register_craft({
output = "digtron:battery_holder",
recipe = {
{"","default:chest",""},
{"","digtron:digtron_core",""},
{"","default:steel_ingot",""}
}
})
end
minetest.register_craft({
output = "digtron:combined_storage",

View File

@ -36,3 +36,8 @@ digtron_dig_cost_choppy (Fuel cost for digging choppy blocks) float 0.75 0.0 100
digtron_dig_cost_default (Fuel cost for digging other block types) float 0.5 0.0 100.0
#How much fuel is required to build a block
digtron_build_cost (Fuel cost to build one block) float 1.0 0.0 100.0
#If the [technic] mod is installed Digtron can draw power from technic batteries.
#A full battery holds 10000 electrical units. This is divided by the power ratio
#setting to convert it into fuel units.
digtron_power_ratio (Electrical charge to coal heat conversion ratio) int 1 1000 100

View File

@ -226,11 +226,9 @@ digtron.tap_batteries = function(battery_positions, target, test)
end
for i, itemstack in pairs(invlist) do
local meta = minetest.deserialize(itemstack:get_metadata())
if (meta =~ nil) then
if (meta ~= nil) then
local power_available = math.floor(meta.charge / digtron.config.power_ratio)
minetest.chat_send_all("Charge reported: "..meta.charge.." which is enough for "..power_available.." power")
if power_available ~= 0 then
local actual_burned = power_available -- we just take all we have from the battery, since they aren't stackable
if test ~= true then
@ -265,11 +263,7 @@ digtron.tap_batteries = function(battery_positions, target, test)
break
end
end
if (current_burned == 0) then
minetest.chat_send_all("Batteries not found!")
end
if test ~= true then
-- only update the list if we're doing this for real.
inv:set_list("batteries", invlist)

View File

@ -207,9 +207,6 @@ digtron.execute_dig_cycle = function(pos, clicker)
local test_fuel_needed = test_build_fuel_cost + digging_fuel_cost - fuel_burning
local test_fuel_burned = 0
-- if test_fuel_needed > 0 then
-- test_fuel_burned = digtron.burn(layout.fuelstores, test_fuel_needed, true)
-- end
if test_fuel_needed > 0 then
-- check for the available electrical power
@ -315,16 +312,6 @@ digtron.execute_dig_cycle = function(pos, clicker)
minetest.sound_play("buzzer", {gain=0.5, pos=pos})
status_text = S("Digtron unexpectedly failed to execute one or more build operations, likely due to an inventory error.") .. "\n"
end
-- -- acutally burn the fuel needed
-- local fuel_cost = digging_fuel_cost + building_fuel_cost
-- fuel_burning = fuel_burning - fuel_cost
-- if digtron.config.particle_effects then
-- table.insert(particle_systems, burn_smoke(pos, fuel_cost))
-- end
-- if fuel_burning < 0 then
-- fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false)
-- end
-- actually burn the fuel needed
fuel_burning = fuel_burning - digging_fuel_cost
@ -522,15 +509,6 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
local status_text = ""
-- -- acutally burn the fuel needed
-- fuel_burning = fuel_burning - digging_fuel_cost
-- if digtron.config.particle_effects then
-- table.insert(particle_systems, burn_smoke(pos, digging_fuel_cost))
-- end
-- if fuel_burning < 0 then
-- fuel_burning = fuel_burning + digtron.burn(layout.fuelstores, -fuel_burning, false)
-- end
-- actually burn the fuel needed
fuel_burning = fuel_burning - digging_fuel_cost
if digtron.particle_effects and exhaust == 1 then
@ -545,7 +523,6 @@ digtron.execute_downward_dig_cycle = function(pos, clicker)
end
end
meta:set_float("fuel_burning", fuel_burning)
meta:set_int("on_coal", exhaust)
status_text = status_text .. S("Heat remaining in controller furnace: @1", math.max(0, fuel_burning))