yl_speak_up/editor/edit_mode.lua

210 lines
9.4 KiB
Lua

-- if player has npc_talk_owner priv AND is owner of this particular npc:
-- chat option: "I am your owner. I have new orders for you.
-- -> enters edit mode
-- when edit_mode has been enabled, the following chat options are added to the options:
-- chat option: "Add new answer/option to this dialog."
-- -> adds a new aswer/option
-- chat option: "That was all. I'm finished with giving you new orders. Remember them!"
-- -> ends edit mode
-- (happens in fs/fs_talkdialog_in_edit_mode.lua)
-- store if the player is editing a particular NPC; format: yl_speak_up.edit_mode[pname] = npc_id
yl_speak_up.edit_mode = {}
-- changes applied in edit_mode are applied immediately - but not immediately stored to disk
-- (this gives the players a chance to back off in case of unwanted changes)
yl_speak_up.npc_was_changed = {}
-- is the player in edit mode?
yl_speak_up.in_edit_mode = function(pname)
return pname
and yl_speak_up.edit_mode[pname]
and (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id)
end
-- reset edit_mode when stopping to talk to an NPC
local old_reset_vars_for_player = yl_speak_up.reset_vars_for_player
yl_speak_up.reset_vars_for_player = function(pname, reset_fs_version)
yl_speak_up.edit_mode[pname] = nil
old_reset_vars_for_player(pname, reset_fs_version)
end
-- make sure generic dialogs are never included in edit_mode (because in edit mode we want to
-- edit this particular NPC without generic parts)
local old_load_dialog = yl_speak_up.load_dialog
yl_speak_up.load_dialog = function(n_id, player) -- returns the saved dialog
if(player and yl_speak_up.in_edit_mode(player:get_player_name())) then
return old_load_dialog(n_id, false)
end
return old_load_dialog(n_id, player)
end
local modname = minetest.get_current_modname()
-- TODO: adjust to new mod name and paths
local modpath = minetest.get_modpath(modname)..DIR_DELIM.."editor"..DIR_DELIM
-- this is a way to provide additional help if a mod adds further commands (like the editor)
yl_speak_up.add_to_command_help_text = yl_speak_up.add_to_command_help_text..
"\nAdditional commands provided by "..tostring(modname)..":\n"..
" force_edit forces edit mode for any NPC you talk to\n"
-- overrides of functions fo fs/fs_talkdialog.lua when in edit_mode (or for entering/leaving it)
dofile(modpath .. "fs/fs_talkdialog_edit_mode.lua")
-- edit preconditions (can be reached through edit options dialog)
dofile(modpath .. "fs/fs_edit_preconditions.lua")
-- edit actions (can be reached through edit options dialog)
dofile(modpath .. "fs/fs_edit_actions.lua")
-- edit effects (can be reached through edit options dialog)
dofile(modpath .. "fs/fs_edit_effects.lua")
-- edit options dialog (detailed configuration of options in edit mode)
dofile(modpath .. "fs/fs_edit_options_dialog.lua")
-- the player wants to change something regarding the dialog
dofile(modpath .. "edit_mode_apply_changes.lua")
-- -- logging and showing the log
-- dofile(modpath .. "api/api_logging.lua")
-- dofile(modpath .. "fs/fs_show_log.lua")
-- -- players *and* npc need privs for certain things; this here handles the NPC side of things
-- dofile(modpath .. "npc_privs.lua")
-- -- add generic dialogs
-- dofile(modpath .. "add_generic_dialogs.lua")
-- -- handle on_player_receive_fields and showing of formspecs
-- dofile(modpath .. "show_fs.lua")
-- -- general decoration part for main formspec, trade window etc.
-- dofile(modpath .. "api/api_decorated.lua")
-- -- the formspec and input handling for the main dialog
-- dofile(modpath .. "api/api_talk.lua")
-- dofile(modpath .. "fs/fs_talkdialog.lua")
-- ask if the player wants to save, discard or go back in edit mode
dofile(modpath .. "fs/fs_save_or_discard_or_back.lua")
-- the player wants to change something regarding the dialog
dofile(modpath .. "edit_mode_apply_changes.lua")
--
-- -- As the name says: a collection of custom functions that you can
-- -- override on your server or in your game to suit your needs;
-- -- Note: No special privs are needed to call custom functions. But...
-- -- of course you can change them only if you have access to
-- -- the server's file system or can execute lua code.
-- -- Note: Please do not edit this file. Instead, create and edit the
-- -- file "local_server_do_on_reload.lua"!
-- dofile(modpath .. "api/custom_functions_you_can_override.lua")
--
-- assign a quest step to a dialog option/answer
dofile(modpath .. "fs/fs_assign_quest_step.lua")
--
-- -- execute preconditions, actions and effects
-- dofile(modpath .. "exec_eval_preconditions.lua")
-- dofile(modpath .. "exec_actions.lua")
-- dofile(modpath .. "exec_apply_effects.lua")
-- in edit_mode we need a more complex reaction to inventory changes
dofile(modpath .. "exec_actions_action_inv_changed.lua")
-- in edit_mode: effects are not executed
dofile(modpath .. "exec_all_relevant_effects.lua")
-- some helper functions for formatting text for a formspec talbe
dofile(modpath .. "print_as_table.lua")
-- -- create i.e. a dropdown list of player names
-- dofile(modpath .. "api/formspec_helpers.lua")
-- handle alternate text for dialogs
dofile(modpath .. "api/api_alternate_text.lua")
-- helpful for debugging the content of the created dialog structure
dofile(modpath .. "fs/fs_show_what_points_to_this_dialog.lua")
-- -- debugging - extended information about what (your own) NPC does
-- dofile(modpath .. "npc_talk_debug.lua")
-- -- execute lua code directly (preconditions and effects) - requires priv
-- dofile(modpath .. "eval_and_execute_function.lua")
-- common functions for editing preconditions and effects
dofile(modpath .. "api/fs_edit_general.lua")
-- edit preconditions (can be reached through edit options dialog)
dofile(modpath .. "fs/fs_edit_preconditions.lua")
-- edit actions (can be reached through edit options dialog)
dofile(modpath .. "fs/fs_edit_actions.lua")
-- edit effects (can be reached through edit options dialog)
dofile(modpath .. "fs/fs_edit_effects.lua")
-- edit options dialog (detailed configuration of options in edit mode)
dofile(modpath .. "fs/fs_edit_options_dialog.lua")
-- -- set name, description and owner (owner only with npc_talk_master priv)
-- dofile(modpath .. "fs/fs_initial_config.lua")
-- -- inspect and accept items the player gave to the NPC
-- dofile(modpath .. "fs/fs_player_offers_item.lua")
-- -- inventory management, trading and handling of quest items:
-- dofile(modpath .. "api/api_inventory.lua")
-- dofile(modpath .. "fs/fs_inventory.lua")
-- -- limit how much the NPC shall buy and sell
-- dofile(modpath .. "api/api_trade.lua")
-- dofile(modpath .. "fs/fs_trade_limit.lua")
-- dofile(modpath .. "fs/fs_edit_trade_limit.lua")
-- -- trade one item(stack) against one other item(stack)
-- dofile(modpath .. "api/api_trade_inv.lua")
dofile(modpath .. "trade_in_edit_mode.lua")
-- dofile(modpath .. "fs/fs_do_trade_simple.lua")
-- handle back button diffrently when editing a trade as an action:
dofile(modpath .. "fs/fs_do_trade_simple_in_edit_mode.lua")
-- dofile(modpath .. "fs/fs_add_trade_simple.lua")
-- -- just click on a button to buy items from the trade list
-- dofile(modpath .. "fs/fs_trade_via_buy_button.lua")
-- -- easily accessible list of all trades the NPC offers
-- dofile(modpath .. "fs/fs_trade_list.lua")
-- as the name says: list which npc acesses a variable how and in which context
dofile(modpath .. "fs/fs_get_list_of_usage_of_variable.lua")
-- show which values are stored for which player in a quest variable
dofile(modpath .. "fs/fs_show_all_var_values.lua")
-- manage quest variables: add, delete, manage access rights etc.
dofile(modpath .. "fs/fs_manage_variables.lua")
-- -- handle variables for quests for player-owned NPC
-- dofile(modpath .. "quest_api.lua")
-- GUI for adding/editing quests
dofile(modpath .. "fs/fs_manage_quests.lua")
-- -- GUI for adding/editing quest steps for the quests
-- dofile(modpath .. "api/api_quest_steps.lua")
dofile(modpath .. "fs/fs_manage_quest_steps.lua")
-- used by the above
dofile(modpath .. "fs/fs_add_quest_steps.lua")
-- -- setting skin, wielded item etc.
-- dofile(modpath .. "old_staff_tool_compatibility.lua")
-- dofile(modpath .. "api/api_fashion.lua")
dofile(modpath .. "fs/fs_fashion.lua")
dofile(modpath .. "fs/fs_fashion_extended.lua")
-- -- properties for NPC without specific dialogs that want to make use of
-- -- some generic dialogs
-- dofile(modpath .. "api/api_properties.lua")
dofile(modpath .. "fs/fs_properties.lua")
-- -- the main functionality of the mod
-- dofile(modpath .. "functions.lua")
-- /npc_talk force_edit (when talking to an NPC in the normal way fails):
dofile(modpath .. "command_force_edit_mode.lua")
-- add the force_edit option to the chat commands
dofile(modpath .. "chat_commands_in_edit_mode.lua")
-- -- implementation of the chat commands registered in register_once.lua:
-- dofile(modpath .. "chat_commands.lua")
-- creating and maintaining quests
dofile(modpath .. "fs/fs_quest_gui.lua")
-- export dialog for cut&paste in .json format
dofile(modpath .. "fs/fs_export.lua")
-- take notes regarding what the NPC is for
dofile(modpath .. "fs/fs_notes.lua")
--
-- -- show a list of all NPC the player can edit
-- dofile(modpath .. "api/api_npc_list.lua")
-- dofile(modpath .. "fs/fs_npc_list.lua")
--
-- -- some general functions that are useful for mobs_redo
-- -- (react to right-click, nametag color etc.)
-- -- only gets loaded if mobs_redo (mobs) exists as mod
-- dofile(modpath .. "interface_mobs_api.lua")
--
-- -- functions and overrides for edit mode
-- dofile(modpath .. "edit_mode.lua")
--