many worldgen mods and gonna try technic now
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
-- MV alloy furnace
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_alloy_furnace',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_alloy_furnace', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
technic.register_alloy_furnace({tier = "MV", speed = 1.5, upgrade = 1, tube = 1, demand = {3000, 2000, 1000}})
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
-- MV Battery box
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_battery_box0',
|
||||
recipe = {
|
||||
{'technic:lv_battery_box0', 'technic:lv_battery_box0', 'technic:lv_battery_box0'},
|
||||
{'technic:lv_battery_box0', 'technic:mv_transformer', 'technic:lv_battery_box0'},
|
||||
{'', 'technic:mv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_battery_box({
|
||||
tier = "MV",
|
||||
max_charge = 200000,
|
||||
charge_rate = 20000,
|
||||
discharge_rate = 80000,
|
||||
charge_step = 2000,
|
||||
discharge_step = 8000,
|
||||
upgrade = 1,
|
||||
tube = 1,
|
||||
})
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
|
||||
minetest.register_alias("mv_cable", "technic:mv_cable")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_cable 3',
|
||||
recipe ={
|
||||
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
|
||||
{'technic:lv_cable', 'technic:lv_cable', 'technic:lv_cable'},
|
||||
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_cable("MV", 2.5/16)
|
||||
|
||||
if minetest.get_modpath("digilines") then
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
if minetest.get_modpath("digistuff") then
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_digi_cable 1',
|
||||
type = "shapeless",
|
||||
recipe = {'digistuff:digimese', 'technic:mv_cable'}
|
||||
})
|
||||
else
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_digi_cable 1',
|
||||
recipe = {
|
||||
{'digilines:wire_std_00000000', 'digilines:wire_std_00000000', 'digilines:wire_std_00000000'},
|
||||
{'digilines:wire_std_00000000', 'technic:mv_cable', 'digilines:wire_std_00000000'},
|
||||
{'digilines:wire_std_00000000', 'digilines:wire_std_00000000', 'digilines:wire_std_00000000'},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
technic.register_cable("MV", 2.5/16, S("MV Cable (digiline)"), "_digi", {
|
||||
digiline = {
|
||||
wire = {
|
||||
rules = {
|
||||
{x = 1, y = 0, z = 0},
|
||||
{x =-1, y = 0, z = 0},
|
||||
{x = 0, y = 1, z = 0},
|
||||
{x = 0, y =-1, z = 0},
|
||||
{x = 0, y = 0, z = 1},
|
||||
{x = 0, y = 0, z =-1}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
minetest.register_craft({
|
||||
output = "technic:mv_centrifuge",
|
||||
recipe = {
|
||||
{"basic_materials:motor", "technic:copper_plate", "technic:diamond_drill_head"},
|
||||
{"technic:copper_plate", "technic:machine_casing", "technic:copper_plate" },
|
||||
{"pipeworks:one_way_tube", "technic:mv_cable", "pipeworks:mese_filter" },
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_centrifuge({
|
||||
tier = "MV",
|
||||
demand = { 8000, 7000, 6000 },
|
||||
speed = 2,
|
||||
upgrade = 1,
|
||||
tube = 1,
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
-- MV compressor
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_compressor',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_compressor', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_compressor({tier = "MV", demand = {800, 600, 400}, speed = 2, upgrade = 1, tube = 1})
|
||||
@@ -0,0 +1,18 @@
|
||||
-- MV Electric Furnace
|
||||
-- This is a faster version of the stone furnace which runs on EUs
|
||||
-- In addition to this it can be upgraded with microcontrollers and batteries
|
||||
-- This new version uses the batteries to lower the power consumption of the machine
|
||||
-- Also in addition this furnace can be attached to the pipe system from the pipeworks mod.
|
||||
|
||||
-- FIXME: kpoppel I'd like to introduce an induction heating element here also
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_electric_furnace',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_electric_furnace', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_electric_furnace({tier="MV", upgrade=1, tube=1, demand={2000, 1000, 500}, speed=4})
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
-- MV extractor
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_extractor',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_extractor', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_extractor({tier = "MV", demand = {800, 600, 400}, speed = 2, upgrade = 1, tube = 1})
|
||||
@@ -0,0 +1,12 @@
|
||||
-- MV freezer
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_freezer',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:motor', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:pipe_1_empty', 'technic:mv_transformer', 'pipeworks:pipe_1_empty'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_freezer({tier = "MV", demand = {800, 600, 400}, speed = 0.5, upgrade = 1, tube = 1})
|
||||
@@ -0,0 +1,13 @@
|
||||
minetest.register_alias("generator_mv", "technic:generator_mv")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_generator',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_generator', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_generator({tier="MV", tube=1, supply=600})
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
-- MV grinder
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:mv_grinder',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:lv_grinder', 'technic:stainless_steel_ingot'},
|
||||
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_grinder({tier="MV", demand={600, 450, 300}, speed=2, upgrade=1, tube=1})
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
-- A Hydro Turbine produces MV EUs by exploiting flowing water across it
|
||||
-- It is a MV EU supplier and fairly high yield (max 1800EUs)
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||
|
||||
minetest.register_alias("hydro_turbine", "technic:hydro_turbine")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:hydro_turbine',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:water_mill', 'technic:stainless_steel_ingot'},
|
||||
{'technic:water_mill', 'technic:mv_transformer', 'technic:water_mill'},
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
local function get_water_flow(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
if minetest.get_item_group(node.name, "water") == 3 then
|
||||
return node.param2 -- returns approx. water flow, if any
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
---
|
||||
-- 10 times better than LV hydro because of 2 extra water mills and 4 stainless steel, a transformer and whatnot ;P.
|
||||
-- Man hydro turbines are tough and long lasting. So, give it some value :)
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local water_flow = 0
|
||||
local production_level
|
||||
local eu_supply
|
||||
local max_output = 40 * 45 -- Generates 1800EU/s
|
||||
|
||||
local positions = {
|
||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||
{x=pos.x-1, y=pos.y, z=pos.z},
|
||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
||||
{x=pos.x, y=pos.y, z=pos.z-1},
|
||||
}
|
||||
|
||||
for _, p in pairs(positions) do
|
||||
water_flow = water_flow + get_water_flow(p)
|
||||
end
|
||||
|
||||
eu_supply = math.min(40 * water_flow, max_output)
|
||||
production_level = math.floor(100 * eu_supply / max_output)
|
||||
|
||||
meta:set_int("MV_EU_supply", eu_supply)
|
||||
|
||||
meta:set_string("infotext",
|
||||
S("Hydro %s Generator"):format("MV").." ("..production_level.."%)")
|
||||
if production_level > 0 and
|
||||
minetest.get_node(pos).name == "technic:hydro_turbine" then
|
||||
technic.swap_node(pos, "technic:hydro_turbine_active")
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
return
|
||||
end
|
||||
if production_level == 0 then
|
||||
technic.swap_node(pos, "technic:hydro_turbine")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:hydro_turbine", {
|
||||
description = S("Hydro %s Generator"):format("MV"),
|
||||
tiles = {
|
||||
"technic_hydro_turbine_top.png",
|
||||
"technic_machine_bottom.png"..cable_entry,
|
||||
"technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png"
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_mv=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Hydro %s Generator"):format("MV"))
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
end,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:hydro_turbine_active", {
|
||||
description = S("Hydro %s Generator"):format("MV"),
|
||||
tiles = {"technic_hydro_turbine_top_active.png", "technic_machine_bottom.png",
|
||||
"technic_hydro_turbine_side.png", "technic_hydro_turbine_side.png",
|
||||
"technic_hydro_turbine_side.png", "technic_hydro_turbine_side.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_mv=1, not_in_creative_inventory=1},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "technic:hydro_turbine",
|
||||
technic_run = run,
|
||||
technic_disabled_machine_name = "technic:hydro_turbine",
|
||||
})
|
||||
|
||||
technic.register_machine("MV", "technic:hydro_turbine", technic.producer)
|
||||
technic.register_machine("MV", "technic:hydro_turbine_active", technic.producer)
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
technic.register_tier("MV", "Medium Voltage")
|
||||
|
||||
local path = technic.modpath.."/machines/MV"
|
||||
|
||||
-- Wiring stuff
|
||||
dofile(path.."/cables.lua")
|
||||
dofile(path.."/battery_box.lua")
|
||||
|
||||
-- Generators
|
||||
if technic.config:get_bool("enable_wind_mill") then
|
||||
dofile(path.."/wind_mill.lua")
|
||||
end
|
||||
dofile(path.."/generator.lua")
|
||||
dofile(path.."/solar_array.lua")
|
||||
dofile(path.."/hydro_turbine.lua")
|
||||
|
||||
-- Machines
|
||||
dofile(path.."/alloy_furnace.lua")
|
||||
dofile(path.."/electric_furnace.lua")
|
||||
dofile(path.."/grinder.lua")
|
||||
dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
dofile(path.."/centrifuge.lua")
|
||||
|
||||
dofile(path.."/tool_workshop.lua")
|
||||
|
||||
dofile(path.."/freezer.lua")
|
||||
|
||||
-- The power radiator supplies appliances with inductive coupled power:
|
||||
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
||||
-- This is currently useless, slow, and mostly copied
|
||||
--dofile(path.."/power_radiator.lua")
|
||||
--dofile(path.."/lighting.lua")
|
||||
|
||||
@@ -0,0 +1,575 @@
|
||||
-- NOTE: The code is takes directly from VanessaE's homedecor mod.
|
||||
-- I just made it the lights into indictive appliances for this mod.
|
||||
|
||||
-- This file supplies electric powered glowlights
|
||||
|
||||
-- Boilerplate to support localized strings if intllib mod is installed.
|
||||
local S
|
||||
if (minetest.get_modpath("intllib")) then
|
||||
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
||||
S = intllib.Getter(minetest.get_current_modname())
|
||||
else
|
||||
S = function (s) return s end
|
||||
end
|
||||
|
||||
local function technic_homedecor_node_is_owned(pos, placer)
|
||||
local ownername = false
|
||||
if type(isprotect) == "function" then -- glomie's protection mod
|
||||
if not isprotect(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
elseif type(protector) == "table" and type(protector.can_dig) == "function" then -- Zeg9's protection mod
|
||||
if not protector.can_dig(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
|
||||
if ownername ~= false then
|
||||
minetest.chat_send_player(placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local dirs2 = {9, 18, 7, 12}
|
||||
|
||||
local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_thing)
|
||||
if not technic_homedecor_node_is_owned(pointed_thing.under, placer)
|
||||
and not technic_homedecor_node_is_owned(pointed_thing.above, placer) then
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
|
||||
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
local pitch = placer:get_look_pitch()
|
||||
local pname = minetest.get_node(under).name
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local wield_name = itemstack:get_name()
|
||||
|
||||
if not minetest.registered_nodes[pname]
|
||||
or not minetest.registered_nodes[pname].on_rightclick then
|
||||
|
||||
local iswall = (above.x ~= under.x) or (above.z ~= under.z)
|
||||
local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
||||
local pos1 = above
|
||||
|
||||
if minetest.registered_nodes[pname]["buildable_to"] then
|
||||
pos1 = under
|
||||
iswall = false
|
||||
end
|
||||
|
||||
if not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
|
||||
|
||||
if iswall then
|
||||
minetest.add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
|
||||
elseif isceiling then
|
||||
minetest.add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
|
||||
else
|
||||
minetest.add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
|
||||
end
|
||||
|
||||
if not homedecor_expect_infinite_stacks then
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
else
|
||||
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Yellow -- Half node
|
||||
minetest.register_node('technic:homedecor_glowlight_half_yellow', {
|
||||
description = S("Yellow Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_yellow_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_half_yellow_active', {
|
||||
description = S("Yellow Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thick_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_half_yellow",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_yellow")
|
||||
end
|
||||
})
|
||||
|
||||
-- Yellow -- Quarter node
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_yellow', {
|
||||
description = S("Yellow Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_yellow_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_yellow_active', {
|
||||
description = S("Yellow Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_thin_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = minetest.LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_quarter_yellow",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_yellow")
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- White -- half node
|
||||
minetest.register_node('technic:homedecor_glowlight_half_white', {
|
||||
description = S("White Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_white_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_half_white_active', {
|
||||
description = S("White Glowlight (thick)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png',
|
||||
'technic_homedecor_glowlight_thick_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = minetest.LIGHT_MAX,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_half_white",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_white")
|
||||
end
|
||||
})
|
||||
|
||||
-- White -- Quarter node
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_white', {
|
||||
description = S("White Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_white_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_quarter_white_active', {
|
||||
description = S("White Glowlight (thin)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_white_tb.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png',
|
||||
'technic_homedecor_glowlight_thin_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = minetest.LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_quarter_white",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_white")
|
||||
end
|
||||
})
|
||||
|
||||
-- Glowlight "cubes" - yellow
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_yellow', {
|
||||
description = S("Yellow Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_yellow_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_yellow_active', {
|
||||
description = S("Yellow Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_tb.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png',
|
||||
'technic_homedecor_glowlight_cube_yellow_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = minetest.LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_small_cube_yellow",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_yellow")
|
||||
end
|
||||
})
|
||||
|
||||
-- Glowlight "cubes" - white
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_white', {
|
||||
description = S("White Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_white_active")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node('technic:homedecor_glowlight_small_cube_white_active', {
|
||||
description = S("White Glowlight (small cube)"),
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_tb.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png',
|
||||
'technic_homedecor_glowlight_cube_white_sides.png'
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
|
||||
},
|
||||
|
||||
sunlight_propagates = false,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
walkable = true,
|
||||
light_source = minetest.LIGHT_MAX-1,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
groups = { snappy = 3, not_in_creative_inventory=1},
|
||||
drop="technic:homedecor_glowlight_small_cube_white",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
|
||||
return itemstack
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_white")
|
||||
end
|
||||
})
|
||||
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_half_yellow")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_half_white")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_quarter_yellow")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_quarter_white")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_yellow")
|
||||
technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_white")
|
||||
@@ -0,0 +1,220 @@
|
||||
-- The power radiator fuctions like an inductive charger
|
||||
-- only better in the game setting.
|
||||
-- The purpose is to allow small appliances to receive power
|
||||
-- without the overhead of the wiring needed for larger machines.
|
||||
--
|
||||
-- The power radiator will consume power corresponding to the
|
||||
-- sum(power rating of the attached appliances)/0.06
|
||||
-- Using inductive power transfer is very inefficient so this is
|
||||
-- set to the factor 0.06.
|
||||
--
|
||||
-- Punching the radiator will toggle the power state of all attached appliances.
|
||||
|
||||
local power_radius = 12
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:power_radiator 1',
|
||||
recipe = {
|
||||
{'technic:stainless_steel_ingot', 'technic:mv_transformer', 'technic:stainless_steel_ingot'},
|
||||
{'technic:copper_coil', 'technic:machine_casing', 'technic:copper_coil'},
|
||||
{'technic:rubber', 'technic:mv_cable', 'technic:rubber'},
|
||||
}
|
||||
})
|
||||
|
||||
------------------------------------------------------------------
|
||||
-- API for inductive powered nodes:
|
||||
-- Use the functions below to set the corresponding callbacks
|
||||
-- Also two nodes are needed: The inactive and the active one. The active must be called <name>_active .
|
||||
------------------------------------------------------------------
|
||||
-- Register a new appliance using this function
|
||||
|
||||
technic.inductive_nodes = {}
|
||||
technic.register_inductive_machine = function(name)
|
||||
table.insert(technic.inductive_nodes, name)
|
||||
table.insert(technic.inductive_nodes, name.."_active")
|
||||
end
|
||||
|
||||
-- Appliances:
|
||||
-- has_supply: pos of supply node if the appliance has a power radiator near with sufficient power for the demand
|
||||
-- EU_demand: The power demand of the device.
|
||||
-- EU_charge: Actual use. set to EU_demand if active==1
|
||||
-- active: set to 1 if the device is on
|
||||
technic.inductive_on_construct = function(pos, eu_demand, infotext)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", infotext)
|
||||
meta:set_int("technic_inductive_power_machine", 1)
|
||||
meta:set_int("EU_demand", eu_demand) -- The power demand of this appliance
|
||||
meta:set_int("EU_charge", 0) -- The actual power draw of this appliance
|
||||
meta:set_string("has_supply", "") -- Register whether we are powered or not. For use with several radiators.
|
||||
meta:set_int("active", 0) -- If the appliance can be turned on and off by using it use this.
|
||||
end
|
||||
|
||||
technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("has_supply") ~= "" then
|
||||
technic.swap_node(pos, swapnode)
|
||||
meta:set_int("active", 1)
|
||||
meta:set_int("EU_charge",eu_charge)
|
||||
--print("-----------")
|
||||
--print("Turn on:")
|
||||
--print("EU_charge: "..meta:get_int("EU_charge"))
|
||||
--print("has_supply: "..meta:get_string("has_supply"))
|
||||
--print("<----------->")
|
||||
end
|
||||
end
|
||||
|
||||
technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
|
||||
local meta = minetest.get_meta(pos)
|
||||
technic.swap_node(pos, swapnode)
|
||||
meta:set_int("active", 0)
|
||||
meta:set_int("EU_charge",eu_charge)
|
||||
--print("-----------")
|
||||
--print("Turn off:")
|
||||
--print("EU_charge: "..meta:get_int("EU_charge"))
|
||||
--print("has_supply: "..meta:get_string("has_supply"))
|
||||
--print("<---------->")
|
||||
end
|
||||
|
||||
local shutdown_inductive_appliances = function(pos)
|
||||
-- The supply radius
|
||||
local rad = power_radius
|
||||
-- If the radiator is removed. turn off all appliances in region
|
||||
-- If another radiator is near it will turn on the appliances again
|
||||
local positions = minetest.find_nodes_in_area(
|
||||
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
|
||||
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
|
||||
technic.inductive_nodes)
|
||||
for _, pos1 in pairs(positions) do
|
||||
local meta1 = minetest.get_meta(pos1)
|
||||
-- If the appliance is belonging to this node
|
||||
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
|
||||
local nodename = minetest.get_node(pos1).name
|
||||
-- Swap the node and make sure it is off and unpowered
|
||||
if string.sub(nodename, -7) == "_active" then
|
||||
technic.swap_node(pos1, string.sub(nodename, 1, -8))
|
||||
meta1:set_int("active", 0)
|
||||
meta1:set_int("EU_charge", 0)
|
||||
end
|
||||
meta1:set_string("has_supply", "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local toggle_on_off_inductive_appliances = function(pos, node, puncher)
|
||||
if pos == nil then return end
|
||||
-- The supply radius
|
||||
local rad = power_radius
|
||||
local positions = minetest.find_nodes_in_area(
|
||||
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
|
||||
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
|
||||
technic.inductive_nodes)
|
||||
for _, pos1 in pairs(positions) do
|
||||
local meta1 = minetest.get_meta(pos1)
|
||||
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
|
||||
minetest.punch_node(pos1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:power_radiator", {
|
||||
description = "MV Power Radiator",
|
||||
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
|
||||
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.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},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("MV_EU_demand",1) -- Demand on the primary side when idle
|
||||
meta:set_int("connected_EU_demand",0) -- Potential demand of connected appliances
|
||||
meta:set_string("infotext", "MV Power Radiator")
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
shutdown_inductive_appliances(pos)
|
||||
return minetest.node_dig(pos, node, digger)
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
toggle_on_off_inductive_appliances(pos, node, puncher)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
label = "Machines: run power radiator",
|
||||
nodenames = {"technic:power_radiator"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("MV_EU_input")
|
||||
local eu_demand = meta:get_int("MV_EU_demand")
|
||||
|
||||
-- Power off automatically if no longer connected to a switching station
|
||||
technic.switching_station_timeout_count(pos, "MV")
|
||||
|
||||
if eu_input == 0 then
|
||||
-- No power
|
||||
meta:set_string("infotext", "MV Power Radiator is unpowered");
|
||||
-- meta:set_int("active", 1) -- used for setting textures someday maybe
|
||||
shutdown_inductive_appliances(pos)
|
||||
meta:set_int("connected_EU_demand", 0)
|
||||
meta:set_int("MV_EU_demand",1)
|
||||
elseif eu_input == eu_demand then
|
||||
-- Powered and ready
|
||||
|
||||
-- The maximum EU sourcing a single radiator can provide.
|
||||
local max_charge = 30000 -- == the max EU demand of the radiator
|
||||
local connected_EU_demand = meta:get_int("connected_EU_demand")
|
||||
|
||||
-- Efficiency factor
|
||||
local eff_factor = 0.06
|
||||
-- The supply radius
|
||||
local rad = power_radius
|
||||
|
||||
local used_charge = 0
|
||||
|
||||
-- Index all nodes within supply range
|
||||
local positions = minetest.find_nodes_in_area(
|
||||
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
|
||||
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
|
||||
technic.inductive_nodes)
|
||||
for _, pos1 in pairs(positions) do
|
||||
local meta1 = minetest.get_meta(pos1)
|
||||
-- If not supplied see if this node can handle it.
|
||||
if meta1:get_string("has_supply") == "" then
|
||||
-- if demand surpasses the capacity of this node, don't bother adding it.
|
||||
local app_eu_demand = math.floor(meta1:get_int("EU_demand") / eff_factor)
|
||||
if connected_EU_demand + app_eu_demand <= max_charge then
|
||||
-- We can power the appliance. Register, and spend power if it is on.
|
||||
connected_EU_demand = connected_EU_demand + app_eu_demand
|
||||
|
||||
meta1:set_string("has_supply", pos.x..pos.y..pos.z)
|
||||
--Always 0: used_charge = math.floor(used_charge + meta1:get_int("EU_charge") / eff_factor)
|
||||
end
|
||||
elseif meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
|
||||
-- The appliance has power from this node. Spend power if it is on.
|
||||
used_charge = used_charge + math.floor(meta1:get_int("EU_charge") / eff_factor)
|
||||
end
|
||||
meta:set_string("infotext", "MV Power Radiator is powered ("
|
||||
..math.floor(used_charge / max_charge * 100)
|
||||
.."% of maximum power)");
|
||||
if used_charge == 0 then
|
||||
meta:set_int("MV_EU_demand", 1) -- Still idle
|
||||
else
|
||||
meta:set_int("MV_EU_demand", used_charge)
|
||||
end
|
||||
end
|
||||
-- Save state
|
||||
meta:set_int("connected_EU_demand", connected_EU_demand)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine("MV", "technic:power_radiator", technic.receiver)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:solar_array_mv 1',
|
||||
recipe = {
|
||||
{'technic:solar_array_lv', 'technic:solar_array_lv', 'technic:solar_array_lv'},
|
||||
{'technic:carbon_steel_ingot', 'technic:mv_transformer', 'technic:carbon_steel_ingot'},
|
||||
{'', 'technic:mv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
technic.register_solar_array({tier="MV", power=30})
|
||||
|
||||
-- compatibility alias for upgrading from old versions of technic
|
||||
minetest.register_alias("technic:solar_panel_mv", "technic:solar_array_mv")
|
||||
@@ -0,0 +1,126 @@
|
||||
-- Tool workshop
|
||||
-- This machine repairs tools.
|
||||
|
||||
minetest.register_alias("tool_workshop", "technic:tool_workshop")
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local tube_entry = "^pipeworks_tube_connection_wooden.png"
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:tool_workshop',
|
||||
recipe = {
|
||||
{'group:wood', 'default:diamond', 'group:wood'},
|
||||
{'mesecons_pistons:piston_sticky_off', 'technic:machine_casing', 'technic:carbon_cloth'},
|
||||
{'default:obsidian', 'technic:mv_cable', 'default:obsidian'},
|
||||
}
|
||||
})
|
||||
|
||||
local workshop_demand = {5000, 3500, 2000}
|
||||
|
||||
local workshop_formspec =
|
||||
"size[8,9;]"..
|
||||
"list[context;src;3,1;1,1;]"..
|
||||
"label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
|
||||
"list[context;upgrade1;1,3;1,1;]"..
|
||||
"list[context;upgrade2;2,3;1,1;]"..
|
||||
"label[1,4;"..S("Upgrade Slots").."]"..
|
||||
"list[current_player;main;0,5;8,4;]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;upgrade1]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[context;upgrade2]"..
|
||||
"listring[current_player;main]"
|
||||
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local eu_input = meta:get_int("MV_EU_input")
|
||||
local machine_name = S("%s Tool Workshop"):format("MV")
|
||||
|
||||
-- Setup meta data if it does not exist.
|
||||
if not eu_input then
|
||||
meta:set_int("MV_EU_demand", workshop_demand[1])
|
||||
meta:set_int("MV_EU_input", 0)
|
||||
return
|
||||
end
|
||||
|
||||
local EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
|
||||
|
||||
local repairable = false
|
||||
local srcstack = inv:get_stack("src", 1)
|
||||
if not srcstack:is_empty() then
|
||||
local itemdef = minetest.registered_items[srcstack:get_name()]
|
||||
if itemdef and
|
||||
(not itemdef.wear_represents or
|
||||
itemdef.wear_represents == "mechanical_wear") and
|
||||
srcstack:get_wear() ~= 0 then
|
||||
repairable = true
|
||||
end
|
||||
end
|
||||
technic.handle_machine_pipeworks(pos, tube_upgrade, function(pos2, x_velocity, z_velocity)
|
||||
if not repairable then
|
||||
technic.send_items(pos2, x_velocity, z_velocity, "src")
|
||||
end
|
||||
end)
|
||||
if not repairable then
|
||||
meta:set_string("infotext", S("%s Idle"):format(machine_name))
|
||||
meta:set_int("MV_EU_demand", 0)
|
||||
return
|
||||
end
|
||||
|
||||
if eu_input < workshop_demand[EU_upgrade+1] then
|
||||
meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
|
||||
elseif eu_input >= workshop_demand[EU_upgrade+1] then
|
||||
meta:set_string("infotext", S("%s Active"):format(machine_name))
|
||||
srcstack:add_wear(-1000)
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
end
|
||||
meta:set_int("MV_EU_demand", workshop_demand[EU_upgrade+1])
|
||||
end
|
||||
|
||||
minetest.register_node("technic:tool_workshop", {
|
||||
description = S("%s Tool Workshop"):format("MV"),
|
||||
paramtype2 = "facedir",
|
||||
tiles = {
|
||||
"technic_workshop_top.png"..tube_entry,
|
||||
"technic_machine_bottom.png"..tube_entry,
|
||||
"technic_workshop_side.png"..tube_entry,
|
||||
"technic_workshop_side.png"..tube_entry,
|
||||
"technic_workshop_side.png"..tube_entry,
|
||||
"technic_workshop_side.png"
|
||||
},
|
||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||
technic_machine=1, technic_mv=1, tubedevice=1, tubedevice_receiver=1},
|
||||
connect_sides = {"bottom", "back", "left", "right"},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("%s Tool Workshop"):format("MV"))
|
||||
meta:set_string("formspec", workshop_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("upgrade1", 1)
|
||||
inv:set_size("upgrade2", 1)
|
||||
end,
|
||||
can_dig = technic.machine_can_dig,
|
||||
allow_metadata_inventory_put = technic.machine_inventory_put,
|
||||
allow_metadata_inventory_take = technic.machine_inventory_take,
|
||||
tube = {
|
||||
can_insert = function (pos, node, stack, direction)
|
||||
return minetest.get_meta(pos):get_inventory():room_for_item("src", stack)
|
||||
end,
|
||||
insert_object = function (pos, node, stack, direction)
|
||||
return minetest.get_meta(pos):get_inventory():add_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
||||
},
|
||||
technic_run = run,
|
||||
after_place_node = pipeworks.after_place,
|
||||
after_dig_node = technic.machine_after_dig_node
|
||||
})
|
||||
|
||||
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:wind_mill_frame 5',
|
||||
recipe = {
|
||||
{'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'},
|
||||
{'', 'technic:carbon_steel_ingot', ''},
|
||||
{'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'technic:wind_mill',
|
||||
recipe = {
|
||||
{'', 'basic_materials:motor', ''},
|
||||
{'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'},
|
||||
{'', 'technic:mv_cable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("technic:wind_mill_frame", {
|
||||
description = S("Wind Mill Frame"),
|
||||
drawtype = "glasslike_framed",
|
||||
tiles = {"technic_carbon_steel_block.png", "default_glass.png"},
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
local function check_wind_mill(pos)
|
||||
if pos.y < 30 then
|
||||
return false
|
||||
end
|
||||
pos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
for i = 1, 20 do
|
||||
pos.y = pos.y - 1
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if not node then
|
||||
-- we reached CONTENT_IGNORE, we can assume, that nothing changed
|
||||
-- as the user will have to load the block to change it
|
||||
return
|
||||
end
|
||||
if node.name ~= "technic:wind_mill_frame" then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local run = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local machine_name = S("Wind %s Generator"):format("MV")
|
||||
|
||||
local check = check_wind_mill(pos)
|
||||
if check == false then
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
|
||||
elseif check == true then
|
||||
local power = math.min(pos.y * 100, 5000)
|
||||
meta:set_int("MV_EU_supply", power)
|
||||
meta:set_string("infotext", S("@1 (@2)", machine_name,
|
||||
technic.EU_string(power)))
|
||||
end
|
||||
-- check == nil: assume nothing has changed
|
||||
end
|
||||
|
||||
minetest.register_node("technic:wind_mill", {
|
||||
description = S("Wind %s Generator"):format("MV"),
|
||||
tiles = {"technic_carbon_steel_block.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=1, technic_machine=1, technic_mv=1},
|
||||
connect_sides = {"top", "bottom", "back", "left", "right"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Main box
|
||||
{-0.1, -0.1, -0.5, 0.1, 0.1, -0.6}, -- Shaft
|
||||
{-0.1, -1, -0.6, 0.1, 1, -0.7}, -- Vertical blades
|
||||
{-1, -0.1, -0.6, 1, 0.1, -0.7}, -- Horizontal blades
|
||||
}
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", S("Wind %s Generator"):format("MV"))
|
||||
meta:set_int("MV_EU_supply", 0)
|
||||
end,
|
||||
technic_run = run,
|
||||
})
|
||||
|
||||
technic.register_machine("MV", "technic:wind_mill", technic.producer)
|
||||
|
||||
Reference in New Issue
Block a user