Advertisement
Guest User

chat window stuff

a guest
Jul 25th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 0 0
  1. -- first, add a script named sysConnectionEvent, with the registered event handler sysConnectionEvent, and the following body:
  2.  
  3. function sysConnectionEvent()
  4.   showCommunicationWindow()
  5. end
  6.  
  7. -- next, add a script named sysWindowResizeEvent, with the registered event handler sysWindowResizeEvent, and the following body:
  8.  
  9. function sysWindowResizeEvent(event, x, y)
  10.   showCommunicationWindow()
  11. end
  12.  
  13. -- now add a script named showCommunicationWindow, with the following body:
  14.  
  15. function showCommunicationWindow()
  16.   local windowWidth, windowHeight = getMainWindowSize()
  17.   local fontSize = 8
  18.   local width,height = calcFontSize(fontSize)
  19.   local consoleWidth = width * 80
  20.   local consoleHeight = height * 30
  21.   local scrollBarWidth = 15
  22.  
  23.   createMiniConsole("communication", windowWidth-consoleWidth-scrollBarWidth,0,consoleWidth,consoleHeight)
  24.   setBackgroundColor("communication",0,0,0,255)
  25.   setMiniConsoleFontSize("communication", fontSize)
  26.   setWindowWrap("communication", 80)
  27. end
  28.  
  29. -- one more script, this one named trackCommunication, with the following body:
  30.  
  31. function trackCommunication(channel, user, message)
  32.   local color = "<white:black>"
  33.   local prefix = ""
  34.   local timestamp = os.date("%H:%M:%S")
  35.   if channel == "gossip" then
  36.     color = "<purple:black>"
  37.     if user == "you" then
  38.       prefix = "You gossip"
  39.     else
  40.       prefix = string.format("%s gossips", user)
  41.     end
  42.   elseif channel == "tell" then
  43.     color = "<red:black>"
  44.     prefix = string.format("%s tells you", user)
  45.   elseif channel == "you-tell" then
  46.     color = "<red:black>"
  47.     prefix = string.format("You tell %s", user)
  48.   end
  49.   local text = string.format("%s%s %s: %s\n", color, timestamp, prefix, message)
  50.   cecho("communication", text)
  51. end
  52.  
  53. -- if you want to mess with the colors, or how things are displayed, you can muck about with the trackCommunication function to do so. next, we'll need some triggers to track things. here are some examples:
  54.  
  55.  
  56. -- for your gossips, a trigger with the perl regex:
  57.  
  58. ^(?:\d+H \d+M \d+V \d+XP (?:[A-Z]+ )*(?: \[.+\] )?\> )?You gossip, \'(.*)\'
  59.  
  60. -- and body:
  61.  
  62. trackCommunication("gossip", "you", matches[2])
  63.  
  64. -- for other peoples' gossips, a trigger with the perl regex:
  65.  
  66. ^(?:\d+H \d+M \d+V \d+XP (?:[A-Z]+ )*(?: \[.+\] )?\> )?(\w+) gossips, \'(.*)\'
  67.  
  68. -- and body:
  69.  
  70. trackCommunication("gossip", matches[2], matches[3])
  71.  
  72.  
  73. -- for your tells, a trigger with the perl regex:
  74.  
  75. ^(?:\d+H \d+M \d+V \d+XP (?:[A-Z]+ )*(?: \[.+\] )?\> )?You tell (\w+), \'(.*)\'
  76.  
  77. -- and body:
  78.  
  79. trackCommunication("you-tell", matches[2], matches[3])
  80.  
  81. -- for other peoples' tells, a trigger with the perl regex:
  82.  
  83. ^(?:\d+H \d+M \d+V \d+XP (?:[A-Z]+ )*(?: \[.+\] )?\> )?(\w+) tells you, \'(.*)\'
  84.  
  85. -- and body:
  86.  
  87. trackCommunication("tell", matches[2], matches[3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement