Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

MUSH Client Scripting



  • LionasLionas Member, Historian Posts: 765 ✭✭✭✭✭
    Posts can only be edited within one hour of the original post time.
    I am the righteous one... 
    the claims are stated - it's the world I've created 
  • DeniDeni Member Posts: 7
    Oh, got it. So, uh, how about that highlighting?

    On a more difficult note, I also wanted to know how to visually show certain variables in the bar along the bottom of the screen. A system that I tested for someone in Lusternia years ago had this, and I always thought it'd be neat to show, say, what my current stance is as well as my current target.image
  • TsinghahlaTsinghahla Member Posts: 25 ✭✭✭
    edited April 2013
    This is what I use to send exits to my bar, shouldn't be too difficult to work out how to change it.

       match="You see exits leading*"

    This send 'You see exits leading to the blablabla' to my bar.

    I didn't quite understand what you were asking for with the highlight, but you can use the Regexp * to match anything. Example below:

       group="Highlighted Words"
       match="\bBalance Taken: *\b"


    This highlights: Balance Taken:(and everything that would come up here).
  • DeniDeni Member Posts: 7
    edited April 2013
    Hey, this bar thing is great!

    I don't really know anything practical about scripting, though, so next I was wondering if I could, say...make a variable and store what stance I'm in (Knifeplay) with it, then have that shown in the bar with a label, e.g. putting STANCE: GYANIS down there and then making a trigger to grab the new stance from the "You quickly flow into the x stance." and change the label.

    As for the highlighting, I just wanted to highlight some combat things, namely:
    1. Bruises forming on a limb
    2. Someone parrying something.
    Post edited by Deni on
  • TsinghahlaTsinghahla Member Posts: 25 ✭✭✭
    edited April 2013
    Well, depending on if it's Lua/Python/Jscript/etc it would be different. You should take a look at the Mushclient forums for expert advice, there are a lot of people willing to help in a way that you would learn how to do it yourself. Even Nick Gammon, the creator, usually pokes his head into forum posts and helps people out.

    You are on the right track already. You should have a way (just like making aliases or triggers) to make variables. You can use that to make a new one or let a trigger create it for you. You can either make a variable to track the stance (with the %0 wildcard for example) or just trigger the bar to send the stance you end up after your combo to it, so you can see what to do next (which seems a bit awkward unless you manual a lot).

    As for highlighting, just get the messages for the different limb statues, copy the message and put into a trigger. Don't need to change anything in it, just send to world and then use the colour option to use whatever you want.

    Same goes with parrying.

    You may want to use a separate window to view messages like parry or stances, or important things about your target.
  • IniarIniar AustraliaMember Posts: 3,213 ✭✭✭✭✭
    Kyrock said:

    H:372 M:430 eb>
    <---begin test--->
    miss: true
    a3: 0.6
    a4: 0.4
    a2: 0.9
    a1: 0.9
    miss: false
    a4: 0.5
    a3: 0.75
    a2: 0.875
    a1: 0.875
    miss: false
    a4: 0.5
    a3: 0.75
    a2: 0.875
    a1: 0.875
    miss: true
    a3: 0.6
    a4: 0.4
    a2: 0.9
    a1: 0.9
    miss: false
    a4: 0.5
    a3: 0.75
    a2: 0.875
    a1: 0.875
    miss: false
    a4: 0.5
    a3: 0.75
    a2: 0.875
    a1: 0.875
    possibilities: 6
    <-----end test------>

    This is awesome @Kyrock. I've pretty much copied it in Mudlet/Lua using really amateurish code.

    Question is, how will you account for a 'bottom-of-the-stack' affliction like the one Garryn describes in the Mage/Summoner revamp? 

    What if you cure: maidenhair, laurel1, laurel2 when you coul've gone laurel1, laurel2, laurelbottom? You can always re-eval after each prompt but by then  I'm assuming cure1 would've been fired off already.
    wit beyond measure is a Sidhe's greatest treasure
  • KyrockKyrock Member Posts: 35 ✭✭
    edited May 2013
    I'm not understanding. This predicts what -could- happen if you went a particular order of healing. What you do with the data is completely up to you. I would throw out any order of curing that produces misses, cause that would be a waste of resource. Then choose the path that would give you the highest chance to cure your affliction rated highest on your priority list. Also, the getOutcomes function is producing the wrong odds for this test data. a4, for instance, is only supposed to be .25 in all situations. The problem was that I was counting each occurrence of an element and dividing it by the total possible outcomes. The problem with this was that it was counting an element at a higher value of odds then it actually was. {a4,a1} in this case is 1/4 * 1/ code:
    probable: function probable (path,elements){
    //world.note("path: " + path.toString());
    //world.note("elements: " + elements.toString());
    this.odds = {};
    this.path = path.concat();
    this.miss = false;
    this.outcomes = [];
    Utilities.probable.prototype = {
    getOutcomes: function getOutcomes(path,pElements,step,odds) {
    //world.Note("path: " + path.toString());
    //if at the end of the path we have the resulting outcome of taking this path.
    if (step == path.length) {
    } else {
    var eventSpace = 0;
    for (var c = 0;c < pElements.length;c++) {
    for (var pC = 0;pC < path[step].length;pC++) {
    if (pElements[c] == path[step][pC]) {
    //world.note("eventSpace: " + eventSpace);
    var tempElements;
    var tempPath;
    var element;
    var missBool = true;
    //world.Note("odds before change: " + odds);
    odds *= (1/eventSpace);//<----this is the needed change
    for (var i = 0;i < path[step].length;i++) {
    //if path[step][i] in pElements modify it and recurse
    for (var j = 0;j < pElements.length;j++) {
    tempElements = pElements.concat();
    element = pElements[j];
    if (path[step][i] == element) {
    //world.Note("step: " + step);
    //odds *= (1/path[step].length);
    //world.Note("odds: " + odds);
    if (!this.odds[element]) {
    //world.Note("making odds: " + element + " = " + odds);
    this.odds[element] = odds;
    } else {
    //world.Note("adding odds: " + element + " += " + odds);
    this.odds[element] += odds;
    missBool = false;
    this.getOutcomes(path,tempElements,step + 1,odds);
    if (missBool) {
    this.miss = true;
    getOdds: function getOdds(){
    return this.odds;
    displayOdds: function displayOdds(){
    var str = "";
    for (var e in this.odds){
    if (str == "") {
    str = e + ": " + this.odds[e];
    } else {
    str += " " + e + ": " + this.odds[e];
  • KyrockKyrock Member Posts: 35 ✭✭
    P.S. this is also great for affliction tracking
  • DelrayneDelrayne Member Posts: 457 ✭✭✭
    Kyrock, I'm seriously going to have sit down and actually pick this apart then ask you a million laymens term questions.
  • LabilLabil Member Posts: 355 ✭✭✭
    Sometimes I worry I code too much for a game. Then I read any of Kyrock's posts, and I feel better.
  • TsinghahlaTsinghahla Member Posts: 25 ✭✭✭
    edited May 2013
    Not my original Plugin, just modified it slightly and put it in recently so feel free to do whatever you want with it. Chat capture in a wonderful window.

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE muclient>
    <!-- Bits of this plugin and ideas were borrowed and remixed from the MUSHclient community. and others. -->
    <!-- Modifications for Aardwolf and extra awesome sauce added by Fiendish with help from Orogan -->
    <!-- Adapated by Nick Gammon for Smaug and similar MUDs -->
    <!-- Adapted to work with Achaea by Ada -->
       purpose="Move chats to a miniwindow"
    <description trim="y">
      chats echo on    : echo chats in main window
      chats echo off   : do not echo chats
      chats show       : show chats window
      chats hide       : hide chats window
      LH-click a line to copy it to the clipboard
      RH-click main window to see menu of options
      Click title bar to drag window.
      match="^\(.*?\)\: (.+)$"
      match="^\<\<.*?\>\>\: (.+)$"
       match="^chats echo( on| off)?$"
       match="chats show"
       match="chats hide"
    require "movewindow"  -- load the movewindow.lua module
    require "copytable"
    BODY_FONT_NAME = "Courier New"
    MAX_LINES = 10000 -- how many lines to store in scrollback
    -- date_format = "[%d %b %H:%M:%S] "        -- [30 Aug 13:29:49]   date and time 24 hour
    -- date_format = "[%d %b %I:%M:%S%p] "  -- [30 Aug 01:20:12PM]     date and time 12 hour
    -- date_format = "[%H:%M:%S] "          -- [13:29:08]          time 24 hour
    -- date_format = "[%X] "                  -- [1:22:06 PM]            time 12 hour
    -- doing it this way makes them default to true the first time around
    timestamp = not (GetVariable("timestamp") == "false")
    echo = not (GetVariable("echo") == "false")
    date_format = GetVariable("date_format")
    WINDOW_WIDTH = tonumber(GetVariable("WINDOW_WIDTH"))
    WINDOW_HEIGHT = tonumber(GetVariable("WINDOW_HEIGHT"))
    -- offset of text from edge
    TEXT_INSET = 5
    -- where to store the chat line
    lines = {}  -- table of recent chat lines
    rawlines = {}
    lineStart = ""
    lineEnd = ""
    theme = {
       WINDOW_BACKGROUND = ColourNameToRGB ("#000000"), -- for miniwindow body
       WINDOW_BORDER = ColourNameToRGB("#E8E8E8"), -- for miniwindow body
       HIGHLIGHT=ColourNameToRGB("#FFFFFF"), -- for 3D surfaces
       FACE=ColourNameToRGB("#D4D0C8"), -- for 3D surfaces
       INNERSHADOW=ColourNameToRGB("#808080"), -- for 3D surfaces
       OUTERSHADOW = ColourNameToRGB("#404040"), -- for 3D surfaces
       BACK_FACE = ColourNameToRGB ("#E8E8E8"), -- for contrasting details
       DETAIL = ColourNameToRGB ("#000000"), -- for contrasting details
       TITLE_HEIGHT = 17, -- for miniwindow title area
       SUBTITLE_HEIGHT = 17, -- for miniwindow title area
       TITLE_FONT_NAME = "Dina", -- for miniwindow title area
       TITLE_FONT_SIZE = 8 -- for miniwindow title area
    }  -- end theme table
    -- replacement for WindowRectOp action 5, which allows for a 3D look while maintaining color theme
    -- Requires global theme.HIGHLIGHT, theme.FACE, theme.INNERSHADOW, and theme.OUTERSHADOW rgb colors to be set.
    function DrawThemed3DRect(Window, left, top, right, bottom)
       WindowRectOp(Window, miniwin.rect_fill, left, top, right, bottom, theme.FACE)
       WindowLine(Window, left, top, right, top, theme.HIGHLIGHT,
                   miniwin.pen_solid + miniwin.pen_endcap_flat, 1)
       WindowLine(Window, left, top, left, bottom, theme.HIGHLIGHT,
                   miniwin.pen_solid + miniwin.pen_endcap_flat, 1)
       WindowLine(Window, left, bottom-2, right, bottom-2, theme.INNERSHADOW,
                   miniwin.pen_solid + miniwin.pen_endcap_flat, 1)
       WindowLine(Window, right-2, top, right-2, bottom-2, theme.INNERSHADOW,
                   miniwin.pen_solid + miniwin.pen_endcap_flat, 1)
       WindowLine(Window, left, bottom-1, right, bottom-1, theme.OUTERSHADOW,
                   miniwin.pen_solid + miniwin.pen_endcap_flat, 1)
       WindowLine(Window, right-1, top, right-1, bottom-1, theme.OUTERSHADOW,
                   miniwin.pen_solid + miniwin.pen_endcap_flat, 1)
    function DrawThemedResizeTag(Window, x1, y1, size)
       local x2, y2 = x1+size, y1+size
       DrawThemed3DRect(Window, x1, y1, x2, y2)
       local m = 2
       local n = 2
       while (x1+m+2 <= x2-3 and y1+n+1 <= y2-4) do
           WindowLine(Window, x1+m+1, y2-4, x2-3, y1+n, theme.HIGHLIGHT,
                       miniwin.pen_solid, 1)
           WindowLine(Window, x1+m+2, y2-4, x2-3, y1+n+1, theme.INNERSHADOW,
                       miniwin.pen_solid, 1)
           m = m+3
           n = n+3
    end  -- function DrawThemedResizeTag
    Win = GetPluginID()
    font_height = ""
    line_height = ""
    windowinfo = ""
    startx = ""
    starty = ""
    function ResizeMoveCallback()
       posx, posy = WindowInfo (Win, 17), WindowInfo (Win, 18)
       if (WindowTextWidth(Win, "titlefont"..Win, "WWWCOMMUNICATION")+2*SCROLL_BAR_WIDTH <= WINDOW_WIDTH+posx-startx) then
           WINDOW_WIDTH = WINDOW_WIDTH+posx-startx
           startx = posx
       end  -- if
       if (3*SCROLL_BAR_WIDTH+10+line_height+theme.TITLE_HEIGHT <= WINDOW_HEIGHT+posy-starty) then
           WINDOW_HEIGHT = WINDOW_HEIGHT+posy-starty
           starty = posy
       end -- if
    end -- function ResizeMoveCallback
    function ResizeReleaseCallback()
       WINDOW_HEIGHT = theme.TITLE_HEIGHT+(line_height*(WINDOW_LINES-1))+3
    end  -- ResizeReleaseCallback
    function OnPluginInstall()
       -- Dummy window to get font characteristics
       check (WindowCreate (Win, 0, 0, 1, 1, 0, 0, theme.WINDOW_BACKGROUND) )
       check (WindowFont(Win, "bodyfont"..Win, BODY_FONT_NAME, BODY_FONT_SIZE))
       check (WindowFont(Win, "titlefont"..Win, theme.TITLE_FONT_NAME, theme.TITLE_FONT_SIZE))
       font_height = WindowFontInfo (Win, "bodyfont"..Win, 1) -  WindowFontInfo (Win, "bodyfont"..Win, 4) + 1
       line_height = font_height+1
       font_width = WindowTextWidth (Win, "bodyfont"..Win, "W")
       -- install the window movement handler, get back the window position
       windowinfo = movewindow.install (Win, miniwin.pos_top_right, miniwin.create_absolute_location, true)
       -- check for Echo/Timestamp/date_format/window size (in pixels) variables, if not there, set them
       if date_format == nil then
           date_format = "[%d %b %H:%M:%S] "
       end -- if
       if WINDOW_WIDTH == nil then
           WINDOW_WIDTH = (font_width*80)+SCROLL_BAR_WIDTH -- 80 columns
       if WINDOW_HEIGHT == nil then
           WINDOW_HEIGHT = theme.TITLE_HEIGHT+(line_height*6)+2 -- 6 lines
       end -- if
       OnPluginEnable ()  -- do initialization stuff
    end -- function OnPluginInstall
    function init(firstTime)
       -- how many lines and columns will fit?
       WINDOW_LINES = math.ceil((WINDOW_HEIGHT-theme.TITLE_HEIGHT)/line_height)
       WINDOW_COLUMNS = math.ceil((WINDOW_WIDTH-SCROLL_BAR_WIDTH)/font_width)
       if firstTime then
           WindowCreate(Win, windowinfo.window_left, windowinfo.window_top, WINDOW_WIDTH, WINDOW_HEIGHT, windowinfo.window_mode, windowinfo.window_flags, theme.WINDOW_BACKGROUND)
           -- catch for right-click menu and line selection
           WindowAddHotspot(Win, "textarea", 0, theme.TITLE_HEIGHT, WINDOW_WIDTH-SCROLL_BAR_WIDTH,0,
               "", "", "MouseDown", "CancelMouseDown", "MouseUp", "",
               miniwin.cursor_ibeam, 0)
           -- add the drag handler so they can move the window around
           movewindow.add_drag_handler (Win, 0, 0, 0, theme.TITLE_HEIGHT)
           -- scroll bar up/down buttons
               "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "",
               miniwin.cursor_hand, 0)
               "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "",
               miniwin.cursor_hand, 0)
           -- add the resize widget hotspot
               "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "",
               miniwin.cursor_nw_se_arrow, 0)
           WindowDragHandler(Win, "resizer", "ResizeMoveCallback", "ResizeReleaseCallback", 0)
           WindowMoveHotspot(Win, "textarea", 0, theme.TITLE_HEIGHT, WINDOW_WIDTH-SCROLL_BAR_WIDTH, 0)
           WindowMoveHotspot(Win, "up", WINDOW_WIDTH-SCROLL_BAR_WIDTH, theme.TITLE_HEIGHT, 0, theme.TITLE_HEIGHT+SCROLL_BAR_WIDTH)
       end -- if
       WindowShow(Win, true)
       if (firstTime == true) then
           lines = {}
           for _,styles in ipairs(rawlines) do
           end  -- for each line
       end -- if
       lineStart = math.max(1, #lines-WINDOW_LINES+2)
       lineEnd = math.max(1, #lines)
    end  -- function init
    function OnPluginClose ()
       -- if enabled
       if GetPluginInfo (GetPluginID(), 17) then
       end -- if enabled
    end -- function OnPluginClose
    function OnPluginEnable ()
       WindowShow (Win, true)
    end -- function OnPluginEnable
    function OnPluginSaveState ()
       -- save window current location for next time
       SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID(), 17)))
       movewindow.save_state (Win)
       -- save echo/timestamp status
       SetVariable ("echo", tostring (echo))
       SetVariable ("timestamp", tostring (timestamp))
       SetVariable("date_format", date_format)
       SetVariable("WINDOW_WIDTH", WINDOW_WIDTH)
    end -- function OnPluginSaveState
    function OnPluginDisable ()
       WindowShow( Win, false )
    end -- function OnPluginDisable
    -- display one line
    function Display_Line (line, styles)
     local left    = TEXT_INSET
     local top     = theme.TITLE_HEIGHT + (line * line_height) + 1
     local bottom  = top + line_height
     local font    = "bodyfont" .. Win
     if backfill then
         WindowRectOp (Win, miniwin.rect_fill, 1, top, WINDOW_WIDTH - SCROLL_BAR_WIDTH, bottom, ColourNameToRGB("#333333"))
     end -- backfill
     if (styles) then
       for _, style in ipairs (styles) do
         local width = WindowTextWidth (Win, font, style.text) -- get width of text
         local right = left + width
         WindowRectOp (Win, miniwin.rect_fill, left, top, right, bottom, style.backcolour)  -- draw background
         WindowText (Win, font, style.text, left, top, 0, 0, style.textcolour)  -- draw text
         left = left + width  -- advance horizontally
       end -- for each style run
     end -- if  styles
    end -- Display_Line
    -- display all visible lines
    function writeLines()
       for count = lineStart, lineEnd do
           Display_Line( count-lineStart, lines[count][1], false )
       end  -- for each line
    end  -- function writeLines
    -- clear and redraw
    function refresh()
       WindowRectOp(Win, miniwin.rect_fill, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, theme.WINDOW_BACKGROUND)
    end  -- function refresh
    barPos = ""
    barSize = ""
    totalSteps = ""
    function drawStuff()
       -- draw border
       WindowRectOp (Win, miniwin.rect_frame, 0, 0, 0, 0, theme.WINDOW_BORDER)
       -- Title bar
       DrawThemed3DRect(Win, 0, 0, WINDOW_WIDTH, theme.TITLE_HEIGHT)
       -- Title text
       WindowText(Win, "titlefont"..Win, "COMMUNICATION", ((WINDOW_WIDTH)-(7.5*line_height))/2, (theme.TITLE_HEIGHT-line_height)/2, WINDOW_WIDTH, theme.TITLE_HEIGHT, theme.DETAIL, false)
       if #lines >= 1 then
       end -- if
       -- Scrollbar base
       WindowRectOp(Win, miniwin.rect_fill, WINDOW_WIDTH-SCROLL_BAR_WIDTH, theme.TITLE_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, theme.BACK_FACE) -- scroll bar background
       WindowRectOp(Win, miniwin.rect_frame, WINDOW_WIDTH-SCROLL_BAR_WIDTH+1, SCROLL_BAR_WIDTH+theme.TITLE_HEIGHT+1, WINDOW_WIDTH-1, WINDOW_HEIGHT-(2*SCROLL_BAR_WIDTH)-1, theme.DETAIL) -- scroll bar background inset rectangle
       -- draw triangle in up button
       points = string.format ("%i,%i,%i,%i,%i,%i", (WINDOW_WIDTH-SCROLL_BAR_WIDTH)+2, theme.TITLE_HEIGHT+8,(WINDOW_WIDTH-SCROLL_BAR_WIDTH)+6, theme.TITLE_HEIGHT+4,(WINDOW_WIDTH-SCROLL_BAR_WIDTH)+10, theme.TITLE_HEIGHT+8)
       WindowPolygon (Win, points,
           theme.DETAIL, miniwin.pen_solid, 1,   -- pen (solid, width 1)
           theme.DETAIL, miniwin.brush_solid, --brush (solid)
           true, --close
           false)  --alt fill
       -- draw triangle in down button
       WindowPolygon (Win, points,
           theme.DETAIL, miniwin.pen_solid, 1,   -- pen (solid, width 1)
           theme.DETAIL, miniwin.brush_solid, --brush (solid)
           true, --close
           false) --alt fill
       -- The scrollbar position indicator
       totalSteps = #lines
       if (totalSteps <= WINDOW_LINES-1) then totalSteps = 1 end
       if (not dragscrolling) then
           stepNum = lineStart-1
           barPos = SCROLL_BAR_WIDTH +theme.TITLE_HEIGHT+ ((SCROLL_BAR_HEIGHT/totalSteps) * stepNum)
           barSize = (SCROLL_BAR_HEIGHT/math.max(WINDOW_LINES-1,totalSteps)) * (WINDOW_LINES-1)
           if barSize < 10 then
               barSize = 10
           if barPos+barSize > SCROLL_BAR_WIDTH+theme.TITLE_HEIGHT+SCROLL_BAR_HEIGHT then
               barPos = SCROLL_BAR_WIDTH+theme.TITLE_HEIGHT+SCROLL_BAR_HEIGHT - barSize
           WindowAddHotspot(Win, "scroller", (WINDOW_WIDTH-SCROLL_BAR_WIDTH), barPos, WINDOW_WIDTH, barPos+barSize,
                           "MouseOver", "CancelMouseOver", "MouseDown", "CancelMouseDown", "MouseUp", "",
                           miniwin.cursor_hand, 0)
           WindowDragHandler(Win, "scroller", "ScrollerMoveCallback", "ScrollerReleaseCallback", 0)
       end  -- if
       DrawThemed3DRect(Win, WINDOW_WIDTH-SCROLL_BAR_WIDTH, barPos, WINDOW_WIDTH, barPos+barSize)
       -- resizer tag
    end  -- function drawStuff
    function ScrollerMoveCallback(flags, hotspot_id)
       mouseposy = WindowInfo(Win, 18)
       windowtop = WindowInfo(Win, 2)
       barPos = math.max(mouseposy-windowtop+clickdelta, SCROLL_BAR_WIDTH+theme.TITLE_HEIGHT)
       if barPos > WINDOW_HEIGHT-(SCROLL_BAR_WIDTH*2)-barSize then
           barPos = WINDOW_HEIGHT-(SCROLL_BAR_WIDTH*2)-barSize
           lineStart = math.max(1,#lines-WINDOW_LINES+2)
           lineEnd = #lines
           lineStart = math.floor((barPos-SCROLL_BAR_WIDTH-theme.TITLE_HEIGHT)/(SCROLL_BAR_HEIGHT/totalSteps)+1)
           lineEnd = math.min(lineStart + WINDOW_LINES-2, #lines)
       end -- if
    end  -- function ScrollerMoveCallback
    function ScrollerReleaseCallback(flags, hotspot_id)
       dragscrolling = false
    end  -- function ScrollerReleaseCallback
    function fillBuffer(rawstyles)
       local avail = 0
       local line_styles
       local beginning = true
       -- keep pulling out styles and trying to fit them on the current line
       local styles = copytable.deep (rawstyles)
       local remove = table.remove
       local insert = table.insert
       while #styles > 0 do
           if avail <= 0 then -- no room available? start new line
               -- remove first line if filled up
               if #lines >= MAX_LINES then
                   remove (lines, 1)
               end -- if
               avail = WINDOW_WIDTH - (TEXT_INSET * 2) - 9
               line_styles = {}
               add_line( line_styles, beginning )
               beginning = false
           end -- line full
           -- get next style, work out how long it is
           local style = remove (styles, 1)
           local width = WindowTextWidth (Win, "bodyfont"..Win, style.text)
           -- if it fits, copy whole style in
           if width <= avail then
               insert (line_styles, style)
               avail = avail - width
           else -- otherwise, have to split style
               -- look for trailing space (work backwards). remember where space is
               local col = style.length - 1
               local split_col
               -- keep going until out of columns
               while col > 1 do
                   width = WindowTextWidth (Win, "bodyfont"..Win, style.text:sub (1, col))
                   if width <= avail then
                       if not split_col then
                           split_col = col  -- in case no space found, this is where we can split
                       end -- if
                       -- see if space here
                       if style.text:sub (col, col) == " " then
                           split_col = col
                       end -- if space
                   end -- if will now fit
                   col = col - 1
               end -- while
               -- if we found a place to split, use old style, and make it shorter. Also make a copy and put the rest in that
               if split_col then
                   insert (line_styles, style)
                   local style_copy = copytable.shallow (style)
                   style.text = style.text:sub (1, split_col)
                   style.length = split_col
                   style_copy.text = style_copy.text:sub (split_col + 1)
                   style_copy.length = #style_copy.text
                   insert (styles, 1, style_copy)
               elseif next (line_styles) == nil then
                   insert (line_styles, style)
                   insert (styles, 1, style)
               end -- if
               avail = 0  -- now we need to wrap
           end -- if could not fit whole thing in
       end -- while we still have styles over
    end  -- function fillBuffer
    -- Main capture routine
    function chats (name, line, wildcards, styles)
       -- echo in this world as well if the user wants
       if echo then
           for _, v in ipairs (styles) do
               ColourTell (RGBColourToName (v.textcolour),RGBColourToName (v.backcolour),v.text)
           end -- for each style run
           Note ("")  -- wrap up line
       end -- echo wanted
       -- inject timestamp if wanted
       if timestamp then
           local tstamp = (date_format)
           table.insert (styles, 1, {
             text = tstamp,
             textcolour  = ColourNameToRGB (TIMESTAMP_TEXT_COLOUR),
             backcolour = ColourNameToRGB (TIMESTAMP_BACK_COLOUR),
             length = string.len (tstamp),
             style = 0,
           } )
       end -- if
       -- store the raw lines for use during resizing
       if #rawlines >= MAX_LINES then
           table.remove(rawlines, 1)
       table.insert(rawlines, styles)
       refresh( )
    end -- function chats
    function add_line ( line, is_beginning_of_message )
       -- add new line
       table.insert (lines, {line, false} )
       lines[#lines][2] = is_beginning_of_message
       -- advance the count
       if #lines >= WINDOW_LINES then
           lineStart = lineStart + 1
       end -- if
       if #lines > 1 then
           lineEnd = lineEnd + 1
       end -- if
    end -- function add_line
    keepscrolling = false
    require "wait"
    function scrollbar(calledBy)
       wait.make (function()
           while keepscrolling == true do
               if calledBy == "up" then
                   if (lineStart > 1) then
                       lineStart = lineStart - 1
                       lineEnd = lineEnd - 1
                       WindowRectOp(Win, miniwin.rect_draw_edge, (WINDOW_WIDTH-SCROLL_BAR_WIDTH), theme.TITLE_HEIGHT, 0, theme.TITLE_HEIGHT+SCROLL_BAR_WIDTH,
                           miniwin.rect_edge_sunken,  miniwin.rect_edge_at_all + miniwin.rect_option_fill_middle) -- up arrow pushed
                       points = string.format ("%i,%i,%i,%i,%i,%i", (WINDOW_WIDTH-SCROLL_BAR_WIDTH)+3, theme.TITLE_HEIGHT+9,(WINDOW_WIDTH-SCROLL_BAR_WIDTH)+7, theme.TITLE_HEIGHT+5,(WINDOW_WIDTH-SCROLL_BAR_WIDTH)+11, theme.TITLE_HEIGHT+9)
                       WindowPolygon (Win, points,
                           theme.DETAIL, miniwin.pen_solid, 1, -- pen (solid, width 1)
                           theme.DETAIL, miniwin.brush_solid, -- brush (solid)
                           true, -- close
                           false) -- alt fill
                       keepscrolling = false
               elseif calledBy == "down" then
                   if (lineEnd < #lines) then
                       lineStart = lineStart + 1
                       lineEnd = lineEnd + 1
                   WindowRectOp(Win, miniwin.rect_draw_edge, (WINDOW_WIDTH-SCROLL_BAR_WIDTH), WINDOW_HEIGHT-(SCROLL_BAR_WIDTH*2), 0, WINDOW_HEIGHT-SCROLL_BAR_WIDTH-1,
                       miniwin.rect_edge_sunken,  miniwin.rect_edge_at_all + miniwin.rect_option_fill_middle) -- down arrow pushed
                   points = string.format ("%i,%i,%i,%i,%i,%i", (WINDOW_WIDTH-SCROLL_BAR_WIDTH)+3, (WINDOW_HEIGHT-SCROLL_BAR_WIDTH)-11,(WINDOW_WIDTH-SCROLL_BAR_WIDTH)+7, (WINDOW_HEIGHT-SCROLL_BAR_WIDTH)-7, (WINDOW_WIDTH-SCROLL_BAR_WIDTH)+11,(WINDOW_HEIGHT-SCROLL_BAR_WIDTH)-11) -- draw triangle in up button
                   WindowPolygon (Win, points,
                       theme.DETAIL, miniwin.pen_solid, 1, -- pen (solid, width 1)
                       theme.DETAIL, miniwin.brush_solid, -- brush (solid)
                       true, -- close
                       false) -- alt fill
                       keepscrolling = false
               end -- if
           end -- while keepscrolling
       end)  -- wait.make
    end  -- function scrollbar
    function GetLineText (styles)
     local t = {}
     for _, style in ipairs (styles) do
       table.insert (t, style.text)
     end -- for
     return table.concat (t)
    end -- function GetLineText
    function GetAllBufferedMessages()
       local t = {}
       for _,styles in ipairs(rawlines) do
         table.insert (t, GetLineText (styles))
       end -- for
    end -- function GetAllBufferedMessages
    function GetBufferedMessage(xpos, ypos)
       windowline = math.floor(((ypos-theme.TITLE_HEIGHT)/line_height)+1)-1
       text = ""
       if (#lines > windowline) then
           local line = windowline+lineStart
           -- go to beginning of message
           while lines[line][2] ~= true and line > 1 do
               line = line - 1
           end -- while
           -- first line
           local styles = copytable.deep(lines[line][1])
           if (line-lineStart+1 > 0) then
               Display_Line (line-lineStart, styles, true)
           end -- if
           text = GetLineText (styles)
           -- remaining lines
           line = line + 1
           while line <= #lines and lines[line][2] ~= true do
               local styles = copytable.deep(lines[line][1])
               if (line-lineStart+1 > 0 and line-lineStart < WINDOW_LINES) then
                   Display_Line (line-lineStart, styles, true)
               text = text.. GetLineText (styles)
               line = line + 1
           end -- while
       end -- if
    end  -- function GetBufferedMessage
    function MouseOver(flags, hotspot_id)
       keepscrolling = false
    end  -- function MouseOver
    function CancelMouseOver(flags, hotspot_id)
       keepscrolling = false
    end  -- function CancelMouseOver
    function MouseDown(flags, hotspot_id)
       if (hotspot_id == "resizer") then
           startx, starty = WindowInfo (Win, 17), WindowInfo (Win, 18)
       elseif (hotspot_id == "scroller") then
           clickdelta = WindowHotspotInfo(Win, "scroller", 2)-WindowInfo (Win, 15)
           dragscrolling = true
       elseif (hotspot_id == "textarea" and flags == miniwin.hotspot_got_lh_mouse) then
           GetBufferedMessage(WindowInfo(Win, 14), WindowInfo(Win,15))
           keepscrolling = true
       end -- if
    end  -- function MouseDown
    function CancelMouseDown(flags, hotspot_id)
       keepscrolling = false
    end  -- function CancelMouseDown
    function MouseUp(flags, hotspot_id)
       if (hotspot_id == "textarea" and flags == miniwin.hotspot_got_rh_mouse) then
           -- build menu for current state
       end -- if
       keepscrolling = false
    end  -- function MouseUp
    function chat_echo (name, line, wildcards)
       if wildcards [1] == false then
         echo = not echo  -- toggle
         echo = wildcards [1]:lower () == " on"
       end -- if
       if echo then
           ColourNote ("yellow", "", "Echoing chats in main window ENABLED.")
           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"
           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
           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 =
               BODY_FONT_SIZE = wanted_font.size
               SetVariable ("bodyfont", BODY_FONT_NAME)
               SetVariable ("font_size", BODY_FONT_SIZE)
       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
  • AzefelAzefel SingaporeMember Posts: 730 ✭✭✭✭
    there are worse hobbies to have
  • OrmOrm Member Posts: 7
    edited June 2013
    i pretty much did what jorachim said up there except a little different. i put a post up with some screens of what i was workin' on.

    also: dang, that's some pretty sweet codes kyrock
  • AhkanAhkan TexasMember Posts: 2,375 ✭✭✭✭✭
    Posting for Vasharr, please reply to him or use a message.

    "I'm looking for anyone who would be willing to help put together an affliction tracker. I've never attempted to make one of these before this, finding some difficulties since it's so different from everything else I've had to make for combat. Some help to get me going in the right direction would be appreciated very much, and if you are willing to help contacting me directly would be most helpful I think. Thanks in advance!"
  • AleutiaAleutia Member, Historian Posts: 363 ✭✭✭✭✭
    Hey everyone, I'm posting on behalf of Vasharr. Any help you can offer would be appreciated! If you'd rather post here I can relay any posts to Vasharr in game. Thanks again!

    Message #13382 Sent By: Vasharr         Received On: 5/06/2015/16:33
    "If possible, will someone contact me, Vasharr, through message or tell? I lost a few triggers when my previous laptop suffered a tragic end. Using lua, I need to replace one that got rid of my prompt appearing between each line, and left it only at the bottom of the screen. I can't remember how I did this before, so any help would be appreciated. Thanks!"
  • LytheLythe Member Posts: 5
    Anyone still active I can turn toward for help?
    Picture by Janet Chui.

  • SeptusSeptus Member, Beta Testers Posts: 781 ✭✭✭✭✭
    What did you need?
  • SeptusSeptus Member, Beta Testers Posts: 781 ✭✭✭✭✭

    Also, I only just noticed Vasharr's question, so (very delayed), if still relevant:

    You need a regex for your prompt line. Most people can help you with this if you don't know how to do it already, but a trivial example might be something like:

    Line: 480h, 480m, 0bleed
    Trigger: ^(\d+)h, (\d+)m, (\d+)bleed$

    Check the regular expression box in that trigger, and set it to send to script in the send to dropdown box.

    in the send box, put:

    Info("%1h %2m %3b")

    You can format the stuff inside the Info() call in whatever way you find best. The %1/%2/%3 equate to the groups captured in the trigger above (each captured item is whatever is between the ()s). Note the capitalisation on the InfoClear and Info calls, this is important.

    Once you have made that trigger, open the view menu (alt+f then either v or two arrows to the right), and make sure that info bar is checked. You might want to make sure all the others are unchecked in that menu; they can be a bit of a pain to navigate and can clog up the output window.

    Finally, hit alt+5. If that doesn't do anything (some people have shortcuts disabled), you'll need to navigate to the output settings the long way. To do this, hit alt+f, then scroll 6 times to the right with the arrows. You'll be in the game menu. From here open the configure sub menu (its the first thing in the list). Scroll down until you find the output option and hit enter.

    Once in the output menu, hit shift+tab until you find the option "Convert IAC EOR/GA to new line", and check it (if its not already). Now tab to close and hit enter.

    The prompt you defined in your trigger should now show up as the bottom line of your buffer when in scroll mode (either jaws or invisible cursor).

    Can message me if you have any problems, you might have noticed I don't check this thread that often.

  • SeptusSeptus Member, Beta Testers Posts: 781 ✭✭✭✭✭
    You'll also need to check "omit from output" in the prompt trigger. That'll make it so only the one at the bottom shows up.
  • LytheLythe Member Posts: 5
    Needed help last night and no one had a clue. Just making sure I'm not the only person that didn't switch to Mudlet.
    Picture by Janet Chui.

  • SeptusSeptus Member, Beta Testers Posts: 781 ✭✭✭✭✭

    I get asked a lot how you use gmcp with mushclient. Most people download one of the gmcp plugins then don't really know what to do with it/see it in action/etc. As I've never used any of said plugins, I'm not much use on elaborating.

    I decided to just pull my gmcp handler out of my system and paste it here. Its mostly commented out (there are a lot of system specific things not included), but the general logic flow might help some people, and in its current operational form (with all the comments), it will just function as a standard gmcp handler that you can use if that's your thing.

    - This is python, not lua. Take your 1 indexing and backwards nonequality operator somewhere else.
    - I have basically slapped in pass and return statements so this will compile with all the function bodies commented out.
    - This is old. I've not needed to really relook at how I handle this since some time in 2012, and the only real update is the addition of gmcp afflictions/defences. There may be some strange things, I have no idea.
    - I may have missed a comment somewhere, I just grabbed this on a break before forgetting, so just in the event of a missing reference error or something if someone does decide to run it for whatever reason.
    - You need to do gmcp from within a plugin in mushclient, the global script space does not have access to telnet subnegotiation callbacks.
    - I use "s instead of 's, because 's are not as noticeable via my software. All complaints shall be similarily noted and ignored.
    - If you ask me "why did you do x this way", I shall preemptively tell you I have no idea and don't remember.


  • SeptusSeptus Member, Beta Testers Posts: 781 ✭✭✭✭✭

    Oops, didn't run my script to clean up files before posting. I write imperian scripts with tabs and stuff to facilitate fast editing while mid fight or w/e. If that made your eyes bleed, properly formatted version at:

  • AnetteAnette Member Posts: 814 ✭✭✭
    Septus said:

    - If you ask me "why did you do x this way", I shall preemptively tell you I have no idea and don't remember.

    A programmer after my own heart.
  • SeptusSeptus Member, Beta Testers Posts: 781 ✭✭✭✭✭

    A couple people lately asked me how you pull info out of the imperian API in mushclient with python, since most of the examples on here are in lua. Making the output more visually appealing is on you!

  • JorachimJorachim Member Posts: 83 ✭✭✭
    Here's how to do it in Lua using MUSH Client:

    Alias: ^get (.*?)$ with regex. Obviously could be made simpler
    socket = require("socket.http")
    local test, err = socket.request("")
    data = json.decode(test)
    tprint should dump the character's data.
    Someone powerful says, "Its broken. No more pulling the guillotine."
  • NolaanNolaan Member Posts: 1
    Alright for the life of me I can't get blank lines to return a prompt. Any ideas? thanks!
  • MereisMereis Member Posts: 229 ✭✭✭
    What Nolaan wants to do is the equivalent of "Force new line on empty commands" setting in Mudlet.
    currently tentatively active
    (may vanish for periods of time)
  • BronachBronach BronachMember Posts: 44
    Hi, does anyone know how to export 17 lines of the regex-matched ASCII map (^(--- Area).*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*$) to notepad? Given that the pattern matches sample text in the regex101 website, I'm still not getting in printing (e.g., send %1) the way I want. Any ideas? Thanks.
  • EoghanEoghan Member, Immortal Posts: 1,073 mod
    I'm not familiar with MUSH Client regex triggers, but to my uneducated eyes it appears that you don't have the map contents in a capture group to fill in %1.
    Like what we're doing? Why not take a second to vote? Vote for Imperian at
  • BronachBronach BronachMember Posts: 44
    Thanks for the reply. By capture group, I understand feeding the regex hits into an array, then build a "for i= 1 to 17" script to send the 17 full lines in array (i) as %1. I'll give that a go. Btw, if any one of the folks in this thread catches me awake, alcoholic drinks and/or advice would be appreciated.
Sign In or Register to comment.