Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename GameScripting to ServerScripting * Make getBuiltinLuaPath static serverside * Add on_shutdown callback * Add on_receiving_chat_message & on_sending_chat_message callbacks * ScriptApiBase: use IGameDef instead of Server This permits to share common attribute between client & server * Enable mod security in client side modding without conditions
- Loading branch information
Showing
37 changed files
with
488 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Minetest: builtin/client/init.lua | ||
local scriptpath = core.get_builtin_path()..DIR_DELIM | ||
local clientpath = scriptpath.."client"..DIR_DELIM | ||
|
||
dofile(clientpath .. "register.lua") | ||
|
||
-- This is an example function to ensure it's working properly, should be removed before merge | ||
core.register_on_shutdown(function() | ||
print("shutdown client") | ||
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) | ||
print("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) | ||
print("Sending message " .. message) | ||
return false | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
core.callback_origins = {} | ||
|
||
function core.run_callbacks(callbacks, mode, ...) | ||
assert(type(callbacks) == "table") | ||
local cb_len = #callbacks | ||
if cb_len == 0 then | ||
if mode == 2 or mode == 3 then | ||
return true | ||
elseif mode == 4 or mode == 5 then | ||
return false | ||
end | ||
end | ||
local ret | ||
for i = 1, cb_len do | ||
local cb_ret = callbacks[i](...) | ||
|
||
if mode == 0 and i == 1 or mode == 1 and i == cb_len then | ||
ret = cb_ret | ||
elseif mode == 2 then | ||
if not cb_ret or i == 1 then | ||
ret = cb_ret | ||
end | ||
elseif mode == 3 then | ||
if cb_ret then | ||
return cb_ret | ||
end | ||
ret = cb_ret | ||
elseif mode == 4 then | ||
if (cb_ret and not ret) or i == 1 then | ||
ret = cb_ret | ||
end | ||
elseif mode == 5 and cb_ret then | ||
return cb_ret | ||
end | ||
end | ||
return ret | ||
end | ||
|
||
-- | ||
-- Callback registration | ||
-- | ||
|
||
local function make_registration() | ||
local t = {} | ||
local registerfunc = function(func) | ||
t[#t + 1] = func | ||
core.callback_origins[func] = { | ||
mod = core.get_current_modname() or "??", | ||
name = debug.getinfo(1, "n").name or "??" | ||
} | ||
--local origin = core.callback_origins[func] | ||
--print(origin.name .. ": " .. origin.mod .. " registering cbk " .. tostring(func)) | ||
end | ||
return t, registerfunc | ||
end | ||
|
||
core.registered_on_shutdown, core.register_on_shutdown = make_registration() | ||
core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration() | ||
core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.