mod1:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_chatcommand("home", {
description = SL(("Teleport you to your home point")),
privs = {home=true},
func = function (name)
local player = minetest.get_player_by_name(name)
if player == nil then
-- just a check to prevent the server crashing
return false
end
if homepos[player:get_player_name()] then
player:setpos(homepos[player:get_player_name()])
minetest.chat_send_player(name, SL("Teleported to home!"))
else
minetest.chat_send_player(name, SL("Set a home using /sethome"))
end
end,
})
mod2:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function execute_home
-- call command home
end
Now the situation is that I want to call this command from mod2 instead of copying and moving code around. This should enforce mod compatibility, and reduce unnecessary edits.
I can of course declare the function globally and call it from mod2, but is it efficient solution? I have to touch the sources of mod1, there for, I break the promise.
mod1:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
gohome = function (name)
local player = minetest.get_player_by_name(name)
if player == nil then
-- just a check to prevent the server crashing
return false
end
if homepos[player:get_player_name()] then
player:setpos(homepos[player:get_player_name()])
minetest.chat_send_player(name, SL("Teleported to home!"))
else
minetest.chat_send_player(name, SL("Set a home using /sethome"))
end
mod2:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function execute_home(player)
gohome(player:get_player_name())
end
So is there a way to execute
registered command server sided?