From d623715d94152e38e817555f43c7c6ab2372045c Mon Sep 17 00:00:00 2001 From: Bryce w <55167737+blockhead100@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:18:51 +0200 Subject: [PATCH] Add LV led and lamp --- modpack.conf | 2 + technic/machines/LV/init.lua | 3 + technic/machines/LV/lamp.lua | 171 ++++++++++++++++++++ technic/machines/LV/led.lua | 108 +++++++++++++ technic/textures/technic_lv_lamp_bottom.png | Bin 0 -> 995 bytes technic/textures/technic_lv_lamp_side.png | Bin 0 -> 1014 bytes technic/textures/technic_lv_lamp_top.png | Bin 0 -> 466 bytes technic/textures/technic_lv_led.png | Bin 0 -> 738 bytes technic/textures/technic_lv_led_inv.png | Bin 0 -> 429 bytes technic/textures/technic_lv_led_side.png | Bin 0 -> 245 bytes technic/textures/technic_lv_led_side2.png | Bin 0 -> 253 bytes technic/textures/technic_lv_led_top.png | Bin 0 -> 466 bytes 12 files changed, 284 insertions(+) create mode 100644 technic/machines/LV/lamp.lua create mode 100644 technic/machines/LV/led.lua create mode 100644 technic/textures/technic_lv_lamp_bottom.png create mode 100644 technic/textures/technic_lv_lamp_side.png create mode 100644 technic/textures/technic_lv_lamp_top.png create mode 100644 technic/textures/technic_lv_led.png create mode 100644 technic/textures/technic_lv_led_inv.png create mode 100644 technic/textures/technic_lv_led_side.png create mode 100644 technic/textures/technic_lv_led_side2.png create mode 100644 technic/textures/technic_lv_led_top.png diff --git a/modpack.conf b/modpack.conf index 1452865..f7e7c23 100644 --- a/modpack.conf +++ b/modpack.conf @@ -1 +1,3 @@ name = technic +description = technic +min_minetest_version = 5.0 diff --git a/technic/machines/LV/init.lua b/technic/machines/LV/init.lua index fde684d..61cb893 100644 --- a/technic/machines/LV/init.lua +++ b/technic/machines/LV/init.lua @@ -22,3 +22,6 @@ dofile(path.."/extractor.lua") dofile(path.."/compressor.lua") dofile(path.."/music_player.lua") +-- NEW LV LAMPS +dofile(path.."/led.lua") +dofile(path.."/lamp.lua") diff --git a/technic/machines/LV/lamp.lua b/technic/machines/LV/lamp.lua new file mode 100644 index 0000000..ebeac36 --- /dev/null +++ b/technic/machines/LV/lamp.lua @@ -0,0 +1,171 @@ + +-- LV Lamp +-- Illuminates a 7x7x3(H) volume below itself with light bright as the sun. + + +local S = technic.getter + +local desc = S("@1 Lamp", S("LV")) +local active_desc = S("@1 Active", desc) +local unpowered_desc = S("@1 Unpowered", desc) +local off_desc = S("@1 Off", desc) +local demand = 50 + + +-- Invisible light source node used for illumination +minetest.register_node("technic:dummy_light_source", { + description = S("Dummy light source node"), + inventory_image = "technic_dummy_light_source.png", + wield_image = "technic_dummy_light_source.png", + paramtype = "light", + drawtype = "airlike", + light_source = 14, + sunlight_propagates = true, + walkable = false, + buildable_to = true, + diggable = false, + pointable = false, + --drop = "", -- Intentionally allowed to drop itself + groups = {not_in_creative_inventory = 1} +}) + + +local function illuminate(pos, active) + local pos1 = {x = pos.x - 3, y = pos.y - 1, z = pos.z - 3} + local pos2 = {x = pos.x + 3, y = pos.y - 3, z = pos.z + 3} + + local find_node = active and "air" or "technic:dummy_light_source" + local set_node = {name = (active and "technic:dummy_light_source" or "air")} + + for _,p in pairs(minetest.find_nodes_in_area(pos1, pos2, find_node)) do + minetest.set_node(p, set_node) + end +end + +local function lamp_run(pos, node) + local meta = minetest.get_meta(pos) + + if meta:get_int("LV_EU_demand") == 0 then + return -- Lamp is turned off + end + + local eu_input = meta:get_int("LV_EU_input") + + if node.name == "technic:lv_lamp_active" then + if eu_input < demand then + technic.swap_node(pos, "technic:lv_lamp") + meta:set_string("infotext", unpowered_desc) + illuminate(pos, false) + else + illuminate(pos, true) + end + elseif node.name == "technic:lv_lamp" then + if eu_input >= demand then + technic.swap_node(pos, "technic:lv_lamp_active") + meta:set_string("infotext", active_desc) + illuminate(pos, true) + end + end +end + +local function lamp_toggle(pos, node, player) + if not player or minetest.is_protected(pos, player:get_player_name()) then + return + end + local meta = minetest.get_meta(pos) + if meta:get_int("LV_EU_demand") == 0 then + meta:set_string("infotext", active_desc) + meta:set_int("LV_EU_demand", demand) + else + illuminate(pos, false) + technic.swap_node(pos, "technic:lv_lamp") + meta:set_string("infotext", off_desc) + meta:set_int("LV_EU_demand", 0) + end +end + +minetest.register_node("technic:lv_lamp", { + description = desc, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {0.5,0.5,0.5,-0.5,-0.2,-0.5} + }, + collision_box = { + type = "fixed", + fixed = {0.5,0.5,0.5,-0.5,-0.2,-0.5} + }, + selection_box = { + type = "fixed", + fixed = {0.5,0.5,0.5,-0.5,-0.2,-0.5} + }, + tiles = { + "technic_lv_lamp_top.png", + "technic_lv_lamp_bottom.png", + "technic_lv_lamp_side.png", + "technic_lv_lamp_side.png", + "technic_lv_lamp_side.png", + "technic_lv_lamp_side.png" + }, + groups = {cracky = 2, technic_machine = 1, technic_lv = 1}, + connect_sides = {"front", "back", "left", "right", "top"}, + can_dig = technic.machine_can_dig, + technic_run = lamp_run, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", desc) + meta:set_int("LV_EU_demand", demand) + end, + on_destruct = illuminate, + on_rightclick = lamp_toggle +}) + +minetest.register_node("technic:lv_lamp_active", { + description = active_desc, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, -0.2, -0.5} + }, + collision_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, -0.2, -0.5} + }, + selection_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, -0.2, -0.5} + }, + tiles = { + "technic_lv_lamp_top.png", + "technic_lv_lamp_bottom.png", + "technic_lv_lamp_side.png", + "technic_lv_lamp_side.png", + "technic_lv_lamp_side.png", + "technic_lv_lamp_side.png" + }, + paramtype = "light", + light_source = 14, + drop = "technic:lv_lamp", + groups = {cracky = 2, technic_machine = 1, technic_lv = 1, not_in_creative_inventory = 1}, + connect_sides = {"front", "back", "left", "right", "top"}, + can_dig = technic.machine_can_dig, + technic_run = lamp_run, + technic_on_disable = function(pos) + illuminate(pos, false) + technic.swap_node(pos, "technic:lv_lamp") + end, + on_destruct = illuminate, + on_rightclick = lamp_toggle, +}) + +technic.register_machine("LV", "technic:lv_lamp", technic.receiver) +technic.register_machine("LV", "technic:lv_lamp_active", technic.receiver) + +minetest.register_craft({ + output = "technic:lv_lamp", + recipe = { + {"default:glass", "default:glass", "default:glass"}, + {"technic:lv_led", "technic:lv_led", "technic:lv_led"}, + {"mesecons_materials:glue", "technic:lv_cable", "mesecons_materials:glue"}, + } +}) diff --git a/technic/machines/LV/led.lua b/technic/machines/LV/led.lua new file mode 100644 index 0000000..1e8a408 --- /dev/null +++ b/technic/machines/LV/led.lua @@ -0,0 +1,108 @@ +-- LED +-- Intended primarily as a core component for LED lamps. + +local S = technic.getter + +local desc = S("@1 LED", S("LV")) +local active_desc = S("@1 Active", desc) +local unpowered_desc = S("@1 Unpowered", desc) +local demand = 5 + + +local function led_run(pos, node) + local meta = minetest.get_meta(pos) + local eu_input = meta:get_int("LV_EU_input") + + if eu_input < demand and node.name == "technic:lv_led_active" then + technic.swap_node(pos, "technic:lv_led") + meta:set_string("infotext", unpowered_desc) + elseif eu_input >= demand and node.name == "technic:lv_led" then + technic.swap_node(pos, "technic:lv_led_active") + meta:set_string("infotext", active_desc) + end +end + +minetest.register_node("technic:lv_led", { + description = desc, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5} + }, + collision_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5} + }, + selection_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5} + }, + tiles = { + "technic_lv_led_top.png", + "technic_lv_led.png", + "technic_lv_led_side.png", + "technic_lv_led_side2.png", + "technic_lv_led_side2.png", + "technic_lv_led_side2.png", + }, + inventory_image = "technic_lv_led_inv.png", + sunlight_propagates = true, + groups = {cracky = 2, technic_machine = 1, technic_lv = 1}, + connect_sides = {"front", "back", "left", "right", "top", "bottom"}, + can_dig = technic.machine_can_dig, + technic_run = led_run, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("infotext", desc) + meta:set_int("LV_EU_demand", demand) + end, +}) + +minetest.register_node("technic:lv_led_active", { + description = active_desc, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5} + }, + collision_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5} + }, + selection_box = { + type = "fixed", + fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5} + }, + tiles = { + "technic_lv_led_top.png", + "technic_lv_led.png", + "technic_lv_led_side.png", + "technic_lv_led_side2.png", + "technic_lv_led_side2.png", + "technic_lv_led_side2.png", + }, + inventory_image = "technic_lv_led_inv.png", + paramtype = "light", + light_source = 9, + drop = "technic:lv_led", + sunlight_propagates = true, + groups = {cracky = 2, technic_machine = 1, technic_lv = 1, not_in_creative_inventory = 1}, + connect_sides = {"front", "back", "left", "right", "top", "bottom"}, + can_dig = technic.machine_can_dig, + technic_run = led_run, + technic_on_disable = function(pos) + technic.swap_node(pos, "technic:lv_led") + end, +}) + +technic.register_machine("LV", "technic:lv_led", technic.receiver) +technic.register_machine("LV", "technic:lv_led_active", technic.receiver) + +minetest.register_craft({ + output = "technic:lv_led 2", + recipe = { + {"", "homedecor:plastic_sheeting", ""}, + {"homedecor:plastic_sheeting", "technic:doped_silicon_wafer", "homedecor:plastic_sheeting"}, + {"", "technic:fine_silver_wire", ""}, + } +}) diff --git a/technic/textures/technic_lv_lamp_bottom.png b/technic/textures/technic_lv_lamp_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..7abc2444e36c252314c4de5ea484590be97f8901 GIT binary patch literal 995 zcmV<9104K`P)-3j=YX-ZuifER`W^sHN)a zk<-+D-{oQ66h#3i}3HN?(eYr_x$<$`2YF%;N^bc=7r|x za_HxX=je~_@wuO&o}#3o)YX35-b&Zii`?H!*42{J*o@lWTi@Sg+~Qr{-)rIFX5->u z-QI@c;%D98joaUp-{7L+;hp2=l;i1%=I4&(=au2*t?B5A-{rIA>x$&%y6Ebd@$jqi z@vQLivhnh>?)1U&^2he{`1EzSymAQFi5_({OeDX{q|67j>5Q9$D1czDL= z^OayEIqecQgY$Fe*Vk2VW~b&{E>|0;WCbgz*p7XhoDPK+TU+10YvWWxs2xg^;a6&T zxx*$^H5XO8I3+Wm(4xxw#sanJp2KDq|?E)jUCzIK`b{?ic5a(WjO7 z>6`f|!AOjCejuToUE}l|0Ro#K@AwhDxMB*1v3x>$=|O@pz&GoOW;qqcJqO zrbd=EW5`z0HkjoPfR*2j6V_{*_9gb`U-)Bo=Veo3m;Qu(*1TpM|Pee5>u1Diq zQcq|JJ)!HmmNX2_NEo_q#L~K^r_!^@+0-2)nNAw%L^3^_zGEycl57r}S-NOpoF!&X zSSDG*cFwl4HY28OT7sBRIX7*KA#dzM1Gr*aoNP=Ygb8d*1soAdFz7k4m2Eph z2+XAoV#x)xUNNaSP(pDEoMMV7<^V1z?1c~zI}$z`tR;6~j2QMpn1VOyC@CC=bC{n) zA;(cz!gTWko&~NN!kF!9@aL<>0ttI-1i|nr+tDm&5H2wFAtO;%dXKc#X{59G)aOt0W zgAvXK@M6a$w=R43snnYi&xnFoNo7sqdd#j>l#(p~Dp7Ie7s(Ux<3(g(d zn5jde|INMgRU5tvoxO`Trv}z1GtZK{zBMxe?M&xB_f%QWgUbCoYS72%ug?=`$Bng1 zsPop)cK@<7Ki_`o+kzvR%?P`Et+Uq=np$)E#A@`QV7hN2^8}h-j)EHy>YQG$?{T%1 pHV^H)_Gl~Ga_)ust(vQU=}9l$w&mc89~GQu)U>O$VWK`b_&;&Lt!V%N literal 0 HcmV?d00001 diff --git a/technic/textures/technic_lv_lamp_top.png b/technic/textures/technic_lv_lamp_top.png new file mode 100644 index 0000000000000000000000000000000000000000..bf74ee8898d2a51be4c88dc34b9d4ba9f9127fd5 GIT binary patch literal 466 zcmWlUKWGzS0L9b3O9aHW z7$+tpoN;Qq0Wm2vCnj@kX8F`6+~=M%p15P1{biIoa`z~b9cf|aX2zIpzuACM09IZ`Udcw>XtmX_2zUgfklj+cSNhVY8r0YJoIV1H;C;u~)^5s`dfJ;eIrS5#!kbpm9q6e*ePHM7BMUn?U5mNN(eE{o(^%``U{Z vq3Q2`r8-hNr!3EJ6nn;K^GP&`<3}Wn6NO%M^l`Kr-JP$@RZCCL=(qj@U9RMW literal 0 HcmV?d00001 diff --git a/technic/textures/technic_lv_led.png b/technic/textures/technic_lv_led.png new file mode 100644 index 0000000000000000000000000000000000000000..ddb8a51bdd6ac32ce75d2b8107f8d00b56640980 GIT binary patch literal 738 zcmV<80v-K{P)`~CX<{Qv*{_5R@^_4@t%`u_jjAN}AU|L7R{_x$+! z_xbzy`1Sh#^!xkx{m{nD(#X!$%hLYa8~oZS{@g78<0bX=|NQ&%d3$(ze0h6)dd|ek z)5*{H+!xl&)BW2j`Qst@^YQ!f_xAMo^Z5Jr`1JYq`~3Fx^!fb$`1kt!`Ehe_bar!h zd3Jn$dw+p`f`oz3zQ)hR%lX$4%*xLA*ChSbCHvVH``IV?-5T`ZD$~%__~IYb(bn0| z)!NY3`s5?l)Y$#uF#F{s|Kl?M=qdQ_^!D)Y_wn%W_4oJi{Ppwq?)dZZ`0e@h^7Qxf z@cQ)e`}Ozv_W$+v`uXqj{P+L${QdU-^Zoer{`vR*^Z5VtK-T2K0004TNkl#Kn8{t z0O%Kopap{;0PnQ$9X8@*x)I~`Ndy47U%-W}#m?Qv;(U@!&sUa_0(!v3^>(|F+(?pz zhbsaA2Z4hW=DOYcNn@#z#0&rctUj9G?rt`&-MTZq4A2CE3Tsc6l1{RdY$xmIaEc)S z5F72zEnqcv+ug;@WN9I;;RDMs1`Mst-JXAXbLT~SAztDL;25a+8Yf$G z_u_+iIgAoUMs008ito@49+u#5og0=3jWlrIC`I{^$(5`YYp zO^g8aeSs3d7}P*+3_=D#3&0oz`lJAYZvZJi0stTYc@xSOKm~AuGXMYps6Yk(0VU`h U&HO_jEdT%j07*qoM6N<$g1J4OXaE2J literal 0 HcmV?d00001 diff --git a/technic/textures/technic_lv_led_inv.png b/technic/textures/technic_lv_led_inv.png new file mode 100644 index 0000000000000000000000000000000000000000..5606262215f4a7da9ce11376d0f4063fc4c47a23 GIT binary patch literal 429 zcmV;e0aE^nP)qnAphtX=;-Ls#>~>l&ehA({@WY;+A03rEdS#rd3$(ze0h6) zdd|ek)5*{H+!xl&)BW2j`Qst>`1JSv|8aA0bar!hd3Jn$dw+p`f`oz3zQ)hR%lX$4 z%*xLA*ChSbCHvVH``IV?-5T`ZD$~%__~IYb(bn0|)!NY3`s5?l)Y$#uF#F{s|Kl?M z=qdN`{QL3u@cQ)k`S$wv{P_C!{QCa&|N8#?{|6=_qyPW_0d!JMQvg8b*k%9#0G>%i zK~xwSjlqR+15pqK!FjtMj!#SmnVFgM56h(p>~8*{_*^Zu@g=DMq=}W)#O$av3DC~0 zOBbPQ+^g*$K)d4@gCD!MHv<7uo%5B4KDd1g(D1gI=V>@RJ+JlzXmsCu@`cZRyd^-g z5Yt_Hd`h+wprPfMyQ%lBjRa^=pEVCBi|5$dT7cfIoYj|hZTkl=0*a5N^rlyB6#VTM X3ndB!+cV7t00000NkvXXu0mjfw*u=f literal 0 HcmV?d00001 diff --git a/technic/textures/technic_lv_led_side.png b/technic/textures/technic_lv_led_side.png new file mode 100644 index 0000000000000000000000000000000000000000..cda7bece2a6efbabb0682dfaf1c2f7b7771bd094 GIT binary patch literal 245 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyP60k4u9{k!`uchX1_p+PhDJt4 z`TyCAii(Phi%UvMN=r-2%E~G#Dk>{0tE#Gg{`~p-_wPS{{`~#>_us#N|2aAT|NZ;_ z|Npv*vrItK@;qG}LoEE?o-!0VWFWxeSlD!TGVipM8UO32wrFuEsC;%2E_t|l-~08F z$$fT>hc<0F*3lub;#vnsFMI3kt!vhzopr0M3_l A4*&oF literal 0 HcmV?d00001 diff --git a/technic/textures/technic_lv_led_top.png b/technic/textures/technic_lv_led_top.png new file mode 100644 index 0000000000000000000000000000000000000000..bf74ee8898d2a51be4c88dc34b9d4ba9f9127fd5 GIT binary patch literal 466 zcmWlUKWGzS0L9b3O9aHW z7$+tpoN;Qq0Wm2vCnj@kX8F`6+~=M%p15P1{biIoa`z~b9cf|aX2zIpzuACM09IZ`Udcw>XtmX_2zUgfklj+cSNhVY8r0YJoIV1H;C;u~)^5s`dfJ;eIrS5#!kbpm9q6e*ePHM7BMUn?U5mNN(eE{o(^%``U{Z vq3Q2`r8-hNr!3EJ6nn;K^GP&`<3}Wn6NO%M^l`Kr-JP$@RZCCL=(qj@U9RMW literal 0 HcmV?d00001