mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-16 13:48:06 +02:00
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
|
||||
|
||||
|
||||
-- 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)
|
||||
yl_speak_up.get_quest_variables = function(pname, has_write_access)
|
||||
if(not(pname)) then
|
||||
return {}
|
||||
end
|
||||
local liste = {}
|
||||
-- first: list the variables owned by the player
|
||||
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
|
||||
-- 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
|
||||
table.sort(liste)
|
||||
return liste
|
||||
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?
|
||||
yl_speak_up.get_quest_variables_with_write_access = function(pname)
|
||||
if(not(pname)) then
|
||||
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
|
||||
return yl_speak_up.get_quest_variables(pname, true)
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user