combined list of read and write acces in quest api
This commit is contained in:
parent
1a9f53fba2
commit
14e0902cf1
@ -111,40 +111,45 @@ yl_speak_up.get_quest_variable_value = function(player_name, variable_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- which variables can player pname read and use in preconditions?
|
yl_speak_up.get_quest_variables = function(pname, has_write_access)
|
||||||
-- returns a sorted list
|
|
||||||
yl_speak_up.get_quest_variables_with_read_access = function(pname)
|
|
||||||
if(not(pname)) then
|
if(not(pname)) then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
local liste = {}
|
local liste = {}
|
||||||
|
-- first: list the variables owned by the player
|
||||||
for k, v in pairs(yl_speak_up.player_vars) do
|
for k, v in pairs(yl_speak_up.player_vars) do
|
||||||
local parts = string.split(k, " ")
|
local parts = string.split(k, " ")
|
||||||
if(parts and parts[1] and parts[1] == "$" and parts[2] and parts[2] == pname) then
|
if(parts and parts[1] and parts[1] == "$" and parts[2] and parts[2] == pname) then
|
||||||
table.insert(liste, k)
|
table.insert(liste, k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- if the player has the right privs: allow to access all other variables as well
|
||||||
|
if( minetest.check_player_privs(pname, {npc_master=true})
|
||||||
|
or minetest.check_player_privs(pname, {npc_talk_master=true})) then
|
||||||
|
for k, v in pairs(yl_speak_up.player_vars) do
|
||||||
|
local parts = string.split(k, " ")
|
||||||
|
-- variables owned by *other* players
|
||||||
|
if(parts and parts[1] and parts[1] == "$" and parts[2] and parts[2] ~= pname) then
|
||||||
|
table.insert(liste, k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
-- TODO: insert those vars owned by other players where this one has read access to
|
-- TODO: insert those vars owned by other players where this one has read access to
|
||||||
table.sort(liste)
|
table.sort(liste)
|
||||||
return liste
|
return liste
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- which variables can player pname read and use in preconditions?
|
||||||
|
-- returns a sorted list
|
||||||
|
yl_speak_up.get_quest_variables_with_read_access = function(pname)
|
||||||
|
return yl_speak_up.get_quest_variables(pname, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- which variables can player pname write and use in effects/results?
|
-- which variables can player pname write and use in effects/results?
|
||||||
yl_speak_up.get_quest_variables_with_write_access = function(pname)
|
yl_speak_up.get_quest_variables_with_write_access = function(pname)
|
||||||
if(not(pname)) then
|
return yl_speak_up.get_quest_variables(pname, true)
|
||||||
return {}
|
|
||||||
end
|
|
||||||
local liste = {}
|
|
||||||
for k, v in pairs(yl_speak_up.player_vars) do
|
|
||||||
local parts = string.split(k, " ")
|
|
||||||
if(parts and parts[1] and parts[1] == "$" and parts[2] and parts[2] == pname) then
|
|
||||||
table.insert(liste, k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- TODO: insert those vars owned by other players where this one has write access to
|
|
||||||
table.sort(liste)
|
|
||||||
return liste
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user