aboutsummaryrefslogtreecommitdiff
path: root/clientmods/preview
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2018-01-20 13:09:58 +0000
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-01-20 14:09:58 +0100
commit9649e4721467dab348011633c814a63a184bd018 (patch)
treeb5c381d8b597406aa21889a1c40c2689adaa39a9 /clientmods/preview
parentd45e5da8ca808e552123bcd94e76b0b435a6ea79 (diff)
downloadminetest-9649e4721467dab348011633c814a63a184bd018.tar.gz
minetest-9649e4721467dab348011633c814a63a184bd018.tar.bz2
minetest-9649e4721467dab348011633c814a63a184bd018.zip
[CSM] Add basic HUD manipulation. (#6067)
* [CSM] Add basic HUD manipulation. Workaround for on_connect not working right now.
Diffstat (limited to 'clientmods/preview')
-rw-r--r--clientmods/preview/init.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua
index 288b1b16c..a384fd6bf 100644
--- a/clientmods/preview/init.lua
+++ b/clientmods/preview/init.lua
@@ -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,
+})