From aea77184e0bd297f57722e4fb05b398f5832ae96 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Wed, 1 Aug 2018 17:41:01 +0300 Subject: [PATCH] Going wireless! Implementing powered teleports --- elepower_dynamics/craftitems.lua | 12 ++- .../textures/elepower_xycrone.png | Bin 0 -> 459 bytes elepower_machines/crafting.lua | 41 ++++++-- elepower_papi/machine.lua | 22 ++++- elepower_papi/tool.lua | 1 - elepower_wireless/crafting.lua | 0 elepower_wireless/craftitems.lua | 75 +++++++++++++++ elepower_wireless/depends.txt | 2 + elepower_wireless/init.lua | 17 ++++ elepower_wireless/machines/init.lua | 4 + .../machines/matter_receiver.lua | 88 ++++++++++++++++++ elepower_wireless/mod.conf | 3 + elepower_wireless/nodes.lua | 0 .../textures/elewireless_device_side.png | Bin 0 -> 403 bytes .../textures/elewireless_receiver_top.png | Bin 0 -> 617 bytes .../elewireless_receiver_top_animated.png | Bin 0 -> 1481 bytes .../elewireless_receiver_top_inactive.png | Bin 0 -> 6026 bytes .../textures/elewireless_wireless_porter.png | Bin 0 -> 720 bytes 18 files changed, 251 insertions(+), 14 deletions(-) create mode 100644 elepower_dynamics/textures/elepower_xycrone.png create mode 100644 elepower_wireless/crafting.lua create mode 100644 elepower_wireless/craftitems.lua create mode 100644 elepower_wireless/depends.txt create mode 100644 elepower_wireless/init.lua create mode 100644 elepower_wireless/machines/init.lua create mode 100644 elepower_wireless/machines/matter_receiver.lua create mode 100644 elepower_wireless/mod.conf create mode 100644 elepower_wireless/nodes.lua create mode 100644 elepower_wireless/textures/elewireless_device_side.png create mode 100644 elepower_wireless/textures/elewireless_receiver_top.png create mode 100644 elepower_wireless/textures/elewireless_receiver_top_animated.png create mode 100644 elepower_wireless/textures/elewireless_receiver_top_inactive.png create mode 100644 elepower_wireless/textures/elewireless_wireless_porter.png diff --git a/elepower_dynamics/craftitems.lua b/elepower_dynamics/craftitems.lua index 45df210..f1bd99d 100644 --- a/elepower_dynamics/craftitems.lua +++ b/elepower_dynamics/craftitems.lua @@ -79,6 +79,12 @@ minetest.register_craftitem("elepower_dynamics:zinc_lump", { groups = {zinc = 1, lump = 1} }) +minetest.register_craftitem("elepower_dynamics:xycrone_lump", { + description = "Xycrone\nUsed for Quantum Superpositioning\nUnstable", + inventory_image = "elepower_xycrone.png", + groups = {xycrone = 1, lump = 1} +}) + -- Special minetest.register_craftitem("elepower_dynamics:carbon_fiber", { @@ -105,8 +111,8 @@ minetest.register_craftitem("elepower_dynamics:silicon_wafer", { groups = {wafer = 1} }) -minetest.register_craftitem("elepower_dynamics:silicon_wafer_solar", { - description = "Silicon Wafer\nFor Solar Panel Crafting", +minetest.register_craftitem("elepower_dynamics:silicon_wafer_doped", { + description = "Doped Silicon Wafer\nFor Solar Panel Crafting", inventory_image = "elepower_silicon_wafer_solar.png", groups = {wafer = 2} }) @@ -118,7 +124,7 @@ minetest.register_craftitem("elepower_dynamics:tree_tap", { }) minetest.register_craftitem("elepower_dynamics:pcb_blank", { - description = "Printed Circuit Board (PCB) Blank", + description = "Printed Circuit Board (PCB) Blank\nUse Etching Acid to etch", inventory_image = "elepower_blank_pcb.png", liquids_pointable = true, groups = {blank_board = 1, static_component = 1} diff --git a/elepower_dynamics/textures/elepower_xycrone.png b/elepower_dynamics/textures/elepower_xycrone.png new file mode 100644 index 0000000000000000000000000000000000000000..0d7922367345ee4f180506815ed2bdc2f1fbd2a9 GIT binary patch literal 459 zcmV;+0W|)JP)Xq02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00A>eL_t(I%gvEJO9N35MbEt5 z&2BWrn1BJ%(mxZcL^~yDVQmn>Mo43;g0&!;)|CF6s2~;wBw!)B*}OLv>lcJ1TIp@3 zn3=?-PkI<$2`9Pz(Z= z4)$~+Ah82(vOd@Oh}*2sT`uHyI;4{g$QZ+7b4SMlI6e~|9#Q9TfU_1W%1hFx6B^<; zo}2*y+Z(Cf`8f~)Rf2Ah2KZ28GX*&ZC+9Ny3+pw-NZPu%l;6E^t*Vp?sa1g9 zQ(9Z?k)W>-YZWDmz&bDj3X}>^oPqkPP6hzw=U1@y8$?q#vw5hm=;RZs6)lGuFdi5K zMo?#wz^6N~&>GHU__o@z;xu*QdEmW|w6BDJsW*QwV-Jah&b= nusage and storage >= nusage) then + minetest.chat_send_player(plname, "Not enough power to commit teleport!") + return itemstack + end + + -- Teleport player + player:set_pos(top) + nmeta:set_int("storage", nstorage - nusage) + + -- Add wear + meta:set_int("storage", storage - nusage) + itemstack = ele.tools.update_tool_wear(itemstack) + + return itemstack + end, + on_place = function(itemstack, placer, pointed_thing) + if not placer or placer:get_player_name() == "" then return itemstack end + local player = placer:get_player_name() + + if minetest.is_protected(pos, player) then + minetest.chat_send_player(player, "You are not allowed to teleport here!") + return itemstack + end + + local meta = itemstack:get_meta() + local pos = pointed_thing.under + local node = minetest.get_node_or_nil(pos) + + if not node or not ele.helpers.get_item_group(node.name, "matter_receiver") then return itemstack end + + local strpos = minetest.pos_to_string(pos) + local curpos = minetest.string_to_pos(meta:get_string("receiver")) + + if (curpos and curpos ~= "") and curpos == strpos then + minetest.chat_send_player(player, "Wireless Porter is already bound to this location!") + return itemstack + end + + meta:set_string("receiver", strpos) + minetest.chat_send_player(player, ("Wireless Porter bound to %s!"):format(strpos)) + + return itemstack + end, + ele_capacity = 1000, +}) diff --git a/elepower_wireless/depends.txt b/elepower_wireless/depends.txt new file mode 100644 index 0000000..527f0a8 --- /dev/null +++ b/elepower_wireless/depends.txt @@ -0,0 +1,2 @@ +elepower_dynamics +elepower_machines diff --git a/elepower_wireless/init.lua b/elepower_wireless/init.lua new file mode 100644 index 0000000..74aea13 --- /dev/null +++ b/elepower_wireless/init.lua @@ -0,0 +1,17 @@ +-- Elepower Mod +-- Copyright 2018 Evert "Diamond" Prants + +local modpath = minetest.get_modpath(minetest.get_current_modname()) + +elewi = rawget(_G, "elewi") or {} +elewi.modpath = modpath + +-- Items +dofile(modpath .. "/craftitems.lua") +dofile(modpath .. "/nodes.lua") + +-- Machines +dofile(modpath .. "/machines/init.lua") + +-- Crafting +dofile(modpath .. "/crafting.lua") diff --git a/elepower_wireless/machines/init.lua b/elepower_wireless/machines/init.lua new file mode 100644 index 0000000..195708d --- /dev/null +++ b/elepower_wireless/machines/init.lua @@ -0,0 +1,4 @@ + +local mp = elewi.modpath .. "/machines/" + +dofile(mp .. "matter_receiver.lua") diff --git a/elepower_wireless/machines/matter_receiver.lua b/elepower_wireless/machines/matter_receiver.lua new file mode 100644 index 0000000..cb012b6 --- /dev/null +++ b/elepower_wireless/machines/matter_receiver.lua @@ -0,0 +1,88 @@ + +local function get_formspec(power, name, player) + return "size[8,8.5]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + ele.formspec.power_meter(power).. + "field[1.5,0.5;5,1;name;Receiver Name;".. name .."]".. + "field_close_on_enter[name;false]".. + "label[0,3.75;Owned by " .. player .. "]".. + "list[current_player;main;0,4.25;8,1;]".. + "list[current_player;main;0,5.5;8,3;8]".. + "listring[current_player;main]".. + default.get_hotbar_bg(0, 4.25) +end + +local function matter_receiver_timer(pos) + local meta = minetest.get_meta(pos) + local name = meta:get_string("name") + local player = meta:get_string("player") + + if name == "" then + name = "Matter Receiver" + end + + local capacity = ele.helpers.get_node_property(meta, pos, "capacity") + local storage = ele.helpers.get_node_property(meta, pos, "storage") + local usage = ele.helpers.get_node_property(meta, pos, "usage") + + local pow_percent = math.floor((storage / capacity) * 100) + + if storage >= usage then + ele.helpers.swap_node(pos, "elepower_wireless:matter_receiver_active") + else + ele.helpers.swap_node(pos, "elepower_wireless:matter_receiver") + end + + meta:set_string("formspec", get_formspec(pow_percent, name, player)) + meta:set_string("infotext", "Matter Receiver\n" .. ele.capacity_text(capacity, storage)) + + return false +end + +ele.register_machine("elepower_wireless:matter_receiver", { + description = "Matter Receiver", + tiles = { + "elewireless_receiver_top_inactive.png", "elewireless_device_side.png^elepower_power_port.png", "elewireless_device_side.png", + "elewireless_device_side.png", "elewireless_device_side.png", "elewireless_device_side.png" + }, + ele_active_node = true, + ele_active_nodedef = { + tiles = { + { + name = "elewireless_receiver_top_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + speed = 5, + }, + }, + "elewireless_device_side.png^elepower_power_port.png", "elewireless_device_side.png", + "elewireless_device_side.png", "elewireless_device_side.png", "elewireless_device_side.png" + }, + }, + groups = {cracky = 1, ele_user = 1, matter_receiver = 1}, + ele_capacity = 8000, + ele_usage = 120, + ele_no_automatic_ports = true, + on_timer = matter_receiver_timer, + after_place_node = function (pos, placer, itemstack, pointed_thing) + local meta = minetest.get_meta(pos) + if not placer or placer:get_player_name() == "" then return false end + + meta:set_string("player", placer:get_player_name()) + end, + on_receive_fields = function (pos, formname, fields, sender) + if sender and sender ~= "" and minetest.is_protected(pos, sender:get_player_name()) then + return + end + + -- Set Name + local meta = minetest.get_meta(pos) + if fields["name"] and fields["key_enter"] == "true" then + meta:set_string("name", fields["name"]) + end + end +}) diff --git a/elepower_wireless/mod.conf b/elepower_wireless/mod.conf new file mode 100644 index 0000000..51feba0 --- /dev/null +++ b/elepower_wireless/mod.conf @@ -0,0 +1,3 @@ +name = elepower_wireless +description = Going wireless! +depends = elepower_dynamics,elepower_machines diff --git a/elepower_wireless/nodes.lua b/elepower_wireless/nodes.lua new file mode 100644 index 0000000..e69de29 diff --git a/elepower_wireless/textures/elewireless_device_side.png b/elepower_wireless/textures/elewireless_device_side.png new file mode 100644 index 0000000000000000000000000000000000000000..0620da7095d6bf6ece5f5c2cc2405b9410a63428 GIT binary patch literal 403 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE(|RU@(lmmW0$=Jif|Tq zL>4nJ=qZCRW5rVYGN2%PiKnkC`y&oU9wQ~ac^7JcLXst}5hc#~xw)x%B@E6*sfi`2 zDGKG8B^e6tp1uL$jeO!jMZY~=978Nl=LQAx9aZ4aey~aUP5$@&v)v=u_Vlas+?^&- zdTpB6OB?_D+j!scF(@oLUwZfWnpGJtEsrghF{l08v*TU$`vk$0&Gs4V5<=IeyyIKv zV9fmBva2z(pz6b4TX!ic85p0@SsN0)Fsjp{E=<7qc?Wmev?B})R@J`={^cx^ZG3p& z`%LAwRdz`W??lbs#BrcBcIUZG?OV4TXx%#P&(%Y-7zKH`nFECTzqPIX@Q14^l=JDU zV3%c2;w6tPow{Zc+p!S!Ze6F9>+@^B2e$5RJ}#5Khbfznq2T^^mpOms7p+y(QIhoA v64do*7OUXGm0DHr*Q-Z$?!P5@^$)|brCcsNONuuEgMq=*)z4*}Q$iB}48@*y literal 0 HcmV?d00001 diff --git a/elepower_wireless/textures/elewireless_receiver_top.png b/elepower_wireless/textures/elewireless_receiver_top.png new file mode 100644 index 0000000000000000000000000000000000000000..0271d04b572861bd7aec795a3c677ca5912b05e3 GIT binary patch literal 617 zcmV-v0+#)WP)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00GfSL_t(I%Wad(ZWBQiL{D{3 zh~$T4k0WErFWDC#qO9%`8l*bYxz5v07eIiS?g2o}EwuJ0VUlz6}9&m5^p{}~s z)pa!-4(;UR1TzCb($V$dem@sQK_ZE6w~HhIR;$%fFo2oSY&J`h#bQC?y~lfxB=S55 zV7Xj!Y;-yuLI^aQO=66g8OfeGgirxr%s$}ofOy~!UkC5VvWzrM2_aCg*SAV1lZiDN z4J4J|SF=x?alXBPh&-_5C!YteOC>QzLI}A1dk-t8JVS`~ShU6J4rF`Lt6r|$>Fe0&HtgHGg zA{%T+v;`Cgvq(6t-Bng@5%F=7$bLgcSoa~rYQjRdL2p3=W~+1l=XT|tyUw1 zK)c=MFdzRm6M%CLNoX`0S&}4WhaFz7eDIO(EQ*4^?G)_Cpe zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00l8gL_t(&-tC#sj}v7W$3M?I zv%AuE+HJe8yQQTpgaiXYF(jPCh)2bPQHhCnJmA4_R>Q%Q9yHO&e*k*($59Co4;lkX z01X5qEKOV4ZOcw)cX4;-eLYM&ZRr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1k*v7 zhNn3Lf*e4IX)ge2FpEy(u>=s0PWzHwfeNq$NRGG(@fyPS8LuGCJ`=}ll5E14=mZgh z2Wd;SV^gW5p6w+%Q`C*{I@53%4D%(ME<2P9~0%j;QHA2 zCgtCm_l5OXd!VvJyf#HxK!Ws}?!N-;Vel985vcH9;jA98({0^bGxkzGIJ`Yr{&3;ZLy{%>*-K0g^F zQv60Q0e|idoYk6$KQj;H`FV4ICBSIl!}7?T&+(Z-GM{h-0FbTJZ!Oi1De?HE4(7}C z)VZgtrEjnGWG$@z_jMTN8HRbF67{nY(0hAMOb}xtqWWGwbg|)30MPo)m*W=Vct(=t zrf8%ZFD+jyp^nRlae6o)qLb3-w@7tkeRpbv{BDJRvQaTLI=AyAvIAz+SZDhXXa1VsQ?(lEWnDC$e+#iTyv0uW*_;)+qo~& z?^mzyZxWE7cJ#n%&JqUKWc5PxvNv$JSLC$^iH1p$-7Ue|hGnbj0pB&73m4cL?ZzU# z*I0+eobJqT=`I;P4&dvPl7GDxV{l5AU(|A^<&}uNQPHI{!l2C{(I&nc-*>>*a~fx# Idvx-@0O|q@a{vGU literal 0 HcmV?d00001 diff --git a/elepower_wireless/textures/elewireless_wireless_porter.png b/elepower_wireless/textures/elewireless_wireless_porter.png new file mode 100644 index 0000000000000000000000000000000000000000..6313248770b735882197ed376c668d0c8f6eab00 GIT binary patch literal 720 zcmV;>0x$iEP)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00KBkL_t(I%dL{lN*hrahMzNM z;y6iQ5G8sxcuWqShEw zZNyA6b50j(?2lcw@8*L8&+{EVUiim|-ye#_;!|MR_xhb)RRL|7>2}Rv1>sz8tp2j_;PQ77M~CZPIe4H6Y2pcm+&EJ?hXZxCC_}SSRLI`Zz#