summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-09-18 18:51:43 -0500
committercheapie <no-email-for-you@example.com>2024-09-18 18:51:43 -0500
commit06ffda5514d7d65140f3a32a28397ef60478f2fc (patch)
tree6c97fbd9da9cc604af1254efe0a09ad75e7d3165 /init.lua
downloadadvtouchscreen-main.tar
advtouchscreen-main.tar.gz
advtouchscreen-main.tar.bz2
advtouchscreen-main.tar.xz
advtouchscreen-main.zip
Add initial contentHEADmain
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua89
1 files changed, 89 insertions, 0 deletions
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..850732b
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,89 @@
+minetest.register_node("advtouchscreen:advtouchscreen", {
+ description = "Advanced Digilines Touchscreen",
+ groups = {
+ cracky=3
+ },
+ on_construct = function(pos)
+ minetest.get_meta(pos):set_string("formspec","field[channel;Channel;]")
+ end,
+ drawtype = "nodebox",
+ tiles = {
+ "advtouchscreen_sides.png",
+ "advtouchscreen_sides.png",
+ "advtouchscreen_sides.png",
+ "advtouchscreen_sides.png",
+ "advtouchscreen_sides.png",
+ "advtouchscreen_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)
+ local meta = minetest.get_meta(pos)
+ meta:set_int("init",1)
+ meta:set_string("formspec","")
+ end,
+ on_receive_fields = function(pos,_,fields,player)
+ local meta = minetest.get_meta(pos)
+ local name = player:get_player_name()
+ local protected = minetest.is_protected(pos,name) and not minetest.check_player_privs(name,"protection_bypass")
+ if meta:get_int("init") == 0 then
+ if fields.channel and fields.channel ~= "" then
+ if protected then
+ minetest.record_protection_violation(pos,name)
+ minetest.chat_send_player(name,"You don't have access to set the channel on this screen.")
+ return
+ end
+ meta:set_string("channel",fields.channel)
+ meta:set_int("init",1)
+ meta:set_string("formspec","")
+ end
+ else
+ local locked = meta:get_int("locked") > 0
+ if locked and protected and not fields.quit then
+ minetest.record_protection_violation(pos,name)
+ minetest.chat_send_player(name,"This screen is locked.")
+ return
+ end
+ fields.clicker = name
+ digilines.receptor_send(pos,digilines.rules.default,meta:get_string("channel"),fields)
+ end
+ end,
+ digiline = {
+ receptor = {},
+ effector = {
+ action = function(pos,_,channel,msg)
+ local meta = minetest.get_meta(pos)
+ if meta:get_string("channel") ~= channel or type(msg) ~= "string" then return end
+ local lockcommands
+ local unlockcommands
+ --string.gsub() returns two values, the second one is how many times the replacement happened
+ msg,lockcommands = string.gsub(msg,"lock%[1]","")
+ msg,unlockcommands = string.gsub(msg,"lock%[0]","")
+ if lockcommands > 0 then
+ meta:set_int("locked",1)
+ elseif unlockcommands > 0 then
+ meta:set_int("locked",0)
+ end
+ meta:set_string("formspec",msg)
+ end,
+ },
+ },
+})
+
+minetest.register_alias_force("digistuff:advtouchscreen","advtouchscreen:advtouchscreen")
+
+minetest.register_craft({
+ output = "advtouchscreen:advtouchscreen",
+ type = "shapeless",
+ recipe = {
+ "digistuff:touchscreen",
+ "default:mese_crystal",
+ },
+})