Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jul 10, 2020
0 parents commit 8558104
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -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 changes: 95 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions mod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = freetouch
depends = digilines
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Freely editable formspec node

# License

## Code

MIT

## Textures

CC BY-SA 3.0
* `textures/*` https://cheapiesystems.com/git/digistuff
Binary file added textures/freetouch_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/freetouch_front.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8558104

Please sign in to comment.