forked from minetest-mods/technic
Move files to subfolders
This commit is contained in:
parent
afc84d6a8d
commit
5d470cd753
@ -1,39 +0,0 @@
|
||||
alloy_recipes ={}
|
||||
|
||||
registered_recipes_count=1
|
||||
|
||||
function register_alloy_recipe (string1,count1, string2,count2, string3,count3)
|
||||
alloy_recipes[registered_recipes_count]={}
|
||||
alloy_recipes[registered_recipes_count].src1_name=string1
|
||||
alloy_recipes[registered_recipes_count].src1_count=count1
|
||||
alloy_recipes[registered_recipes_count].src2_name=string2
|
||||
alloy_recipes[registered_recipes_count].src2_count=count2
|
||||
alloy_recipes[registered_recipes_count].dst_name=string3
|
||||
alloy_recipes[registered_recipes_count].dst_count=count3
|
||||
registered_recipes_count=registered_recipes_count+1
|
||||
alloy_recipes[registered_recipes_count]={}
|
||||
alloy_recipes[registered_recipes_count].src1_name=string2
|
||||
alloy_recipes[registered_recipes_count].src1_count=count2
|
||||
alloy_recipes[registered_recipes_count].src2_name=string1
|
||||
alloy_recipes[registered_recipes_count].src2_count=count1
|
||||
alloy_recipes[registered_recipes_count].dst_name=string3
|
||||
alloy_recipes[registered_recipes_count].dst_count=count3
|
||||
registered_recipes_count=registered_recipes_count+1
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "alloy",
|
||||
output = string3.." "..count3,
|
||||
items = {string1.." "..count1,string2.." "..count2},
|
||||
width = 2,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
register_alloy_recipe ("technic:copper_dust",3, "technic:tin_dust",1, "technic:bronze_dust",4)
|
||||
register_alloy_recipe ("moreores:copper_ingot",3, "moreores:tin_ingot",1, "moreores:bronze_ingot",4)
|
||||
register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4)
|
||||
register_alloy_recipe ("default:steel_ingot",3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
|
||||
register_alloy_recipe ("technic:copper_dust",2, "technic:zinc_dust",1, "technic:brass_dust",3)
|
||||
register_alloy_recipe ("moreores:copper_ingot",2, "technic:zinc_ingot",1, "technic:brass_ingot",3)
|
||||
register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1)
|
||||
register_alloy_recipe ("technic:silicon_wafer",1, "technic:gold_dust",1, "technic:doped_silicon_wafer",1)
|
@ -1,21 +0,0 @@
|
||||
technic.creative_inventory_size = 0
|
||||
technic.creative_list = {}
|
||||
|
||||
-- Create detached creative inventory after loading all mods
|
||||
minetest.after(0, function()
|
||||
local inv = minetest.create_detached_inventory("technic_creative", {})
|
||||
technic.creative_list = {}
|
||||
for name,def in pairs(minetest.registered_items) do
|
||||
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
|
||||
and def.description and def.description ~= "" then
|
||||
table.insert(technic.creative_list, name)
|
||||
end
|
||||
end
|
||||
table.sort(technic.creative_list)
|
||||
--inv:set_size("main", #technic.creative_list)
|
||||
--for _,itemstring in ipairs(technic.creative_list) do
|
||||
-- local stack = ItemStack(itemstring)
|
||||
-- inv:add_item("main", stack)
|
||||
--end
|
||||
--technic.creative_inventory_size = #technic.creative_list
|
||||
end)
|
@ -1,225 +0,0 @@
|
||||
-- The HV down converter will step down HV EUs to MV EUs
|
||||
-- If we take the solar panel as calibration then the
|
||||
-- 1 HVEU = 5 MVEU as we stack 5 MV arrays to get a HV array.
|
||||
-- The downconverter does of course have a conversion loss.
|
||||
-- This loses 30% of the power.
|
||||
-- The converter does not store any energy by itself.
|
||||
minetest.register_node("technic:down_converter_hv", {
|
||||
description = "HV Down Converter",
|
||||
tiles = {"technic_hv_down_converter_top.png", "technic_hv_down_converter_bottom.png", "technic_hv_down_converter_side.png",
|
||||
"technic_hv_down_converter_side.png", "technic_hv_down_converter_side.png", "technic_hv_down_converter_side.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_float("technic_hv_power_machine", 1)
|
||||
meta:set_float("technic_mv_power_machine", 1)
|
||||
meta:set_float("internal_EU_buffer",0)
|
||||
meta:set_float("internal_EU_buffer_size",0)
|
||||
meta:set_string("infotext", "HV Down Converter")
|
||||
meta:set_float("active", false)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:down_converter_hv 1',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot','technic:stainless_steel_ingot'},
|
||||
{'technic:hv_transformer', 'technic:hv_cable', 'technic:mv_transformer'},
|
||||
{'technic:hv_cable', 'technic:rubber', 'technic:mv_cable'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"technic:down_converter_hv"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
-- HV->MV conversion factor
|
||||
local hv_mv_factor = 5
|
||||
-- The maximun charge a single converter can handle. Let's set this to
|
||||
-- what 5 HV solar arrays can produce - 30% loss (2880*5*0.7)
|
||||
local max_charge = 10080*hv_mv_factor
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta1 = nil
|
||||
local pos1 = {}
|
||||
local available_charge = 0 -- counted in MV units
|
||||
local used_charge = 0 -- counted in MV units
|
||||
|
||||
-- Index all HV nodes connected to the network
|
||||
-- HV cable comes in through the bottom
|
||||
pos1.y = pos.y-1
|
||||
pos1.x = pos.x
|
||||
pos1.z = pos.z
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
if meta1:get_float("hv_cablelike")~=1 then return end
|
||||
|
||||
local HV_nodes = {} -- HV type
|
||||
local HV_PR_nodes = {} -- HV type
|
||||
local HV_BA_nodes = {} -- HV type
|
||||
|
||||
HV_nodes[1] = {}
|
||||
HV_nodes[1].x = pos1.x
|
||||
HV_nodes[1].y = pos1.y
|
||||
HV_nodes[1].z = pos1.z
|
||||
|
||||
local table_index = 1
|
||||
repeat
|
||||
check_HV_node(HV_PR_nodes,nil,HV_BA_nodes,HV_nodes,table_index)
|
||||
table_index = table_index + 1
|
||||
if HV_nodes[table_index] == nil then break end
|
||||
until false
|
||||
|
||||
--print("HV_nodes: PR="..table.getn(HV_PR_nodes).." BA="..table.getn(HV_BA_nodes))
|
||||
|
||||
-- Index all MV nodes connected to the network
|
||||
-- MV cable comes out of the top
|
||||
pos1.y = pos.y+1
|
||||
pos1.x = pos.x
|
||||
pos1.z = pos.z
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
if meta1:get_float("mv_cablelike")~=1 then return end
|
||||
|
||||
local MV_nodes = {} -- MV type
|
||||
local MV_RE_nodes = {} -- MV type
|
||||
local MV_BA_nodes = {} -- MV type
|
||||
|
||||
MV_nodes[1] = {}
|
||||
MV_nodes[1].x = pos1.x
|
||||
MV_nodes[1].y = pos1.y
|
||||
MV_nodes[1].z = pos1.z
|
||||
|
||||
table_index = 1
|
||||
repeat
|
||||
check_MV_node(nil,MV_RE_nodes,MV_BA_nodes,MV_nodes,table_index)
|
||||
table_index = table_index + 1
|
||||
if MV_nodes[table_index] == nil then break end
|
||||
until false
|
||||
|
||||
--print("MV_nodes: RE="..table.getn(MV_RE_nodes).." BA="..table.getn(MV_BA_nodes))
|
||||
|
||||
-- First get available power from all the attached HV suppliers
|
||||
-- Get the supplier internal EU buffer and read the EUs from it
|
||||
-- No update yet!
|
||||
local pos1
|
||||
-- FIXME: Until further leave the producers out of it and just let the batteries be the hub
|
||||
-- for _,pos1 in ipairs(HV_PR_nodes) do
|
||||
-- meta1 = minetest.env:get_meta(pos1)
|
||||
-- local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
-- available_charge = available_charge + meta1:get_float("internal_EU_buffer") * hv_mv_factor
|
||||
-- -- Limit conversion capacity
|
||||
-- if available_charge > max_charge then
|
||||
-- available_charge = max_charge
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
-- --print("Available_charge PR:"..available_charge)
|
||||
|
||||
for _,pos1 in ipairs(HV_BA_nodes) do
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
available_charge = available_charge + meta1:get_float("internal_EU_buffer") * hv_mv_factor
|
||||
-- Limit conversion capacity
|
||||
if available_charge > max_charge then
|
||||
available_charge = max_charge
|
||||
break
|
||||
end
|
||||
end
|
||||
--print("Available_charge PR+BA:"..available_charge)
|
||||
|
||||
-- Calculate total number of receivers:
|
||||
local MV_receivers = table.getn(MV_RE_nodes)+table.getn(MV_BA_nodes)
|
||||
|
||||
-- Next supply power to all connected MV machines
|
||||
-- Get the power receiver internal EU buffer and give EUs to it
|
||||
-- Note: for now leave out RE type machines until producers distribute power themselves even without a battery
|
||||
-- for _,pos1 in ipairs(MV_RE_nodes) do
|
||||
-- local meta1 = minetest.env:get_meta(pos1)
|
||||
-- local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
-- local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
|
||||
-- local charge_to_give = math.min(4000, available_charge/MV_receivers) -- power rating limit on the MV wire
|
||||
-- -- How much can this unit take?
|
||||
-- if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
|
||||
-- charge_to_give=internal_EU_buffer_size-internal_EU_buffer
|
||||
-- end
|
||||
-- -- If we are emptying the supply take the remainder
|
||||
-- if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
|
||||
-- -- Update the unit supplied to
|
||||
-- internal_EU_buffer = internal_EU_buffer + charge_to_give
|
||||
-- meta1:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
-- -- Do the accounting
|
||||
-- used_charge = used_charge + charge_to_give
|
||||
-- if available_charge == used_charge then break end -- bail out if supply depleted
|
||||
-- end
|
||||
--print("used_charge RE:"..used_charge)
|
||||
|
||||
for _,pos1 in ipairs(MV_BA_nodes) do
|
||||
local meta1 = minetest.env:get_meta(pos1)
|
||||
local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
|
||||
--print("internal_EU_buffer:"..internal_EU_buffer)
|
||||
--print("internal_EU_buffer_size:"..internal_EU_buffer_size)
|
||||
local charge_to_give = math.min(math.floor(available_charge/MV_receivers), 4000) -- power rating limit on the MV wire
|
||||
--print("charge_to_give:"..charge_to_give)
|
||||
-- How much can this unit take?
|
||||
if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
|
||||
charge_to_give=internal_EU_buffer_size-internal_EU_buffer
|
||||
end
|
||||
--print("charge_to_give2:"..charge_to_give)
|
||||
-- If we are emptying the supply take the remainder
|
||||
if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
|
||||
-- Update the unit supplied to
|
||||
--print("charge_to_give3:"..charge_to_give)
|
||||
internal_EU_buffer = internal_EU_buffer + charge_to_give
|
||||
--print("internal_EU_buffer:"..internal_EU_buffer)
|
||||
meta1:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
-- Do the accounting
|
||||
used_charge = used_charge + charge_to_give
|
||||
--print("used_charge:"..used_charge)
|
||||
if available_charge == used_charge then break end -- bail out if supply depleted
|
||||
end
|
||||
--print("used_charge RE+BA:"..used_charge)
|
||||
|
||||
-- Last update the HV suppliers with the actual demand.
|
||||
-- Get the supplier internal EU buffer and update the EUs from it
|
||||
-- Note: So far PR nodes left out and only BA nodes are updated
|
||||
local HV_BA_size = table.getn(HV_BA_nodes)
|
||||
for _,pos1 in ipairs(HV_BA_nodes) do
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
local charge_to_take = math.floor(used_charge/HV_BA_size/hv_mv_factor) -- HV units
|
||||
if internal_EU_buffer-charge_to_take <= 0 then
|
||||
charge_to_take = internal_EU_buffer
|
||||
end
|
||||
if charge_to_take > 0 then
|
||||
internal_EU_buffer = internal_EU_buffer-charge_to_take
|
||||
meta1:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
end
|
||||
end
|
||||
|
||||
if used_charge>0 then
|
||||
meta:set_string("infotext", "HV Down Converter is active (HV:"..available_charge.."/MV:"..used_charge..")");
|
||||
meta:set_float("active",1) -- used for setting textures someday maybe
|
||||
else
|
||||
meta:set_string("infotext", "HV Down Converter is inactive (HV:"..available_charge.."/MV:"..used_charge..")");
|
||||
meta:set_float("active",0) -- used for setting textures someday maybe
|
||||
return
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- This machine does not store energy it receives energy from the HV side and outputs it on the MV side
|
||||
register_HV_machine ("technic:down_converter_hv","RE")
|
||||
register_MV_machine ("technic:down_converter_hv","PR")
|
@ -1,226 +0,0 @@
|
||||
-- The MV down converter will step down MV EUs to LV EUs
|
||||
-- If we take the solar panel as calibration then the
|
||||
-- 1 MVEU = 5 LVEU as we stack 5 LV arrays to get an MV array.
|
||||
-- The downconverter does of course have a conversion loss.
|
||||
-- This loses 30% of the power.
|
||||
-- The converter does not store any energy by itself.
|
||||
minetest.register_node(
|
||||
"technic:down_converter_mv", {
|
||||
description = "MV Down Converter",
|
||||
tiles = {"technic_mv_down_converter_top.png", "technic_mv_down_converter_bottom.png", "technic_mv_down_converter_side.png",
|
||||
"technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_float("technic_mv_power_machine", 1)
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_float("internal_EU_buffer",0)
|
||||
meta:set_float("internal_EU_buffer_size",0)
|
||||
meta:set_string("infotext", "MV Down Converter")
|
||||
meta:set_float("active", false)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:down_converter_mv 1',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot','technic:stainless_steel_ingot'},
|
||||
{'technic:mv_transformer', 'technic:mv_cable', 'technic:lv_transformer'},
|
||||
{'technic:mv_cable', 'technic:rubber', 'technic:lv_cable'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"technic:down_converter_mv"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
-- MV->LV conversion factor
|
||||
local mv_lv_factor = 5
|
||||
-- The maximun charge a single converter can handle. Let's set this to
|
||||
-- what 5 MV solar arrays can produce - 30% loss (720*5*0.7)
|
||||
local max_charge = 2520*mv_lv_factor
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta1 = nil
|
||||
local pos1 = {}
|
||||
local available_charge = 0 -- counted in LV units
|
||||
local used_charge = 0 -- counted in LV units
|
||||
|
||||
-- Index all MV nodes connected to the network
|
||||
-- MV cable comes in through the bottom
|
||||
pos1.y = pos.y-1
|
||||
pos1.x = pos.x
|
||||
pos1.z = pos.z
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
if meta1:get_float("mv_cablelike")~=1 then return end
|
||||
|
||||
local MV_nodes = {} -- MV type
|
||||
local MV_PR_nodes = {} -- MV type
|
||||
local MV_BA_nodes = {} -- MV type
|
||||
|
||||
MV_nodes[1] = {}
|
||||
MV_nodes[1].x = pos1.x
|
||||
MV_nodes[1].y = pos1.y
|
||||
MV_nodes[1].z = pos1.z
|
||||
|
||||
local table_index = 1
|
||||
repeat
|
||||
check_MV_node(MV_PR_nodes,nil,MV_BA_nodes,MV_nodes,table_index)
|
||||
table_index = table_index + 1
|
||||
if MV_nodes[table_index] == nil then break end
|
||||
until false
|
||||
|
||||
--print("MV_nodes: PR="..table.getn(MV_PR_nodes).." BA="..table.getn(MV_BA_nodes))
|
||||
|
||||
-- Index all LV nodes connected to the network
|
||||
-- LV cable comes out of the top
|
||||
pos1.y = pos.y+1
|
||||
pos1.x = pos.x
|
||||
pos1.z = pos.z
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
if meta1:get_float("cablelike")~=1 then return end
|
||||
|
||||
local LV_nodes = {} -- LV type
|
||||
local LV_RE_nodes = {} -- LV type
|
||||
local LV_BA_nodes = {} -- LV type
|
||||
|
||||
LV_nodes[1] = {}
|
||||
LV_nodes[1].x = pos1.x
|
||||
LV_nodes[1].y = pos1.y
|
||||
LV_nodes[1].z = pos1.z
|
||||
|
||||
table_index = 1
|
||||
repeat
|
||||
check_LV_node(nil,LV_RE_nodes,LV_BA_nodes,LV_nodes,table_index)
|
||||
table_index = table_index + 1
|
||||
if LV_nodes[table_index] == nil then break end
|
||||
until false
|
||||
|
||||
--print("LV_nodes: RE="..table.getn(LV_RE_nodes).." BA="..table.getn(LV_BA_nodes))
|
||||
|
||||
-- First get available power from all the attached MV suppliers
|
||||
-- Get the supplier internal EU buffer and read the EUs from it
|
||||
-- No update yet!
|
||||
local pos1
|
||||
-- FIXME: Until further leave the producers out of it and just let the batteries be the hub
|
||||
-- for _,pos1 in ipairs(MV_PR_nodes) do
|
||||
-- meta1 = minetest.env:get_meta(pos1)
|
||||
-- local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
-- available_charge = available_charge + meta1:get_float("internal_EU_buffer") * mv_lv_factor
|
||||
-- -- Limit conversion capacity
|
||||
-- if available_charge > max_charge then
|
||||
-- available_charge = max_charge
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
-- print("Available_charge PR:"..available_charge)
|
||||
|
||||
for _,pos1 in ipairs(MV_BA_nodes) do
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
available_charge = available_charge + meta1:get_float("internal_EU_buffer") * mv_lv_factor
|
||||
-- Limit conversion capacity
|
||||
if available_charge > max_charge then
|
||||
available_charge = max_charge
|
||||
break
|
||||
end
|
||||
end
|
||||
--print("Available_charge PR+BA:"..available_charge)
|
||||
|
||||
-- Calculate total number of receivers:
|
||||
local LV_receivers = table.getn(LV_RE_nodes)+table.getn(LV_BA_nodes)
|
||||
|
||||
-- Next supply power to all connected LV machines
|
||||
-- Get the power receiver internal EU buffer and give EUs to it
|
||||
-- Note: for now leave out RE type machines until producers distribute power themselves even without a battery
|
||||
-- for _,pos1 in ipairs(LV_RE_nodes) do
|
||||
-- local meta1 = minetest.env:get_meta(pos1)
|
||||
-- local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
-- local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
|
||||
-- local charge_to_give = math.min(1000, available_charge/LV_receivers) -- power rating limit on the LV wire
|
||||
-- -- How much can this unit take?
|
||||
-- if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
|
||||
-- charge_to_give=internal_EU_buffer_size-internal_EU_buffer
|
||||
-- end
|
||||
-- -- If we are emptying the supply take the remainder
|
||||
-- if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
|
||||
-- -- Update the unit supplied to
|
||||
-- internal_EU_buffer = internal_EU_buffer + charge_to_give
|
||||
-- meta1:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
-- -- Do the accounting
|
||||
-- used_charge = used_charge + charge_to_give
|
||||
-- if available_charge == used_charge then break end -- bail out if supply depleted
|
||||
-- end
|
||||
--print("used_charge RE:"..used_charge)
|
||||
|
||||
for _,pos1 in ipairs(LV_BA_nodes) do
|
||||
local meta1 = minetest.env:get_meta(pos1)
|
||||
local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
|
||||
--print("internal_EU_buffer:"..internal_EU_buffer)
|
||||
--print("internal_EU_buffer_size:"..internal_EU_buffer_size)
|
||||
local charge_to_give = math.min(math.floor(available_charge/LV_receivers), 1000) -- power rating limit on the LV wire
|
||||
--print("charge_to_give:"..charge_to_give)
|
||||
-- How much can this unit take?
|
||||
if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
|
||||
charge_to_give=internal_EU_buffer_size-internal_EU_buffer
|
||||
end
|
||||
--print("charge_to_give2:"..charge_to_give)
|
||||
-- If we are emptying the supply take the remainder
|
||||
if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
|
||||
-- Update the unit supplied to
|
||||
--print("charge_to_give3:"..charge_to_give)
|
||||
internal_EU_buffer = internal_EU_buffer + charge_to_give
|
||||
--print("internal_EU_buffer:"..internal_EU_buffer)
|
||||
meta1:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
-- Do the accounting
|
||||
used_charge = used_charge + charge_to_give
|
||||
--print("used_charge:"..used_charge)
|
||||
if available_charge == used_charge then break end -- bail out if supply depleted
|
||||
end
|
||||
--print("used_charge RE+BA:"..used_charge)
|
||||
|
||||
-- Last update the MV suppliers with the actual demand.
|
||||
-- Get the supplier internal EU buffer and update the EUs from it
|
||||
-- Note: So far PR nodes left out and only BA nodes are updated
|
||||
local MV_BA_size = table.getn(MV_BA_nodes)
|
||||
for _,pos1 in ipairs(MV_BA_nodes) do
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
|
||||
local charge_to_take = math.floor(used_charge/MV_BA_size/mv_lv_factor) -- MV units
|
||||
if internal_EU_buffer-charge_to_take <= 0 then
|
||||
charge_to_take = internal_EU_buffer
|
||||
end
|
||||
if charge_to_take > 0 then
|
||||
internal_EU_buffer = internal_EU_buffer-charge_to_take
|
||||
meta1:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
end
|
||||
end
|
||||
|
||||
if used_charge>0 then
|
||||
meta:set_string("infotext", "MV Down Converter is active (MV:"..available_charge.."/LV:"..used_charge..")");
|
||||
meta:set_float("active",1) -- used for setting textures someday maybe
|
||||
else
|
||||
meta:set_string("infotext", "MV Down Converter is inactive (MV:"..available_charge.."/LV:"..used_charge..")");
|
||||
meta:set_float("active",0) -- used for setting textures someday maybe
|
||||
return
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- This machine does not store energy it receives energy from the MV side and outputs it on the LV side
|
||||
register_MV_machine ("technic:down_converter_mv","RE")
|
||||
register_LV_machine ("technic:down_converter_mv","PR")
|
@ -1,268 +0,0 @@
|
||||
power_tools ={}
|
||||
|
||||
registered_power_tools_count=1
|
||||
|
||||
function register_power_tool (string1,max_charge)
|
||||
power_tools[registered_power_tools_count]={}
|
||||
power_tools[registered_power_tools_count].tool_name=string1
|
||||
power_tools[registered_power_tools_count].max_charge=max_charge
|
||||
registered_power_tools_count=registered_power_tools_count+1
|
||||
end
|
||||
|
||||
register_power_tool ("technic:mining_drill",60000)
|
||||
register_power_tool ("technic:laser_mk1",40000)
|
||||
register_power_tool ("technic:battery",10000)
|
||||
|
||||
minetest.register_alias("battery", "technic:battery")
|
||||
minetest.register_alias("battery_box", "technic:battery_box")
|
||||
minetest.register_alias("electric_furnace", "technic:electric_furnace")
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:battery 1',
|
||||
recipe = {
|
||||
{'default:wood', 'default:copper_ingot', 'default:wood'},
|
||||
{'default:wood', 'moreores:tin_ingot', 'default:wood'},
|
||||
{'default:wood', 'default:copper_ingot', 'default:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:battery_box 1',
|
||||
recipe = {
|
||||
{'technic:battery', 'default:wood', 'technic:battery'},
|
||||
{'technic:battery', 'default:copper_ingot', 'technic:battery'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:electric_furnace',
|
||||
recipe = {
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
{'default:brick', '', 'default:brick'},
|
||||
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_tool("technic:battery",
|
||||
{description = "RE Battery",
|
||||
inventory_image = "technic_battery.png",
|
||||
energy_charge = 0,
|
||||
tool_capabilities = {max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}})
|
||||
|
||||
minetest.register_craftitem("technic:battery_box", {
|
||||
description = "Battery box",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
|
||||
|
||||
battery_box_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"image[4,1;1,1;technic_battery_reload.png]"..
|
||||
"list[current_name;dst;5,1;1,1;]"..
|
||||
"label[0,0;Battery box]"..
|
||||
"label[3,0;Charge]"..
|
||||
"label[5,0;Discharge]"..
|
||||
"label[1,3;Power level]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
minetest.register_node("technic:battery_box", {
|
||||
description = "Battery box",
|
||||
tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png", "technic_battery_box_side.png",
|
||||
"technic_battery_box_side.png", "technic_battery_box_side.png", "technic_battery_box_side.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
technic_power_machine=1,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("infotext", "Battery box")
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", battery_box_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 1)
|
||||
battery_charge = 0
|
||||
max_charge = 60000
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
electric_furnace_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"label[0,0;Electric Furnace]"..
|
||||
"label[1,3;Power level]"
|
||||
|
||||
minetest.register_node("technic:electric_furnace", {
|
||||
description = "Electric furnace",
|
||||
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
|
||||
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
technic_power_machine=1,
|
||||
internal_EU_buffer=0;
|
||||
interal_EU_buffer_size=2000;
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("infotext", "Electric furnace")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
local EU_used = 0
|
||||
local furnace_is_cookin = 0
|
||||
local cooked = nil
|
||||
meta:set_float("internal_EU_buffer",0)
|
||||
meta:set_float("internal_EU_buffer_size",2000)
|
||||
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:electric_furnace_active", {
|
||||
description = "Electric Furnace",
|
||||
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
|
||||
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "technic:electric_furnace",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
internal_EU_buffer=0;
|
||||
interal_EU_buffer_size=2000;
|
||||
technic_power_machine=1,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("infotext", "Electric furnace");
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
local EU_used = 0
|
||||
local furnace_is_cookin = 0
|
||||
local cooked = nil
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:electric_furnace","technic:electric_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
internal_EU_buffer=meta:get_float("internal_EU_buffer")
|
||||
internal_EU_buffer_size=meta:get_float("internal_EU_buffer")
|
||||
local load = math.floor(internal_EU_buffer/2000 * 100)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
|
||||
(load)..":technic_power_meter_fg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"label[0,0;Electric Furnace]"..
|
||||
"label[1,3;Power level]")
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local furnace_is_cookin = meta:get_float("furnace_is_cookin")
|
||||
|
||||
|
||||
local srclist = inv:get_list("src")
|
||||
local cooked=nil
|
||||
|
||||
if srclist then
|
||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
end
|
||||
|
||||
|
||||
if (furnace_is_cookin == 1) then
|
||||
if internal_EU_buffer>=150 then
|
||||
internal_EU_buffer=internal_EU_buffer-150;
|
||||
meta:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
meta:set_float("src_time", meta:get_float("src_time") + 3)
|
||||
if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
|
||||
-- check if there's room for output in "dst" list
|
||||
if inv:room_for_item("dst",cooked.item) then
|
||||
-- Put result in "dst" list
|
||||
inv:add_item("dst", cooked.item)
|
||||
-- take stuff from "src" list
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
else
|
||||
print("Furnace inventory full!")
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
if srclist then
|
||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
if cooked.time>0 then
|
||||
hacky_swap_node(pos,"technic:electric_furnace_active")
|
||||
meta:set_string("infotext","Furnace active")
|
||||
meta:set_string("furnace_is_cookin",1)
|
||||
-- meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("src_time", 0)
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
hacky_swap_node(pos,"technic:electric_furnace")
|
||||
meta:set_string("infotext","Furnace inactive")
|
||||
meta:set_string("furnace_is_cookin",0)
|
||||
-- meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("src_time", 0)
|
||||
|
||||
|
||||
end,
|
||||
})
|
@ -1,353 +0,0 @@
|
||||
grinder_recipes ={}
|
||||
|
||||
registered_grinder_recipes_count=1
|
||||
|
||||
function register_grinder_recipe (string1,string2)
|
||||
grinder_recipes[registered_grinder_recipes_count]={}
|
||||
grinder_recipes[registered_grinder_recipes_count].src_name=string1
|
||||
grinder_recipes[registered_grinder_recipes_count].dst_name=string2
|
||||
registered_grinder_recipes_count=registered_grinder_recipes_count+1
|
||||
if unified_inventory then
|
||||
unified_inventory.register_craft({
|
||||
type = "grinding",
|
||||
output = string2,
|
||||
items = {string1},
|
||||
width = 0,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
register_grinder_recipe("default:stone","default:sand")
|
||||
register_grinder_recipe("default:cobble","default:gravel")
|
||||
register_grinder_recipe("default:gravel","default:dirt")
|
||||
register_grinder_recipe("default:desert_stone","default:desert_sand")
|
||||
register_grinder_recipe("default:iron_lump","technic:iron_dust 2")
|
||||
register_grinder_recipe("default:steel_ingot","technic:iron_dust 1")
|
||||
register_grinder_recipe("default:coal_lump","technic:coal_dust 2")
|
||||
register_grinder_recipe("default:copper_lump","technic:copper_dust 2")
|
||||
register_grinder_recipe("default:copper_ingot","technic:copper_dust 1")
|
||||
register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
|
||||
register_grinder_recipe("default:gold_ingot","technic:gold_dust 1")
|
||||
--register_grinder_recipe("default:bronze_ingot","technic:bronze_dust 1") -- Dust does not exist yet
|
||||
--register_grinder_recipe("home_decor:brass_ingot","technic:brass_dust 1") -- needs check for the mod
|
||||
register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2")
|
||||
register_grinder_recipe("moreores:tin_ingot","technic:tin_dust 1")
|
||||
register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
|
||||
register_grinder_recipe("moreores:silver_ingot","technic:silver_dust 1")
|
||||
register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2")
|
||||
register_grinder_recipe("moreores:mithril_ingot","technic:mithril_dust 1")
|
||||
register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2")
|
||||
register_grinder_recipe("technic:chromium_ingot","technic:chromium_dust 1")
|
||||
register_grinder_recipe("technic:stainless_steel_ingot","stainless_steel_dust 1")
|
||||
register_grinder_recipe("group:brass_ingot","technic:brass_dust 1")
|
||||
register_grinder_recipe("technic:zinc_lump","technic:zinc_dust 2")
|
||||
register_grinder_recipe("technic:zinc_ingot","technic:zinc_dust 1")
|
||||
register_grinder_recipe("technic:coal_dust","dye:black 2")
|
||||
register_grinder_recipe("default:cactus","dye:green 2")
|
||||
register_grinder_recipe("default:dry_shrub","dye:brown 2")
|
||||
register_grinder_recipe("flowers:flower_geranium","dye:blue 2")
|
||||
register_grinder_recipe("flowers:flower_dandelion_white","dye:white 2")
|
||||
register_grinder_recipe("flowers:flower_dandelion_yellow","dye:yellow 2")
|
||||
register_grinder_recipe("flowers:flower_tulip","dye:orange 2")
|
||||
register_grinder_recipe("flowers:flower_rose","dye:red 2")
|
||||
register_grinder_recipe("flowers:flower_viola","dye:violet 2")
|
||||
|
||||
minetest.register_craftitem( "technic:coal_dust", {
|
||||
description = "Coal Dust",
|
||||
inventory_image = "technic_coal_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:iron_dust", {
|
||||
description = "Iron Dust",
|
||||
inventory_image = "technic_iron_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "default:steel_ingot",
|
||||
recipe = "technic:iron_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:copper_dust", {
|
||||
description = "Copper Dust",
|
||||
inventory_image = "technic_copper_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "moreores:copper_ingot",
|
||||
recipe = "technic:copper_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:tin_dust", {
|
||||
description = "Tin Dust",
|
||||
inventory_image = "technic_tin_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "moreores:tin_ingot",
|
||||
recipe = "technic:tin_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:silver_dust", {
|
||||
description = "Silver Dust",
|
||||
inventory_image = "technic_silver_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "moreores:silver_ingot",
|
||||
recipe = "technic:silver_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:gold_dust", {
|
||||
description = "Gold Dust",
|
||||
inventory_image = "technic_gold_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "moreores:gold_ingot",
|
||||
recipe = "technic:gold_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:mithril_dust", {
|
||||
description = "Mithril Dust",
|
||||
inventory_image = "technic_mithril_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "moreores:mithril_ingot",
|
||||
recipe = "technic:mithril_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:chromium_dust", {
|
||||
description = "Chromium Dust",
|
||||
inventory_image = "technic_chromium_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "technic:chromium_ingot",
|
||||
recipe = "technic:chromium_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:bronze_dust", {
|
||||
description = "Bronze Dust",
|
||||
inventory_image = "technic_bronze_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "moreores:bronze_ingot",
|
||||
recipe = "technic:bronze_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:brass_dust", {
|
||||
description = "Brass Dust",
|
||||
inventory_image = "technic_brass_dust.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "technic:brass_ingot",
|
||||
recipe = "technic:brass_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:stainless_steel_dust", {
|
||||
description = "Stainless Steel Dust",
|
||||
inventory_image = "technic_stainless_steel_dust.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "technic:stainless_steel_ingot",
|
||||
recipe = "technic:stainless_steel_dust",
|
||||
})
|
||||
|
||||
minetest.register_craftitem( "technic:zinc_dust", {
|
||||
description = "Zinc Dust",
|
||||
inventory_image = "technic_zinc_dust.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "technic:zinc_ingot",
|
||||
recipe = "technic:zinc_dust",
|
||||
})
|
||||
|
||||
minetest.register_alias("grinder", "technic:grinder")
|
||||
minetest.register_craft({
|
||||
output = 'technic:grinder',
|
||||
recipe = {
|
||||
{'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
|
||||
{'default:desert_stone', 'default:diamond', 'default:desert_stone'},
|
||||
{'default:stone', 'moreores:copper_ingot', 'default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:grinder", {
|
||||
description = "Grinder",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
grinder_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png]"..
|
||||
"label[0,0;Grinder]"..
|
||||
"label[1,3;Power level]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
|
||||
minetest.register_node("technic:grinder", {
|
||||
description = "Grinder",
|
||||
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
|
||||
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
technic_power_machine=1,
|
||||
internal_EU_buffer=0;
|
||||
internal_EU_buffer_size=5000;
|
||||
grind_time=0;
|
||||
grinded = nil;
|
||||
src_time = 0;
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("infotext", "Grinder")
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_float("internal_EU_buffer", 0)
|
||||
meta:set_float("internal_EU_buffer_size", 5000)
|
||||
meta:set_string("formspec", grinder_formspec)
|
||||
meta:set_float("grind_time", 0)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:grinder_active", {
|
||||
description = "Grinder",
|
||||
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
|
||||
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2,not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:grinder","technic:grinder_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local charge= meta:get_float("internal_EU_buffer")
|
||||
local max_charge= meta:get_float("internal_EU_buffer_size")
|
||||
local grind_cost=200
|
||||
|
||||
local load = math.floor((charge/max_charge)*100)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
|
||||
(load)..":technic_power_meter_fg.png]"..
|
||||
"label[0,0;Grinder]"..
|
||||
"label[1,3;Power level]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
)
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
local srclist = inv:get_list("src")
|
||||
if inv:is_empty("src") then meta:set_float("grinder_on",0) end
|
||||
|
||||
if (meta:get_float("grinder_on") == 1) then
|
||||
if charge>=grind_cost then
|
||||
charge=charge-grind_cost;
|
||||
meta:set_float("internal_EU_buffer",charge)
|
||||
meta:set_float("src_time", meta:get_float("src_time") + 1)
|
||||
if meta:get_float("src_time") >= meta:get_float("grind_time") then
|
||||
-- check if there's room for output in "dst" list
|
||||
grinded = get_grinded_item (inv:get_stack("src", 1))
|
||||
if inv:room_for_item("dst",grinded) then
|
||||
-- Put result in "dst" list
|
||||
inv:add_item("dst", grinded)
|
||||
-- take stuff from "src" list
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
if inv:is_empty("src") then meta:set_float("grinder_on",0) end
|
||||
else
|
||||
print("Grinder inventory full!")
|
||||
end
|
||||
meta:set_float("src_time", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
if (meta:get_float("grinder_on")==0) then
|
||||
local grinded=nil
|
||||
if not inv:is_empty("src") then
|
||||
grinded = get_grinded_item (inv:get_stack("src", 1))
|
||||
if grinded then
|
||||
meta:set_float("grinder_on",1)
|
||||
hacky_swap_node(pos,"technic:grinder_active")
|
||||
meta:set_string("infotext", "Grinder Active")
|
||||
grind_time=4
|
||||
meta:set_float("grind_time",grind_time)
|
||||
meta:set_float("src_time", 0)
|
||||
return
|
||||
end
|
||||
else
|
||||
hacky_swap_node(pos,"technic:grinder")
|
||||
meta:set_string("infotext", "Grinder Inactive")
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
function get_grinded_item (items)
|
||||
new_item =nil
|
||||
src_item=items:to_table()
|
||||
item_name=src_item["name"]
|
||||
|
||||
local counter=registered_grinder_recipes_count-1
|
||||
for i=1, counter,1 do
|
||||
if grinder_recipes[i].src_name==item_name then return ItemStack(grinder_recipes[i].dst_name) end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
register_LV_machine ("technic:grinder","RE")
|
||||
register_LV_machine ("technic:grinder_active","RE")
|
@ -4,14 +4,16 @@
|
||||
|
||||
technic = {}
|
||||
|
||||
local modpath = minetest.get_modpath("technic")
|
||||
|
||||
technic.modpath = modpath
|
||||
|
||||
technic.dprint = function(string)
|
||||
if technic.DBG == 1 then
|
||||
print(string)
|
||||
end
|
||||
end
|
||||
|
||||
local modpath = minetest.get_modpath("technic")
|
||||
|
||||
--Read technic config file
|
||||
dofile(modpath.."/config.lua")
|
||||
--helper functions
|
||||
@ -22,65 +24,9 @@ dofile(modpath.."/items.lua")
|
||||
|
||||
-- Register functions
|
||||
dofile(modpath.."/register_machine_and_tool.lua")
|
||||
dofile(modpath.."/alloy_furnaces_commons.lua") -- Idea: Let the LV, MV, HV version of the furnace support different alloys
|
||||
|
||||
-- Switching station LV,MV,HV
|
||||
dofile(modpath.."/switching_station.lua")
|
||||
dofile(modpath.."/supply_converter.lua")
|
||||
|
||||
--LV machines
|
||||
dofile(modpath.."/wires.lua")
|
||||
dofile(modpath.."/battery_box.lua")
|
||||
dofile(modpath.."/alloy_furnace.lua")
|
||||
dofile(modpath.."/solar_panel.lua")
|
||||
dofile(modpath.."/solar_array_lv.lua")
|
||||
dofile(modpath.."/geothermal.lua")
|
||||
dofile(modpath.."/water_mill.lua")
|
||||
dofile(modpath.."/generator.lua")
|
||||
dofile(modpath.."/electric_furnace.lua")
|
||||
dofile(modpath.."/tool_workshop.lua")
|
||||
dofile(modpath.."/music_player.lua")
|
||||
dofile(modpath.."/grinder.lua")
|
||||
dofile(modpath.."/cnc.lua")
|
||||
dofile(modpath.."/cnc_api.lua")
|
||||
dofile(modpath.."/cnc_nodes.lua")
|
||||
dofile(modpath.."/extractor.lua")
|
||||
|
||||
--MV machines
|
||||
dofile(modpath.."/wires_mv.lua")
|
||||
dofile(modpath.."/battery_box_mv.lua")
|
||||
dofile(modpath.."/solar_array_mv.lua")
|
||||
--dofile(modpath.."/down_converter_mv.lua")
|
||||
dofile(modpath.."/electric_furnace_mv.lua")
|
||||
dofile(modpath.."/alloy_furnace_mv.lua")
|
||||
dofile(modpath.."/forcefield.lua")
|
||||
---- The power radiator supplies appliances with inductive coupled power:
|
||||
---- lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
||||
dofile(modpath.."/power_radiator.lua")
|
||||
dofile(modpath.."/lighting.lua")
|
||||
|
||||
--HV machines
|
||||
dofile(modpath.."/wires_hv.lua")
|
||||
dofile(modpath.."/battery_box_hv.lua")
|
||||
dofile(modpath.."/solar_array_hv.lua")
|
||||
--dofile(modpath.."/down_converter_hv.lua")
|
||||
dofile(modpath.."/nuclear_reactor_hv.lua")
|
||||
|
||||
--Tools
|
||||
if technic.config:getBool("enable_mining_drill") then dofile(modpath.."/mining_drill.lua") end
|
||||
if technic.config:getBool("enable_mining_laser") then dofile(modpath.."/mining_laser_mk1.lua") end
|
||||
if technic.config:getBool("enable_flashlight") then dofile(modpath.."/flashlight.lua") end
|
||||
dofile(modpath.."/cans.lua")
|
||||
dofile(modpath.."/chainsaw.lua")
|
||||
dofile(modpath.."/tree_tap.lua")
|
||||
dofile(modpath.."/sonic_screwdriver.lua")
|
||||
|
||||
---- mesecons and tubes related
|
||||
dofile(modpath.."/injector.lua")
|
||||
dofile(modpath.."/node_breaker.lua")
|
||||
dofile(modpath.."/deployer.lua")
|
||||
dofile(modpath.."/constructor.lua")
|
||||
dofile(modpath.."/frames.lua")
|
||||
-- Machines
|
||||
dofile(modpath.."/machines/init.lua")
|
||||
|
||||
function has_locked_chest_privilege(meta, player)
|
||||
if player:get_player_name() ~= meta:get_string("owner") then
|
||||
|
@ -1,326 +0,0 @@
|
||||
minetest.register_craftitem("technic:injector", {
|
||||
description = "Injector",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:injector", {
|
||||
description = "Injector",
|
||||
tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
|
||||
"technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[9,9;]"..
|
||||
"list[current_name;main;0,2;8,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Injector")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
on_punch = function (pos, node, puncher)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
for _,stack in ipairs(inv:get_list("main")) do
|
||||
if stack:get_name() ~="" then
|
||||
inv:remove_item("main",stack)
|
||||
pos1=pos
|
||||
pos1.y=pos1.y
|
||||
local x=pos1.x+1.5
|
||||
local z=pos1.z
|
||||
item1=tube_item({x=pos1.x,y=pos1.y,z=pos1.z},stack)
|
||||
item1:get_luaentity().start_pos = {x=pos1.x,y=pos1.y,z=pos1.z}
|
||||
item1:setvelocity({x=1, y=0, z=0})
|
||||
item1:setacceleration({x=0, y=0, z=0})
|
||||
return
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
function tube_item(pos, item)
|
||||
local TUBE_nodes = {}
|
||||
local CHEST_nodes = {}
|
||||
|
||||
TUBE_nodes[1]={}
|
||||
TUBE_nodes[1].x=pos.x
|
||||
TUBE_nodes[1].y=pos.y
|
||||
TUBE_nodes[1].z=pos.z
|
||||
|
||||
|
||||
table_index=1
|
||||
repeat
|
||||
check_TUBE_node (TUBE_nodes,CHEST_nodes,table_index)
|
||||
table_index=table_index+1
|
||||
if TUBE_nodes[table_index]==nil then break end
|
||||
until false
|
||||
found=table_index-1
|
||||
|
||||
|
||||
print("Found "..found.." tubes connected")
|
||||
print(dump(CHEST_nodes))
|
||||
-- Take item in any format
|
||||
local stack = ItemStack(item)
|
||||
local obj = minetest.env:add_entity(pos, "technic:tubed_item")
|
||||
obj:get_luaentity():set_item(stack:to_string())
|
||||
return obj
|
||||
end
|
||||
|
||||
minetest.register_entity("technic:tubed_item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
visual = "sprite",
|
||||
visual_size = {x=0.5, y=0.5},
|
||||
textures = {""},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = false,
|
||||
start_pos={},
|
||||
route={}
|
||||
},
|
||||
|
||||
itemstring = '',
|
||||
physical_state = false,
|
||||
|
||||
set_item = function(self, itemstring)
|
||||
self.itemstring = itemstring
|
||||
local stack = ItemStack(itemstring)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if minetest.registered_items[itemname] then
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
prop = {
|
||||
is_visible = true,
|
||||
visual = "sprite",
|
||||
textures = {"unknown_item.png"}
|
||||
}
|
||||
if item_texture and item_texture ~= "" then
|
||||
prop.visual = "sprite"
|
||||
prop.textures = {item_texture}
|
||||
prop.visual_size = {x=0.3, y=0.3}
|
||||
else
|
||||
prop.visual = "wielditem"
|
||||
prop.textures = {itemname}
|
||||
prop.visual_size = {x=0.15, y=0.15}
|
||||
end
|
||||
self.object:set_properties(prop)
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
|
||||
return minetest.serialize({
|
||||
itemstring=self.itemstring,
|
||||
velocity=self.object:getvelocity(),
|
||||
start_pos=self.start_pos
|
||||
})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
-- print (dump(staticdata))
|
||||
if staticdata=="" or staticdata==nil then return end
|
||||
local item = minetest.deserialize(staticdata)
|
||||
local stack = ItemStack(item.itemstring)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
|
||||
if itemname then
|
||||
self.start_pos=item.start_pos
|
||||
self.object:setvelocity(item.velocity)
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.object:setpos(item.start_pos)
|
||||
end
|
||||
self:set_item(item.itemstring)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
if self.start_pos then
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
tubelike=meta:get_int("tubelike")
|
||||
local stack = ItemStack(self.itemstring)
|
||||
local drop_pos=nil
|
||||
|
||||
local velocity=self.object:getvelocity()
|
||||
|
||||
if velocity==nil then print ("wypadl") return end
|
||||
|
||||
if math.abs(velocity.x)==1 then
|
||||
local next_node=math.abs(pos.x-self.start_pos.x)
|
||||
if next_node >= 1 then
|
||||
self.start_pos.x=self.start_pos.x+velocity.x
|
||||
if check_pos_vector (self.start_pos, velocity)==0 then
|
||||
if check_next_step (self.start_pos, velocity)==0 then
|
||||
drop_pos=minetest.env:find_node_near({x=self.start_pos.x,y=self.start_pos.y,z=self.start_pos.z+velocity.x}, 1, "air")
|
||||
if drop_pos then minetest.item_drop(stack, "", drop_pos) end
|
||||
self.object:remove()
|
||||
end
|
||||
self.object:setpos(self.start_pos)
|
||||
self.object:setvelocity(velocity)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if math.abs(velocity.y)==1 then
|
||||
local next_node=math.abs(pos.y-self.start_pos.y)
|
||||
if next_node >= 1 then
|
||||
self.start_pos.y=self.start_pos.y+velocity.y
|
||||
if check_pos_vector (self.start_pos, velocity)==0 then
|
||||
if check_next_step (self.start_pos, velocity)==0 then
|
||||
drop_pos=minetest.env:find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
|
||||
if drop_pos then minetest.item_drop(stack, "", drop_pos) end
|
||||
self.object:remove()
|
||||
end
|
||||
self.object:setpos(self.start_pos)
|
||||
self.object:setvelocity(velocity)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if math.abs(velocity.z)==1 then
|
||||
local next_node=math.abs(pos.z-self.start_pos.z)
|
||||
if next_node >= 1 then
|
||||
self.start_pos.z=self.start_pos.z+velocity.z
|
||||
if check_pos_vector (self.start_pos, velocity)==0 then
|
||||
if check_next_step (self.start_pos, velocity)==0 then
|
||||
drop_pos=minetest.env:find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
|
||||
if drop_pos then minetest.item_drop(stack, "", drop_pos) end
|
||||
self.object:remove()
|
||||
end
|
||||
self.object:setpos(self.start_pos)
|
||||
self.object:setvelocity(velocity)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
function check_next_step (pos,velocity)
|
||||
local meta
|
||||
local tubelike
|
||||
|
||||
if velocity.x==0 then
|
||||
meta = minetest.env:get_meta({x=pos.x-1,y=pos.y,z=pos.z})
|
||||
tubelike=meta:get_int("tubelike")
|
||||
if tubelike==1 then velocity.x=-1 velocity.y=0 velocity.z=0 return 1 end
|
||||
meta = minetest.env:get_meta({x=pos.x+1,y=pos.y,z=pos.z})
|
||||
tubelike=meta:get_int("tubelike")
|
||||
if tubelike==1 then velocity.x=1 velocity.y=0 velocity.z=0 return 1 end
|
||||
end
|
||||
|
||||
if velocity.z==0 then
|
||||
meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z+1})
|
||||
tubelike=meta:get_int("tubelike")
|
||||
if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=1 return 1 end
|
||||
meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z-1})
|
||||
tubelike=meta:get_int("tubelike")
|
||||
if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=-1 return 1 end
|
||||
end
|
||||
|
||||
if velocity.y==0 then
|
||||
meta = minetest.env:get_meta({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
tubelike=meta:get_int("tubelike")
|
||||
if tubelike==1 then velocity.x=0 velocity.y=1 velocity.z=0 return 1 end
|
||||
meta = minetest.env:get_meta({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
tubelike=meta:get_int("tubelike")
|
||||
if tubelike==1 then velocity.x=0 velocity.y=-1 velocity.z=0 return 1 end
|
||||
end
|
||||
|
||||
print ("spadl")
|
||||
return 0
|
||||
end
|
||||
|
||||
function check_pos_vector (pos,velocity)
|
||||
added={}
|
||||
added.x=pos.x+velocity.x
|
||||
added.y=pos.y+velocity.y
|
||||
added.z=pos.z+velocity.z
|
||||
local meta=minetest.env:get_meta(added)
|
||||
--print(dump(added).." : "..tubelike)
|
||||
if meta:get_int("tubelike")==1 then return 1 end
|
||||
return 0
|
||||
end
|
||||
|
||||
function add_new_TUBE_node (TUBE_nodes,pos1,parent)
|
||||
local i=1
|
||||
repeat
|
||||
if TUBE_nodes[i]==nil then break end
|
||||
if pos1.x==TUBE_nodes[i].x and pos1.y==TUBE_nodes[i].y and pos1.z==TUBE_nodes[i].z then return false end
|
||||
i=i+1
|
||||
until false
|
||||
TUBE_nodes[i]={}
|
||||
TUBE_nodes[i].x=pos1.x
|
||||
TUBE_nodes[i].y=pos1.y
|
||||
TUBE_nodes[i].z=pos1.z
|
||||
TUBE_nodes[i].parent_x=parent.x
|
||||
TUBE_nodes[i].parent_y=parent.y
|
||||
TUBE_nodes[i].parent_z=parent.z
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function check_TUBE_node (TUBE_nodes,CHEST_nodes,i)
|
||||
local pos1={}
|
||||
local parent={}
|
||||
pos1.x=TUBE_nodes[i].x
|
||||
pos1.y=TUBE_nodes[i].y
|
||||
pos1.z=TUBE_nodes[i].z
|
||||
parent.x=pos1.x
|
||||
parent.y=pos1.y
|
||||
parent.z=pos1.z
|
||||
new_node_added=false
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
|
||||
pos1.x=pos1.x-2
|
||||
check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
|
||||
pos1.y=pos1.y-2
|
||||
check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
|
||||
pos1.z=pos1.z-2
|
||||
check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
|
||||
pos1.z=pos1.z+1
|
||||
return new_node_added
|
||||
end
|
||||
|
||||
function check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
|
||||
meta = minetest.env:get_meta(pos1)
|
||||
if meta:get_float("tubelike")==1 then add_new_TUBE_node(TUBE_nodes,pos1,parent) return end
|
||||
nctr = minetest.env:get_node(pos1)
|
||||
if minetest.get_item_group(nctr.name, "tubedevice_receiver") == 1 then add_new_TUBE_node(CHEST_nodes,pos1,parent) return end
|
||||
end
|
||||
|
8
technic/machines/hv/init.lua
Normal file
8
technic/machines/hv/init.lua
Normal file
@ -0,0 +1,8 @@
|
||||
local path = technic.modpath.."/machines/hv"
|
||||
|
||||
dofile(path.."/forcefield.lua")
|
||||
dofile(path.."/wires.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/nuclear_reactor.lua")
|
||||
|
10
technic/machines/init.lua
Normal file
10
technic/machines/init.lua
Normal file
@ -0,0 +1,10 @@
|
||||
local path = technic.modpath.."/machines"
|
||||
|
||||
dofile(path.."/switching_station.lua")
|
||||
dofile(path.."/supply_converter.lua")
|
||||
dofile(path.."/alloy_furnaces_commons.lua")
|
||||
dofile(path.."/lv/init.lua")
|
||||
dofile(path.."/mv/init.lua")
|
||||
dofile(path.."/hv/init.lua")
|
||||
dofile(path.."/other/init.lua")
|
||||
|
19
technic/machines/lv/init.lua
Normal file
19
technic/machines/lv/init.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local path = technic.modpath.."/machines/lv"
|
||||
|
||||
dofile(path.."/wires.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/solar_panel.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/geothermal.lua")
|
||||
dofile(path.."/water_mill.lua")
|
||||
dofile(path.."/generator.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/tool_workshop.lua")
|
||||
dofile(path.."/music_player.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/cnc.lua")
|
||||
dofile(path.."/cnc_api.lua")
|
||||
dofile(path.."/cnc_nodes.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
|
13
technic/machines/mv/init.lua
Normal file
13
technic/machines/mv/init.lua
Normal file
@ -0,0 +1,13 @@
|
||||
local path = technic.modpath.."/machines/mv"
|
||||
|
||||
dofile(path.."/wires.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
|
||||
-- The power radiator supplies appliances with inductive coupled power:
|
||||
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
||||
dofile(path.."/power_radiator.lua")
|
||||
dofile(path.."/lighting.lua")
|
||||
|
8
technic/machines/other/init.lua
Normal file
8
technic/machines/other/init.lua
Normal file
@ -0,0 +1,8 @@
|
||||
local path = technic.modpath.."/machines/other"
|
||||
|
||||
-- mesecons and tubes related
|
||||
dofile(path.."/injector.lua")
|
||||
dofile(path.."/node_breaker.lua")
|
||||
dofile(path.."/deployer.lua")
|
||||
dofile(path.."/constructor.lua")
|
||||
dofile(path.."/frames.lua")
|
@ -1,39 +0,0 @@
|
||||
minetest.register_craft({
|
||||
output = 'technic:project_table 1',
|
||||
recipe = {
|
||||
{'default:wood','default:wood','default:wood'},
|
||||
{'default:wood','default:chest','default:wood'},
|
||||
{'default:stone','default:stone','default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("technic:project_table", {
|
||||
description = "Project Table",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:project_table", {
|
||||
description = "Project Table",
|
||||
tiles = {"technic_iron_chest_top.png", "technic_iron_chest_top.png", "technic_iron_chest_side.png",
|
||||
"technic_iron_chest_side.png", "technic_iron_chest_side.png", "technic_iron_chest_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[9,9;]"..
|
||||
"list[current_name;main;0,2;8,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Iron Chest")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
})
|
@ -1,131 +0,0 @@
|
||||
minetest.register_craft({
|
||||
output = 'technic:silver_chest 1',
|
||||
recipe = {
|
||||
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
||||
{'moreores:silver_ingot','technic:copper_chest','moreores:silver_ingot'},
|
||||
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:silver_locked_chest 1',
|
||||
recipe = {
|
||||
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
||||
{'moreores:silver_ingot','technic:copper_locked_chest','moreores:silver_ingot'},
|
||||
{'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:silver_locked_chest 1',
|
||||
recipe = {
|
||||
{'default:steel_ingot'},
|
||||
{'technic:silver_chest'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("technic:silver_chest", {
|
||||
description = "Silver Chest",
|
||||
stack_max = 99,
|
||||
})
|
||||
minetest.register_craftitem("technic:silver_locked_chest", {
|
||||
description = "Silver Locked Chest",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:silver_chest", {
|
||||
description = "Silver Chest",
|
||||
tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png",
|
||||
"technic_silver_chest_side.png", "technic_silver_chest_side.png", "technic_silver_chest_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = chest_groups1,
|
||||
tube = tubes_properties,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[11,9;]"..
|
||||
"list[current_name;main;0,0;11,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Silver Chest")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 11*4)
|
||||
end,
|
||||
can_dig = chest_can_dig,
|
||||
|
||||
on_punch = function (pos, node, puncher)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
meta:set_string("formspec", "hack:sign_text_input")
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
fields.text = fields.text or ""
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("infotext", '"'..fields.text..'"')
|
||||
|
||||
meta:set_string("formspec",
|
||||
"invsize[11,9;]"..
|
||||
"list[current_name;main;0,0;11,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
end,
|
||||
|
||||
on_metadata_inventory_move = def_on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = def_on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = def_on_metadata_inventory_take
|
||||
})
|
||||
|
||||
minetest.register_node("technic:silver_locked_chest", {
|
||||
description = "Silver Locked Chest",
|
||||
tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png",
|
||||
"technic_silver_chest_side.png", "technic_silver_chest_side.png", "technic_silver_chest_locked.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = chest_groups2,
|
||||
tube = tubes_properties,
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", "Silver Locked Chest (owned by "..
|
||||
meta:get_string("owner")..")")
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[11,9;]"..
|
||||
"list[current_name;main;0,0;11,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Silver Locked Chest")
|
||||
meta:set_string("owner", "")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 11*4)
|
||||
end,
|
||||
can_dig = chest_can_dig,
|
||||
|
||||
on_punch = function (pos, node, puncher)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
meta:set_string("formspec", "hack:sign_text_input")
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
fields.text = fields.text or ""
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("infotext", '"'..fields.text..'"')
|
||||
|
||||
meta:set_string("formspec",
|
||||
"invsize[11,9;]"..
|
||||
"list[current_name;main;0,0;11,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
end,
|
||||
|
||||
|
||||
allow_metadata_inventory_move = def_allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_put = def_allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = def_allow_metadata_inventory_take,
|
||||
on_metadata_inventory_move = def_on_metadata_inventory_move,
|
||||
on_metadata_inventory_put = def_on_metadata_inventory_put,
|
||||
on_metadata_inventory_take = def_on_metadata_inventory_take
|
||||
})
|
16
technic/tools/init.lua
Normal file
16
technic/tools/init.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local path = technic.modpath.."/tools"
|
||||
|
||||
if technic.config:getBool("enable_mining_drill") then
|
||||
dofile(path.."/mining_drill.lua")
|
||||
end
|
||||
if technic.config:getBool("enable_mining_laser") then
|
||||
dofile(path.."/mining_laser_mk1.lua")
|
||||
end
|
||||
if technic.config:getBool("enable_flashlight") then
|
||||
dofile(path.."/flashlight.lua")
|
||||
end
|
||||
dofile(path.."/cans.lua")
|
||||
dofile(path.."/chainsaw.lua")
|
||||
dofile(path.."/tree_tap.lua")
|
||||
dofile(path.."/sonic_screwdriver.lua")
|
||||
|
@ -1,588 +0,0 @@
|
||||
minetest.register_alias("battery", "technic:battery")
|
||||
minetest.register_alias("battery_box", "technic:battery_box")
|
||||
minetest.register_alias("electric_furnace", "technic:electric_furnace")
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:battery 1',
|
||||
recipe = {
|
||||
{'default:wood', 'default:copper_ingot', 'default:wood'},
|
||||
{'default:wood', 'moreores:tin_ingot', 'default:wood'},
|
||||
{'default:wood', 'default:copper_ingot', 'default:wood'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:battery_box 1',
|
||||
recipe = {
|
||||
{'technic:battery', 'default:wood', 'technic:battery'},
|
||||
{'technic:battery', 'default:copper_ingot', 'technic:battery'},
|
||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:electric_furnace',
|
||||
recipe = {
|
||||
{'default:brick', 'default:brick', 'default:brick'},
|
||||
{'default:brick', '', 'default:brick'},
|
||||
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
--minetest.register_craftitem("technic:battery", {
|
||||
-- description = "Recharcheable battery",
|
||||
-- inventory_image = "technic_battery.png",
|
||||
-- stack_max = 1,
|
||||
--})
|
||||
|
||||
minetest.register_tool("technic:battery",
|
||||
{description = "RE Battery",
|
||||
inventory_image = "technic_battery.png",
|
||||
energy_charge = 0,
|
||||
tool_capabilities = {max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}})
|
||||
|
||||
minetest.register_craftitem("technic:battery_box", {
|
||||
description = "Battery box",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
|
||||
|
||||
battery_box_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"image[4,1;1,1;technic_battery_reload.png]"..
|
||||
"list[current_name;dst;5,1;1,1;]"..
|
||||
"label[0,0;Battery box]"..
|
||||
"label[3,0;Charge]"..
|
||||
"label[5,0;Discharge]"..
|
||||
"label[1,3;Power level]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
minetest.register_node("technic:battery_box", {
|
||||
description = "Battery box",
|
||||
tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png", "technic_battery_box_side.png",
|
||||
"technic_battery_box_side.png", "technic_battery_box_side.png", "technic_battery_box_side.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
technic_power_machine=1,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("infotext", "Battery box")
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", battery_box_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 1)
|
||||
battery_charge = 0
|
||||
max_charge = 60000
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
electric_furnace_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"label[0,0;Electric Furnace]"..
|
||||
"label[1,3;Power level]"
|
||||
|
||||
minetest.register_node("technic:electric_furnace", {
|
||||
description = "Electric furnace",
|
||||
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
|
||||
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
technic_power_machine=1,
|
||||
internal_EU_buffer=0;
|
||||
interal_EU_buffer_size=2000;
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("infotext", "Electric furnace")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
local EU_used = 0
|
||||
local furnace_is_cookin = 0
|
||||
local cooked = nil
|
||||
meta:set_float("internal_EU_buffer",0)
|
||||
meta:set_float("internal_EU_buffer_size",2000)
|
||||
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:electric_furnace_active", {
|
||||
description = "Electric Furnace",
|
||||
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
|
||||
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "technic:electric_furnace",
|
||||
groups = {cracky=2, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
internal_EU_buffer=0;
|
||||
interal_EU_buffer_size=2000;
|
||||
technic_power_machine=1,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("infotext", "Electric furnace");
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
local EU_used = 0
|
||||
local furnace_is_cookin = 0
|
||||
local cooked = nil
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:electric_furnace","technic:electric_furnace_active"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
internal_EU_buffer=meta:get_float("internal_EU_buffer")
|
||||
internal_EU_buffer_size=meta:get_float("internal_EU_buffer")
|
||||
local load = math.floor(internal_EU_buffer/2000 * 100)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
|
||||
(load)..":technic_power_meter_fg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"label[0,0;Electric Furnace]"..
|
||||
"label[1,3;Power level]")
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local furnace_is_cookin = meta:get_float("furnace_is_cookin")
|
||||
|
||||
|
||||
local srclist = inv:get_list("src")
|
||||
local cooked=nil
|
||||
|
||||
if srclist then
|
||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
end
|
||||
|
||||
|
||||
if (furnace_is_cookin == 1) then
|
||||
if internal_EU_buffer>=150 then
|
||||
internal_EU_buffer=internal_EU_buffer-150;
|
||||
meta:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
meta:set_float("src_time", meta:get_float("src_time") + 3)
|
||||
if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
|
||||
-- check if there's room for output in "dst" list
|
||||
if inv:room_for_item("dst",cooked.item) then
|
||||
-- Put result in "dst" list
|
||||
inv:add_item("dst", cooked.item)
|
||||
-- take stuff from "src" list
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
else
|
||||
print("Furnace inventory full!")
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
if srclist then
|
||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
if cooked.time>0 then
|
||||
hacky_swap_node(pos,"technic:electric_furnace_active")
|
||||
meta:set_string("infotext","Furnace active")
|
||||
meta:set_string("furnace_is_cookin",1)
|
||||
-- meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("src_time", 0)
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
hacky_swap_node(pos,"technic:electric_furnace")
|
||||
meta:set_string("infotext","Furnace inactive")
|
||||
meta:set_string("furnace_is_cookin",0)
|
||||
-- meta:set_string("formspec", electric_furnace_formspec)
|
||||
meta:set_string("src_time", 0)
|
||||
|
||||
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
function take_EU_from_net(pos, EU_to_take)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local pos1=pos
|
||||
pos1.z=pos1.z +1
|
||||
local meta1 = minetest.env:get_meta(pos1)
|
||||
charge=meta1:get_float("battery_charge")
|
||||
charge=charge - EU_to_take
|
||||
meta1:set_float("battery_charge",charge)
|
||||
end
|
||||
|
||||
LV_nodes_visited = {}
|
||||
|
||||
function get_RE_item_load (load1,max_load)
|
||||
if load1==0 then load1=65535 end
|
||||
local temp = 65536-load1
|
||||
temp= temp/65535*max_load
|
||||
return math.floor(temp + 0.5)
|
||||
end
|
||||
|
||||
function set_RE_item_load (load1,max_load)
|
||||
if load1 == 0 then return 65535 end
|
||||
local temp=load1/max_load*65535
|
||||
temp=65536-temp
|
||||
return math.floor(temp)
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"technic:battery_box"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
charge= meta:get_float("battery_charge")
|
||||
max_charge= 60000
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("src")==false then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
src_item=srcstack:to_table()
|
||||
if src_item["name"]== "technic:battery" then
|
||||
local load1=tonumber((src_item["wear"]))
|
||||
load1=get_RE_item_load(load1,10000)
|
||||
load_step=1000
|
||||
if load1<10000 and charge>0 then
|
||||
if charge-load_step<0 then load_step=charge end
|
||||
if load1+load_step>10000 then load_step=10000-load1 end
|
||||
load1=load1+load_step
|
||||
charge=charge-load_step
|
||||
|
||||
load1=set_RE_item_load(load1,10000)
|
||||
src_item["wear"]=tostring(load1)
|
||||
inv:set_stack("src", 1, src_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
meta:set_float("battery_charge",charge)
|
||||
|
||||
|
||||
if inv:is_empty("src")==false then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
src_item=srcstack:to_table()
|
||||
if src_item["name"]== "technic:laser_mk1" then
|
||||
local load1=tonumber((src_item["wear"]))
|
||||
load1=get_RE_item_load(load1,40000)
|
||||
load_step=1000
|
||||
if load1<40000 and charge>0 then
|
||||
if charge-load_step<0 then load_step=charge end
|
||||
if load1+load_step>40000 then load_step=40000-load1 end
|
||||
load1=load1+load_step
|
||||
charge=charge-load_step
|
||||
load1=set_RE_item_load(load1,40000)
|
||||
src_item["wear"]=tostring(load1)
|
||||
inv:set_stack("src", 1, src_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
meta:set_float("battery_charge",charge)
|
||||
|
||||
|
||||
if inv:is_empty("dst") == false then
|
||||
srcstack = inv:get_stack("dst", 1)
|
||||
src_item=srcstack:to_table()
|
||||
if src_item["name"]== "technic:battery" then
|
||||
local load1=tonumber((src_item["wear"]))
|
||||
load1=get_RE_item_load(load1,10000)
|
||||
load_step=1000
|
||||
if load1>0 and charge<max_charge then
|
||||
if charge+load_step>max_charge then load_step=max_charge-charge end
|
||||
if load1-load_step<0 then load_step=load1 end
|
||||
load1=load1-load_step
|
||||
charge=charge+load_step
|
||||
|
||||
load1=set_RE_item_load(load1,10000)
|
||||
src_item["wear"]=tostring(load1)
|
||||
inv:set_stack("dst", 1, src_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
meta:set_float("battery_charge",charge)
|
||||
meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge);
|
||||
|
||||
local load = math.floor(charge/60000 * 100)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
|
||||
(load)..":technic_power_meter_fg.png]"..
|
||||
"list[current_name;src;3,1;1,1;]"..
|
||||
"image[4,1;1,1;technic_battery_reload.png]"..
|
||||
"list[current_name;dst;5,1;1,1;]"..
|
||||
"label[0,0;Battery box]"..
|
||||
"label[3,0;Charge]"..
|
||||
"label[5,0;Discharge]"..
|
||||
"label[1,3;Power level]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
|
||||
local pos1={}
|
||||
|
||||
pos1.y=pos.y-1
|
||||
pos1.x=pos.x
|
||||
pos1.z=pos.z
|
||||
|
||||
|
||||
meta1 = minetest.env:get_meta(pos1)
|
||||
if meta1:get_float("cablelike")~=1 then return end
|
||||
|
||||
local LV_nodes = {}
|
||||
local PR_nodes = {}
|
||||
local RE_nodes = {}
|
||||
|
||||
LV_nodes[1]={}
|
||||
LV_nodes[1].x=pos1.x
|
||||
LV_nodes[1].y=pos1.y
|
||||
LV_nodes[1].z=pos1.z
|
||||
LV_nodes[1].visited=false
|
||||
|
||||
|
||||
table_index=1
|
||||
repeat
|
||||
check_LV_node (PR_nodes,RE_nodes,LV_nodes,table_index)
|
||||
table_index=table_index+1
|
||||
if LV_nodes[table_index]==nil then break end
|
||||
until false
|
||||
|
||||
|
||||
local pos1={}
|
||||
i=1
|
||||
repeat
|
||||
if PR_nodes[i]==nil then break end
|
||||
pos1.x=PR_nodes[i].x
|
||||
pos1.y=PR_nodes[i].y
|
||||
pos1.z=PR_nodes[i].z
|
||||
local meta1 = minetest.env:get_meta(pos1)
|
||||
local active=meta1:get_float("active")
|
||||
if active==1 then charge=charge+80 end
|
||||
i=i+1
|
||||
until false
|
||||
|
||||
if charge>max_charge then charge=max_charge end
|
||||
|
||||
i=1
|
||||
repeat
|
||||
if RE_nodes[i]==nil then break end
|
||||
pos1.x=RE_nodes[i].x -- loading all conected machines buffers
|
||||
pos1.y=RE_nodes[i].y
|
||||
pos1.z=RE_nodes[i].z
|
||||
local meta1 = minetest.env:get_meta(pos1)
|
||||
local internal_EU_buffer=meta1:get_float("internal_EU_buffer")
|
||||
local internal_EU_buffer_size=meta1:get_float("internal_EU_buffer_size")
|
||||
|
||||
local charge_to_give=200
|
||||
if internal_EU_buffer+charge_to_give>internal_EU_buffer_size then
|
||||
charge_to_give=internal_EU_buffer_size-internal_EU_buffer
|
||||
end
|
||||
if charge-charge_to_give<0 then charge_to_give=charge end
|
||||
|
||||
internal_EU_buffer=internal_EU_buffer+charge_to_give
|
||||
meta1:set_float("internal_EU_buffer",internal_EU_buffer)
|
||||
charge=charge-charge_to_give;
|
||||
|
||||
i=i+1
|
||||
until false
|
||||
|
||||
meta:set_float("battery_charge",charge)
|
||||
meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge);
|
||||
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
function add_new_cable_node (LV_nodes,pos1)
|
||||
local i=1
|
||||
repeat
|
||||
if LV_nodes[i]==nil then break end
|
||||
if pos1.x==LV_nodes[i].x and pos1.y==LV_nodes[i].y and pos1.z==LV_nodes[i].z then return false end
|
||||
i=i+1
|
||||
until false
|
||||
LV_nodes[i]={}
|
||||
LV_nodes[i].x=pos1.x
|
||||
LV_nodes[i].y=pos1.y
|
||||
LV_nodes[i].z=pos1.z
|
||||
LV_nodes[i].visited=false
|
||||
return true
|
||||
end
|
||||
|
||||
function check_LV_node (PR_nodes,RE_nodes,LV_nodes,i)
|
||||
local pos1={}
|
||||
pos1.x=LV_nodes[i].x
|
||||
pos1.y=LV_nodes[i].y
|
||||
pos1.z=LV_nodes[i].z
|
||||
LV_nodes[i].visited=true
|
||||
new_node_added=false
|
||||
|
||||
pos1.x=pos1.x+1
|
||||
check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
|
||||
pos1.x=pos1.x-2
|
||||
check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
|
||||
pos1.x=pos1.x+1
|
||||
|
||||
pos1.y=pos1.y+1
|
||||
check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
|
||||
pos1.y=pos1.y-2
|
||||
check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
|
||||
pos1.y=pos1.y+1
|
||||
|
||||
pos1.z=pos1.z+1
|
||||
check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
|
||||
pos1.z=pos1.z-2
|
||||
check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
|
||||
pos1.z=pos1.z+1
|
||||
return new_node_added
|
||||
end
|
||||
|
||||
function check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
|
||||
meta = minetest.env:get_meta(pos1)
|
||||
if meta:get_float("cablelike")==1 then new_node_added=add_new_cable_node(LV_nodes,pos1) end
|
||||
if minetest.env:get_node(pos1).name == "technic:solar_panel" then new_node_added=add_new_cable_node(PR_nodes,pos1) end
|
||||
if minetest.env:get_node(pos1).name == "technic:electric_furnace" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
|
||||
if minetest.env:get_node(pos1).name == "technic:electric_furnace_active" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
|
||||
if minetest.env:get_node(pos1).name == "technic:tool_workshop" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
|
||||
if minetest.env:get_node(pos1).name == "technic:music_player" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
|
||||
if minetest.env:get_node(pos1).name == "technic:grinder" then new_node_added=add_new_cable_node(RE_nodes,pos1) end
|
||||
end
|
||||
|
||||
|
||||
function get_connected_charge (charge,pos1)
|
||||
local charge1=0
|
||||
local meta={}
|
||||
if minetest.env:get_node(pos1).name == "technic:battery_box" then
|
||||
print ("found batbox")
|
||||
meta = minetest.env:get_meta(pos1)
|
||||
return meta:get_float("cable_OUT")
|
||||
end
|
||||
|
||||
if minetest.env:get_node(pos1).name == "technic:lv_cable" then
|
||||
meta = minetest.env:get_meta(pos1)
|
||||
charge1=meta:get_float("cable_OUT")
|
||||
if charge1>charge then
|
||||
charge=charge1
|
||||
end
|
||||
end
|
||||
return charge
|
||||
end
|
||||
|
||||
minetest.register_node("technic:solar_panel", {
|
||||
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png",
|
||||
"technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
description="Solar Panel",
|
||||
active = false,
|
||||
technic_power_machine=1,
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_float("technic_power_machine", 1)
|
||||
meta:set_string("infotext", "Solar Panel")
|
||||
meta:set_float("active", false)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:solar_panel 1',
|
||||
recipe = {
|
||||
{'default:sand', 'default:sand', 'default:sand'},
|
||||
{'default:sand', 'default:copper_ingot', 'default:sand'},
|
||||
{'default:sand', 'default:sand', 'default:sand'},
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"technic:solar_panel"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
|
||||
local pos1={}
|
||||
pos1.y=pos.y+1
|
||||
pos1.x=pos.x
|
||||
pos1.z=pos.z
|
||||
|
||||
local light = minetest.env:get_node_light(pos1, nil)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if light == nil then light = 0 end
|
||||
if light >= 12 then
|
||||
meta:set_string("infotext", "Solar Panel is active ")
|
||||
meta:set_float("active",1)
|
||||
else
|
||||
meta:set_string("infotext", "Solar Panel is inactive");
|
||||
meta:set_float("active",0)
|
||||
end
|
||||
end,
|
||||
})
|
Loading…
Reference in New Issue
Block a user