summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpagliaccio <mangheriniroberto@alice.it>2013-07-23 14:43:14 +0200
committerShadowNinja <noreply@gmail.com>2013-10-27 14:39:44 -0400
commit704925aa7b2dc78dd7af86b71e0a95a64b3afce1 (patch)
treede2630b1da07d98d6abd2a2f561a35be407a0168
parent4a35d5dd98c8c08dd79cd0d0789b902fd4470edf (diff)
Add MV and HV generators and make coal dust a fuel
-rw-r--r--technic/legacy.lua2
-rw-r--r--technic/machines/HV/generator.lua14
-rw-r--r--technic/machines/HV/init.lua1
-rw-r--r--technic/machines/LV/generator.lua127
-rw-r--r--technic/machines/LV/init.lua1
-rw-r--r--technic/machines/MV/generator.lua14
-rw-r--r--technic/machines/MV/init.lua1
-rw-r--r--technic/machines/register/generator.lua118
-rw-r--r--technic/machines/register/grinder_recipes.lua6
-rw-r--r--technic/machines/register/init.lua1
-rw-r--r--technic/textures/technic_hv_generator_front.pngbin0 -> 450 bytes
-rw-r--r--technic/textures/technic_hv_generator_front_active.pngbin0 -> 469 bytes
-rw-r--r--technic/textures/technic_hv_generator_side.pngbin0 -> 357 bytes
-rw-r--r--technic/textures/technic_hv_generator_top.pngbin0 -> 384 bytes
-rw-r--r--technic/textures/technic_lv_generator_front.png (renamed from technic/textures/technic_generator_front.png)bin430 -> 430 bytes
-rw-r--r--technic/textures/technic_lv_generator_front_active.png (renamed from technic/textures/technic_generator_front_active.png)bin454 -> 454 bytes
-rw-r--r--technic/textures/technic_lv_generator_side.png (renamed from technic/textures/technic_generator_side.png)bin341 -> 341 bytes
-rw-r--r--technic/textures/technic_lv_generator_top.png (renamed from technic/textures/technic_generator_top.png)bin388 -> 388 bytes
-rw-r--r--technic/textures/technic_mv_generator_front.pngbin0 -> 425 bytes
-rw-r--r--technic/textures/technic_mv_generator_front_active.pngbin0 -> 440 bytes
-rw-r--r--technic/textures/technic_mv_generator_side.pngbin0 -> 317 bytes
-rw-r--r--technic/textures/technic_mv_generator_top.pngbin0 -> 322 bytes
22 files changed, 159 insertions, 126 deletions
diff --git a/technic/legacy.lua b/technic/legacy.lua
index e6f7eb3..37fb1d5 100644
--- a/technic/legacy.lua
+++ b/technic/legacy.lua
@@ -22,6 +22,8 @@ technic.legacy_nodenames = {
["technic:lv_cable"] = "technic:lv_cable0",
["technic:mv_cable"] = "technic:mv_cable0",
["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
diff --git a/technic/machines/HV/generator.lua b/technic/machines/HV/generator.lua
new file mode 100644
index 0000000..d73b68a
--- /dev/null
+++ b/technic/machines/HV/generator.lua
@@ -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})
+
diff --git a/technic/machines/HV/init.lua b/technic/machines/HV/init.lua
index dc80673..908daed 100644
--- a/technic/machines/HV/init.lua
+++ b/technic/machines/HV/init.lua
@@ -9,4 +9,5 @@ dofile(path.."/forcefield.lua")
dofile(path.."/battery_box.lua")
dofile(path.."/solar_array.lua")
dofile(path.."/nuclear_reactor.lua")
+dofile(path.."/generator.lua")
diff --git a/technic/machines/LV/generator.lua b/technic/machines/LV/generator.lua
index 3358f67..eae7951 100644
--- a/technic/machines/LV/generator.lua
+++ b/technic/machines/LV/generator.lua
@@ -3,11 +3,10 @@
-- Inefficient and expensive in fuel (200EU per tick)
-- Also only allows for LV machinery to run.
-minetest.register_alias("generator", "technic:generator")
-minetest.register_alias("generator", "technic:generator_active")
+minetest.register_alias("lv_generator", "technic:lv_generator")
minetest.register_craft({
- output = 'technic:generator',
+ output = 'technic:lv_generator',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'default:stone', '', 'default:stone'},
@@ -15,125 +14,5 @@ minetest.register_craft({
}
})
-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;]"
-
-
-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)
+technic.register_generator({tier="LV", supply=200})
diff --git a/technic/machines/LV/init.lua b/technic/machines/LV/init.lua
index 291b0bd..dc47087 100644
--- a/technic/machines/LV/init.lua
+++ b/technic/machines/LV/init.lua
@@ -20,4 +20,3 @@ dofile(path.."/cnc_api.lua")
dofile(path.."/cnc_nodes.lua")
dofile(path.."/extractor.lua")
dofile(path.."/compressor.lua")
-
diff --git a/technic/machines/MV/generator.lua b/technic/machines/MV/generator.lua
new file mode 100644
index 0000000..973bbd2
--- /dev/null
+++ b/technic/machines/MV/generator.lua
@@ -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})
+
diff --git a/technic/machines/MV/init.lua b/technic/machines/MV/init.lua
index af0f556..92d1da9 100644
--- a/technic/machines/MV/init.lua
+++ b/technic/machines/MV/init.lua
@@ -13,6 +13,7 @@ dofile(path.."/tool_workshop.lua")
if technic.config:get_bool("enable_wind_mill") then
dofile(path.."/wind_mill.lua")
end
+dofile(path.."/generator.lua")
-- The power radiator supplies appliances with inductive coupled power:
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
diff --git a/technic/machines/register/generator.lua b/technic/machines/register/generator.lua
new file mode 100644
index 0000000..622da8b
--- /dev/null
+++ b/technic/machines/register/generator.lua
@@ -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
diff --git a/technic/machines/register/grinder_recipes.lua b/technic/machines/register/grinder_recipes.lua
index 09ab060..4f30f08 100644
--- a/technic/machines/register/grinder_recipes.lua
+++ b/technic/machines/register/grinder_recipes.lua
@@ -93,4 +93,8 @@ register_dust("Stainless Steel", "technic:stainless_steel_ingot")
register_dust("Talinite", "glooptest:talinite_ingot")
register_dust("Tin", "moreores:tin_ingot")
register_dust("Zinc", "technic:zinc_ingot")
-
+minetest.register_craft({
+ type = "fuel",
+ recipe = "technic:coal_dust",
+ burntime = 50,
+})
diff --git a/technic/machines/register/init.lua b/technic/machines/register/init.lua
index d3af184..673b265 100644
--- a/technic/machines/register/init.lua
+++ b/technic/machines/register/init.lua
@@ -8,4 +8,5 @@ dofile(path.."/electric_furnace.lua")
dofile(path.."/grinder.lua")
dofile(path.."/grinder_recipes.lua")
dofile(path.."/solar_array.lua")
+dofile(path.."/generator.lua")
diff --git a/technic/textures/technic_hv_generator_front.png b/technic/textures/technic_hv_generator_front.png
new file mode 100644
index 0000000..6a14686
--- /dev/null
+++ b/technic/textures/technic_hv_generator_front.png
Binary files differ
diff --git a/technic/textures/technic_hv_generator_front_active.png b/technic/textures/technic_hv_generator_front_active.png
new file mode 100644
index 0000000..d92c699
--- /dev/null
+++ b/technic/textures/technic_hv_generator_front_active.png
Binary files differ
diff --git a/technic/textures/technic_hv_generator_side.png b/technic/textures/technic_hv_generator_side.png
new file mode 100644
index 0000000..3073e0f
--- /dev/null
+++ b/technic/textures/technic_hv_generator_side.png
Binary files differ
diff --git a/technic/textures/technic_hv_generator_top.png b/technic/textures/technic_hv_generator_top.png
new file mode 100644
index 0000000..646168c
--- /dev/null
+++ b/technic/textures/technic_hv_generator_top.png
Binary files differ
diff --git a/technic/textures/technic_generator_front.png b/technic/textures/technic_lv_generator_front.png
index 2d64844..2d64844 100644
--- a/technic/textures/technic_generator_front.png
+++ b/technic/textures/technic_lv_generator_front.png
Binary files differ
diff --git a/technic/textures/technic_generator_front_active.png b/technic/textures/technic_lv_generator_front_active.png
index 4e57ca0..4e57ca0 100644
--- a/technic/textures/technic_generator_front_active.png
+++ b/technic/textures/technic_lv_generator_front_active.png
Binary files differ
diff --git a/technic/textures/technic_generator_side.png b/technic/textures/technic_lv_generator_side.png
index 5cbcbef..5cbcbef 100644
--- a/technic/textures/technic_generator_side.png
+++ b/technic/textures/technic_lv_generator_side.png
Binary files differ
diff --git a/technic/textures/technic_generator_top.png b/technic/textures/technic_lv_generator_top.png
index e2f3db3..e2f3db3 100644
--- a/technic/textures/technic_generator_top.png
+++ b/technic/textures/technic_lv_generator_top.png
Binary files differ
diff --git a/technic/textures/technic_mv_generator_front.png b/technic/textures/technic_mv_generator_front.png
new file mode 100644
index 0000000..570e0c5
--- /dev/null
+++ b/technic/textures/technic_mv_generator_front.png
Binary files differ
diff --git a/technic/textures/technic_mv_generator_front_active.png b/technic/textures/technic_mv_generator_front_active.png
new file mode 100644
index 0000000..3006a17
--- /dev/null
+++ b/technic/textures/technic_mv_generator_front_active.png
Binary files differ
diff --git a/technic/textures/technic_mv_generator_side.png b/technic/textures/technic_mv_generator_side.png
new file mode 100644
index 0000000..21c0d41
--- /dev/null
+++ b/technic/textures/technic_mv_generator_side.png
Binary files differ
diff --git a/technic/textures/technic_mv_generator_top.png b/technic/textures/technic_mv_generator_top.png
new file mode 100644
index 0000000..7afa5a1
--- /dev/null
+++ b/technic/textures/technic_mv_generator_top.png
Binary files differ