diff --git a/fs_fashion.lua b/fs_fashion.lua index 814c4ce..b27f04e 100644 --- a/fs_fashion.lua +++ b/fs_fashion.lua @@ -443,6 +443,10 @@ end yl_speak_up.update_nametag = function(self) + if(self.yl_speak_up.hide_nametag) then + self.object:set_nametag_attributes({text=nil}) + return + end if self.yl_speak_up.npc_name then -- the nametag is normal (cyan by default) if(self.yl_speak_up.talk) then diff --git a/fs_initial_config.lua b/fs_initial_config.lua index dc3dd83..9b276fd 100644 --- a/fs_initial_config.lua +++ b/fs_initial_config.lua @@ -26,7 +26,7 @@ yl_speak_up.input_fs_initial_config = function(player, formname, fields) return end - if(not(fields.save_initial_config) or (fields and fields.exit)) then + if((not(fields.save_initial_config) and not(fields.show_nametag)) or (fields and fields.exit)) then -- is the player editing the npc? then leaving this config -- dialog has to lead back to the talk dialog if(yl_speak_up.edit_mode[pname] == n_id and n_id) then @@ -221,6 +221,26 @@ yl_speak_up.input_fs_initial_config = function(player, formname, fields) local obj = yl_speak_up.speak_to[pname].obj local ent = obj:get_luaentity() if ent ~= nil then + if(fields.show_nametag) then + local new_nametag_state = "- UNDEFINED -" + if(fields.show_nametag == "false") then + ent.yl_speak_up.hide_nametag = true + dialog.hide_nametag = true + new_nametag_state = "HIDE" + -- update_nametag else will only work on reload + obj:set_nametag_attributes({text=""}) + elseif(fields.show_nametag == "true") then + ent.yl_speak_up.hide_nametag = nil + dialog.hide_nametag = nil + new_nametag_state = "SHOW" + end + yl_speak_up.save_dialog(n_id, dialog) + yl_speak_up.log_change(pname, n_id, + tostring(new_nametag_state).." nametag.") + minetest.chat_send_player(pname, + tostring(dialog.n_npc)..": I will ".. + tostring(new_nametag_state).." my nametag.") + end ent.yl_speak_up.npc_name = dialog.n_npc ent.yl_speak_up.npc_description = dialog.n_description ent.owner = yl_speak_up.npc_owner[ n_id ] or dialog.npc_owner @@ -228,7 +248,7 @@ yl_speak_up.input_fs_initial_config = function(player, formname, fields) dialog.n_description .. "\n" .. yl_speak_up.infotext obj:set_properties({infotext = i_text}) - yl_speak_up.update_nametag(ent) + yl_speak_up.update_nametag(ent) end end @@ -254,6 +274,7 @@ yl_speak_up.get_fs_initial_config = function(player, n_id, d_id, is_initial_conf "button_exit[2,1.5;1,0.9;back_from_error_msg;Exit]" end + local tmp_show_nametag = "true" local tmp_name = n_id local tmp_descr = "A new NPC without description" local tmp_text = "Please provide your new NPC with a name and description!" @@ -263,6 +284,7 @@ yl_speak_up.get_fs_initial_config = function(player, n_id, d_id, is_initial_conf -- use existing name and description as presets when just editing if(not(is_initial_config)) then local dialog = yl_speak_up.speak_to[pname].dialog + tmp_show_nametag = not(dialog.hide_nametag) tmp_name = (dialog.n_npc or tmp_name) tmp_descr = (dialog.n_description or tmp_descr) tmp_text = "You can change the name and description of your NPC." @@ -291,6 +313,8 @@ yl_speak_up.get_fs_initial_config = function(player, n_id, d_id, is_initial_conf local formspec = "size[11,8.0]".. "label[0.2,0.5;"..tmp_text.."]".. -- name of the npc + "checkbox[2.2,0.9;show_nametag;;"..tostring(tmp_show_nametag).."]".. + "label[2.7,0.9;Show nametag]".. "label[0.2,1.65;Name:]".. "field[2.2,1.2;4,0.9;n_npc;;"..minetest.formspec_escape(tmp_name).."]".. "label[7.0,1.65;NPC ID: "..minetest.colorize("#FFFF00",tostring(n_id)).."]"..