/usr/share/games/minetest/mods/mobf/mobf_settings/tab_path_manager.lua is in minetest-mod-mobf-core 2.5.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | --------------------------------------------------------------------------------
-- Mob Framework Settings Mod by Sapier
--
-- You may copy, use, modify or do nearly anything except removing this
-- copyright notice.
-- And of course you are NOT allowed to pretend you have written it.
--
--! @file tab_restore_mobs.lua
--! @brief settings gui for mobf
--! @copyright Sapier
--! @author Sapier
--! @date 2014-05-30
--
-- Contact sapier a t gmx net
--------------------------------------------------------------------------------
local function get_formspec(tabview, name, tabdata)
if tabdata.selected_entry == nil then
tabdata.selected_entry = 0
end
if tabdata.selected_point_entry == nil then
tabdata.selected_point_entry = 0
end
local retval = "button[0.25,0.0;6,0.5;btn_give_pathmarker; Give pathmarker tool]" ..
"label[0.25,0.5;Pathname]" ..
"label[4,0.5;Owner]"
local content = ""
local all_paths = mobf_path.get_pathlist(tabdata.playername,tabdata.is_admin)
if all_paths ~= nil then
for i=1,#all_paths,1 do
content = content .. all_paths[i].pathname .. ",(" ..
all_paths[i].ownername .. ")"
if i ~= #all_paths then
content = content .. ","
end
end
end
retval = retval ..
"tablecolumns[text,width=16;text]" ..
"table[0.25,1;6,8;tbl_pathlist;" .. content .. ";"
.. tabdata.selected_entry .. "]"
if tabdata.selected_entry ~= 0 then
local selected_path = all_paths[tabdata.selected_entry]
if selected_path == nil then
return retval
end
local path_data = mobf_rtd.path_data.users
[selected_path.ownername].paths[selected_path.pathname]
if path_data == nil then
return retval
end
local point_content = ""
local first = true
for i,v in ipairs(path_data.points) do
if not first then
point_content = point_content ..","
else
first = false
end
point_content = point_content ..
i .. ":," ..
v.x .. "," ..
v.y .. "," ..
v.z
end
retval = retval ..
"tablecolumns[text,width=5,align=right;"..
"text,align=right;" ..
"text,align=right;" ..
"text,align=right]" ..
"table[6.5,0;5.25,8;tbl_path_points;" .. point_content .. ";"
.. tabdata.selected_point_entry .. "]"
if path_data.locked then
retval = retval ..
"button[6.5,8.5;1.5,0.5;btn_unlock_path;unlock]"
else
retval = retval ..
"button[6.5,8.5;1.5,0.5;btn_lock_path;lock]"
end
retval = retval ..
"button[8,8.5;2,0.5;btn_show_points;show points]" ..
"button[10,8.5;2,0.5;btn_delete_path;delete path]"
end
return retval
end
local function handle_settings_buttons(self, fields, tabname, tabdata)
if fields["btn_give_pathmarker"] then
local player = core.get_player_by_name(tabdata.playername)
if not player then
return true
end
player:get_inventory():add_item("main", "mobf:path_marker 1")
return true
end
if fields["tbl_pathlist"] then
local event = core.explode_table_event(fields["tbl_pathlist"])
if event.type == "CHG" then
tabdata.selected_entry = event.row
end
return true;
end
if fields["btn_lock_path"] or fields["btn_unlock_path"] then
local all_paths = mobf_path.get_pathlist(tabdata.playername,tabdata.is_admin)
local selected_path = all_paths[tabdata.selected_entry]
if selected_path == nil then
return true
end
local path_data = mobf_rtd.path_data.users
[selected_path.ownername].paths[selected_path.pathname]
if path_data == nil then
return true
end
if fields["btn_unlock_path"] then
path_data.locked = false
else
path_data.locked = true
end
mobf_path.save()
return true
end
if fields["btn_show_points"] then
local all_paths = mobf_path.get_pathlist(tabdata.playername,tabdata.is_admin)
local selected_path = all_paths[tabdata.selected_entry]
if selected_path == nil then
return true
end
mobf_path.show_pathmarkers(selected_path.ownername,selected_path.pathname)
return true
end
if fields["btn_delete_path"] then
local all_paths = mobf_path.get_pathlist(tabdata.playername,tabdata.is_admin)
local selected_path = all_paths[tabdata.selected_entry]
if selected_path == nil then
return true
end
--TODO add confirmation dialog
mobf_path.delete_path(selected_path.ownername,selected_path.pathname)
return true
end
return false
end
mobf_settings_tab_paths = {
name = "paths",
caption = fgettext("Paths"),
cbf_formspec = get_formspec,
cbf_button_handler = handle_settings_buttons,
tabsize = {width=12,height=9}
}
|