moved variable presets into individual functions
This commit is contained in:
parent
73ac297b98
commit
506db0ea67
@ -1076,11 +1076,12 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
x_id = "new"
|
x_id = "new"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local e = nil
|
||||||
-- does the element exist already? if so: use the existing values as presets for data
|
-- does the element exist already? if so: use the existing values as presets for data
|
||||||
-- (so that the element can be edited)
|
-- (so that the element can be edited)
|
||||||
-- does kind of the opposite than the saving of values starting in line 323 of this file
|
-- does kind of the opposite than the saving of values starting in line 323 of this file
|
||||||
if(x_id ~= "new" and data.what == 1 and elements[ x_id ]) then
|
if(x_id ~= "new" and data.what == 1 and elements[ x_id ]) then
|
||||||
local e = elements[ x_id ]
|
e = elements[ x_id ]
|
||||||
if( id_prefix == "r_" and e[ "r_type" ] == "dialog") then
|
if( id_prefix == "r_" and e[ "r_type" ] == "dialog") then
|
||||||
-- dialog effects cannot be edited this way
|
-- dialog effects cannot be edited this way
|
||||||
return "size[9,2]"..
|
return "size[9,2]"..
|
||||||
@ -1099,56 +1100,9 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
data.what = table.indexof(values_what, e[ id_prefix.."type" ])
|
data.what = table.indexof(values_what, e[ id_prefix.."type" ])
|
||||||
if(data.what == -1) then
|
if(data.what == -1) then
|
||||||
data.what = 1
|
data.what = 1
|
||||||
-- a state/variable (precondition + effect)
|
|
||||||
elseif(data.what == 2 and id_prefix ~= "a_") then
|
|
||||||
data.operator = math.max(1,table.indexof(values_operator, e[ id_prefix.."operator" ]))
|
|
||||||
data.var_cmp_value = e[ id_prefix.."var_cmp_value" ]
|
|
||||||
data.variable_name = e[ id_prefix.."variable" ]
|
|
||||||
local var_list = get_sorted_player_var_list_function(pname)
|
|
||||||
data.variable = math.max(1, table.indexof(var_list, e[ id_prefix.."variable"])+1)
|
|
||||||
-- a block (precondition + effect)
|
|
||||||
elseif(data.what == 3 and id_prefix ~= "a_") then
|
|
||||||
data.block = math.max(1,table.indexof(values_block, e[ id_prefix.."value" ]))
|
|
||||||
data.node_data = {}
|
|
||||||
data.node_data.data = e[ id_prefix.."node" ]
|
|
||||||
data.node_data.param2 = e[ id_prefix.."param2" ]
|
|
||||||
data.block_pos = {x=e[ id_prefix.."pos" ].x,
|
|
||||||
y=e[ id_prefix.."pos" ].y,
|
|
||||||
z=e[ id_prefix.."pos" ].z}
|
|
||||||
-- the block below was punched
|
|
||||||
if(id_prefix == "p_" and data.block == 5) then
|
|
||||||
data.block_pos.y = data.block_pos.y - 1
|
|
||||||
end
|
|
||||||
-- a trade (precondition)
|
|
||||||
elseif(data.what == 4 and id_prefix == "p_") then
|
|
||||||
data.trade = math.max(1,table.indexof(values_trade, e[ "p_value" ]))
|
|
||||||
-- an invenetory (precondition)
|
|
||||||
elseif((data.what == 5 or data.what == 6) and id_prefix == "p_") then
|
|
||||||
data.inv = math.max(1,table.indexof(values_inv, e["p_value"]))
|
|
||||||
data.inv_stack_name = e[ "p_itemstack" ]
|
|
||||||
-- crafting (effect)
|
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 4) then
|
|
||||||
-- those items can at least be shown as background images
|
|
||||||
data.craftresult = e[ "r_value" ]
|
|
||||||
data.craft_grid = e[ "r_craft_grid"]
|
|
||||||
-- on failure (effect)
|
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 5) then
|
|
||||||
data.on_failure = e[ "r_value" ]
|
|
||||||
-- send a chat message (effect)
|
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 6) then
|
|
||||||
data.chat_msg_text = e[ "r_value" ]
|
|
||||||
-- normal trade (action)
|
|
||||||
elseif(data.what and id_prefix == "a_" and data.what == 3) then
|
|
||||||
data.trade_id = e[ "a_value" ]
|
|
||||||
-- use as background images
|
|
||||||
if(dialog and dialog.trades and dialog.trades[ data.trade_id ]) then
|
|
||||||
data.pay = dialog.trades[ data.trade_id ].pay[1]
|
|
||||||
data.buy = dialog.trades[ data.trade_id ].buy[1]
|
|
||||||
end
|
|
||||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
|
||||||
data.action_failure_dialog = math.max(1,
|
|
||||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
|
||||||
-- npc_gives/npc_wants (action)
|
-- npc_gives/npc_wants (action)
|
||||||
|
-- (two seperate functions, but can be handled here together)
|
||||||
elseif(data.what and id_prefix == "a_" and (data.what == 4 or data.what == 5)) then
|
elseif(data.what and id_prefix == "a_" and (data.what == 4 or data.what == 5)) then
|
||||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||||
data.action_failure_dialog = math.max(1,
|
data.action_failure_dialog = math.max(1,
|
||||||
@ -1160,47 +1114,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||||
data.action_failure_dialog = math.max(1,
|
data.action_failure_dialog = math.max(1,
|
||||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||||
-- entering password (action)
|
end
|
||||||
elseif(data.what and id_prefix == "a_" and data.what == 6) then
|
|
||||||
data.quest_question = e[ "a_question" ]
|
|
||||||
data.quest_answer = e[ "a_value" ]
|
|
||||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
|
||||||
data.action_failure_dialog = math.max(1,
|
|
||||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
|
||||||
-- custom function (action)
|
|
||||||
elseif(data.what
|
|
||||||
and ((id_prefix == "a_" and data.what == 7)
|
|
||||||
or (id_prefix == "p_" and data.what == 8)
|
|
||||||
or (id_prefix == "r_" and data.what == 11))) then
|
|
||||||
data.custom_param = e[ id_prefix.."value" ]
|
|
||||||
if(id_prefix == "a_") then
|
|
||||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
|
||||||
data.action_failure_dialog = math.max(1,
|
|
||||||
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- give_item/take_item
|
|
||||||
elseif(data.what and id_prefix == "r_" and data.what >= 7 and data.what <= 8) then
|
|
||||||
data.inv_stack_name = e[ "r_value" ] or ""
|
|
||||||
|
|
||||||
-- move
|
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 9) then
|
|
||||||
if(e[ "r_value"] and type(e[ "r_value" ]) == "string") then
|
|
||||||
local pos = minetest.string_to_pos(e[ "r_value" ])
|
|
||||||
if(pos) then
|
|
||||||
data.move_to_x = pos.x
|
|
||||||
data.move_to_y = pos.y
|
|
||||||
data.move_to_z = pos.z
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- lua code (precondition and effect)
|
|
||||||
elseif((data.what and id_prefix == "p_" and data.what == 7)
|
|
||||||
or (data.what and id_prefix == "r_" and data.what == 10)) then
|
|
||||||
if(e[ id_prefix.."value"] and e[ id_prefix.."value"] ~= "") then
|
|
||||||
data.lua_code = e[ id_prefix.."value" ]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if(e[ "alternate_text"]) then
|
if(e[ "alternate_text"]) then
|
||||||
data.alternate_text = e[ "alternate_text" ]
|
data.alternate_text = e[ "alternate_text" ]
|
||||||
@ -1235,84 +1149,84 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
-- "an internal state (i.e. of a quest)", -- 2
|
-- "an internal state (i.e. of a quest)", -- 2
|
||||||
-- (state is the second offered option in both preconditions and effects list)
|
-- (state is the second offered option in both preconditions and effects list)
|
||||||
if(data.what and data.what == 2 and id_prefix ~= "a_") then
|
if(data.what and data.what == 2 and id_prefix ~= "a_") then
|
||||||
return yl_speak_up.get_fs_edit_option_precondition_state(
|
return yl_speak_up.get_fs_edit_option_p_and_e_state(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "a block somewhere", -- 3
|
-- "a block somewhere", -- 3
|
||||||
-- (block is the third offered option in both preconditions and effects list)
|
-- (block is the third offered option in both preconditions and effects list)
|
||||||
elseif(data.what and data.what == 3 and id_prefix ~= "a_") then
|
elseif(data.what and data.what == 3 and id_prefix ~= "a_") then
|
||||||
return yl_speak_up.get_fs_edit_option_precondition_block(
|
return yl_speak_up.get_fs_edit_option_p_and_e_block(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "a trade", -- 4
|
-- "a trade", -- 4
|
||||||
-- (trade - only for preconditions; effects have something else here)
|
-- (trade - only for preconditions; effects have something else here)
|
||||||
elseif(data.what and id_prefix == "p_" and data.what == 4) then
|
elseif(data.what and id_prefix == "p_" and data.what == 4) then
|
||||||
return yl_speak_up.get_fs_edit_option_precondition_trade(
|
return yl_speak_up.get_fs_edit_option_precondition_trade(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "the inventory of the player", -- 5
|
-- "the inventory of the player", -- 5
|
||||||
-- "the inventory of the NPC", -- 6
|
-- "the inventory of the NPC", -- 6
|
||||||
-- (inventory - only for preconditions; effects have something else here)
|
-- (inventory - only for preconditions; effects have something else here)
|
||||||
elseif(data.what and id_prefix == "p_" and data.what >= 5 and data.what <= 6) then
|
elseif(data.what and id_prefix == "p_" and data.what >= 5 and data.what <= 6) then
|
||||||
return yl_speak_up.get_fs_edit_option_precondition_inv(
|
return yl_speak_up.get_fs_edit_option_precondition_inv(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "give item (created out of thin air) to player (requires npc_master priv)", -- 7
|
-- "give item (created out of thin air) to player (requires npc_master priv)", -- 7
|
||||||
-- "take item from player and destroy it (requires npc_master priv)", -- 8
|
-- "take item from player and destroy it (requires npc_master priv)", -- 8
|
||||||
elseif(data.what and id_prefix == "r_" and (data.what == 7 or data.what == 8)) then
|
elseif(data.what and id_prefix == "r_" and (data.what == 7 or data.what == 8)) then
|
||||||
return yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item(
|
return yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "move the player to a given position (requires npc_master priv)", -- 9
|
-- "move the player to a given position (requires npc_master priv)", -- 9
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 9) then
|
elseif(data.what and id_prefix == "r_" and data.what == 9) then
|
||||||
return yl_speak_up.get_fs_edit_option_effect_move(
|
return yl_speak_up.get_fs_edit_option_effect_move(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "execute Lua code (requires npc_master priv)", -- precondition: 7; effect: 10
|
-- "execute Lua code (requires npc_master priv)", -- precondition: 7; effect: 10
|
||||||
elseif((data.what and id_prefix == "p_" and data.what == 7)
|
elseif((data.what and id_prefix == "p_" and data.what == 7)
|
||||||
or (data.what and id_prefix == "r_" and data.what == 10)) then
|
or (data.what and id_prefix == "r_" and data.what == 10)) then
|
||||||
return yl_speak_up.get_fs_edit_option_p_and_e_function(
|
return yl_speak_up.get_fs_edit_option_p_and_e_function(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "NPC crafts something", -- 4
|
-- "NPC crafts something", -- 4
|
||||||
-- (craft - only for effects - not for preconditions)
|
-- (craft - only for effects - not for preconditions)
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 4) then
|
elseif(data.what and id_prefix == "r_" and data.what == 4) then
|
||||||
return yl_speak_up.get_fs_edit_option_effect_craft(
|
return yl_speak_up.get_fs_edit_option_effect_craft(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "go to other dialog if the *previous* effect 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
|
||||||
return yl_speak_up.get_fs_edit_option_effect_on_failure(
|
return yl_speak_up.get_fs_edit_option_effect_on_failure(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "send a chat message to all players" -- 6
|
-- "send a chat message to all players" -- 6
|
||||||
elseif(data.what and id_prefix == "r_" and data.what == 6) then
|
elseif(data.what and id_prefix == "r_" and data.what == 6) then
|
||||||
return yl_speak_up.get_fs_edit_option_effect_chat_all(
|
return yl_speak_up.get_fs_edit_option_effect_chat_all(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "Normal trade - one item(stack) for another item(stack).", -- 3
|
-- "Normal trade - one item(stack) for another item(stack).", -- 3
|
||||||
elseif(data.what and id_prefix == "a_" and data.what == 3) then
|
elseif(data.what and id_prefix == "a_" and data.what == 3) then
|
||||||
return yl_speak_up.get_fs_edit_option_action_trade(
|
return yl_speak_up.get_fs_edit_option_action_trade(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "The NPC gives something to the player (i.e. a quest item).", -- 4
|
-- "The NPC gives something to the player (i.e. a quest item).", -- 4
|
||||||
-- (only for actions)
|
-- (only for actions)
|
||||||
elseif(data.what and id_prefix == "a_" and data.what == 4) then
|
elseif(data.what and id_prefix == "a_" and data.what == 4) then
|
||||||
return yl_speak_up.get_fs_edit_option_action_npc_gives(
|
return yl_speak_up.get_fs_edit_option_action_npc_gives(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "The player is expected to give something to the NPC (i.e. a quest item).", -- 5
|
-- "The player is expected to give something to the NPC (i.e. a quest item).", -- 5
|
||||||
-- (only for actions)
|
-- (only for actions)
|
||||||
elseif(data.what and id_prefix == "a_" and data.what == 5) then
|
elseif(data.what and id_prefix == "a_" and data.what == 5) then
|
||||||
return yl_speak_up.get_fs_edit_option_action_npc_wants(
|
return yl_speak_up.get_fs_edit_option_action_npc_wants(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "The player has to manually enter a password or passphrase or some other text.", -- 6
|
-- "The player has to manually enter a password or passphrase or some other text.", -- 6
|
||||||
-- (only for actions)
|
-- (only for actions)
|
||||||
elseif(data.what and id_prefix == "a_" and data.what == 6) then
|
elseif(data.what and id_prefix == "a_" and data.what == 6) then
|
||||||
return yl_speak_up.get_fs_edit_option_action_text_input(
|
return yl_speak_up.get_fs_edit_option_action_text_input(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
|
||||||
-- "Call custom functions that are supposed to be overridden by the server.", -- 7
|
-- "Call custom functions that are supposed to be overridden by the server.", -- 7
|
||||||
-- precondition: 8; action: 7; effect: 11
|
-- precondition: 8; action: 7; effect: 11
|
||||||
@ -1321,7 +1235,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
or (id_prefix == "p_" and data.what == 8)
|
or (id_prefix == "p_" and data.what == 8)
|
||||||
or (id_prefix == "r_" and data.what == 11))) then
|
or (id_prefix == "r_" and data.what == 11))) then
|
||||||
return yl_speak_up.get_fs_edit_option_action_custom(
|
return yl_speak_up.get_fs_edit_option_action_custom(
|
||||||
pname, dialog, formspec, data, id_prefix, save_button)
|
pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
end
|
end
|
||||||
|
|
||||||
return "ERROR"
|
return "ERROR"
|
||||||
@ -1331,8 +1245,15 @@ end
|
|||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
-- begin of formspecs for types of preconditions, actions and effects
|
-- begin of formspecs for types of preconditions, actions and effects
|
||||||
|
|
||||||
-- TODO: text_variable, text_select_operator
|
-- TODO: text_variable, text_select_operator, values_operator, get_sorted_player_var_list_function
|
||||||
yl_speak_up.get_fs_edit_option_precondition_state = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_p_and_e_state = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.operator = math.max(1,table.indexof(values_operator, e[ id_prefix.."operator" ]))
|
||||||
|
data.var_cmp_value = e[ id_prefix.."var_cmp_value" ]
|
||||||
|
data.variable_name = e[ id_prefix.."variable" ]
|
||||||
|
local var_list = get_sorted_player_var_list_function(pname)
|
||||||
|
data.variable = math.max(1, table.indexof(var_list, e[ id_prefix.."variable"])+1)
|
||||||
|
end
|
||||||
if(not(data.variable) or data.variable < 1) then
|
if(not(data.variable) or data.variable < 1) then
|
||||||
data.variable = 1
|
data.variable = 1
|
||||||
-- not enough selected yet for saving
|
-- not enough selected yet for saving
|
||||||
@ -1391,8 +1312,21 @@ yl_speak_up.get_fs_edit_option_precondition_state = function(pname, dialog, form
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- TODO: block_pos as parameter?
|
-- TODO: block_pos as parameter?, values_block
|
||||||
yl_speak_up.get_fs_edit_option_precondition_block = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_p_and_e_block = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.block = math.max(1,table.indexof(values_block, e[ id_prefix.."value" ]))
|
||||||
|
data.node_data = {}
|
||||||
|
data.node_data.data = e[ id_prefix.."node" ]
|
||||||
|
data.node_data.param2 = e[ id_prefix.."param2" ]
|
||||||
|
data.block_pos = {x=e[ id_prefix.."pos" ].x,
|
||||||
|
y=e[ id_prefix.."pos" ].y,
|
||||||
|
z=e[ id_prefix.."pos" ].z}
|
||||||
|
-- the block below was punched
|
||||||
|
if(id_prefix == "p_" and data.block == 5) then
|
||||||
|
data.block_pos.y = data.block_pos.y - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
local block_pos_str = "- none set -"
|
local block_pos_str = "- none set -"
|
||||||
local node = {name = "- unknown -", param2 = "- unkown -"}
|
local node = {name = "- unknown -", param2 = "- unkown -"}
|
||||||
if(not(block_pos) and data and data.block_pos) then
|
if(not(block_pos) and data and data.block_pos) then
|
||||||
@ -1461,7 +1395,10 @@ yl_speak_up.get_fs_edit_option_precondition_block = function(pname, dialog, form
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_precondition_trade = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_precondition_trade = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.trade = math.max(1,table.indexof(values_trade, e[ "p_value" ]))
|
||||||
|
end
|
||||||
if(not(data.trade) or data.trade == 1) then
|
if(not(data.trade) or data.trade == 1) then
|
||||||
data.trade = 1
|
data.trade = 1
|
||||||
-- not enough selected yet for saving
|
-- not enough selected yet for saving
|
||||||
@ -1476,7 +1413,11 @@ yl_speak_up.get_fs_edit_option_precondition_trade = function(pname, dialog, form
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_precondition_inv = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_precondition_inv = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.inv = math.max(1,table.indexof(values_inv, e["p_value"]))
|
||||||
|
data.inv_stack_name = e[ "p_itemstack" ]
|
||||||
|
end
|
||||||
if(not(data.inv) or data.inv == 1) then
|
if(not(data.inv) or data.inv == 1) then
|
||||||
data.inv = 1
|
data.inv = 1
|
||||||
-- not enough selected yet for saving
|
-- not enough selected yet for saving
|
||||||
@ -1501,7 +1442,10 @@ yl_speak_up.get_fs_edit_option_precondition_inv = function(pname, dialog, formsp
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.inv_stack_name = e[ "r_value" ] or ""
|
||||||
|
end
|
||||||
local text = "The following item shall be created out of thin air and added to the "..
|
local text = "The following item shall be created out of thin air and added to the "..
|
||||||
"player's inventory:"
|
"player's inventory:"
|
||||||
if(data.what == 8) then
|
if(data.what == 8) then
|
||||||
@ -1526,7 +1470,17 @@ yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item = function(pname, d
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_effect_move = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_effect_move = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
if(e[ "r_value"] and type(e[ "r_value" ]) == "string") then
|
||||||
|
local pos = minetest.string_to_pos(e[ "r_value" ])
|
||||||
|
if(pos) then
|
||||||
|
data.move_to_x = pos.x
|
||||||
|
data.move_to_y = pos.y
|
||||||
|
data.move_to_z = pos.z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
return
|
return
|
||||||
"label[0.2,3.0;Move the player to this position:]"..
|
"label[0.2,3.0;Move the player to this position:]"..
|
||||||
"label[0.2,3.5;Note: You can *save* this effect only if you have the "..
|
"label[0.2,3.5;Note: You can *save* this effect only if you have the "..
|
||||||
@ -1542,7 +1496,12 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- for "precondition and effect"
|
-- for "precondition and effect"
|
||||||
yl_speak_up.get_fs_edit_option_p_and_e_function = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_p_and_e_function = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
if(e[ id_prefix.."value"] and e[ id_prefix.."value"] ~= "") then
|
||||||
|
data.lua_code = e[ id_prefix.."value" ]
|
||||||
|
end
|
||||||
|
end
|
||||||
return
|
return
|
||||||
"label[0.2,3.0;Execute the following Lua code (ought to return true or false):]"..
|
"label[0.2,3.0;Execute the following Lua code (ought to return true or false):]"..
|
||||||
"label[0.2,3.5;Note: You can *save* this effect only if you have the "..
|
"label[0.2,3.5;Note: You can *save* this effect only if you have the "..
|
||||||
@ -1553,7 +1512,12 @@ yl_speak_up.get_fs_edit_option_p_and_e_function = function(pname, dialog, formsp
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_effect_craft = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_effect_craft = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
-- those items can at least be shown as background images
|
||||||
|
data.craftresult = e[ "r_value" ]
|
||||||
|
data.craft_grid = e[ "r_craft_grid"]
|
||||||
|
end
|
||||||
local bg_img = ""
|
local bg_img = ""
|
||||||
if(data and data.craftresult and data.craft_grid) then
|
if(data and data.craftresult and data.craft_grid) then
|
||||||
bg_img = "item_image[5.95,4.90;0.7,0.7;"..tostring(data.craftresult).."]"
|
bg_img = "item_image[5.95,4.90;0.7,0.7;"..tostring(data.craftresult).."]"
|
||||||
@ -1580,7 +1544,10 @@ yl_speak_up.get_fs_edit_option_effect_craft = function(pname, dialog, formspec,
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_effect_on_failure = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_effect_on_failure = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.on_failure = e[ "r_value" ]
|
||||||
|
end
|
||||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||||
local nr = 1
|
local nr = 1
|
||||||
@ -1614,7 +1581,10 @@ yl_speak_up.get_fs_edit_option_effect_on_failure = function(pname, dialog, forms
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_effect_chat_all = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_effect_chat_all = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.chat_msg_text = e[ "r_value" ]
|
||||||
|
end
|
||||||
local default_text = "$NPC_NAME$ (owned by $OWNER_NAME$) announces: $PLAYER_NAME$ "..
|
local default_text = "$NPC_NAME$ (owned by $OWNER_NAME$) announces: $PLAYER_NAME$ "..
|
||||||
"- example; please enter the text -"
|
"- example; please enter the text -"
|
||||||
return
|
return
|
||||||
@ -1631,7 +1601,18 @@ yl_speak_up.get_fs_edit_option_effect_chat_all = function(pname, dialog, formspe
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_action_trade = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_action_trade = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.trade_id = e[ "a_value" ]
|
||||||
|
-- use as background images
|
||||||
|
if(dialog and dialog.trades and dialog.trades[ data.trade_id ]) then
|
||||||
|
data.pay = dialog.trades[ data.trade_id ].pay[1]
|
||||||
|
data.buy = dialog.trades[ data.trade_id ].buy[1]
|
||||||
|
end
|
||||||
|
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||||
|
data.action_failure_dialog = math.max(1,
|
||||||
|
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||||
|
end
|
||||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
local d_id = yl_speak_up.speak_to[pname].d_id
|
local d_id = yl_speak_up.speak_to[pname].d_id
|
||||||
local o_id = yl_speak_up.speak_to[pname].o_id
|
local o_id = yl_speak_up.speak_to[pname].o_id
|
||||||
@ -1663,7 +1644,7 @@ yl_speak_up.get_fs_edit_option_action_trade = function(pname, dialog, formspec,
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_action_npc_gives = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_action_npc_gives = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
local bg_img = ""
|
local bg_img = ""
|
||||||
if(data and data.item_string) then
|
if(data and data.item_string) then
|
||||||
bg_img = "item_image[2.15,3.65;0.7,0.7;"..tostring(data.item_string).."]"
|
bg_img = "item_image[2.15,3.65;0.7,0.7;"..tostring(data.item_string).."]"
|
||||||
@ -1710,7 +1691,7 @@ yl_speak_up.get_fs_edit_option_action_npc_gives = function(pname, dialog, formsp
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_action_npc_wants = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_action_npc_wants = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
local bg_img = ""
|
local bg_img = ""
|
||||||
if(data and data.item_string) then
|
if(data and data.item_string) then
|
||||||
bg_img = "item_image[2.15,3.65;0.7,0.7;"..tostring(data.item_string).."]"
|
bg_img = "item_image[2.15,3.65;0.7,0.7;"..tostring(data.item_string).."]"
|
||||||
@ -1745,7 +1726,14 @@ yl_speak_up.get_fs_edit_option_action_npc_wants = function(pname, dialog, formsp
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_action_text_input = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_action_text_input = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.quest_question = e[ "a_question" ]
|
||||||
|
data.quest_answer = e[ "a_value" ]
|
||||||
|
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||||
|
data.action_failure_dialog = math.max(1,
|
||||||
|
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||||
|
end
|
||||||
return
|
return
|
||||||
"label[0.2,3.3;What to ask the player and which answer to expect:]"..
|
"label[0.2,3.3;What to ask the player and which answer to expect:]"..
|
||||||
"label[0.2,4.0;Question to show:]"..
|
"label[0.2,4.0;Question to show:]"..
|
||||||
@ -1778,7 +1766,15 @@ yl_speak_up.get_fs_edit_option_action_text_input = function(pname, dialog, forms
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
yl_speak_up.get_fs_edit_option_action_custom = function(pname, dialog, formspec, data, id_prefix, save_button)
|
yl_speak_up.get_fs_edit_option_action_custom = function(pname, dialog, formspec, data, id_prefix, save_button, e)
|
||||||
|
if(e) then
|
||||||
|
data.custom_param = e[ id_prefix.."value" ]
|
||||||
|
if(id_prefix == "a_") then
|
||||||
|
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||||
|
data.action_failure_dialog = math.max(1,
|
||||||
|
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
|
||||||
|
end
|
||||||
|
end
|
||||||
formspec = formspec..
|
formspec = formspec..
|
||||||
"label[0.2,3.3;Note: Calling a custom function will require direct support "..
|
"label[0.2,3.3;Note: Calling a custom function will require direct support "..
|
||||||
"from the server.]"..
|
"from the server.]"..
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user