initial commit

master
BuckarooBanzay 2020-07-10 10:50:45 +02:00
commit 8558104ab6
7 changed files with 146 additions and 0 deletions

17
.github/workflows/luacheck.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: luacheck
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: apt
run: sudo apt-get install -y luarocks
- name: luacheck install
run: luarocks install --local luacheck
- name: luacheck run
run: $HOME/.luarocks/bin/luacheck ./

19
.luacheckrc Normal file
View File

@ -0,0 +1,19 @@
globals = {
"freetouch"
}
read_globals = {
-- Stdlib
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Minetest
"vector", "ItemStack",
"dump", "VoxelArea",
-- deps
"mesecon",
"digilines",
"minetest"
}

95
init.lua Normal file
View File

@ -0,0 +1,95 @@
local FORMSPEC_NAME = "freetouch_edit"
minetest.register_node("freetouch:freetouch", {
description = "Formspec touch node",
groups = {cracky=3},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("channel", "freetouch")
meta:set_string("formspec", "size[10,8]")
end,
drawtype = "nodebox",
tiles = {
"freetouch_back.png",
"freetouch_back.png",
"freetouch_back.png",
"freetouch_back.png",
"freetouch_back.png",
"freetouch_front.png"
},
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{ -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
}
},
on_punch = function(pos, _, player)
local meta = minetest.get_meta(pos)
local fs = meta:get_string("formspec")
local playername = player:get_player_name()
local has_freetouch_priv = minetest.check_player_privs(playername, "freetouch")
if minetest.is_protected(pos, playername) or not has_freetouch_priv then
return
end
local formspec = "size[12,10;]" ..
"textarea[0.2,0;12,10;fs;Formspec;" .. minetest.formspec_escape(fs) .. "]" ..
"button_exit[0,9;6,1;remove;Remove]" ..
"button_exit[6,9;6,1;save;Save]" ..
""
minetest.show_formspec(playername,
FORMSPEC_NAME .. ";" .. minetest.pos_to_string(pos),
formspec
)
end,
on_receive_fields = function(pos, _, fields, sender)
local meta = minetest.get_meta(pos)
local channel = meta:get_string("channel")
print(channel)
digilines.receptor_send(pos, digilines.rules.default, channel, {
fields = fields,
pos = pos,
playername = sender:get_player_name()
})
end,
digiline = {
receptor = {}
},
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
local parts = formname:split(";")
local name = parts[1]
if name ~= FORMSPEC_NAME then
return
end
local pos = minetest.string_to_pos(parts[2])
local playername = player:get_player_name()
local has_freetouch_priv = minetest.check_player_privs(playername, "freetouch")
if minetest.is_protected(pos, playername) or not has_freetouch_priv then
return
end
if fields.save then
local meta = minetest.get_meta(pos)
meta:set_string("formspec", fields.fs)
end
if fields.remove then
minetest.set_node(pos, { name = "air" })
end
end)
minetest.register_privilege("freetouch", {
description = "can edit freetouch formspecs",
give_to_singleplayer = true
})

2
mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = freetouch
depends = digilines

13
readme.md Normal file
View File

@ -0,0 +1,13 @@
Freely editable formspec node
# License
## Code
MIT
## Textures
CC BY-SA 3.0
* `textures/*` https://cheapiesystems.com/git/digistuff

BIN
textures/freetouch_back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB