1
0
mirror of https://github.com/pyrollo/display_modpack.git synced 2025-10-15 00:35:20 +02:00

Escape formspec content of boards and steles

This commit is contained in:
Niklp09
2023-07-27 17:31:41 +02:00
parent 1f8e99c9c5
commit bd59f7f78b
2 changed files with 23 additions and 10 deletions

View File

@@ -31,9 +31,10 @@ dofile(boards.path.."/font_tinycurs.lua")
local function set_formspec(pos)
local meta = minetest.get_meta(pos)
local display_text = minetest.formspec_escape(meta:get_string("display_text"))
meta:set_string("formspec",
"size[6,4]"..default.gui_bg..default.gui_bg_img..default.gui_slots..
"textarea[0.5,0.7;5.5,3;display_text;"..FS("Text")..";${display_text}]"..
"textarea[0.5,0.7;5.5,3;display_text;"..FS("Text")..";" .. display_text .. "]"..
"button_exit[3,3.5;2,1;ok;"..FS("Write").."]"..
"button_exit[1,3.5;2,1;wipe;"..FS("Wipe").."]")
end
@@ -83,6 +84,9 @@ local models = {
set_formspec(pos)
display_api.update_entities(pos)
end,
on_rightclick = function(pos)
set_formspec(pos)
end,
on_receive_fields = on_receive_fields,
},
},

View File

@@ -32,6 +32,20 @@ for i, material in ipairs(steles.materials) do
local parts = material:split(":")
groups.display_api = 1
local function set_formspec(pos)
local meta = minetest.get_meta(pos)
local display_text = minetest.formspec_escape(meta:get_string("display_text"))
meta:set_string("formspec", string.format([=[
size[6,4]%s%s%s
textarea[0.5,0.7;5.5,2;display_text;%s;%s]
button[1,3;2,1;font;%s]
button_exit[3,3;2,1;ok;%s]]=],
default.gui_bg, default.gui_bg_img, default.gui_slots,
FS("Displayed text (3 lines max)"),
display_text,
FS("Font"), FS("Write")))
end
minetest.register_node("steles:"..parts[2].."_stele", {
description = steles.materials_desc[i],
sunlight_propagates = true,
@@ -62,17 +76,12 @@ for i, material in ipairs(steles.materials) do
return display_api.on_place(itemstack, placer, pointed_thing)
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", string.format([=[
size[6,4]%s%s%s
textarea[0.5,0.7;5.5,2;display_text;%s;${display_text}]
button[1,3;2,1;font;%s]
button_exit[3,3;2,1;ok;%s]]=],
default.gui_bg, default.gui_bg_img, default.gui_slots,
FS("Displayed text (3 lines max)"),
FS("Font"), FS("Write")))
set_formspec(pos)
display_api.on_construct(pos)
end,
on_rightclick = function(pos)
set_formspec(pos)
end,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
on_receive_fields = function(pos, formname, fields, player)