1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

[CSM] Add basic HUD manipulation. (#6067)

* [CSM] Add basic HUD manipulation.

Workaround for on_connect not working right now.
This commit is contained in:
red-001 2018-01-20 13:09:58 +00:00 committed by Loïc Blot
parent d45e5da8ca
commit 9649e47214
21 changed files with 1401 additions and 1109 deletions

View file

@ -7,7 +7,7 @@ dofile("preview:example.lua")
core.register_on_shutdown(function()
print("[PREVIEW] shutdown client")
end)
local id = 0
core.register_on_connect(function()
print("[PREVIEW] Player connection completed")
local server_info = core.get_server_info()
@ -15,7 +15,6 @@ core.register_on_connect(function()
print("Server ip: " .. server_info.ip)
print("Server address: " .. server_info.address)
print("Server port: " .. server_info.port)
mod_channel = core.mod_channel_join("experimental_preview")
core.after(4, function()
@ -25,6 +24,19 @@ core.register_on_connect(function()
end)
end)
core.after(1, function()
id = core.localplayer:hud_add({
hud_elem_type = "text",
name = "example",
number = 0xff0000,
position = {x=0, y=1},
offset = {x=8, y=-8},
text = "You are using the preview mod",
scale = {x=200, y=60},
alignment = {x=1, y=-1},
})
end)
core.register_on_modchannel_message(function(channel, sender, message)
print("[PREVIEW][modchannels] Received message `" .. message .. "` on channel `"
.. channel .. "` from sender `" .. sender .. "`")
@ -184,3 +196,9 @@ core.register_chatcommand("privs", {
return true, core.privs_to_string(minetest.get_privilege_list())
end,
})
core.register_chatcommand("text", {
func = function(param)
return core.localplayer:hud_change(id, "text", param)
end,
})