forked from Mirrorlandia_minetest/digistuff
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.
This commit is contained in:
parent
b16d25c828
commit
a38debb592
BIN
textures/digistuff_advts_front.png
Normal file
BIN
textures/digistuff_advts_front.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
@ -8,6 +8,8 @@ digistuff.update_ts_formspec = function (pos)
|
|||||||
if meta:get_int("init") == 0 then
|
if meta:get_int("init") == 0 then
|
||||||
fs = fs.."field[3.75,3;3,1;channel;Channel;]"..
|
fs = fs.."field[3.75,3;3,1;channel;Channel;]"..
|
||||||
"button_exit[4,3.75;2,1;save;Save]"
|
"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
|
else
|
||||||
local data = minetest.deserialize(meta:get_string("data")) or {}
|
local data = minetest.deserialize(meta:get_string("data")) or {}
|
||||||
for _,field in pairs(data) do
|
for _,field in pairs(data) do
|
||||||
@ -252,6 +254,9 @@ digistuff.ts_on_digiline_receive = function (pos, node, channel, msg)
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local setchan = meta:get_string("channel")
|
local setchan = meta:get_string("channel")
|
||||||
if channel ~= setchan then return end
|
if channel ~= setchan then return end
|
||||||
|
if node.name == "digistuff:advtouchscreen" then
|
||||||
|
if type(msg) == "string" then meta:set_string("formspec",msg) end
|
||||||
|
else
|
||||||
if type(msg) ~= "table" then return end
|
if type(msg) ~= "table" then return end
|
||||||
local data = minetest.deserialize(meta:get_string("data")) or {}
|
local data = minetest.deserialize(meta:get_string("data")) or {}
|
||||||
if msg.command then
|
if msg.command then
|
||||||
@ -265,6 +270,7 @@ digistuff.ts_on_digiline_receive = function (pos, node, channel, msg)
|
|||||||
end
|
end
|
||||||
meta:set_string("data",minetest.serialize(data))
|
meta:set_string("data",minetest.serialize(data))
|
||||||
digistuff.update_ts_formspec(pos)
|
digistuff.update_ts_formspec(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("digistuff:touchscreen", {
|
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({
|
minetest.register_craft({
|
||||||
output = "digistuff:touchscreen",
|
output = "digistuff:touchscreen",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
Loading…
Reference in New Issue
Block a user