moved adding npc/locations to quest steps into quest_api
This commit is contained in:
parent
6f8dde7e61
commit
1dd6c587c7
@ -324,17 +324,6 @@ yl_speak_up.input_fs_add_quest_steps = function(player, formname, fields)
|
||||
else
|
||||
return show_error_fs(player, "Failed to update NPC.")
|
||||
end
|
||||
-- make sure quest.npcs or quest.locations contains this entry
|
||||
if(string.sub(n_id, 1, 2) == "n_") then
|
||||
-- only npcs that are not yet added (and we store IDs without n_ prefix)
|
||||
local id = tonumber(string.sub(n_id, 3))
|
||||
if(id and table.indexof(quest.npcs or {}, id) == -1) then
|
||||
table.insert(yl_speak_up.quests[q_id].npcs, id)
|
||||
end
|
||||
elseif(string.sub(n_id, 1, 1) == "p"
|
||||
and table.indexof(quest.locations or {}, n_id) == -1) then
|
||||
table.insert(yl_speak_up.quests[q_id].locations, n_id)
|
||||
end
|
||||
-- show the newly created or selected step
|
||||
yl_speak_up.speak_to[pname].quest_step = work_step
|
||||
return yl_speak_up.show_fs(player, "manage_quest_steps", work_step)
|
||||
|
@ -994,10 +994,22 @@ yl_speak_up.quest_step_add_where = function(pname, q_id, quest_step_name, new_lo
|
||||
end
|
||||
local new_loc_id = yl_speak_up.get_location_id(new_location)
|
||||
if(not(new_loc_id)) then
|
||||
return "Failed to create location ID for this location."
|
||||
return "Failed to create location ID for this location/NPC."
|
||||
end
|
||||
-- overwrite existing/old entries
|
||||
yl_speak_up.quests[q_id].step_data[quest_step_name].where[new_loc_id] = new_location
|
||||
-- make sure quest.npcs or quest.locations contains this entry
|
||||
local n_id = new_location.n_id or "?"
|
||||
if(string.sub(n_id, 1, 2) == "n_") then
|
||||
-- only npcs that are not yet added (and we store IDs without n_ prefix)
|
||||
local id = tonumber(string.sub(n_id, 3))
|
||||
if(id and table.indexof(yl_speak_up.quests[q_id].npcs or {}, id) == -1) then
|
||||
table.insert(yl_speak_up.quests[q_id].npcs, id)
|
||||
end
|
||||
elseif(string.sub(n_id, 1, 1) == "p"
|
||||
and table.indexof(yl_speak_up.quests[q_id].locations or {}, n_id) == -1) then
|
||||
table.insert(yl_speak_up.quests[q_id].locations, n_id)
|
||||
end
|
||||
yl_speak_up.save_quest(q_id)
|
||||
-- return OK even if the quest step existed already
|
||||
return "OK"
|
||||
@ -1005,7 +1017,7 @@ end
|
||||
|
||||
|
||||
-- delete a quest step location with the id location_id
|
||||
yl_speak_up.quest_step_del_where = function(pname, q_id, quest_step_name, location_id)
|
||||
yl_speak_up.quest_step_del_where = function(pname, q_id, quest_step_name, old_location)
|
||||
local error_msg = yl_speak_up.quest_allow_access(q_id, pname, false)
|
||||
if(error_msg ~= "OK") then
|
||||
return error_msg
|
||||
@ -1014,11 +1026,16 @@ yl_speak_up.quest_step_del_where = function(pname, q_id, quest_step_name, locati
|
||||
if(not(quest_step)) then
|
||||
return "Quest step \""..tostring(quest_step_name).."\" does not exist."
|
||||
end
|
||||
if(not(step_data.where)) then
|
||||
step_data.where = {}
|
||||
local loc_id = yl_speak_up.get_location_id(old_location)
|
||||
if(not(loc_id)) then
|
||||
return "Failed to create location ID for this location/NPC."
|
||||
end
|
||||
if(not(yl_speak_up.quests[q_id].step_data[quest_step_name])) then
|
||||
yl_speak_up.quests[q_id].step_data[quest_step_name].where = {}
|
||||
end
|
||||
-- delete the quest step location
|
||||
yl_speak_up.quests[q_id].step_data[quest_step_name].where[location_id] = nil
|
||||
yl_speak_up.quests[q_id].step_data[quest_step_name].where[loc_id] = nil
|
||||
yl_speak_up.save_quest(q_id)
|
||||
return "OK"
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user