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.lua36
1 files changed, 35 insertions, 1 deletions
diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua
index 790bab0..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 ()
@@ -15,6 +16,9 @@ function plugin.onLoad ()
con:LoadDocument("altcraft/ui/hud")
con:LoadDocument("altcraft/ui/pause")
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()
@@ -70,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