1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
--[[
boards mod for Minetest. Black boards with text on it.
(c) Pierre-Yves Rollo
This file is part of boards.
boards is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
boards is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with boards. If not, see <http://www.gnu.org/licenses/>.
--]]
boards = {}
boards.name = minetest.get_current_modname()
boards.path = minetest.get_modpath(boards.name)
-- Load support for intllib.
local S, NS = dofile(boards.path.."/intllib.lua")
boards.intllib = S
local F = function(...) return minetest.formspec_escape(S(...)) end
-- Load font
dofile(boards.path.."/font_tinycurs.lua")
local function set_formspec(pos)
local meta = minetest.get_meta(pos)
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;"..F("Text")..";${display_text}]"..
"button_exit[3,3.5;2,1;ok;"..F("Write").."]"..
"button_exit[1,3.5;2,1;wipe;"..F("Wipe").."]")
end
-- On boards, everyone is allowed to write and wipe
local function on_receive_fields(pos, formname, fields, player)
if fields then
if fields.ok or fields.key_enter then
signs_api.set_display_text(pos, fields.display_text, fields.font)
end
if fields.wipe then
signs_api.set_display_text(pos, "", fields.font)
end
end
end
models = {
black_board = {
depth = 1/16, width = 1, height = 1,
entity_fields = {
top = -1/32,
size = { x = 1, y = 15/16 },
maxlines = 5,
color = "#fff",
font_name = "tinycurs",
valign = "top",
},
node_fields = {
description = S("Black board"),
tiles = { "default_wood.png", "default_wood.png",
"default_wood.png", "default_wood.png",
"default_wood.png", "board_black_front.png" },
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, 7/16, 0.5, 0.5, 0.5},
{-0.5, -7/16, 6/16, 0.5, -0.5, 7/16}
},
},
on_construct = function(pos)
set_formspec(pos)
display_api.on_construct(pos)
end,
on_receive_fields = on_receive_fields,
},
},
green_board = {
depth = 1/16, width = 1, height = 1,
entity_fields = {
top = -1/32,
size = { x = 1, y = 15/16 },
maxlines = 5,
color = "#fff",
font_name = "tinycurs",
valign = "top",
},
node_fields = {
description = S("Green board"),
tiles = { "default_wood.png", "default_wood.png",
"default_wood.png", "default_wood.png",
"default_wood.png", "board_green_front.png" },
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, 7/16, 0.5, 0.5, 0.5},
{-0.5, -7/16, 6/16, 0.5, -0.5, 7/16}
},
},
on_construct = function(pos)
set_formspec(pos)
display_api.on_construct(pos)
end,
on_receive_fields = on_receive_fields,
},
},
}
-- Node registration
for name, model in pairs(models)
do
signs_api.register_sign("boards", name, model)
end
-- Recipes
minetest.register_craft(
{
output = "boards:black_board",
recipe = {
{"group:wood", "group:stone", "dye:black"},
}
})
minetest.register_craft(
{
output = "boards:green_board",
recipe = {
{"group:wood", "group:stone", "dye:dark_green"},
}
})
|