A bunch of module bugfixes
This commit is contained in:
@ -15,31 +15,30 @@ priv_to_org.config = {
|
||||
}
|
||||
|
||||
--- (Required): initiate function
|
||||
-- Modules have access to the following instance variables:
|
||||
-- <li><code>self.org</code> (the org the module was called in),</li>
|
||||
-- <li><code>self.initiator</code> (the user that callced the module),</li>
|
||||
-- <li><code>self.id</code> (the process id of the module instance)</li>
|
||||
-- @param config (optional) If user wants to override fields in the config table
|
||||
-- @param result (optional) Callback if this module is embedded in other modules
|
||||
-- @function initiate
|
||||
function priv_to_org:initiate(config, result)
|
||||
function priv_to_org:initiate(result)
|
||||
local player_privs = minetest.get_player_privs(self.initiator)
|
||||
for i,v in ipairs(player_privs) do
|
||||
if not v then table.remove(player_privs,i) end
|
||||
-- construct table for display
|
||||
local player_privs_table = {"View..."}
|
||||
for k,v in pairs(player_privs) do
|
||||
if player_privs[k] then
|
||||
table.insert(player_privs_table,k)
|
||||
end
|
||||
end
|
||||
modpol.interactions.dropdown_query(
|
||||
self.initiator,
|
||||
"Which privilege do you want to share with members of "..self.org.name.."?",
|
||||
player_privs,
|
||||
player_privs_table,
|
||||
function(input)
|
||||
for member in self.org.members do
|
||||
local member_privs = minetest.get_player_privs(member.name)
|
||||
for i,member in ipairs(self.org.members) do
|
||||
local member_privs = minetest.get_player_privs(member)
|
||||
member_privs[input] = true
|
||||
minetest.set_player_privs(member.name, member_privs)
|
||||
minetest.set_player_privs(member, member_privs)
|
||||
end
|
||||
local message = self.initiator .. " has set " .. input ..
|
||||
local message = self.initiator .. " added " .. input ..
|
||||
" privilege to all members of " .. self.org.name
|
||||
modpol.interactions.message_org(self.initiator,self.org.id, message)
|
||||
modpol.interactions.message_org(self.initiator, self.org.id, message)
|
||||
end)
|
||||
-- call result function
|
||||
if result then result() end
|
||||
|
Reference in New Issue
Block a user