[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Mini-Window chatter

Mini-Window chatter

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2  3 

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #30 on Mon 26 Oct 2015 07:38 PM (UTC)

Amended on Mon 26 Oct 2015 11:39 PM (UTC) by Nick Gammon

Message

function init_ansi()
   ANSI_colours = {
      [GetNormalColour (BLACK)]   = ANSI(0,30),
      [GetNormalColour (RED)]     = ANSI(0,31),
      [GetNormalColour (GREEN)]   = ANSI(0,32),
      [GetNormalColour (YELLOW)]  = ANSI(0,33),
      [GetNormalColour (BLUE)]    = ANSI(0,34),
      [GetNormalColour (MAGENTA)] = ANSI(0,35),
      [GetNormalColour (CYAN)]    = ANSI(0,36),
      [GetNormalColour (WHITE)]   = ANSI(0,37),
      [GetBoldColour   (BLACK)]   = ANSI(1,30),
      [GetBoldColour   (RED)]     = ANSI(1,31),
      [GetBoldColour   (GREEN)]   = ANSI(1,32),
      [GetBoldColour   (YELLOW)]  = ANSI(1,33),
      [GetBoldColour   (BLUE)]    = ANSI(1,34),
      [GetBoldColour   (MAGENTA)] = ANSI(1,35),
      [GetBoldColour   (CYAN)]    = ANSI(1,36),
      [GetBoldColour   (WHITE)]   = ANSI(1,37)
   }  -- end conversion table
end

init_ansi()

-- also provide the reverse of the extended_colours global table
colours_extended = {}
for i,v in ipairs(extended_colours) do
   colours_extended[v] = i
end

-- Returns a string with embedded ansi codes.
-- This can get confused if the player has redefined their color chart.
function stylesToANSI (styles)
   local line = {}
   local reinit = true
   for _,v in ipairs (styles) do
      if ANSI_colours[v.textcolour] then
         table.insert(line, ANSI_colours[v.textcolour])
      elseif colours_extended[v.textcolour] then -- use 256 color xterm ansi when necessary
         table.insert(line, ANSI(38,5,colours_extended[v.textcolour]))
      elseif reinit then -- limit performance damage
         reinit = false
         init_ansi()
      end
      table.insert(line, v.text)
   end
   table.insert(line, ANSI(0))
   return table.concat(line)
end

function chat_echo (name, line, wildcards)
    if wildcards [1] == false then
      echo = not echo  -- toggle
    else
      echo = wildcards [1]:lower () == " on"
    end -- if

    if echo then
        ColourNote ("yellow", "", "Echoing chats in main window ENABLED.")
    else
        ColourNote ("yellow", "", "Echoing chats in main window DISABLED.")
    end -- if
end -- function chat_echo

function chat_show (name, line, wildcards)
   WindowShow( Win, true )
   ColourNote ("yellow", "", "Chats window now shown. Type 'chats hide' to hide it.")
end -- function chat_show

function chat_hide (name, line, wildcards)
   WindowShow( Win, false )
   ColourNote ("yellow", "", "Chats window now hidden. Type 'chats show' to see it again.")
end -- function chat_hide

-- right click menu
function right_click_menu ()
    menustring ="Copy All To Clipboard|Change Font|Turn Echo "
    
    if echo then
        menustring = menustring .. "Off"
    else
        menustring = menustring .. "On"
    end -- if
    
    menustring = menustring.."|>Timestamp|No Timestamps|30 Aug 13:29:49|30 Aug 01:20:12PM|13:29:08|1:22:06 PM"
    result = WindowMenu (Win, 
        WindowInfo (Win, 14),  -- x position
        WindowInfo (Win, 15),   -- y position
        menustring) -- content
    if result == "Copy All To Clipboard" then
        GetAllBufferedMessages()
        ColourNote ("yellow", "", "All buffered messages copied to clipboard.")
    elseif result == "Change Font" then
        wanted_font = utils.fontpicker (BODY_FONT_NAME, BODY_FONT_SIZE) --font dialog
        if wanted_font then
            BODY_FONT_NAME = wanted_font.name
            BODY_FONT_SIZE = wanted_font.size
            SetVariable ("bodyfont", BODY_FONT_NAME)
            SetVariable ("font_size", BODY_FONT_SIZE)
            OnPluginInstall()
        end
    elseif result == "Turn Echo Off" then
        echo = false
        ColourNote ("yellow", "", "Echoing chats in main window DISABLED.")
    elseif result == "Turn Echo On" then
        echo = true
        ColourNote ("yellow", "", "Echoing chats in main window ENABLED.")
    elseif result == "No Timestamps" then
        timestamp = false
        ColourNote ("yellow", "", "Timestamps in communication window DISABLED.")
    elseif result == "30 Aug 13:29:49" then
        timestamp = true
        date_format = "[%d %b %H:%M:%S] "
        ColourNote ("yellow", "", "Timestamps in communication window ENABLED using format like '30 Aug 13:29:49'.")
    elseif result == "30 Aug 01:20:12PM" then
        timestamp = true
        date_format = "[%d %b %I:%M:%S%p] "
        ColourNote ("yellow", "", "Timestamps in communication window ENABLED using format like '30 Aug 01:20:12PM'.")
    elseif result == "13:29:08" then
        timestamp = true
        date_format = "[%H:%M:%S] "
        ColourNote ("yellow", "", "Timestamps in communication window ENABLED using format like '13:29:08'.")
    elseif result == "1:22:06 PM" then
        timestamp = true
        date_format = "[%I:%M:%S%p] "
        ColourNote ("yellow", "", "Timestamps in communication window ENABLED using format like '1:22:06 PM'.")
    end -- if
end -- function right_click_menu
]]>
</script>
</muclient>


[EDIT] Code tags added.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #31 on Mon 26 Oct 2015 07:43 PM (UTC)
Message
Yikes! Please use code tags! I'll see what I can do with this...

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #32 on Mon 26 Oct 2015 08:22 PM (UTC)
Message
Hi Fiendish,

I could always send you the link for the file, if you want :)
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #33 on Mon 26 Oct 2015 08:24 PM (UTC)
Message
Oh! Ahhh...I know what the problem is.

On Aardwolf, channels come in with some extra information on the front of the line, so that our triggers would never fire again on the new output because our output doesn't have that extra information, so our triggers don't match our output. But your output looks exactly like your input! So the trigger fires over and over and over...

Sigh. Of course.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #34 on Mon 26 Oct 2015 08:29 PM (UTC)
Message
There you go.

https://www.dropbox.com/s/83rbrjw1yzr42xb/Chat_Capture_Miniwindow_Reorx.xml?dl=0

Thank you for your help.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #35 on Mon 26 Oct 2015 08:33 PM (UTC)

Amended on Mon 26 Oct 2015 08:42 PM (UTC) by Fiendish

Message
Let's go back to the beginning. Technically, on your game it is just not safe to use omit_from_output with any of your chat triggers because there seems to be no apparent way to reliably differentiate them from other text. What you should actually be doing is not using any of the echo code at all because you should not be omitting from output.

But if you like where we're going so far and just want this to work and you're also really set on having the "echo off" feature, then you'll need to build into your triggers a little bit of memory so that you don't keep spitting out the same line over and over again.

Something like...


previous_line = nil
blocked_previous = false

-- Main capture routine
function chats (name, line, wildcards, styles)
   if not blocked_previous and previous_line == line then
      blocked_previous = true
      return
    end
    blocked_previous = false
    previous_line = line

   ... etc.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #36 on Mon 26 Oct 2015 08:43 PM (UTC)
Message
And thus the world is made whole again.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #37 on Mon 26 Oct 2015 09:17 PM (UTC)
Message
Fiendish,

Sorry about the question, but where do i put that and what exactly? So i may delete the echo part on the plugin?

Sorry about this, but i really need some guidance. I'm starting to learn a bit more.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #38 on Mon 26 Oct 2015 09:19 PM (UTC)
Message
replace

-- Main capture routine
function chats (name, line, wildcards, styles)


With

previous_line = nil
blocked_previous = false

-- Main capture routine
function chats (name, line, wildcards, styles)
   if not blocked_previous and previous_line == line then
      blocked_previous = true
      return
    end
    blocked_previous = false
    previous_line = line

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #39 on Mon 26 Oct 2015 09:30 PM (UTC)
Message
Fiendish,

The world is made whole again (using your words) :)

Thank you. All is working now. I really need to learn more about all this.
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #40 on Tue 27 Oct 2015 02:04 PM (UTC)
Message
Hi again Fiendish,

I did something wrong. Removed everything of the echo, and now nothing works. I then got the file back, with the echo, and now, it omits the chats on the main window and the hyperlinks go duplicated again.
Jesus, don't know what is wrong.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #41 on Tue 27 Oct 2015 02:37 PM (UTC)

Amended on Tue 27 Oct 2015 02:39 PM (UTC) by Fiendish

Message
Halig said:

Hi again Fiendish,

I did something wrong. Removed everything of the echo, and now nothing works.

Wasn't it working before? Were you just engaging in an academic exercise? :)

Quote:
I then got the file back, with the echo, and now, it omits the chats on the main window and the hyperlinks go duplicated again.
Jesus, don't know what is wrong.

I think you have two options:
1) Redo the process up to the point where it was working, as before. This preserves the (technically unsafe in your MUD's case) option to omit from output.
2) Start with the original file, delete the ColourTell section instead of replacing it with the Simulate stuff, and then remove all the "omit_from_output" lines from your triggers. This eliminates the (technically unsafe in your MUD's case) option to omit from output.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #42 on Tue 27 Oct 2015 03:05 PM (UTC)
Message
Thank you again Fiendish,

You're the man. I removed the omit_from_output from the triggers, and everything is fine now, and managed to get the echos off.

Now i will try to make a mini-window with some other information. Now i have the chat, the logins (when a player logs, it saves the name and the time) and another one that shows me all the players online, it refreshes from 5 minutes to 5 minutes.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


77,194 views.

This is page 3, subject is 3 pages long:  [Previous page]  1  2  3 

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]