forked from Sokomine/yl_speak_up
on_failure effect now acts upon failed *effects* instead of a failed action
This commit is contained in:
parent
28ffd87362
commit
d21141ec1f
@ -25,7 +25,7 @@
|
||||
-- r_craft_grid array containing the stacks in the 9 craft grid fields in string form
|
||||
--
|
||||
-- on_failure:
|
||||
-- r_value alternate target dialog if the action failed
|
||||
-- r_value alternate target dialog if the previous *effect* failed
|
||||
--
|
||||
-- chat_all:
|
||||
-- r_value chat message sent to all players
|
||||
@ -165,7 +165,7 @@ yl_speak_up.show_effect = function(r)
|
||||
end
|
||||
return craft_str
|
||||
elseif(r.r_type == "on_failure") then
|
||||
return "If the action (i.e. trade) failed, go to dialog \""..tostring(r.r_value).. "\"."
|
||||
return "If the *previous* effect failed, go to dialog \""..tostring(r.r_value).. "\"."
|
||||
elseif(r.r_type == "chat_all") then
|
||||
return "Send chat message: \""..tostring(r.r_value).."\""
|
||||
end
|
||||
@ -204,13 +204,14 @@ yl_speak_up.execute_all_relevant_effects = function(player, effects, o_id, actio
|
||||
local last_result = action_was_successful
|
||||
-- Important: the list of effects is *sorted* here. The order remains constant!
|
||||
local sorted_key_list = yl_speak_up.sort_keys(effects)
|
||||
local res = true
|
||||
for i, k in ipairs(sorted_key_list) do
|
||||
local r = effects[ k ]
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "..executing "..
|
||||
tostring(r.r_id)..": "..yl_speak_up.show_effect(r))
|
||||
-- do not execute effects in edit mode
|
||||
if(not(edit_mode)) then
|
||||
local res = yl_speak_up.execute_effect(player, n_id, o_id, r)
|
||||
res = yl_speak_up.execute_effect(player, n_id, o_id, r)
|
||||
if(not(res)) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id)..
|
||||
" -> Effect failed to execute.")
|
||||
@ -227,6 +228,7 @@ yl_speak_up.execute_all_relevant_effects = function(player, effects, o_id, actio
|
||||
-- we also stop execution here
|
||||
return r.r_value
|
||||
end
|
||||
last_result = res
|
||||
end
|
||||
-- all preconditions are true
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "Finished executing effects.")
|
||||
|
@ -361,7 +361,7 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
player_inv:get_stack("craft", i):to_string())
|
||||
end
|
||||
|
||||
-- "go to other dialog if the action (i.e. trade) failed", -- 5
|
||||
-- "go to other dialog if the *previous* effect failed", -- 5
|
||||
-- (only for effects; not for preconditions)
|
||||
elseif(data.what and id_prefix == "r_" and data.what == 5) then
|
||||
v[ "r_value" ] = data.on_failure
|
||||
@ -736,7 +736,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
||||
"label[1,8.0;Use your craft grid to show your NPC what to craft "..
|
||||
"and how. Click on \"Save\" to save.]"
|
||||
|
||||
-- "go to other dialog if the action (i.e. trade) failed", -- 5
|
||||
-- "go to other dialog if the *previous* effect failed", -- 5
|
||||
-- (on_failure - only for effects - not for preconditions)
|
||||
elseif(data.what and id_prefix == "r_" and data.what == 5) then
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
@ -748,7 +748,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
||||
nr = table.indexof(sorted_dialog_list, data.on_failure)
|
||||
end
|
||||
formspec = formspec..
|
||||
"label[0.2,3.3;If the action *failed* (i.e. the player didn't trade),]"..
|
||||
"label[0.2,3.3;If the *previous* effect failed,]"..
|
||||
"label[0.2,3.8;switch to the following dialog:]"..
|
||||
"dropdown[5.0,3.5;6.5,0.6;select_on_failure;"..
|
||||
table.concat(sorted_dialog_list, ",")..";"..
|
||||
|
Loading…
Reference in New Issue
Block a user