document what run_each_serverstart does in initialize #14

Open
opened 2024-07-13 21:59:29 +02:00 by AliasAlreadyTaken · 1 comment

Add examples and usecases for the various ways to start a function. When does minetest.after run? when does on_mods_loaded run? Which comes first?

    yl_template.data = {}
    --minetest.on_mods_loaded(0.0, yl_template.on_mods_loaded)
    --minetest.after(0.0, yl_template.after)

Add examples and usecases for the various ways to start a function. When does minetest.after run? when does on_mods_loaded run? Which comes first? ``` yl_template.data = {} --minetest.on_mods_loaded(0.0, yl_template.on_mods_loaded) --minetest.after(0.0, yl_template.after) ```
Member

Idk why, but here's a call graph:

- Server::start()
-- Server::init()
--- ServerModManager::loadMods(ServerScripting &script)
---- script.on_mods_loaded();   # <-------------------- on_mods_loaded
--- m_env = new ServerEnvironment(...)
--- m_env->init();
-- m_thread->start();
--- Thread::threadProc(Thread *thr)
---- thr->run();


- ServerThread::run()
-- Server::AsyncRunStep(float dtime, bool initial_step)
--- ServerEnvironment::step(float dtime)
---- ScriptApiEnv::environment_Step(dtime)
----- runCallbacks(1, RUN_CALLBACKS_MODE_FIRST); # <---- globalsteps

core.after() is impletemnted in lua builtins and just uses register_globalstep() callback to process the queue.
So, on_mods_loaded is called before first server step is processed, and after callbacks are processed during steps.

Idk why, but here's a call graph: ```fortran - Server::start() -- Server::init() --- ServerModManager::loadMods(ServerScripting &script) ---- script.on_mods_loaded(); # <-------------------- on_mods_loaded --- m_env = new ServerEnvironment(...) --- m_env->init(); -- m_thread->start(); --- Thread::threadProc(Thread *thr) ---- thr->run(); - ServerThread::run() -- Server::AsyncRunStep(float dtime, bool initial_step) --- ServerEnvironment::step(float dtime) ---- ScriptApiEnv::environment_Step(dtime) ----- runCallbacks(1, RUN_CALLBACKS_MODE_FIRST); # <---- globalsteps ``` `core.after()` is impletemnted in lua builtins and just uses register_globalstep() callback to process the queue. So, `on_mods_loaded` is called before first server step is processed, and `after` callbacks are processed during steps.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/yl_template#14
No description provided.