forked from Sokomine/yl_speak_up
begin of refactoring of fs_edit_option_related into formspecs for types of preconditions, actions and effects
This commit is contained in:
parent
9d3a08e854
commit
0b9b7d6287
@ -1231,9 +1231,15 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"\"/npc_talk_debug off\".]"
|
"\"/npc_talk_debug off\".]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
-- begin of formspecs for types of preconditions, actions and effects
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
-- TODO: text_variable, text_select_operator
|
||||||
|
yl_speak_up.get_fs_edit_option_precondition_state = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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
|
||||||
@ -1266,7 +1272,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
end
|
end
|
||||||
var_list_text = var_list_text..","..minetest.formspec_escape(tostring(var_name))
|
var_list_text = var_list_text..","..minetest.formspec_escape(tostring(var_name))
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[0.2,3.3;"..text_variable.."]"..
|
"label[0.2,3.3;"..text_variable.."]"..
|
||||||
"label[0.2,4.3;Name of variable:]"..
|
"label[0.2,4.3;Name of variable:]"..
|
||||||
"dropdown[0.2,4.8;6.5,0.6;select_variable;"..
|
"dropdown[0.2,4.8;6.5,0.6;select_variable;"..
|
||||||
@ -1287,11 +1293,16 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"than x seconds ago\" or \"less than x seconds ago\". This can be "..
|
"than x seconds ago\" or \"less than x seconds ago\". This can be "..
|
||||||
"useful for prevending your NPC from handing out the same quest item again "..
|
"useful for prevending your NPC from handing out the same quest item again "..
|
||||||
"too quickly (players are inventive and may use your quest item for their "..
|
"too quickly (players are inventive and may use your quest item for their "..
|
||||||
"own needs).\n</normal>]"
|
"own needs).\n</normal>]"..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
-- TODO: block_pos as parameter?
|
||||||
|
yl_speak_up.get_fs_edit_option_precondition_block = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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
|
||||||
@ -1339,7 +1350,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
-- not enough selected yet for saving
|
-- not enough selected yet for saving
|
||||||
save_button = ""
|
save_button = ""
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[0.2,3.3;"..text_block_position.."]"..
|
"label[0.2,3.3;"..text_block_position.."]"..
|
||||||
"dropdown[4.0,3.5;16.0,0.6;select_block;"..
|
"dropdown[4.0,3.5;16.0,0.6;select_block;"..
|
||||||
table.concat(check_block, ",")..";"..
|
table.concat(check_block, ",")..";"..
|
||||||
@ -1355,32 +1366,40 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"This menu will close and you will be asked to punch\n"..
|
"This menu will close and you will be asked to punch\n"..
|
||||||
"the block at the position you want to check or change.\n"..
|
"the block at the position you want to check or change.\n"..
|
||||||
"After punching it, you will be returned to this menu.]"..
|
"After punching it, you will be returned to this menu.]"..
|
||||||
error_is_protected
|
error_is_protected..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_precondition_trade = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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
|
||||||
save_button = ""
|
save_button = ""
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[0.2,3.3;If the action is a trade, the following shall be true:]"..
|
"label[0.2,3.3;If the action is a trade, the following shall be true:]"..
|
||||||
"dropdown[4.0,3.5;16.0,0.6;select_trade;"..
|
"dropdown[4.0,3.5;16.0,0.6;select_trade;"..
|
||||||
table.concat(check_trade, ",")..";"..
|
table.concat(check_trade, ",")..";"..
|
||||||
tostring(data.trade)..";]"
|
tostring(data.trade)..";]"..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_precondition_inv = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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
|
||||||
save_button = ""
|
save_button = ""
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[0.2,3.0;The following shall be true about the inventory:]"..
|
"label[0.2,3.0;The following shall be true about the inventory:]"..
|
||||||
"dropdown[4.0,3.2;16.0,0.6;select_inv;"..
|
"dropdown[4.0,3.2;16.0,0.6;select_inv;"..
|
||||||
table.concat(check_inv, ",")..";"..
|
table.concat(check_inv, ",")..";"..
|
||||||
@ -1394,11 +1413,14 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"button[5.5,5.5;1.5,0.9;store_item_name;Store]"..
|
"button[5.5,5.5;1.5,0.9;store_item_name;Store]"..
|
||||||
"list[detached:yl_speak_up_player_"..pname..";npc_wants;4.0,5.5;1,1;]"..
|
"list[detached:yl_speak_up_player_"..pname..";npc_wants;4.0,5.5;1,1;]"..
|
||||||
"label[8,4.9;Your inventory:]"..
|
"label[8,4.9;Your inventory:]"..
|
||||||
"list[current_player;main;8,5.3;8,4;]"
|
"list[current_player;main;8,5.3;8,4;]"..
|
||||||
|
save_button
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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
|
||||||
@ -1418,11 +1440,15 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"button[5.5,5.5;1.5,0.9;store_item_name;Store]"..
|
"button[5.5,5.5;1.5,0.9;store_item_name;Store]"..
|
||||||
"list[detached:yl_speak_up_player_"..pname..";npc_wants;4.0,5.5;1,1;]"..
|
"list[detached:yl_speak_up_player_"..pname..";npc_wants;4.0,5.5;1,1;]"..
|
||||||
"label[8,4.9;Your inventory:]"..
|
"label[8,4.9;Your inventory:]"..
|
||||||
"list[current_player;main;8,5.3;8,4;]"
|
"list[current_player;main;8,5.3;8,4;]"..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
formspec = formspec..
|
|
||||||
|
yl_speak_up.get_fs_edit_option_effect_move = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
|
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 "..
|
||||||
"\"npc_master\" priv!]"..
|
"\"npc_master\" priv!]"..
|
||||||
@ -1431,21 +1457,29 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"label[7.2,5.3;Z:]"..
|
"label[7.2,5.3;Z:]"..
|
||||||
"field[0.7,5.0;2.0,0.6;move_to_x;;"..(data.move_to_x or "").."]"..
|
"field[0.7,5.0;2.0,0.6;move_to_x;;"..(data.move_to_x or "").."]"..
|
||||||
"field[4.2,5.0;2.0,0.6;move_to_y;;"..(data.move_to_y or "").."]"..
|
"field[4.2,5.0;2.0,0.6;move_to_y;;"..(data.move_to_y or "").."]"..
|
||||||
"field[7.7,5.0;2.0,0.6;move_to_z;;"..(data.move_to_z or "").."]"
|
"field[7.7,5.0;2.0,0.6;move_to_z;;"..(data.move_to_z or "").."]"..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
formspec = formspec..
|
|
||||||
|
-- for "precondition and effect"
|
||||||
|
yl_speak_up.get_fs_edit_option_p_and_e_function = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
|
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 "..
|
||||||
"\"npc_master\" priv!]"..
|
"\"npc_master\" priv!]"..
|
||||||
"textarea[0.2,4.5;20,4.0;lua_code;;"..
|
"textarea[0.2,4.5;20,4.0;lua_code;;"..
|
||||||
minetest.formspec_escape(tostring(data.lua_code)).."]"
|
minetest.formspec_escape(tostring(data.lua_code)).."]"..
|
||||||
|
save_button
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_effect_craft = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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).."]"
|
||||||
@ -1458,7 +1492,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[8,2.6;Your invnetory:]"..
|
"label[8,2.6;Your invnetory:]"..
|
||||||
"list[current_player;main;8,3;8,4;]"..
|
"list[current_player;main;8,3;8,4;]"..
|
||||||
"label[1,3.1;Your craft grid:]"..
|
"label[1,3.1;Your craft grid:]"..
|
||||||
@ -1467,11 +1501,15 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"image[4.6,4.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
"image[4.6,4.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
||||||
"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.]"..
|
||||||
bg_img
|
bg_img..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_effect_on_failure = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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
|
||||||
@ -1494,22 +1532,26 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
":]",
|
":]",
|
||||||
"button_edit_effect_on_failure_text_change")
|
"button_edit_effect_on_failure_text_change")
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[0.2,3.3;If the *previous* effect failed,]"..
|
"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, ",")..";"..
|
||||||
tostring(nr)..";]"..
|
tostring(nr)..";]"..
|
||||||
on_failure_dialog
|
on_failure_dialog..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_effect_chat_all = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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 -"
|
||||||
if(not(data)) then
|
if(not(data)) then
|
||||||
data = {}
|
data = {}
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[0.2,3.3;Send the following chat message to *all* players:]"..
|
"label[0.2,3.3;Send the following chat message to *all* players:]"..
|
||||||
"label[0.2,4.1;Message:]"..
|
"label[0.2,4.1;Message:]"..
|
||||||
"field[2.0,3.8;16.0,0.6;chat_msg_text;;"..
|
"field[2.0,3.8;16.0,0.6;chat_msg_text;;"..
|
||||||
@ -1518,10 +1560,14 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
or default_text).."]"..
|
or default_text).."]"..
|
||||||
"label[0.2,5.3;Note: Your chat message needs to contain the following placeholders,"..
|
"label[0.2,5.3;Note: Your chat message needs to contain the following placeholders,"..
|
||||||
" which will be replaced automaticly like in dialog texts:"..
|
" which will be replaced automaticly like in dialog texts:"..
|
||||||
"\n$NPC_NAME$, $PLAYER_NAME$ and $OWNER_NAME$.]"
|
"\n$NPC_NAME$, $PLAYER_NAME$ and $OWNER_NAME$.]"..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_action_trade = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
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
|
||||||
@ -1535,7 +1581,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"item_image[5.15,4.35;0.7,0.7;"..tostring(data.pay).."]"
|
"item_image[5.15,4.35;0.7,0.7;"..tostring(data.pay).."]"
|
||||||
end
|
end
|
||||||
yl_speak_up.speak_to[pname].trade_id = data.trade_id
|
yl_speak_up.speak_to[pname].trade_id = data.trade_id
|
||||||
formspec = formspec..
|
return
|
||||||
"label[8,2.6;Your invnetory:]"..
|
"label[8,2.6;Your invnetory:]"..
|
||||||
"list[current_player;main;8,3;8,4;]"..
|
"list[current_player;main;8,3;8,4;]"..
|
||||||
"label[0.2,3.1;Configure trade with "..minetest.formspec_escape(dialog.n_npc)..":]"..
|
"label[0.2,3.1;Configure trade with "..minetest.formspec_escape(dialog.n_npc)..":]"..
|
||||||
@ -1548,11 +1594,15 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"list[detached:yl_speak_up_player_"..pname..";setup;5,4.2;1,1;1]"..
|
"list[detached:yl_speak_up_player_"..pname..";setup;5,4.2;1,1;1]"..
|
||||||
bg_img..
|
bg_img..
|
||||||
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
||||||
"The player shall trade at least once.")
|
"The player shall trade at least once.")..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_action_npc_gives = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
if(not(data)) then
|
if(not(data)) then
|
||||||
data = {}
|
data = {}
|
||||||
end
|
end
|
||||||
@ -1560,7 +1610,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
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).."]"
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[8,2.6;Your inventory:]"..
|
"label[8,2.6;Your inventory:]"..
|
||||||
"list[current_player;main;8,3;8,4;]"..
|
"list[current_player;main;8,3;8,4;]"..
|
||||||
"label[1,3.1;"..minetest.formspec_escape(dialog.n_npc or "?").." gives:]"..
|
"label[1,3.1;"..minetest.formspec_escape(dialog.n_npc or "?").." gives:]"..
|
||||||
@ -1597,12 +1647,16 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"This description is shown in the inventory on mouseover.]"..
|
"This description is shown in the inventory on mouseover.]"..
|
||||||
bg_img..
|
bg_img..
|
||||||
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
||||||
"The player shall take this offered item.")
|
"The player shall take this offered item.")..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_action_npc_wants = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
if(not(data)) then
|
if(not(data)) then
|
||||||
data = {}
|
data = {}
|
||||||
end
|
end
|
||||||
@ -1610,7 +1664,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
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).."]"
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
return
|
||||||
"label[8,2.6;Your inventory:]"..
|
"label[8,2.6;Your inventory:]"..
|
||||||
"list[current_player;main;8,3;8,4;]"..
|
"list[current_player;main;8,3;8,4;]"..
|
||||||
"label[1,3.1;"..minetest.formspec_escape(dialog.n_npc or "?").." wants:]"..
|
"label[1,3.1;"..minetest.formspec_escape(dialog.n_npc or "?").." wants:]"..
|
||||||
@ -1635,15 +1689,19 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
or "- none set -").."]"..
|
or "- none set -").."]"..
|
||||||
bg_img..
|
bg_img..
|
||||||
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
||||||
"The player shall give the NPC this item.")
|
"The player shall give the NPC this item.")..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_action_text_input = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
if(not(data)) then
|
if(not(data)) then
|
||||||
data = {}
|
data = {}
|
||||||
end
|
end
|
||||||
formspec = formspec..
|
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:]"..
|
||||||
"field[4.0,3.8;10.0,0.6;quest_question;;"..
|
"field[4.0,3.8;10.0,0.6;quest_question;;"..
|
||||||
@ -1670,7 +1728,9 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"effects/results of the current dialog option are *not*\n"..
|
"effects/results of the current dialog option are *not*\n"..
|
||||||
"executed.]"..
|
"executed.]"..
|
||||||
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
yl_speak_up.set_on_action_failure_dialog(pname, data,
|
||||||
"The player shall enter the correct answer.")
|
"The player shall enter the correct answer.")..
|
||||||
|
save_button
|
||||||
|
end
|
||||||
|
|
||||||
-- "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
|
||||||
@ -1678,6 +1738,8 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
and ((id_prefix == "a_" and data.what == 7)
|
and ((id_prefix == "a_" and data.what == 7)
|
||||||
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
|
||||||
|
|
||||||
|
yl_speak_up.get_fs_edit_option_action_custom = function(pname, dialog, formspec, data, id_prefix, save_button)
|
||||||
if(not(data)) then
|
if(not(data)) then
|
||||||
data = {}
|
data = {}
|
||||||
end
|
end
|
||||||
@ -1708,10 +1770,13 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
|
|||||||
"label[0.3,5.0;Note: Your custom function has to return either true "..
|
"label[0.3,5.0;Note: Your custom function has to return either true "..
|
||||||
"or false.]"
|
"or false.]"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return formspec..save_button
|
return formspec..save_button
|
||||||
end
|
end
|
||||||
|
-- return formspec..save_button
|
||||||
|
--end
|
||||||
|
|
||||||
|
-- end of formspecs for types of preconditions, actions and effects
|
||||||
|
----------------------------------------------------------------------------
|
||||||
|
|
||||||
-- helper function
|
-- helper function
|
||||||
yl_speak_up.set_on_action_failure_dialog = function(pname, data, instruction)
|
yl_speak_up.set_on_action_failure_dialog = function(pname, data, instruction)
|
||||||
|
Loading…
Reference in New Issue
Block a user