added menu entries for put_into_block_inv, take_from_block_inv

This commit is contained in:
Sokomine 2021-12-26 18:50:04 +01:00
parent f5ceb9b04c
commit aae92b7da3
2 changed files with 43 additions and 36 deletions

View File

@ -45,18 +45,25 @@ local check_what = {
"- please select -",
"an internal state (i.e. of a quest)", -- 2
"a block somewhere", -- 3
"NPC crafts something", -- 4
"go to other dialog if the previous effect failed", -- 5
"send a chat message to all players", -- 6
"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
"move the player to a given position (requires npc_master priv)", -- 9
"execute Lua code (requires npc_master priv)", -- 10
"Call custom functions that are supposed to be overridden by the server.", -- 11
minetest.formspec_escape("put item from the NPC's inventory into a chest, furnace etc."), -- 4
minetest.formspec_escape("take item from a chest, furnace etc. and put it into the NPC's inventory"),
-- 5
"NPC crafts something", -- 6
"go to other dialog if the previous effect failed", -- 7
"send a chat message to all players", -- 8
"give item (created out of thin air) to player (requires npc_master priv)", -- 9
"take item from player and destroy it (requires npc_master priv)", -- 10
"move the player to a given position (requires npc_master priv)", -- 11
"execute Lua code (requires npc_master priv)", -- 12
"Call custom functions that are supposed to be overridden by the server.", -- 13
}
-- how to store these as r_type in the precondition:
local values_what = {"", "state", "block", "craft", "on_failure", "chat_all",
local values_what = {"", "state", "block",
-- interact with the inventory of blocks on the map
"put_into_block_inv", "take_from_block_inv",
-- crafting, handling failure, send chat message to all
"craft", "on_failure", "chat_all",
-- the following require the npc_master priv:
"give_item", "take_item", "move", "function",
-- custom function (does not require npc_master priv)
@ -752,7 +759,7 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
minetest.colorize(yl_speak_up.chat_all_color, text))
-- sending a chat message always counts as successful
return true
-- "Call custom functions that are supposed to be overridden by the server.", -- 11
-- "Call custom functions that are supposed to be overridden by the server.", -- 13
elseif(r.r_type == "custom") then
-- execute the custom function
return yl_speak_up.effect_custom(player, r.r_value)

View File

@ -369,8 +369,8 @@ yl_speak_up.save_element_p_or_a_or_e = function(
v[ id_prefix.."pos" ] = {x = data.block_pos.x, y = data.block_pos.y, z = data.block_pos.z }
end
-- "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
-- "give item (created out of thin air) to player (requires npc_master priv)", -- 9
-- "take item from player and destroy it (requires npc_master priv)", -- 10
elseif(id_prefix == "r_" and (what_type == "give_item" or what_type == "take_item")) then
if(not(data.inv_stack_name) or data.inv_stack_name == "") then
yl_speak_up.show_fs(player, "msg", {
@ -393,7 +393,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
v[ "r_value" ] = data.inv_stack_name
-- "move the player to a given position (requires npc_master priv)", -- 9
-- "move the player to a given position (requires npc_master priv)", -- 11
elseif(what_type == "move" and id_prefix == "r_") then
if(not(data.move_to_x) or not(data.move_to_y) or not(data.move_to_z)) then
yl_speak_up.show_fs(player, "msg", {
@ -416,7 +416,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
v[ "r_value" ] = minetest.pos_to_string(
{x = data.move_to_x, y = data.move_to_y, z = data.move_to_z})
-- effect "execute Lua code (requires npc_master priv)", -- precondition: 8; effect: 10
-- effect "execute Lua code (requires npc_master priv)", -- precondition: 8; effect: 12
elseif((what_type == "function" and id_prefix == "p_")
or (what_type == "function" and id_prefix == "r_")) then
if(not(data.lua_code) or data.lua_code == "") then
@ -439,7 +439,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
end
v[ id_prefix.."value" ] = data.lua_code
-- "NPC crafts something", -- 4
-- "NPC crafts something", -- 6
-- (only for effects; not for preconditions)
elseif(what_type == "craft" and id_prefix == "r_") then
local player_inv = player:get_inventory()
@ -462,12 +462,12 @@ yl_speak_up.save_element_p_or_a_or_e = function(
player_inv:get_stack("craft", i):to_string())
end
-- "go to other dialog if the *previous* effect failed", -- 5
-- "go to other dialog if the *previous* effect failed", -- 7
-- (only for effects; not for preconditions)
elseif(what_type == "on_failure" and id_prefix == "r_") then
v[ "r_value" ] = data.on_failure
-- "send a chat message to all players", -- 6
-- "send a chat message to all players", -- 8
-- (only for effects; not for preconditions)
elseif(what_type == "chat_all" and id_prefix == "r_") then
data.chat_msg_text = fields.chat_msg_text
@ -670,7 +670,7 @@ yl_speak_up.save_element_p_or_a_or_e = function(
v[ "a_on_failure" ] = sorted_dialog_list[ data.action_failure_dialog ]
-- "Call custom functions that are supposed to be overridden by the server.", --
-- precondition: 9; action: 7; effect: 11
-- precondition: 9; action: 7; effect: 13
elseif((id_prefix == "a_" and what_type == "custom")
or (id_prefix == "p_" and what_type == "custom")
or (id_prefix == "r_" and what_type == "custom")) then
@ -797,8 +797,8 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
or (fields.store_item_name and fields.store_item_name ~= ""))
and data and data.what
and ((id_prefix == "p_" and (what_type == "player_inv" or what_type == "npc_inv" or what_type == "block_inv"))
-- "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
-- "give item (created out of thin air) to player (requires npc_master priv)", -- 9
-- "take item from player and destroy it (requires npc_master priv)", -- 10
or (id_prefix == "r_" and (what_type == "give_item" or what_type == "take_item")))) then
local wanted = ""
local wanted_name = ""
@ -899,7 +899,7 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
was_changed = true
end
-- "move the player to a given position (requires npc_master priv)", -- 9
-- "move the player to a given position (requires npc_master priv)", -- 11
if(fields.move_to_x or fields.move_to_y or fields.move_to_z) then
local dimension = {"x","y","z"}
for i, dim in ipairs(dimension) do
@ -1345,24 +1345,24 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
pname, dialog, formspec, data, id_prefix, save_button, e,
values_inv, check_inv, values_block)
-- "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
-- "give item (created out of thin air) to player (requires npc_master priv)", -- 9
-- "take item from player and destroy it (requires npc_master priv)", -- 10
elseif(data.what and id_prefix == "r_" and (what_type == "give_item" or what_type=="take_item")) then
return yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item(
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)", -- 11
elseif(data.what and id_prefix == "r_" and what_type == "move") then
return yl_speak_up.get_fs_edit_option_effect_move(
pname, dialog, formspec, data, id_prefix, save_button, e)
-- "execute Lua code (requires npc_master priv)", -- precondition: 8; effect: 10
-- "execute Lua code (requires npc_master priv)", -- precondition: 8; effect: 12
elseif((data.what and id_prefix == "p_" and what_type == "function")
or (data.what and id_prefix == "r_" and what_type == "function")) then
return yl_speak_up.get_fs_edit_option_p_and_e_function(
pname, dialog, formspec, data, id_prefix, save_button, e)
-- "NPC crafts something", -- 4
-- "NPC crafts something", -- 6
-- (craft - only for effects - not for preconditions)
elseif(data.what and id_prefix == "r_" and what_type == "craft") then
return yl_speak_up.get_fs_edit_option_effect_craft(
@ -1374,7 +1374,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
return yl_speak_up.get_fs_edit_option_effect_on_failure(
pname, dialog, formspec, data, id_prefix, save_button, e)
-- "send a chat message to all players" -- 6
-- "send a chat message to all players" -- 8
elseif(data.what and id_prefix == "r_" and what_type == "chat_all") then
return yl_speak_up.get_fs_edit_option_effect_chat_all(
pname, dialog, formspec, data, id_prefix, save_button, e)
@ -1403,7 +1403,7 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
pname, dialog, formspec, data, id_prefix, save_button, e)
-- "Call custom functions that are supposed to be overridden by the server.", -- 7
-- precondition: 9; action: 7; effect: 11
-- precondition: 9; action: 7; effect: 13
elseif(data.what
and ((id_prefix == "a_" and what_type == "custom")
or (id_prefix == "p_" and what_type == "custom")
@ -1689,8 +1689,8 @@ yl_speak_up.get_fs_edit_option_precondition_inv = function(
end
-- "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
-- "give item (created out of thin air) to player (requires npc_master priv)", -- 9
-- "take item from player and destroy it (requires npc_master priv)", -- 10
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
@ -1698,7 +1698,7 @@ yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item = function(
end
local text = "The following item shall be created out of thin air and added to the "..
"player's inventory:"
if(data.what == 8) then
if(data.what == 10) then
text = "The following item shall be removed from the player's inventory and "..
"be destroyed:"
end
@ -1720,7 +1720,7 @@ yl_speak_up.get_fs_edit_option_effect_give_item_or_take_item = function(
end
-- "move the player to a given position (requires npc_master priv)", -- 9
-- "move the player to a given position (requires npc_master priv)", -- 11
yl_speak_up.get_fs_edit_option_effect_move = function(
pname, dialog, formspec, data, id_prefix, save_button, e)
if(e) then
@ -1747,7 +1747,7 @@ yl_speak_up.get_fs_edit_option_effect_move = function(
end
-- "execute Lua code (requires npc_master priv)", -- precondition: 8; effect: 10
-- "execute Lua code (requires npc_master priv)", -- precondition: 8; effect: 12
yl_speak_up.get_fs_edit_option_p_and_e_function = function(
pname, dialog, formspec, data, id_prefix, save_button, e)
if(e) then
@ -1765,7 +1765,7 @@ yl_speak_up.get_fs_edit_option_p_and_e_function = function(
end
-- "NPC crafts something", -- 4
-- "NPC crafts something", -- 6
-- (craft - only for effects - not for preconditions)
yl_speak_up.get_fs_edit_option_effect_craft = function(
pname, dialog, formspec, data, id_prefix, save_button, e)
@ -1841,7 +1841,7 @@ yl_speak_up.get_fs_edit_option_effect_on_failure = function(
end
-- "send a chat message to all players" -- 6
-- "send a chat message to all players" -- 8
yl_speak_up.get_fs_edit_option_effect_chat_all = function(
pname, dialog, formspec, data, id_prefix, save_button, e)
if(e) then
@ -2040,7 +2040,7 @@ end
-- "Call custom functions that are supposed to be overridden by the server.", -- 7
-- precondition: 9; action: 7; effect: 11
-- precondition: 9; action: 7; effect: 13
yl_speak_up.get_fs_edit_option_all_custom = function(
pname, dialog, formspec, data, id_prefix, save_button, e)
if(e) then