mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-10-09 19:13:05 +02:00
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
|
-- r_craft_grid array containing the stacks in the 9 craft grid fields in string form
|
||||||
--
|
--
|
||||||
-- on_failure:
|
-- on_failure:
|
||||||
-- r_value alternate target dialog if the action failed
|
-- r_value alternate target dialog if the previous *effect* failed
|
||||||
--
|
--
|
||||||
-- chat_all:
|
-- chat_all:
|
||||||
-- r_value chat message sent to all players
|
-- r_value chat message sent to all players
|
||||||
@ -165,7 +165,7 @@ yl_speak_up.show_effect = function(r)
|
|||||||
end
|
end
|
||||||
return craft_str
|
return craft_str
|
||||||
elseif(r.r_type == "on_failure") then
|
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
|
elseif(r.r_type == "chat_all") then
|
||||||
return "Send chat message: \""..tostring(r.r_value).."\""
|
return "Send chat message: \""..tostring(r.r_value).."\""
|
||||||
end
|
end
|
||||||
@ -204,13 +204,14 @@ yl_speak_up.execute_all_relevant_effects = function(player, effects, o_id, actio
|
|||||||
local last_result = action_was_successful
|
local last_result = action_was_successful
|
||||||
-- Important: the list of effects is *sorted* here. The order remains constant!
|
-- Important: the list of effects is *sorted* here. The order remains constant!
|
||||||
local sorted_key_list = yl_speak_up.sort_keys(effects)
|
local sorted_key_list = yl_speak_up.sort_keys(effects)
|
||||||
|
local res = true
|
||||||
for i, k in ipairs(sorted_key_list) do
|
for i, k in ipairs(sorted_key_list) do
|
||||||
local r = effects[ k ]
|
local r = effects[ k ]
|
||||||
yl_speak_up.debug_msg(player, n_id, o_id, "..executing "..
|
yl_speak_up.debug_msg(player, n_id, o_id, "..executing "..
|
||||||
tostring(r.r_id)..": "..yl_speak_up.show_effect(r))
|
tostring(r.r_id)..": "..yl_speak_up.show_effect(r))
|
||||||
-- do not execute effects in edit mode
|
-- do not execute effects in edit mode
|
||||||
if(not(edit_mode)) then
|
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
|
if(not(res)) then
|
||||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id)..
|
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id)..
|
||||||
" -> Effect failed to execute.")
|
" -> 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
|
-- we also stop execution here
|
||||||
return r.r_value
|
return r.r_value
|
||||||
end
|
end
|
||||||
|
last_result = res
|
||||||
end
|
end
|
||||||
-- all preconditions are true
|
-- all preconditions are true
|
||||||
yl_speak_up.debug_msg(player, n_id, o_id, "Finished executing effects.")
|
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())
|
player_inv:get_stack("craft", i):to_string())
|
||||||
end
|
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)
|
-- (only for effects; not for preconditions)
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 5) then
|
elseif(data.what and id_prefix == "r_" and data.what == 5) then
|
||||||
v[ "r_value" ] = data.on_failure
|
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 "..
|
"label[1,8.0;Use your craft grid to show your NPC what to craft "..
|
||||||
"and how. Click on \"Save\" to save.]"
|
"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)
|
-- (on_failure - only for effects - not for preconditions)
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 5) then
|
elseif(data.what and id_prefix == "r_" and data.what == 5) then
|
||||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
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)
|
nr = table.indexof(sorted_dialog_list, data.on_failure)
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
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:]"..
|
"label[0.2,3.8;switch to the following dialog:]"..
|
||||||
"dropdown[5.0,3.5;6.5,0.6;select_on_failure;"..
|
"dropdown[5.0,3.5;6.5,0.6;select_on_failure;"..
|
||||||
table.concat(sorted_dialog_list, ",")..";"..
|
table.concat(sorted_dialog_list, ",")..";"..
|
||||||
|
Loading…
Reference in New Issue
Block a user