From a94e5259b04726e3f3a4763552e029147cf2ea85 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 1 Jun 2021 12:58:13 +0200 Subject: [PATCH] init --- init.lua | 121 ++++++++++++++++++ locale/mesecons_onlinedetector.fr.tr | 5 + locale/template.txt | 5 + mod.conf | 4 + ...ons_onlinedetector_online_detector_off.png | Bin 0 -> 5786 bytes ...cons_onlinedetector_online_detector_on.png | Bin 0 -> 5815 bytes 6 files changed, 135 insertions(+) create mode 100644 init.lua create mode 100644 locale/mesecons_onlinedetector.fr.tr create mode 100644 locale/template.txt create mode 100644 mod.conf create mode 100644 textures/mesecons_onlinedetector_online_detector_off.png create mode 100644 textures/mesecons_onlinedetector_online_detector_on.png diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..168f698 --- /dev/null +++ b/init.lua @@ -0,0 +1,121 @@ +minetest.log("action", "[mesecons_onlinedetector] loading...") + +local S = minetest.get_translator(minetest.get_current_modname()) +local F = minetest.formspec_escape + +local table = table + +local function get_detector_form(default) + return table.concat({ + "formspec_version[4]", + "size[8,3]", + "field[0.25,0.75;7.5,0.75;name;"..F(S("Online Detector"))..";"..default.."]", + "label[0.25,2.25;"..F(S("Detecting:")).." "..default.."]" + }) +end + +local playerlist = {} + +minetest.register_on_joinplayer(function(player) + playerlist[player:get_player_name()] = true +end) + +minetest.register_on_leaveplayer(function(player) + playerlist[player:get_player_name()] = nil +end) + +local function update_detector_on(pos, target) + if not playerlist[target] then + minetest.swap_node(pos, { name = "mesecons_onlinedetector:online_detector_off" }) + mesecon.receptor_off(pos, mesecon.rules.alldirs) + end +end + +local function update_detector_off(pos, target) + if playerlist[target] then + minetest.swap_node(pos, { name = "mesecons_onlinedetector:online_detector_on" }) + mesecon.receptor_on(pos, mesecon.rules.alldirs) + end +end + +minetest.register_node("mesecons_onlinedetector:online_detector_off", { + description = S("Online Detector"), + _doc_items_longdesc = S("Allows you to know if a player is connected."), + tiles = {"mesecons_onlinedetector_online_detector_off.png"}, + groups = {cracky = 2, mesecon_detector_off = 1, mesecon = 2}, + mesecons = { + receptor = { + state = mesecon.state.off, + rules = mesecon.rules.alldirs, + }, + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", get_detector_form(meta:get_string("name"))) + end, + on_receive_fields = function(pos, formname, fields, sender) + if fields.name then + local meta = minetest.get_meta(pos) + meta:set_string("name", fields.name) + meta:set_string("formspec", get_detector_form(fields.name)) + update_detector_off(pos, fields.name) + end + end, +}) + +minetest.register_node("mesecons_onlinedetector:online_detector_on", { + description = S("Online Detector"), + _doc_items_longdesc = S("Allows you to know if a player is connected."), + tiles = {"mesecons_onlinedetector_online_detector_on.png"}, + groups = {cracky = 2, mesecon_detector_on = 1, mesecon = 2, not_in_creative_inventory = 1}, + drop = "mesecons_onlinedetector:online_detector_off", + mesecons = { + receptor = { + state = mesecon.state.on, + rules = mesecon.rules.alldirs, + }, + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", get_detector_form(meta:get_string("name"))) + end, + on_receive_fields = function(pos, formname, fields, sender) + if fields.name then + local meta = minetest.get_meta(pos) + meta:set_string("name", fields.name) + meta:set_string("formspec", get_detector_form(fields.name)) + update_detector_on(pos, fields.name) + end + end, +}) + +minetest.register_abm({ + label = "mesecons_onlinedetector:online_detector_off", + nodenames = {"mesecons_onlinedetector:online_detector_off"}, + interval = 30, + chance = 1, + action = function(pos) + update_detector_off(pos, minetest.get_meta(pos):get_string("name")) + end, +}) + +minetest.register_abm({ + label = "mesecons_onlinedetector:online_detector_on", + nodenames = {"mesecons_onlinedetector:online_detector_on"}, + interval = 30, + chance = 1, + action = function(pos) + update_detector_on(pos, minetest.get_meta(pos):get_string("name")) + end, +}) + +--[[minetest.register_craft({ + output = "mesecons_onlinedetector:online_detector_off", + recipe = { + {'mcl_dye:black', 'mcl_dye:black', 'mcl_dye:black'}, + {'mcl_dye:black', 'pala_paladium:paladium_ingot', 'mcl_dye:black'}, + {'pala_paladium:titanium_ingot', 'pala_paladium:titanium_ingot', 'pala_paladium:titanium_ingot'}, + } +})]] + +minetest.log("action", "[mesecons_onlinedetector] loaded succesfully") diff --git a/locale/mesecons_onlinedetector.fr.tr b/locale/mesecons_onlinedetector.fr.tr new file mode 100644 index 0000000..f231356 --- /dev/null +++ b/locale/mesecons_onlinedetector.fr.tr @@ -0,0 +1,5 @@ +# textdomain: mesecons_onlinedetector + +Online Detector=Online Detector +Detecting:=Détecte : +Allows you to know if a player is connected.=Vous permet de savoir si un joueur est connecté. diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..be77bb2 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,5 @@ +# textdomain: mesecons_onlinedetector + +Online Detector= +Detecting:= +Allows you to know if a player is connected.= diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..ca72ad4 --- /dev/null +++ b/mod.conf @@ -0,0 +1,4 @@ +name = mesecons_onlinedetector +description = Add online detector to mesecons +depends = mesecons +author = AFCMS diff --git a/textures/mesecons_onlinedetector_online_detector_off.png b/textures/mesecons_onlinedetector_online_detector_off.png new file mode 100644 index 0000000000000000000000000000000000000000..46a1af982c47f5c3841a030dde401d368057280d GIT binary patch literal 5786 zcmeHLdpy(o8(&H;QIw-Y)J!7U)i&E0$K8m~kcxb_eW%4Pw%MkVTk7W;k;);VoDNBm zyVAv_a_XF-3zZ_5E`;Pzy8OP={q;Nl^m_fye{K72`#zuNc|XtdexC2M?`H{~9?t5j zx~ec3Or7T9;0=9h$PeYY(EGCS_W%s0*uIs%PV5ax;Q}F_%?SnJ;s^l<2W1>K3?}O; z_4D7m{P+292DLtup=d>7kA&l{{fqsY9+`#2c+vl|`uCKGfte(rSur}mxi__t{hO%1ZdHE3RbjarhPbUw;|J#rhnvuN~9!r0JpL$pja zWF)}B@}%|x>u0d8d96<_q3p_fw&$HtTYXPWC&hS)zsc1p!;DeMI89YwrG+)LBb(N+ zD>E8)By3IQOQZ39zwR!Ks@+k3Tz`eRTF0WF>nF6ARZn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#}PwRXL)+H#ccFa+;S%cuB{#*?=El;~;Dp;}5gaPOs}yY61C z#m?s|A3kKBdit>Ucu8CdT-o}Ud-rm*0**9^GVGFmUa;|bYt*0bMI*J*je+dqPVC%c z+2E0dVFnoiKgE_kj$L4oT)2i&WNn;Clij*ao$$WjEX$HU$h%qCw|ef>oL>K;CE88vw%&ozg;WlTo5=?6We?N_^;u5kLzE345RP7g8_U-M)B%C@W?AbTu} z#$Pp!n60O$V5oQ{a8f3fPTzYs%(*tAWH~HMZ;K3XhxVp(8E(!FFhlus&?7hqlBft= z{6#Pr%20mHk{z{?Ktd%k&D~L{f9@<*JRzVA<_n2*#E$F4_I$2O!In;HJDOp`zlTw4jyf&l&41pD7geEb6L*wtzh7XXlv{pZT@qQ& zDvtwOZ@Wb!jNs878B3?8oDVrPgbf=}^`@O^J`AQ7nwNYj&VZmBiL_mhBw%n8<(%KSe3SwJFnuePBAflMtg^uQ9b< zbdlRWdd&Qdxsyla8jIBA_`bv-Q_jeZCiNu n-I#TN literal 0 HcmV?d00001 diff --git a/textures/mesecons_onlinedetector_online_detector_on.png b/textures/mesecons_onlinedetector_online_detector_on.png new file mode 100644 index 0000000000000000000000000000000000000000..d42dd31986609e0750b14a29fc08aa00a357d443 GIT binary patch literal 5815 zcmeHLdpJ~U7as~mE>XEwV^EU08e?WM3ga?vNhD5W&&(bMb1^f_pj1K;<(8sy3%Nuo zrwer`MW;@kqEHcuP)SamgB0H$x<23er|0>;|C)JbX7BZ`^;>KG*4k_KyA$2r9F!Gx z6k#x!GR=|d0sX2;Kl9|F@8xf&0T@i~a+K$0kq01#^94K>I~0VABKaU3l(1PanB-BV zx6heA;{_iE776DX62kPBtf6x;&3V_&N)r*=P2Z zIaZOP^{Sh0Dl3mhy?g0o129q8F zyI(q*WvvEeqg1L69WRP|lJN0T9S$?P&{(pCM77gyJ7CjD+3GDAbi|xXwYhfCrgraG zs=C_Fnn&wycQdVoZ+iwco7Z1GgTL6)Kv8e>7s}H0<+%fyZ!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