local modname = core.get_current_modname() or "??"
local modstorage = core.get_mod_storage()
+local mod_channel
+dofile("preview:example.lua")
-- This is an example function to ensure it's working properly, should be removed before merge
core.register_on_shutdown(function()
print("[PREVIEW] shutdown client")
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()
+ if mod_channel:is_writeable() then
+ mod_channel:send_all("preview talk to experimental")
+ end
+ end)
+end)
+
+core.register_on_modchannel_message(function(channel, sender, message)
+ print("[PREVIEW][modchannels] Received message `" .. message .. "` on channel `"
+ .. channel .. "` from sender `" .. sender .. "`")
+ core.after(1, function()
+ mod_channel:send_all("CSM preview received " .. message)
+ end)
+end)
+
+core.register_on_modchannel_signal(function(channel, signal)
+ print("[PREVIEW][modchannels] Received signal id `" .. signal .. "` on channel `"
+ .. channel)
+end)
+
+core.register_on_inventory_open(function(inventory)
+ print("INVENTORY OPEN")
+ print(dump(inventory))
+ return false
end)
core.register_on_placenode(function(pointed_thing, node)
return false
end)
+core.register_on_item_use(function(itemstack, pointed_thing)
+ print("The local player used an item!")
+ print("pointed_thing :" .. dump(pointed_thing))
+ print("item = " .. itemstack:get_name())
+ return false
+end)
+
-- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_receiving_chat_messages(function(message)
+core.register_on_receiving_chat_message(function(message)
print("[PREVIEW] Received message " .. message)
return false
end)
-- This is an example function to ensure it's working properly, should be removed before merge
-core.register_on_sending_chat_messages(function(message)
+core.register_on_sending_chat_message(function(message)
print("[PREVIEW] Sending message " .. message)
return false
end)
local function preview_minimap()
local minimap = core.ui.minimap
+ if not minimap then
+ print("[PREVIEW] Minimap is disabled. Skipping.")
+ return
+ end
minimap:set_mode(4)
minimap:show()
minimap:set_pos({x=5, y=50, z=5})
end)
core.after(5, function()
- core.ui.minimap:show()
+ if core.ui.minimap then
+ core.ui.minimap:show()
+ end
print("[PREVIEW] Day count: " .. core.get_day_count() ..
" time of day " .. core.get_timeofday())
return false
end)
+core.register_chatcommand("privs", {
+ func = function(param)
+ return true, core.privs_to_string(minetest.get_privilege_list())
+ end,
+})