summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/scripts/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'cwd/assets/altcraft/scripts/init.lua')
-rw-r--r--cwd/assets/altcraft/scripts/init.lua34
1 files changed, 33 insertions, 1 deletions
diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua
index e13fc81..b60a988 100644
--- a/cwd/assets/altcraft/scripts/init.lua
+++ b/cwd/assets/altcraft/scripts/init.lua
@@ -6,6 +6,7 @@ local plugin = {
onChangeState = nil,
onTick = nil,
onRequestBlockInfo = nil,
+ onChatMessage = nil,
}
function plugin.onLoad ()
@@ -17,6 +18,7 @@ function plugin.onLoad ()
con:LoadDocument("altcraft/ui/options")
con:LoadDocument("altcraft/ui/loading")
con:LoadDocument("altcraft/ui/respawn")
+ con:LoadDocument("altcraft/ui/chat")
uiMainMenu:Show()
AC.Settings.Load()
@@ -72,9 +74,39 @@ function plugin.onRequestBlockInfo(blockPos)
return blocks.GetBlockInfo(blockPos)
end
+function plugin.onChatMessage(chat, pos)
+ local chatDoc = {}
+ for i,d in ipairs(rmlui.contexts["default"].documents) do
+ if d.title == "Chat" then
+ chatDoc = d
+ end
+ end
+
+ local msg = chat:ToPlainText()
+ msg = string.gsub(msg,'&','&')
+ msg = string.gsub(msg,'<','&lt;')
+ msg = string.gsub(msg,'>','&gt;')
+ msg = string.gsub(msg,'""','&quot;')
+ msg = string.gsub(msg,"''",'&apos;')
+
+ local color = ""
+ if pos == 0 then
+ color = ""
+ elseif pos == 1 then
+ color = 'style="color: #BBBBBB"'
+ elseif pos == 2 then
+ color = 'style="color: maroon"'
+ else
+ color = 'style="color: navy"'
+ end
+
+ chatDoc:GetElementById('chat').inner_rml = chatDoc:GetElementById('chat').inner_rml .. string.format('<p class="chat-msg" %s>%s</p>', color, msg)
+ MoveChatToBottom = true
+end
+
AC.RegisterDimension(0, Dimension.new("overworld", true))
AC.RegisterDimension(-1, Dimension.new("the_nether", false))
AC.RegisterDimension(1, Dimension.new("the_end", false))
AC.RegisterPlugin(plugin)
-plugin = nil \ No newline at end of file
+plugin = nil