Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
scripting_server.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21#include "cpp_api/s_base.h"
22#include "cpp_api/s_entity.h"
23#include "cpp_api/s_env.h"
24#include "cpp_api/s_inventory.h"
26#include "cpp_api/s_node.h"
27#include "cpp_api/s_player.h"
28#include "cpp_api/s_server.h"
29#include "cpp_api/s_security.h"
30#include "cpp_api/s_async.h"
31
32struct PackedValue;
33
34/*****************************************************************************/
35/* Scripting <-> Server Game Interface */
36/*****************************************************************************/
37
39 virtual public ScriptApiBase,
40 public ScriptApiDetached,
41 public ScriptApiEntity,
42 public ScriptApiEnv,
44 public ScriptApiNode,
45 public ScriptApiPlayer,
46 public ScriptApiServer,
48{
49public:
51
52 void loadBuiltin();
53 // use ScriptApiBase::loadMod() to load mods
54
55 // Save globals that are copied into other Lua envs
56 void saveGlobals();
57
58 // Initialize async engine, call this AFTER loading all mods
59 void initAsync();
60
61 // Global step handler to collect async results
62 void stepAsync();
63
64 // Pass job to async threads
65 u32 queueAsync(std::string &&serialized_func,
66 PackedValue *param, const std::string &mod_origin);
67
68private:
69 void InitializeModApi(lua_State *L, int top);
70
71 static void InitializeAsync(lua_State *L, int top);
72
74};
Definition: s_async.h:79
Definition: s_base.h:79
Definition: s_inventory.h:29
Definition: s_entity.h:32
Definition: s_env.h:32
Definition: s_modchannels.h:27
Definition: s_player.h:34
Definition: s_security.h:41
Definition: s_server.h:27
Definition: scripting_server.h:48
void loadBuiltin()
Definition: scripting_server.cpp:93
u32 queueAsync(std::string &&serialized_func, PackedValue *param, const std::string &mod_origin)
Definition: scripting_server.cpp:136
void InitializeModApi(lua_State *L, int top)
Definition: scripting_server.cpp:143
AsyncEngine asyncEngine
Definition: scripting_server.h:73
void saveGlobals()
Definition: scripting_server.cpp:99
void initAsync()
Definition: scripting_server.cpp:116
static void InitializeAsync(lua_State *L, int top)
Definition: scripting_server.cpp:181
void stepAsync()
Definition: scripting_server.cpp:131
Definition: server.h:146
Definition: activeobjectmgr.cpp:26
A packed value can be a primitive like a string or number but also a table including all of its conte...
Definition: c_packer.h:87
Definition: s_node.cpp:32