-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.lua
More file actions
34 lines (34 loc) · 1.32 KB
/
gui.lua
File metadata and controls
34 lines (34 loc) · 1.32 KB
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
--make inventory tab
sfinv.register_page("automod:gui", {
title = "AutoMod",
--only people with kick privs can see it
is_in_nav = function(self, player, context)
local pname = player:get_player_name()
local has_privs = minetest.check_player_privs(pname, {kick=true})
return has_privs
end,
get = function(self, player, context)
local file = io.open(minetest.get_worldpath() .. "/AUTOMOD_LOGS_TEMP.txt")
local content = ""
if file then
content = file:read("*all")
file:close()
end
local gui_elements = "textarea[0.3,0;8,10;fieldlogs;;" .. content .. "]" ..
"button[0,8.5;4,1;refresh;Refresh]" ..
"button[4,8.5;4,1;clear_field;Clear]"
return sfinv.make_formspec(player, context, gui_elements, false)
end,
on_player_receive_fields = function(self, player, context, fields)
if fields.refresh then
sfinv.set_player_inventory_formspec(player)
elseif fields.clear_field then
local file = io.open(minetest.get_worldpath() .. "/AUTOMOD_LOGS_TEMP.txt", "w")
if file then
file:write("")
file:close()
sfinv.set_player_inventory_formspec(player)
end
end
end
})