diff --git a/command_npc_talk_style.lua b/command_npc_talk_style.lua new file mode 100644 index 0000000..eaf11e8 --- /dev/null +++ b/command_npc_talk_style.lua @@ -0,0 +1,35 @@ +-- change the formspec style used in fs_decorated.lua + +-- because the player may have wandered off from his NPC and get too many messages +-- without a quick way to get rid of them otherwise +minetest.register_chatcommand( 'npc_talk_style', { + description = "This command sets your formspec version ".. + "for the yl_speak_up NPC to value .\n".. + " Version 1: For very old clients. Not recommended.\n".. + " Version 2: Adds extra scroll buttons. Perhaps you like this more.\n".. + " Version 3: Default version.", + privs = {}, + func = function(pname, param) + -- set a default value + if(not(yl_speak_up.fs_version[pname])) then + yl_speak_up.fs_version[pname] = 3 + end + if(param and param == "1") then + yl_speak_up.fs_version[pname] = 1 + elseif(param and param == "2") then + yl_speak_up.fs_version[pname] = 2 + elseif(param and param == "3") then + yl_speak_up.fs_version[pname] = 3 + else + minetest.chat_send_player(pname, "This command sets your formspec version ".. + "for the yl_speak_up NPC to value .\n".. + " Version 1: For very old clients. Not recommended.\n".. + " Version 2: Adds extra scroll buttons.\n".. + " Version 3: Default (recommended) version.") + end + minetest.chat_send_player(pname, "Your formspec version for the yl_speak_up NPC ".. + "has been set to version "..tostring(yl_speak_up.fs_version[pname]).. + " for this session.") + end + }) + diff --git a/fs_decorated.lua b/fs_decorated.lua index 939d2e5..a71bc42 100644 --- a/fs_decorated.lua +++ b/fs_decorated.lua @@ -1,39 +1,8 @@ -- the formspec menu used for talking to the NPC can also used for -- the trading formspec and similar things --- because the player may have wandered off from his NPC and get too many messages --- without a quick way to get rid of them otherwise -minetest.register_chatcommand( 'npc_talk_style', { - description = "This command sets your formspec version ".. - "for the yl_speak_up NPC to value .\n".. - " Version 1: For very old clients. Not recommended.\n".. - " Version 2: Adds extra scroll buttons. Perhaps you like this more.\n".. - " Version 3: Default version.", - privs = {}, - func = function(pname, param) - -- set a default value - if(not(yl_speak_up.fs_version[pname])) then - yl_speak_up.fs_version[pname] = 3 - end - if(param and param == "1") then - yl_speak_up.fs_version[pname] = 1 - elseif(param and param == "2") then - yl_speak_up.fs_version[pname] = 2 - elseif(param and param == "3") then - yl_speak_up.fs_version[pname] = 3 - else - minetest.chat_send_player(pname, "This command sets your formspec version ".. - "for the yl_speak_up NPC to value .\n".. - " Version 1: For very old clients. Not recommended.\n".. - " Version 2: Adds extra scroll buttons.\n".. - " Version 3: Default (recommended) version.") - end - minetest.chat_send_player(pname, "Your formspec version for the yl_speak_up NPC ".. - "has been set to version "..tostring(yl_speak_up.fs_version[pname]).. - " for this session.") - end - }) - +-- the chat command npc_talk_style found in command_npc_talk_style.lua +-- can be used to switch formspec style. -- helper function for yl_speak_up.show_fs_decorated diff --git a/init.lua b/init.lua index 939732c..9b269a2 100644 --- a/init.lua +++ b/init.lua @@ -40,6 +40,8 @@ dofile(modpath .. "interface_mobs_api.lua") dofile(modpath .. "show_fs.lua") -- general decoration part for main formspec, trade window etc. dofile(modpath .. "fs_decorated.lua") +-- command for switching the formspec version of the player +dofile(modpath .. "command_npc_talk_style.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