-
Notifications
You must be signed in to change notification settings - Fork 7
/
form.missionblock_main.lua
83 lines (59 loc) · 1.73 KB
/
form.missionblock_main.lua
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
local FORMNAME = "mission_block_main"
missions.form.missionblock_main = function(pos, node, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
-- check for migration
missions.migrate_mission_block(pos, meta)
local has_override = minetest.check_player_privs(player, "protection_bypass")
-- check if plain user rightclicks
if player:get_player_name() ~= owner and not has_override then
missions.form.missionblock_user(pos, node, player)
return
end
local formspec = "size[8,8;]" ..
--left
"label[0,0;Mission block]" ..
"button[0,1;8,1;configure;Configure]" ..
"button[0,2;8,1;stepeditor;Step editor]" ..
"button[0,3;8,1;user;User view]" ..
"button[0,4;8,1;stats;Statistics]" ..
"button[0,5;8,1;help;Help]" ..
"button_exit[0,7;8,1;exit;Exit]" ..
missions.FORMBG
minetest.show_formspec(player:get_player_name(),
FORMNAME .. ";" .. minetest.pos_to_string(pos),
formspec
)
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
local parts = formname:split(";")
local name = parts[1]
if name ~= FORMNAME then
return
end
local pos = minetest.string_to_pos(parts[2])
local node = minetest.get_node(pos)
if not missions.check_owner(pos, player) then
return
end
if fields.stepeditor then
missions.form.missionblock_stepeditor(pos, node, player)
return true
end
if fields.user then
missions.form.missionblock_user(pos, node, player)
return true
end
if fields.stats then
missions.form.missionblock_stats(pos, node, player)
return true
end
if fields.configure then
missions.form.missionblock_config(pos, node, player)
return true
end
if fields.help then
missions.form.missionblock_help(pos, node, player)
return true
end
end)