From 704925aa7b2dc78dd7af86b71e0a95a64b3afce1 Mon Sep 17 00:00:00 2001 From: pagliaccio Date: Tue, 23 Jul 2013 14:43:14 +0200 Subject: [PATCH] Add MV and HV generators and make coal dust a fuel --- technic/legacy.lua | 2 + technic/machines/HV/generator.lua | 14 ++ technic/machines/HV/init.lua | 1 + technic/machines/LV/generator.lua | 127 +----------------- technic/machines/LV/init.lua | 1 - technic/machines/MV/generator.lua | 14 ++ technic/machines/MV/init.lua | 1 + technic/machines/register/generator.lua | 118 ++++++++++++++++ technic/machines/register/grinder_recipes.lua | 6 +- technic/machines/register/init.lua | 1 + .../textures/technic_hv_generator_front.png | Bin 0 -> 450 bytes .../technic_hv_generator_front_active.png | Bin 0 -> 469 bytes .../textures/technic_hv_generator_side.png | Bin 0 -> 357 bytes technic/textures/technic_hv_generator_top.png | Bin 0 -> 384 bytes ...ont.png => technic_lv_generator_front.png} | Bin ... => technic_lv_generator_front_active.png} | Bin ...side.png => technic_lv_generator_side.png} | Bin ...r_top.png => technic_lv_generator_top.png} | Bin .../textures/technic_mv_generator_front.png | Bin 0 -> 425 bytes .../technic_mv_generator_front_active.png | Bin 0 -> 440 bytes .../textures/technic_mv_generator_side.png | Bin 0 -> 317 bytes technic/textures/technic_mv_generator_top.png | Bin 0 -> 322 bytes 22 files changed, 159 insertions(+), 126 deletions(-) create mode 100644 technic/machines/HV/generator.lua create mode 100644 technic/machines/MV/generator.lua create mode 100644 technic/machines/register/generator.lua create mode 100644 technic/textures/technic_hv_generator_front.png create mode 100644 technic/textures/technic_hv_generator_front_active.png create mode 100644 technic/textures/technic_hv_generator_side.png create mode 100644 technic/textures/technic_hv_generator_top.png rename technic/textures/{technic_generator_front.png => technic_lv_generator_front.png} (100%) rename technic/textures/{technic_generator_front_active.png => technic_lv_generator_front_active.png} (100%) rename technic/textures/{technic_generator_side.png => technic_lv_generator_side.png} (100%) rename technic/textures/{technic_generator_top.png => technic_lv_generator_top.png} (100%) create mode 100644 technic/textures/technic_mv_generator_front.png create mode 100644 technic/textures/technic_mv_generator_front_active.png create mode 100644 technic/textures/technic_mv_generator_side.png create mode 100644 technic/textures/technic_mv_generator_top.png 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 0000000000000000000000000000000000000000..6a146866db745799f892714ab3d6c205ca1af5dd GIT binary patch literal 450 zcmV;z0X_bSP)90Uy!|-;DqO02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00AmVL_t(I%Z-yUP6IIzMc>%7 z0*MMb3T^-r9X%C2r{x$N0STcL5Q3DTC~L1Nytc<7f_!PUUhn)F|372l?lBQY@Cq?d zp#wM%Q*3)Ffk<9E4>6#XY>6r5Cx%QY#6m9rVn8dQkRd0$eaP$Qr*<-%$axT4Xl^&{?cL~OLHEr)yrEvtQN5OqQk5i$ZxN(+oGLDfQ!rDWDAidRR>(% zEXIAj?o}4}UiF3=^d2~$1Ga0J!mQip;|`~NJG%r$-xMK?uv90XC4hN8tbf02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00BKoL_t(I%Z-ygP6IIzg+H%n zA+&T9+yErHh?a^zXW$;W2PfeK)HD=OAt96kq96sd%GzrRukCS&2v1u1XXlOm-i!^? zS-|yR1-v6eT4*c`zU+kn#>9DJ!8;_AH8F(vc^3(Zn8@j$cSt5AGQ@-z*Kz)ES8k>g zH5QDa9G$XTfwL=EzQy(FIjooP{!(HfN^2~VPfw$(=^H$_9ySXIzL4ZF zCK-HPN@GS7b+aUWL5g9?yuO1*R7@C6Oh5m^;MCYE39iqJ`}qy~a5=v%Hv=TM@!)uT zdgk94d4}mM5W;>58V5(p#8kp|Qn%`M$@EKAjVC*U_1jPnXIJtcmT8es)PA}<00000 LNkvXXu0mjfI6=GB literal 0 HcmV?d00001 diff --git a/technic/textures/technic_hv_generator_side.png b/technic/textures/technic_hv_generator_side.png new file mode 100644 index 0000000000000000000000000000000000000000..3073e0f6abc8e4fe001b78b56fa1675925a2e265 GIT binary patch literal 357 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#E|(||6W5eq8B2jek|nMYCC>S|xv6<249-QVi6yBi3gww484B*6z5(HleBwYw z_dQ)4Lp08pPI{etz<{I0KF27S{pG*v5Yr=n3;D{TL|rHHlpnwRF_$`hm&}T-!m2F&8(tP=X%=WrFm!M)}?CfkN5X6GGvfAuuPNXj_2!rEMN2k zrmF0>x%>0qr`Xpw<2^%!ME7_Jxf^YIH~XiU6<6+G)?ez0(aiHETX!Cub0lJZh>H5M z$mk2R)*M^@E_uR6m3cOCA-YBOt9#2=?z>^t>oony+}raRZEl)A`|NXW;n4&7t@CWJ zG|mZ|8gk{$4d>kD&sH>7=O3$=zqwxSU(Pf3Hydi-$}61O4)iL6r>mdKI;Vst09Lz< A@&Et; literal 0 HcmV?d00001 diff --git a/technic/textures/technic_hv_generator_top.png b/technic/textures/technic_hv_generator_top.png new file mode 100644 index 0000000000000000000000000000000000000000..646168cb99db23f76e8a66eeb36a764042eb1337 GIT binary patch literal 384 zcmV-`0e}99P)_RffDK_ac9N=&p0ph`LIuK*mZ94D=x3|6DoDJtom>*PmHFOVk_ZeHOeP;b z{ZF)t#MHmn*M1t({6tD7A^aa{f-%9&*|+XeIo%&KP$CkCq0OAz`in~?15|s5YiJ|3 z7Y0@LM=L-Gz)-==IUlZPo#dleQ$=jON+!)NHoA0iBOw3@Rnp{Rjj-Ov&9(5wzQ31E eVma5IxB3Mw;)INSeEwAc0000FFc5~nX{NML3krMjB9c85B~WGClA&^UqK^@NTFIHtH5yr0UkPd8^gM9;I0Pe;d@$D zr70Z`gAcX8TR6D#rjc-Neb7qh5>%2n0^HVXa1m0HW=jb(Nh9z&mH-jhPvJb*D{*AZ zy@9<8T3Fy^1QXA$s<84d6a;e_ZH#z|5mlfQxHg+Jp{wEOD(K2ypZ9(lGV7y=5Yqmy zwI(ZJ$VB;Ye}i|X$V`hdzQlAP$Xc^A7m`TincJklyg<%gY9_pHUY1R5;6xld(?2Fc5~ni?1S5L2XCGGw=Yc%J=RFx(<9$Fuy?rpd=M^{RZo+&EH909HuV{&n&B;5+t5R6H7r;;E72S;)4%=5Il zszL`E7i4~&zz~$(EXsC{5<~?mp%bl#rNBa9Wzt;atyJkv%!gxDg)cWO5*n9gVi=@I zZXC1FI;c%nLYwM&dwl+vfA{iKDARn5-#{XE z)7O>#E|(||i`s{Z#Rq^wk|nMYCC>S|xv6<249-QVi6yBi3gww484B*6z5(HleBwYw z+dW+zLp09U2JPlMV!&ZMwSC?9+28*=v#I1Y2rOQ8d=f{GA^+j;&7ukqG`ZNBpsh%)sE-Z~b!H@CFECb2&gT|9C}Yxk<5QLEK4-Z*Noki&96DAc#~KCrhJAHa zFJ5K%dgh9?D^@$cPxO}Av0P==n?|#DCGodUE<9USBX|CET3vow3fsk{HI+awFnGH9 KxvX{XE z)7O>#E|(||i;loruX{it$r9Iy66gHf+|;}h2Ir#G#FEq$h4Rdj3Mi(wHb`?%~cIv@oUJe}voA)cs3K>i} zO83mFmUOVV!qAc|zBfmpNRQL&;X*$*>%2KVs^_%#+?!z2uQz?Y z{QBV`qvA)Kxje(9EM~p=nPva8lzsI=!N>L4CflAoI&&*DXm^NawAHFDw{FVxEff1y z!MbqsLEY#NmW4AL*gY(kz5kPK-zm$%D6nGT#jW2;#Vc=|nt%D#?jMZHmxWE5THj{? P^aq2dtDnm{r-UW|PLp~V literal 0 HcmV?d00001