Guest User

Untitled

a guest
Dec 8th, 2016
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. If the label callbacks ever decide to start taking a function which is part of a table, 0then this will change.
  3. Or if it's modified to take actual functions. Anonymouse function clickcallback would be awfully nice.
  4. ]]
  5.  
  6. function demonnicChatSwitch(chat)
  7. local r = demonnic.chat.config.inactiveColors.r
  8. local g = demonnic.chat.config.inactiveColors.g
  9. local b = demonnic.chat.config.inactiveColors.b
  10. local newr = demonnic.chat.config.activeColors.r
  11. local newg = demonnic.chat.config.activeColors.g
  12. local newb = demonnic.chat.config.activeColors.b
  13. local oldchat = demonnic.chat.currentTab
  14. if demonnic.chat.currentTab ~= chat then
  15. demonnic.chat.windows[oldchat]:hide()
  16. demonnic.chat.tabs[oldchat]:setColor(r,g,b)
  17. demonnic.chat.tabs[oldchat]:echo(oldchat, demonnic.chat.config.inactiveTabText, "c")
  18. if demonnic.chat.config.blink and demonnic.chat.tabsToBlink[chat] then
  19. demonnic.chat.tabsToBlink[chat] = nil
  20. end
  21. if demonnic.chat.config.blink and chat == demonnic.chat.config.Alltab then
  22. demonnic.chat.tabsToBlink = {}
  23. end
  24. end
  25. demonnic.chat.tabs[chat]:setColor(newr,newg,newb)
  26. demonnic.chat.tabs[chat]:echo(chat, demonnic.chat.config.activeTabText, "c")
  27. demonnic.chat.windows[chat]:show()
  28. demonnic.chat.currentTab = chat
  29. end
  30.  
  31. function demonnic.chat:resetUI()
  32. demonnic.chat.container = Geyser.Container:new(demonnic.chat[demonnic.chat.config.location]())
  33. demonnic.chat.tabBox = Geyser.HBox:new({
  34. x=0,
  35. y=0,
  36. width = "100%",
  37. height = "25px",
  38. name = "DemonChatTabs",
  39. },demonnic.chat.container)
  40.  
  41. end
  42.  
  43. function demonnic.chat:create()
  44. --reset the UI
  45. demonnic.chat:resetUI()
  46. --Set some variables locally to increase readability
  47. local r = demonnic.chat.config.inactiveColors.r
  48. local g = demonnic.chat.config.inactiveColors.g
  49. local b = demonnic.chat.config.inactiveColors.b
  50. local winr = demonnic.chat.config.windowColors.r
  51. local wing = demonnic.chat.config.windowColors.g
  52. local winb = demonnic.chat.config.windowColors.b
  53.  
  54. --iterate the table of channels and create some windows and tabs
  55. for i,tab in ipairs(demonnic.chat.config.channels) do
  56. demonnic.chat.tabs[tab] = Geyser.Label:new({
  57. name=string.format("tab%s", tab),
  58. }, demonnic.chat.tabBox)
  59. demonnic.chat.tabs[tab]:echo(tab, demonnic.chat.config.inactiveTabText, "c")
  60. demonnic.chat.tabs[tab]:setColor(r,g,b)
  61. demonnic.chat.tabs[tab]:setClickCallback("demonnicChatSwitch", tab)
  62. demonnic.chat.windows[tab] = Geyser.MiniConsole:new({
  63. -- fontSize = demonnic.chat.config.fontSize,
  64. x = 0,
  65. y = 25,
  66. height = "100%",
  67. width = "100%",
  68. name = string.format("win%s", tab),
  69. }, demonnic.chat.container)
  70. demonnic.chat.windows[tab]:setFontSize(demonnic.chat.config.fontSize)
  71. demonnic.chat.windows[tab]:setColor(winr,wing,winb)
  72. demonnic.chat.windows[tab]:setWrap(demonnic.chat.config.width)
  73. demonnic.chat.windows[tab]:hide()
  74. end
  75. local showme = demonnic.chat.config.Alltab or demonnic.chat.config.channels[1]
  76. demonnicChatSwitch(showme)
  77. --start the blink timers, if enabled
  78. if demonnic.chat.config.blink and not demonnic.chat.blinkTimerOn then
  79. demonnic.chat:blink()
  80. end
  81. end
  82.  
  83. function demonnic.chat:append(chat)
  84. local r = demonnic.chat.config.windowColors.r
  85. local g = demonnic.chat.config.windowColors.g
  86. local b = demonnic.chat.config.windowColors.b
  87. selectCurrentLine()
  88. local ofr,ofg,ofb = getFgColor()
  89. local obr,obg,obb = getBgColor()
  90. if demonnic.chat.config.preserveBackground then
  91. setBgColor(r,g,b)
  92. end
  93. copy()
  94. local curLine = getCurrentLine()
  95. if demonnic.chat.config.timestamp then
  96. local timestamp = getTime(true, demonnic.chat.config.timestamp)
  97. local tsfg = {}
  98. local tsbg = {}
  99. local colorLeader = ""
  100. if demonnic.chat.config.timestampCustomColor then
  101. if type(demonnic.chat.config.timestampFG) == "string" then
  102. tsfg = color_table[demonnic.chat.config.timestampFG]
  103. else
  104. tsfg = demonnic.chat.config.timestampFG
  105. end
  106. if type(demonnic.chat.config.timestampBG) == "string" then
  107. tsbg = color_table[demonnic.chat.config.timestampBG]
  108. else
  109. tsbg = demonnic.chat.config.timestampBG
  110. end
  111. colorLeader = string.format("<%s,%s,%s:%s,%s,%s>",tsfg[1],tsfg[2],tsfg[3],tsbg[1],tsbg[2],tsbg[3])
  112. else
  113. colorLeader = string.format("<%s,%s,%s:%s,%s,%s>",ofr,ofg,ofb,obr,obg,obb)
  114. end
  115. local fullstamp = string.format("%s%s",colorLeader,timestamp)
  116. demonnic.chat.windows[chat]:decho(fullstamp)
  117. demonnic.chat.windows[chat]:echo(" ")
  118. demonnic.chat.windows[chat]:decho(string.format("<%s,%s,%s:%s,%s,%s>",ofr,ofg,ofb,obr,obg,obb) .. curLine .. "\n")
  119. if demonnic.chat.config.Alltab then
  120. demonnic.chat.windows[demonnic.chat.config.Alltab]:decho(fullstamp)
  121. demonnic.chat.windows[demonnic.chat.config.Alltab]:echo(" ")
  122. demonnic.chat.windows[demonnic.chat.config.Alltab]:decho(string.format("<%s,%s,%s:%s,%s,%s>",ofr,ofg,ofb,obr,obg,obb) .. curLine .. "\n")
  123. end
  124. end
  125. --demonnic.chat.windows[chat]:append()
  126. if demonnic.chat.config.gag then
  127. deleteLine()
  128. tempLineTrigger(1,1, [[if isPrompt() then deleteLine() end]])
  129. end
  130. if demonnic.chat.config.Alltab then
  131. -- appendBuffer(string.format("win%s", demonnic.chat.config.Alltab))
  132. end
  133. if demonnic.chat.config.blink and chat ~= demonnic.chat.currentTab then
  134. if (demonnic.chat.config.Alltab == demonnic.chat.currentTab) and not demonnic.chat.config.blinkOnAll then
  135. return
  136. else
  137. demonnic.chat.tabsToBlink[chat] = true
  138. end
  139. end
  140. end
  141.  
  142.  
  143.  
  144. function demonnic.chat:blink()
  145. if demonnic.chat.blinkID then killTimer(demonnic.chat.blinkID) end
  146. if not demonnic.chat.config.blink then
  147. demonnic.chat.blinkTimerOn = false
  148. return
  149. end
  150. for tab,_ in pairs(demonnic.chat.tabsToBlink) do
  151. demonnic.chat.tabs[tab]:flash()
  152. end
  153. demonnic.chat.blinkID = tempTimer(demonnic.chat.config.blinkTime, function () demonnic.chat:blink() end)
  154. end
  155.  
  156. function demonnic.chat:topright()
  157. return {
  158. fontSize = demonnic.chat.config.fontSize,
  159. x=string.format("-%sc",demonnic.chat.config.width + 2),
  160. y=0,
  161. width="-15px",
  162. height=string.format("%ic", demonnic.chat.config.lines + 2),
  163. }
  164. end
  165.  
  166. function demonnic.chat:topleft()
  167. return {
  168. fontSize = demonnic.chat.config.fontSize,
  169. x=0,
  170. y=0,
  171. width=string.format("%sc",demonnic.chat.config.width),
  172. height=string.format("%ic", demonnic.chat.config.lines + 2),
  173. }
  174. end
  175.  
  176. function demonnic.chat:bottomright()
  177. return {
  178. fontSize = demonnic.chat.config.fontSize,
  179. x=string.format("-%sc",demonnic.chat.config.width + 2),
  180. y=string.format("-%sc",demonnic.chat.config.lines + 2),
  181. width="-15px",
  182. height=string.format("%ic", demonnic.chat.config.lines + 2),
  183. }
  184. end
  185.  
  186. function demonnic.chat:bottomleft()
  187. return {
  188. fontSize = demonnic.chat.config.fontSize,
  189. x=0,
  190. y=string.format("-%sc",demonnic.chat.config.lines + 2),
  191. width=string.format("%sc",demonnic.chat.config.width),
  192. height=string.format("%ic", demonnic.chat.config.lines + 2),
  193. }
  194. end</script>
  195. <eventHandlerList/>
  196. </Script>
  197. <Script isActive="yes" isFolder="no">
  198. <name>demonnicOnStart</name>
  199. <packageName></packageName>
  200. <script>function demonnicOnStart()
  201. if demonnic.chat.use then
  202. demonnic.chat:create()
  203. end
  204. end</script>
  205. <eventHandlerList>
  206. <string>sysLoadEvent</string>
  207. </eventHandlerList>
  208. </Script>
  209. <Script isActive="yes" isFolder="no">
  210. <name>echo functions</name>
  211. <packageName></packageName>
  212. <script>
  213. function demonnic.chat:cecho(chat, message)
  214. local alltab = demonnic.chat.config.Alltab
  215. local blink = demonnic.chat.config.blink
  216. cecho(string.format("win%s",chat), message)
  217. if alltab and chat ~= alltab then
  218. cecho(string.format("win%s", alltab), message)
  219. end
  220. if blink and chat ~= demonnic.chat.currentTab then
  221. if (alltab == demonnic.chat.currentTab) and not demonnic.chat.config.blinkOnAll then
  222. return
  223. else
  224. demonnic.chat.tabsToBlink[chat] = true
  225. end
  226. end
  227. end
  228.  
  229. function demonnic.chat:decho(chat, message)
  230. local alltab = demonnic.chat.config.Alltab
  231. local blink = demonnic.chat.config.blink
  232. decho(string.format("win%s",chat), message)
  233. if alltab and chat ~= alltab then
  234. decho(string.format("win%s", alltab), message)
  235. end
  236. if blink and chat ~= demonnic.chat.currentTab then
  237. if (alltab == demonnic.chat.currentTab) and not demonnic.chat.config.blinkOnAll then
  238. return
  239. else
  240. demonnic.chat.tabsToBlink[chat] = true
  241. end
  242. end
  243. end
  244.  
  245. function demonnic.chat:hecho(chat, message)
  246. local alltab = demonnic.chat.config.Alltab
  247. local blink = demonnic.chat.config.blink
  248. hecho(string.format("win%s",chat), message)
  249. if alltab and chat ~= alltab then
  250. hecho(string.format("win%s", alltab), message)
  251. end
  252. if blink and chat ~= demonnic.chat.currentTab then
  253. if (alltab == demonnic.chat.currentTab) and not demonnic.chat.config.blinkOnAll then
  254. return
  255. else
  256. demonnic.chat.tabsToBlink[chat] = true
  257. end
  258. end
  259. end
  260.  
  261. function demonnic.chat:echo(chat, message)
  262. local alltab = demonnic.chat.config.Alltab
  263. local blink = demonnic.chat.config.blink
  264. echo(string.format("win%s",chat), message)
  265. if alltab and chat ~= alltab then
  266. echo(string.format("win%s", alltab), message)
  267. end
  268. if blink and chat ~= demonnic.chat.currentTab then
  269. if (alltab == demonnic.chat.currentTab) and not demonnic.chat.config.blinkOnAll then
  270. return
  271. else
  272. demonnic.chat.tabsToBlink[chat] = true
  273. end
  274. end
  275. end</script>
  276. <eventHandlerList/>
  277. </Script>
  278. </ScriptGroup>
  279. </ScriptGroup>
  280. </ScriptGroup>
  281. </ScriptPackage>
  282. <KeyPackage/>
  283. </MudletPackage>
RAW Paste Data