From 9649e4721467dab348011633c814a63a184bd018 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 20 Jan 2018 13:09:58 +0000 Subject: [CSM] Add basic HUD manipulation. (#6067) * [CSM] Add basic HUD manipulation. Workaround for on_connect not working right now. --- clientmods/preview/init.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'clientmods/preview') 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, +}) -- cgit v1.2.3