Add MV and HV generators and make coal dust a fuel
authorpagliaccio <mangheriniroberto@alice.it>
Tue, 23 Jul 2013 12:43:14 +0000 (14:43 +0200)
committerShadowNinja <noreply@gmail.com>
Sun, 27 Oct 2013 18:39:44 +0000 (14:39 -0400)
26 files changed:
technic/legacy.lua
technic/machines/HV/generator.lua [new file with mode: 0644]
technic/machines/HV/init.lua
technic/machines/LV/generator.lua
technic/machines/LV/init.lua
technic/machines/MV/generator.lua [new file with mode: 0644]
technic/machines/MV/init.lua
technic/machines/register/generator.lua [new file with mode: 0644]
technic/machines/register/grinder_recipes.lua
technic/machines/register/init.lua
technic/textures/technic_generator_front.png [deleted file]
technic/textures/technic_generator_front_active.png [deleted file]
technic/textures/technic_generator_side.png [deleted file]
technic/textures/technic_generator_top.png [deleted file]
technic/textures/technic_hv_generator_front.png [new file with mode: 0644]
technic/textures/technic_hv_generator_front_active.png [new file with mode: 0644]
technic/textures/technic_hv_generator_side.png [new file with mode: 0644]
technic/textures/technic_hv_generator_top.png [new file with mode: 0644]
technic/textures/technic_lv_generator_front.png [new file with mode: 0644]
technic/textures/technic_lv_generator_front_active.png [new file with mode: 0644]
technic/textures/technic_lv_generator_side.png [new file with mode: 0644]
technic/textures/technic_lv_generator_top.png [new file with mode: 0644]
technic/textures/technic_mv_generator_front.png [new file with mode: 0644]
technic/textures/technic_mv_generator_front_active.png [new file with mode: 0644]
technic/textures/technic_mv_generator_side.png [new file with mode: 0644]
technic/textures/technic_mv_generator_top.png [new file with mode: 0644]

index e6f7eb31616ce7e193e879adb99168bdc9d59b93..37fb1d52437a3aee676c861ed785bfa810fd9f42 100644 (file)
@@ -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 (file)
index 0000000..d73b68a
--- /dev/null
@@ -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})
+
index dc806730331bb2041aa3ea2ee33db11de3b66058..908daed9016f2cd90a09bedc278797feb412cad3 100644 (file)
@@ -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")
 
index 3358f67b02943b2f8b2f0e1911f5258aa096edf1..eae79518285ec5ef92b2dd6646a40dbc84375b42 100644 (file)
@@ -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})
 
index 291b0bdfbbfb41f846d768789b96c5d7c8060f82..dc47087ecef4c36a34e32fc21f9c7da6ff2e5065 100644 (file)
@@ -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 (file)
index 0000000..973bbd2
--- /dev/null
@@ -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})
+
index af0f5568df3d3bdfef99f072a48b8614d16375ce..92d1da93634a05200eccb3408a3a543120aa4573 100644 (file)
@@ -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 (file)
index 0000000..622da8b
--- /dev/null
@@ -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
index 09ab060a70b5a530654783d02ca14825fa99a7d3..4f30f08da914785e4b602b3049c2d171cfdccf59 100644 (file)
@@ -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,
+})
index d3af184dc775e071bc0566199a23cdb395d35c04..673b2651790bdfd93d30be038c1d6ce91ee7aa36 100644 (file)
@@ -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_generator_front.png b/technic/textures/technic_generator_front.png
deleted file mode 100644 (file)
index 2d64844..0000000
Binary files a/technic/textures/technic_generator_front.png and /dev/null differ
diff --git a/technic/textures/technic_generator_front_active.png b/technic/textures/technic_generator_front_active.png
deleted file mode 100644 (file)
index 4e57ca0..0000000
Binary files a/technic/textures/technic_generator_front_active.png and /dev/null differ
diff --git a/technic/textures/technic_generator_side.png b/technic/textures/technic_generator_side.png
deleted file mode 100644 (file)
index 5cbcbef..0000000
Binary files a/technic/textures/technic_generator_side.png and /dev/null differ
diff --git a/technic/textures/technic_generator_top.png b/technic/textures/technic_generator_top.png
deleted file mode 100644 (file)
index e2f3db3..0000000
Binary files a/technic/textures/technic_generator_top.png and /dev/null differ
diff --git a/technic/textures/technic_hv_generator_front.png b/technic/textures/technic_hv_generator_front.png
new file mode 100644 (file)
index 0000000..6a14686
Binary files /dev/null and b/technic/textures/technic_hv_generator_front.png 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 (file)
index 0000000..d92c699
Binary files /dev/null and b/technic/textures/technic_hv_generator_front_active.png differ
diff --git a/technic/textures/technic_hv_generator_side.png b/technic/textures/technic_hv_generator_side.png
new file mode 100644 (file)
index 0000000..3073e0f
Binary files /dev/null and b/technic/textures/technic_hv_generator_side.png differ
diff --git a/technic/textures/technic_hv_generator_top.png b/technic/textures/technic_hv_generator_top.png
new file mode 100644 (file)
index 0000000..646168c
Binary files /dev/null and b/technic/textures/technic_hv_generator_top.png differ
diff --git a/technic/textures/technic_lv_generator_front.png b/technic/textures/technic_lv_generator_front.png
new file mode 100644 (file)
index 0000000..2d64844
Binary files /dev/null and b/technic/textures/technic_lv_generator_front.png differ
diff --git a/technic/textures/technic_lv_generator_front_active.png b/technic/textures/technic_lv_generator_front_active.png
new file mode 100644 (file)
index 0000000..4e57ca0
Binary files /dev/null and b/technic/textures/technic_lv_generator_front_active.png differ
diff --git a/technic/textures/technic_lv_generator_side.png b/technic/textures/technic_lv_generator_side.png
new file mode 100644 (file)
index 0000000..5cbcbef
Binary files /dev/null and b/technic/textures/technic_lv_generator_side.png differ
diff --git a/technic/textures/technic_lv_generator_top.png b/technic/textures/technic_lv_generator_top.png
new file mode 100644 (file)
index 0000000..e2f3db3
Binary files /dev/null and b/technic/textures/technic_lv_generator_top.png differ
diff --git a/technic/textures/technic_mv_generator_front.png b/technic/textures/technic_mv_generator_front.png
new file mode 100644 (file)
index 0000000..570e0c5
Binary files /dev/null and b/technic/textures/technic_mv_generator_front.png 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 (file)
index 0000000..3006a17
Binary files /dev/null and b/technic/textures/technic_mv_generator_front_active.png differ
diff --git a/technic/textures/technic_mv_generator_side.png b/technic/textures/technic_mv_generator_side.png
new file mode 100644 (file)
index 0000000..21c0d41
Binary files /dev/null and b/technic/textures/technic_mv_generator_side.png differ
diff --git a/technic/textures/technic_mv_generator_top.png b/technic/textures/technic_mv_generator_top.png
new file mode 100644 (file)
index 0000000..7afa5a1
Binary files /dev/null and b/technic/textures/technic_mv_generator_top.png differ