Add MV and HV generators and make coal dust a fuel
@ -22,6 +22,8 @@ technic.legacy_nodenames = {
|
|||||||
["technic:lv_cable"] = "technic:lv_cable0",
|
["technic:lv_cable"] = "technic:lv_cable0",
|
||||||
["technic:mv_cable"] = "technic:mv_cable0",
|
["technic:mv_cable"] = "technic:mv_cable0",
|
||||||
["technic:mv_battery_box"] = "technic:mv_battery_box0",
|
["technic:mv_battery_box"] = "technic:mv_battery_box0",
|
||||||
|
["technic:generator"] = "technic:lv_generator",
|
||||||
|
["technic:generator_active"] = "technic:lv_generator_active",
|
||||||
}
|
}
|
||||||
|
|
||||||
for old, new in pairs(technic.legacy_nodenames) do
|
for old, new in pairs(technic.legacy_nodenames) do
|
||||||
|
14
technic/machines/HV/generator.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
minetest.register_alias("hv_generator", "technic:hv_generator")
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:hv_generator',
|
||||||
|
recipe = {
|
||||||
|
{'technic:stainless_steel_ingot', 'technic:mv_generator', 'technic:stainless_steel_ingot'},
|
||||||
|
{'pipeworks:tube_000000', 'technic:hv_transformer', 'pipeworks:tube_000000'},
|
||||||
|
{'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.register_generator({tier="HV", supply=1200})
|
||||||
|
|
@ -9,4 +9,5 @@ dofile(path.."/forcefield.lua")
|
|||||||
dofile(path.."/battery_box.lua")
|
dofile(path.."/battery_box.lua")
|
||||||
dofile(path.."/solar_array.lua")
|
dofile(path.."/solar_array.lua")
|
||||||
dofile(path.."/nuclear_reactor.lua")
|
dofile(path.."/nuclear_reactor.lua")
|
||||||
|
dofile(path.."/generator.lua")
|
||||||
|
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
-- Inefficient and expensive in fuel (200EU per tick)
|
-- Inefficient and expensive in fuel (200EU per tick)
|
||||||
-- Also only allows for LV machinery to run.
|
-- Also only allows for LV machinery to run.
|
||||||
|
|
||||||
minetest.register_alias("generator", "technic:generator")
|
minetest.register_alias("lv_generator", "technic:lv_generator")
|
||||||
minetest.register_alias("generator", "technic:generator_active")
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'technic:generator',
|
output = 'technic:lv_generator',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:stone', 'default:stone', 'default:stone'},
|
{'default:stone', 'default:stone', 'default:stone'},
|
||||||
{'default:stone', '', 'default:stone'},
|
{'default:stone', '', 'default:stone'},
|
||||||
@ -15,125 +14,5 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
local generator_formspec =
|
technic.register_generator({tier="LV", supply=200})
|
||||||
"invsize[8,9;]"..
|
|
||||||
"label[0,0;Generator]"..
|
|
||||||
"list[current_name;src;3,1;1,1;]"..
|
|
||||||
"image[4,1;1,1;default_furnace_fire_bg.png]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]"
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("technic:generator", {
|
|
||||||
description = "Electric Generator",
|
|
||||||
tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
|
|
||||||
"technic_generator_side.png", "technic_generator_side.png", "technic_generator_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.get_meta(pos)
|
|
||||||
meta:set_string("infotext", "Electric Generator")
|
|
||||||
meta:set_int("LV_EU_supply", 0)
|
|
||||||
-- Signal to the switching station that this device burns some
|
|
||||||
-- sort of fuel and needs special handling
|
|
||||||
meta:set_int("LV_EU_from_fuel", 1)
|
|
||||||
meta:set_int("burn_time", 0)
|
|
||||||
meta:set_string("formspec", generator_formspec)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size("src", 1)
|
|
||||||
end,
|
|
||||||
can_dig = function(pos,player)
|
|
||||||
local meta = minetest.get_meta(pos);
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
if not inv:is_empty("src") then
|
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
|
||||||
"Machine cannot be removed because it is not empty");
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:generator_active", {
|
|
||||||
description = "Electric Generator",
|
|
||||||
tiles = {"technic_generator_top.png", "technic_machine_bottom.png",
|
|
||||||
"technic_generator_side.png", "technic_generator_side.png",
|
|
||||||
"technic_generator_side.png", "technic_generator_front_active.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
|
||||||
not_in_creative_inventory=1},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
drop = "technic:generator",
|
|
||||||
can_dig = function(pos,player)
|
|
||||||
local meta = minetest.get_meta(pos);
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
if not inv:is_empty("src") then
|
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
|
||||||
"Machine cannot be removed because it is not empty");
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"technic:generator", "technic:generator_active"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local burn_time = meta:get_int("burn_time")
|
|
||||||
local burn_totaltime = meta:get_int("burn_totaltime")
|
|
||||||
|
|
||||||
-- If more to burn and the energy produced was used: produce some more
|
|
||||||
if burn_time > 0 then
|
|
||||||
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
|
|
||||||
burn_time = burn_time - 1
|
|
||||||
meta:set_int("burn_time", burn_time)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Burn another piece of fuel
|
|
||||||
if burn_time == 0 then
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
if not inv:is_empty("src") then
|
|
||||||
local fuellist = inv:get_list("src")
|
|
||||||
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
|
||||||
if not fuel or fuel.time == 0 then
|
|
||||||
meta:set_string("infotext", "Generator out of fuel")
|
|
||||||
hacky_swap_node(pos, "technic:generator")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
meta:set_int("burn_time", fuel.time)
|
|
||||||
meta:set_int("burn_totaltime", fuel.time)
|
|
||||||
|
|
||||||
|
|
||||||
local stack = inv:get_stack("src", 1)
|
|
||||||
stack:take_item()
|
|
||||||
inv:set_stack("src", 1, stack)
|
|
||||||
hacky_swap_node(pos, "technic:generator_active")
|
|
||||||
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
|
|
||||||
else
|
|
||||||
hacky_swap_node(pos, "technic:generator")
|
|
||||||
meta:set_int("LV_EU_supply", 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
|
||||||
meta:set_string("infotext", "Electric Generator ("..percent.."%)")
|
|
||||||
meta:set_string("formspec",
|
|
||||||
"size[8,9]"..
|
|
||||||
"label[0,0;Generator]"..
|
|
||||||
"list[current_name;src;3,1;1,1;]"..
|
|
||||||
"image[4,1;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
|
||||||
(percent)..":default_furnace_fire_fg.png]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]")
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:generator", technic.producer)
|
|
||||||
technic.register_machine("LV", "technic:generator_active", technic.producer)
|
|
||||||
|
|
||||||
|
@ -20,4 +20,3 @@ dofile(path.."/cnc_api.lua")
|
|||||||
dofile(path.."/cnc_nodes.lua")
|
dofile(path.."/cnc_nodes.lua")
|
||||||
dofile(path.."/extractor.lua")
|
dofile(path.."/extractor.lua")
|
||||||
dofile(path.."/compressor.lua")
|
dofile(path.."/compressor.lua")
|
||||||
|
|
||||||
|
14
technic/machines/MV/generator.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
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_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
|
||||||
|
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.register_generator({tier="MV", supply=600})
|
||||||
|
|
@ -13,6 +13,7 @@ dofile(path.."/tool_workshop.lua")
|
|||||||
if technic.config:get_bool("enable_wind_mill") then
|
if technic.config:get_bool("enable_wind_mill") then
|
||||||
dofile(path.."/wind_mill.lua")
|
dofile(path.."/wind_mill.lua")
|
||||||
end
|
end
|
||||||
|
dofile(path.."/generator.lua")
|
||||||
|
|
||||||
-- The power radiator supplies appliances with inductive coupled power:
|
-- The power radiator supplies appliances with inductive coupled power:
|
||||||
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
|
||||||
|
118
technic/machines/register/generator.lua
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
|
||||||
|
function technic.register_generator(data)
|
||||||
|
local tier = data.tier
|
||||||
|
local ltier = string.lower(tier)
|
||||||
|
|
||||||
|
local generator_formspec =
|
||||||
|
"invsize[8,9;]"..
|
||||||
|
"label[0,0;Generator]"..
|
||||||
|
"list[current_name;src;3,1;1,1;]"..
|
||||||
|
"image[4,1;1,1;default_furnace_fire_bg.png]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
|
||||||
|
local desc = tier.." Generator"
|
||||||
|
minetest.register_node("technic:generator_"..ltier, {
|
||||||
|
description = desc,
|
||||||
|
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_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.get_meta(pos)
|
||||||
|
meta:set_string("infotext", desc)
|
||||||
|
meta:set_int(data.tier.."_EU_supply", 0)
|
||||||
|
meta:set_int("burn_time", 0)
|
||||||
|
meta:set_string("formspec", generator_formspec)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size("src", 1)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if not inv:is_empty("src") then
|
||||||
|
minetest.chat_send_player(player:get_player_name(),
|
||||||
|
"Machine cannot be removed because it is not empty")
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
minetest.register_node("technic:"..ltier.."_generator_active", {
|
||||||
|
description = desc,
|
||||||
|
tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
|
||||||
|
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
|
||||||
|
not_in_creative_inventory=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drop = "technic:"..ltier.."_generator",
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if not inv:is_empty("src") then
|
||||||
|
minetest.chat_send_player(player:get_player_name(),
|
||||||
|
"Machine cannot be removed because it is not empty")
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"technic:"..ltier.."_generator", "technic:"..ltier.."_generator_active"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local burn_time = meta:get_int("burn_time")
|
||||||
|
local burn_totaltime = meta:get_int("burn_totaltime")
|
||||||
|
-- If more to burn and the energy produced was used: produce some more
|
||||||
|
if burn_time > 0 then
|
||||||
|
meta:set_int(data.tier.."_EU_supply", data.supply)
|
||||||
|
burn_time = burn_time - 1
|
||||||
|
meta:set_int("burn_time", burn_time)
|
||||||
|
end
|
||||||
|
-- Burn another piece of fuel
|
||||||
|
if burn_time == 0 then
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if not inv:is_empty("src") then
|
||||||
|
local fuellist = inv:get_list("src")
|
||||||
|
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||||
|
if not fuel or fuel.time == 0 then
|
||||||
|
meta:set_string("infotext", "Generator out of fuel")
|
||||||
|
hacky_swap_node(pos, "technic:"..ltier.."_generator")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
meta:set_int("burn_time", fuel.time)
|
||||||
|
meta:set_int("burn_totaltime", fuel.time)
|
||||||
|
local stack = inv:get_stack("src", 1)
|
||||||
|
stack:take_item()
|
||||||
|
inv:set_stack("src", 1, stack)
|
||||||
|
hacky_swap_node(pos, "technic:"..ltier.."_generator_active")
|
||||||
|
meta:set_int(data.tier.."_EU_supply", data.supply)
|
||||||
|
else
|
||||||
|
hacky_swap_node(pos, "technic:"..ltier.."_generator")
|
||||||
|
meta:set_int(data.tier.."_EU_supply", 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if burn_totaltime == 0 then burn_totaltime = 1 end
|
||||||
|
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||||
|
meta:set_string("infotext", desc.." ("..percent.."%)")
|
||||||
|
meta:set_string("formspec",
|
||||||
|
"size[8, 9]"..
|
||||||
|
"label[0, 0;Generator]"..
|
||||||
|
"list[current_name;src;3, 1;1, 1;]"..
|
||||||
|
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
|
(percent)..":default_furnace_fire_fg.png]"..
|
||||||
|
"list[current_player;main;0, 5;8, 4;]")
|
||||||
|
end
|
||||||
|
})
|
||||||
|
technic.register_machine(data.tier, "technic:"..ltier.."_generator", technic.producer)
|
||||||
|
technic.register_machine(data.tier, "technic:"..ltier.."_generator", technic.producer)
|
||||||
|
end
|
@ -93,4 +93,8 @@ register_dust("Stainless Steel", "technic:stainless_steel_ingot")
|
|||||||
register_dust("Talinite", "glooptest:talinite_ingot")
|
register_dust("Talinite", "glooptest:talinite_ingot")
|
||||||
register_dust("Tin", "moreores:tin_ingot")
|
register_dust("Tin", "moreores:tin_ingot")
|
||||||
register_dust("Zinc", "technic:zinc_ingot")
|
register_dust("Zinc", "technic:zinc_ingot")
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "fuel",
|
||||||
|
recipe = "technic:coal_dust",
|
||||||
|
burntime = 50,
|
||||||
|
})
|
||||||
|
@ -8,4 +8,5 @@ dofile(path.."/electric_furnace.lua")
|
|||||||
dofile(path.."/grinder.lua")
|
dofile(path.."/grinder.lua")
|
||||||
dofile(path.."/grinder_recipes.lua")
|
dofile(path.."/grinder_recipes.lua")
|
||||||
dofile(path.."/solar_array.lua")
|
dofile(path.."/solar_array.lua")
|
||||||
|
dofile(path.."/generator.lua")
|
||||||
|
|
||||||
|
BIN
technic/textures/technic_hv_generator_front.png
Normal file
After Width: | Height: | Size: 450 B |
BIN
technic/textures/technic_hv_generator_front_active.png
Normal file
After Width: | Height: | Size: 469 B |
BIN
technic/textures/technic_hv_generator_side.png
Normal file
After Width: | Height: | Size: 357 B |
BIN
technic/textures/technic_hv_generator_top.png
Normal file
After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 430 B After Width: | Height: | Size: 430 B |
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 454 B |
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 341 B |
Before Width: | Height: | Size: 388 B After Width: | Height: | Size: 388 B |
BIN
technic/textures/technic_mv_generator_front.png
Normal file
After Width: | Height: | Size: 425 B |
BIN
technic/textures/technic_mv_generator_front_active.png
Normal file
After Width: | Height: | Size: 440 B |
BIN
technic/textures/technic_mv_generator_side.png
Normal file
After Width: | Height: | Size: 317 B |
BIN
technic/textures/technic_mv_generator_top.png
Normal file
After Width: | Height: | Size: 322 B |