Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ==SERVER==
- ==========
- -- Mod Channels
- -- Requires dcbl_csm clientmod.
- local channel = minetest.mod_channel_join("dcbl")
- print(channel:is_writeable())
- minetest.register_on_modchannel_message(function(channel_name, sender, message)
- print("channel_name:", channel_name)
- print("sender:", sender)
- print("message:", message)
- end)
- --[[minetest.register_on_modchannel_signal(function(channel_name, signal)
- print("channel_name:", channel_name)
- print("signal:", signal)
- end)]]
- minetest.register_chatcommand("c", {
- func = function(name, param)
- channel:send_all("hi")
- end,
- })
- ==CLIENT==
- ==========
- local hl = minetest.sound_play("dcbl_front_center")
- local hr = minetest.sound_play("default_place_node_hard")
- local player
- local channel
- local t = 0
- minetest.register_on_connect(function()
- player = minetest.localplayer
- channel = minetest.mod_channel_join("dcbl")
- end)
- minetest.register_on_modchannel_signal(function(
- channel_name, signal)
- print("channel_name:", channel_name)
- print("signal:", signal)
- end)
- minetest.register_on_modchannel_message(function(
- channel_name, sender, message)
- print("channel_name:", channel_name)
- print("sender:", sender)
- print("message:", message)
- end)
- -- STEP
- minetest.register_globalstep(function(dtime)
- if t > 10 then
- t = 0
- print("ping")
- end
- t = dtime + t
- end)
- -- COMMANDS
- minetest.register_chatcommand("dcbl", {
- description = "Interface with dcbl.",
- params = "hr, hl, send, join, leave, list, test",
- func = function(param)
- if param == "hr" then
- return hr
- elseif param == "hl" then
- return hl
- elseif param == "send" then
- channel:send_all("Hello world!")
- elseif param == "join" then
- channel = minetest.mod_channel_join("dcbl")
- elseif param == "leave" then
- channel:leave()
- elseif param == "list" then
- print(dump(channel))
- elseif param == "test" then
- print(channel:is_writeable())
- else
- return false, "No parameter specified."
- end
- end,
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement