summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/scripts/init.lua
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2021-06-22 02:47:45 +0200
committerGitHub <noreply@github.com>2021-06-22 02:47:45 +0200
commite93df8332d86b67dff89d24788525a027b8d0c4c (patch)
tree3c2e085706f3824aa34d2dce5747c9c86a79723a /cwd/assets/altcraft/scripts/init.lua
parentMerge pull request #56 from LaG1924/ftr/upgrade-build-system (diff)
parentMinor changes to Ui scripts (diff)
downloadAltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.gz
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.bz2
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.lz
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.xz
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.tar.zst
AltCraft-e93df8332d86b67dff89d24788525a027b8d0c4c.zip
Diffstat (limited to 'cwd/assets/altcraft/scripts/init.lua')
-rw-r--r--cwd/assets/altcraft/scripts/init.lua34
1 files changed, 32 insertions, 2 deletions
diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua
index 96b5ec3..790bab0 100644
--- a/cwd/assets/altcraft/scripts/init.lua
+++ b/cwd/assets/altcraft/scripts/init.lua
@@ -9,18 +9,48 @@ local plugin = {
}
function plugin.onLoad ()
- print("Loaded AltCraft plugin!")
+ rmlui:LoadFontFace("altcraft/fonts/OpenSans-Regular")
+ local con = rmlui.contexts["default"]
+ local uiMainMenu = con:LoadDocument("altcraft/ui/main-menu")
+ con:LoadDocument("altcraft/ui/hud")
+ con:LoadDocument("altcraft/ui/pause")
+ con:LoadDocument("altcraft/ui/options")
+
+ uiMainMenu:Show()
+ AC.Settings.Load()
+ uiMainMenu:GetElementById("username"):SetAttribute("value", AC.Settings.Read("username","Username"..tostring(math.random(10000))))
+ uiMainMenu:GetElementById("hostname"):SetAttribute("value",AC.Settings.Read("hostname","127.0.0.1"))
end
function plugin.onChangeState (newState)
- AC.LogWarning("New state: "..newState)
+ local toHide = {}
+ local toShow = {}
+
+ for i,doc in ipairs(rmlui.contexts["default"].documents) do
+ if doc.title == newState then
+ toShow[#toShow+1]=doc
+ else
+ toHide[#toHide+1]=doc
+ end
+ end
+
+ for i,doc in ipairs(toHide) do
+ doc:Hide()
+ end
+
+ for i,doc in ipairs(toShow) do
+ doc:Show()
+ end
end
function plugin.onUnload ()
AC.LogInfo("AC Core unloaded")
end
+require("altcraft/ui")
+
function plugin.onTick (deltaTime)
+ UpdateUi()
if AC.GetGameState() and AC.GetGameState():GetPlayer() and AC.GetGameState():GetTimeStatus().worldAge > 0 then
-- local player = AC.GetGameState():GetPlayer()
-- player.pos.x = player.pos.x + deltaTime * 0.5