yl_speak_up = {} local modpath = minetest.get_modpath("yl_speak_up")..DIR_DELIM yl_speak_up.worldpath = minetest.get_worldpath()..DIR_DELIM yl_speak_up.modpath = modpath yl_speak_up.modstorage = minetest.get_mod_storage() -- status -- 0: NPCs may speak -- 1: NPCs may not speak -- 2: NPCs must selfdestruct on load. Their dialogs remain safed yl_speak_up.status = yl_speak_up.modstorage:get_int("status") or 0 -- needed for assigning individual IDs (n_id) to NPC yl_speak_up.number_of_npcs = yl_speak_up.modstorage:get_int("amount") or 0 -- which player (key) is talking to which NPC? yl_speak_up.speak_to = {} -- allow to request the highest possible version number for formspec_version -- for each individual player; formspec_version... -- ver 1 looks very bad because button height can't be set) -- ver 2 works pretty well because the code has workarounds for the scroll elements -- ver 3 is what this was developed with and looks best yl_speak_up.fs_version = {} -- used for storing custom functions only this server may have yl_speak_up.custom_server_functions = {} -- the functions in here can be reloaded without restarting the server -- log_entry: what to write in the logfile yl_speak_up.reload = function(modpath, log_entry) -- the server-specific configuration dofile(modpath .. "config.lua") -- those paths are set in config.lua - so make sure they exist minetest.mkdir(yl_speak_up.worldpath..yl_speak_up.path) minetest.mkdir(yl_speak_up.worldpath..yl_speak_up.inventory_path) minetest.mkdir(yl_speak_up.worldpath..yl_speak_up.log_path) -- logging and showing the log dofile(modpath .. "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 .. "fs_decorated.lua") -- the formspec and input handling for the main dialog dofile(modpath .. "fs_talkdialog.lua") -- ask if the player wants to save, discard or go back in edit mode dofile(modpath .. "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. dofile(modpath .. "custom_functions_you_can_override.lua") -- execute preconditions, actions and effects dofile(modpath .. "exec_eval_preconditions.lua") dofile(modpath .. "exec_actions.lua") dofile(modpath .. "exec_apply_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 .. "formspec_helpers.lua") -- handle alternate text for dialogs dofile(modpath .. "fs_alternate_text.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 .. "fs_edit_general.lua") -- edit preconditions (can be reached through edit options dialog) dofile(modpath .. "fs_edit_preconditions.lua") -- edit actions (can be reached through edit options dialog) dofile(modpath .. "fs_edit_actions.lua") -- edit effects (can be reached through edit options dialog) dofile(modpath .. "fs_edit_effects.lua") -- edit options dialog (detailed configuration of options in edit mode) dofile(modpath .. "fs_edit_options_dialog.lua") -- set name, description and owner (owner only with npc_talk_master priv) dofile(modpath .. "fs_initial_config.lua") -- inspect and accept items the player gave to the NPC dofile(modpath .. "fs_player_offers_item.lua") -- inventory management, trading and handling of quest items: dofile(modpath .. "inventory.lua") -- limit how much the NPC shall buy and sell dofile(modpath .. "fs_trade_limit.lua") dofile(modpath .. "fs_edit_trade_limit.lua") -- trade one item(stack) against one other item(stack) dofile(modpath .. "trade_simple.lua") -- just click on a button to buy items from the trade list dofile(modpath .. "fs_trade_via_buy_button.lua") -- easily accessible list of all trades the NPC offers dofile(modpath .. "fs_trade_list.lua") -- as the name says: list which npc acesses a variable how and in which context dofile(modpath .. "fs_get_list_of_usage_of_variable.lua") -- show which values are stored for which player in a quest variable dofile(modpath .. "fs_show_all_var_values.lua") -- manage quest variables: add, delete, manage access rights etc. dofile(modpath .. "fs_manage_variables.lua") -- handle variables for quests for player-owned NPC dofile(modpath .. "quest_api.lua") -- setting skin, wielded item etc. dofile(modpath .. "fs_fashion.lua") -- properties for NPC without specific dialogs that want to make use of -- some generic dialogs dofile(modpath .. "fs_properties.lua") -- the main functionality of the mod dofile(modpath .. "functions.lua") -- initialize and load all registered generic dialogs yl_speak_up.load_generic_dialogs() if(log_entry) then minetest.log("action","[MOD] yl_speak_up "..tostring(log_entry)) end end -- register all the necessary things; this ought to be done only once -- (although most might work without a server restart as well; but we -- better want to be on the safe side here) dofile(modpath .. "register_once.lua") -- load all those files that can also be reloaded without a server restart -- load here for the first time: yl_speak_up.reload(modpath, "loaded") -- these functions here mostly cannot be reloaded without a server restart -- because they register tools and entities -- -- the staffs (requires npc_master priv) if(yl_speak_up.enable_staff_based_editing) then -- editing the npc with the staff: dofile(modpath .. "staff_based_editing.lua") -- defining the staffs: dofile(modpath .. "tools.lua") end -- mobs registered as yl_speak_up-mobs (based on mobs_redo) if(yl_speak_up.enable_yl_mobs) then -- react to right-click etc. dofile(modpath .. "interface_mobs_api.lua") -- the actual mobs, using mobs_redo dofile(modpath .. "mobs.lua") -- may store a table of registered mobs in the future; currently not really used yl_speak_up.mob_table = yl_speak_up.init_mob_table() or {} end minetest.log("action","[MOD] yl_speak_up loaded tools and mobs")