core.registered_globalsteps, core.register_globalstep = make_registration()
core.registered_on_shutdown, core.register_on_shutdown = make_registration()
-core.registered_on_connect, core.register_on_connect = make_registration()
core.registered_on_receiving_chat_message, core.register_on_receiving_chat_message = make_registration()
core.registered_on_sending_chat_message, core.register_on_sending_chat_message = make_registration()
core.registered_on_death, core.register_on_death = make_registration()
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()
- print("Server version: " .. server_info.protocol_version)
- 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)
+local id = nil
+
+local server_info = core.get_server_info()
+print("Server version: " .. server_info.protocol_version)
+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)
core.after(1, function()
* **Warning**: If the client terminates abnormally (i.e. crashes), the registered
callbacks **will likely not be run**. Data should be saved at
semi-frequent intervals as well as on server shutdown.
-* `minetest.register_on_connect(func())`
- * Called at the end of client connection (when player is loaded onto map)
* `minetest.register_on_receiving_chat_message(func(message))`
* Called always when a client receive a message
* Return `true` to mark the message as handled, which means that it will not be shown to chat
* Client joins channel `channel_name`, and creates it, if necessary. You
should listen from incoming messages with `minetest.register_on_modchannel_message`
call to receive incoming messages. Warning, this function is asynchronous.
- * You should use a minetest.register_on_connect(function() ... end) to perform
- a successful channel join on client startup.
### Particles
* `minetest.add_particle(particle definition)`
* Returns aspect ratio of screen
### LocalPlayer
-An interface to retrieve information about the player. The player is
-not accessible until the client is fully done loading and therefore
-not at module init time.
-
-To get the localplayer handle correctly, use `on_connect()` as follows:
-
-```lua
-local localplayer
-minetest.register_on_connect(function()
- localplayer = minetest.localplayer
-end)
-```
+An interface to retrieve information about the player.
Methods:
if (g_settings->getBool("enable_client_modding")) {
m_script->on_client_ready(m_env.getLocalPlayer());
- m_script->on_connect();
}
text = wgettext("Done!");
runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
}
-void ScriptApiClient::on_connect()
-{
- SCRIPTAPI_PRECHECKHEADER
-
- // get registered connect hooks
- lua_getglobal(L, "core");
- lua_getfield(L, -1, "registered_on_connect");
- // Call callback
- runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
-}
-
bool ScriptApiClient::on_sending_message(const std::string &message)
{
SCRIPTAPI_PRECHECKHEADER
// Calls on_shutdown handlers
void on_shutdown();
- void on_connect();
-
// Chat message handlers
bool on_sending_message(const std::string &message);
bool on_receiving_message(const std::string &message);