From a38debb5924a7febcbe33617afbfda4722c0611e Mon Sep 17 00:00:00 2001 From: cheapie Date: Sun, 21 Feb 2021 18:46:55 -0600 Subject: [PATCH] Add advanced touchscreen Basically just lets you provide any formspec you want, which should resolve all of the "but the touchscreen can't do XYZ" issues :) I don't believe this to be a security problem as arbitrary formspecs should do nothing unless you actually right-click the node (and you can always just... not), and if the client does crash in response to a bad formspec then this is probably a client bug anyway. --- textures/digistuff_advts_front.png | Bin 0 -> 9900 bytes touchscreen.lua | 62 ++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 textures/digistuff_advts_front.png diff --git a/textures/digistuff_advts_front.png b/textures/digistuff_advts_front.png new file mode 100644 index 0000000000000000000000000000000000000000..89dc343dd5c546d27520db8f032f7f62f6f540f6 GIT binary patch literal 9900 zcmeHrcUaR)w{GaY3aE$>f`EXbw?wLRrAY??2}yv^5|YqCI!H%42m*ps5ouDSgA`GS z(k&F}T|`7IcmlfjcHi^e@7(Ws?)h)?JR!fCdDpwvytCHKZxU^&uf;&iNech~7<9DN zjfmg*#7{6aCGme8-2Myzz=-fOvA`R_ynz@j+5zQ?1mb-$NFdS&+=VGw9>1VgeKC8hNZ$hxt!4Z5c7pkU%eijUtr_WUEdtt7&2a6AD(gw zWr9NQs3O{?>{lbeZ7)T4wc`F?kZGjlM z-}7cbZ54I*`J)p7@H0*J5I1+17gx}>YuWk>ffLp!>8`qku|30m^x@JD$VorCVf>x$ zr7G{>c!cy|QvZOIISaF*K_2VXdh7e>gti~II;=n|8MjYRrWd-ijICF_sbO_2yD{8- z_Hi$MqXb|b?mlc^$4{z77+=p%bkZH=R2Fz=Y|&IbWKx+uK7D&gIKEbvnX4S|_RWdC z=5e1|gRnc~U9au<3I-lAUszUHJz-d#2c>p4tHsNVSzqA`%ywyu z;JD`8l;+-SntN%hpzn^~7IH;Zm_hCvHD7}Chw~{Wx4oKI9WyzNGERmIxL-Uu^xQurX`7Ux?1_s!RVJk^=9~hVYaA+IaH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<+^1X%4r|8MR@hU;@ui60e?snueP*+-tlZJn~kVy%Y z?(Nv+izTZ$o|r`c7!0cbRAshGW?nbJ@R4&a$oXCGeI*{Q;#3+k5Ly7Cnu}f~oFPrj z$xomy;3JPr$T@L|lT>lxl{mRdqvGMBQ+Nvh(}EI;%(E{X$(cmLi>Xh+Z+)2QB+g0* za#LMP`Xe^nf}fMK){d$*m@vVp&~<@8r)2WE0PgbKuuu#c237pv59kboV;i1D|YEkQR@8qy2zc7+pI}kOe^T1 zK)QhsD;ZaP_MWOUOeFGOtL(cVbcuW0%-L%{JR+xE&$u5LZFR*L`b1BI#&bCYj_O&`3n zn-QpMvAXfW*3<2i%j^Bu!_$HF33-ov&%PcB?2eR^DfF)Lb?$}-%~ihls9(yRk@IJK zvh>iRs}{7klsx1G>Z(vN%@z(;OV9&doq58Xr$tlw>N(Qv@@J4c!_MXw^>*%Zb&>qw z(xQ%-M;fMFx6K;y+GRq(ccW}L_I<03iEX4!U1QqJm9CLA2@Z-$z04csv0hwavOAkG z_yvu3SEvaJhBV#i2e;+|%&kw8?tC8lfwy@=h&B!wLBj27;jtL*lNi^NuZjhPKFWo6 Xaylp~E8HZWRsbChef0;I>_YzwV0^l? literal 0 HcmV?d00001 diff --git a/touchscreen.lua b/touchscreen.lua index e3255f2..d288996 100644 --- a/touchscreen.lua +++ b/touchscreen.lua @@ -8,6 +8,8 @@ digistuff.update_ts_formspec = function (pos) if meta:get_int("init") == 0 then fs = fs.."field[3.75,3;3,1;channel;Channel;]".. "button_exit[4,3.75;2,1;save;Save]" + elseif minetest.get_node(pos).name == "digistuff:advtouchscreen" then + fs = fs.."label[0,0;No data received yet]" else local data = minetest.deserialize(meta:get_string("data")) or {} for _,field in pairs(data) do @@ -252,19 +254,23 @@ digistuff.ts_on_digiline_receive = function (pos, node, channel, msg) local meta = minetest.get_meta(pos) local setchan = meta:get_string("channel") if channel ~= setchan then return end - if type(msg) ~= "table" then return end - local data = minetest.deserialize(meta:get_string("data")) or {} - if msg.command then - data = digistuff.process_command(meta,data,msg) + if node.name == "digistuff:advtouchscreen" then + if type(msg) == "string" then meta:set_string("formspec",msg) end else - for _,i in ipairs(msg) do - if type(i) == "table" and i.command then - data = digistuff.process_command(meta,data,i) or data + if type(msg) ~= "table" then return end + local data = minetest.deserialize(meta:get_string("data")) or {} + if msg.command then + data = digistuff.process_command(meta,data,msg) + else + for _,i in ipairs(msg) do + if type(i) == "table" and i.command then + data = digistuff.process_command(meta,data,i) or data + end end end + meta:set_string("data",minetest.serialize(data)) + digistuff.update_ts_formspec(pos) end - meta:set_string("data",minetest.serialize(data)) - digistuff.update_ts_formspec(pos) end minetest.register_node("digistuff:touchscreen", { @@ -305,6 +311,44 @@ minetest.register_node("digistuff:touchscreen", { }, }) +minetest.register_node("digistuff:advtouchscreen", { + description = "Advanced Digilines Touchscreen", + groups = {cracky=3}, + on_construct = function(pos) + digistuff.update_ts_formspec(pos,true) + end, + drawtype = "nodebox", + tiles = { + "digistuff_panel_back.png", + "digistuff_panel_back.png", + "digistuff_panel_back.png", + "digistuff_panel_back.png", + "digistuff_panel_back.png", + "digistuff_advts_front.png" + }, + paramtype = "light", + paramtype2 = "facedir", + node_box = { + type = "fixed", + fixed = { + { -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 } + } + }, + _digistuff_channelcopier_fieldname = "channel", + _digistuff_channelcopier_onset = function(pos) + minetest.get_meta(pos):set_int("init",1) + digistuff.update_ts_formspec(pos) + end, + on_receive_fields = digistuff.ts_on_receive_fields, + digiline = + { + receptor = {}, + effector = { + action = digistuff.ts_on_digiline_receive + }, + }, +}) + minetest.register_craft({ output = "digistuff:touchscreen", recipe = {