aboutsummaryrefslogtreecommitdiff
path: root/src/script/scripting_game.cpp
blob: e716bc979489bc357617ec2f2d8f4cce73ff95d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "scripting_game.h"
#include "server.h"
#include "log.h"
#include "cpp_api/s_internal.h"
#include "lua_api/l_base.h"
#include "lua_api/l_craft.h"
#include "lua_api/l_env.h"
#include "lua_api/l_inventory.h"
#include "lua_api/l_item.h"
#include "lua_api/l_mapgen.h"
#include "lua_api/l_nodemeta.h"
#include "lua_api/l_nodetimer.h"
#include "lua_api/l_noise.h"
#include "lua_api/l_object.h"
#include "lua_api/l_particles.h"
#include "lua_api/l_rollback.h"
#include "lua_api/l_server.h"
#include "lua_api/l_util.h"
#include "lua_api/l_vmanip.h"
#include "lua_api/l_settings.h"

extern "C" {
#include "lualib.h"
}

GameScripting::GameScripting(Server* server)
{
	setServer(server);

	// setEnv(env) is called by ScriptApiEnv::initializeEnvironment()
	// once the environment has been created

	//TODO add security

	SCRIPTAPI_PRECHECKHEADER

	lua_getglobal(L, "core");
	int top = lua_gettop(L);

	lua_newtable(L);
	lua_setfield(L, -2, "object_refs");

	lua_newtable(L);
	lua_setfield(L, -2, "luaentities");

	// Initialize our lua_api modules
	InitializeModApi(L, top);
	lua_pop(L, 1);

	// Push builtin initialization type
	lua_pushstring(L, "game");
	lua_setglobal(L, "INIT");

	infostream << "SCRIPTAPI: Initialized game modules" << std::endl;
}

void GameScripting::InitializeModApi(lua_State *L, int top)
{
	// Initialize mod api modules
	ModApiCraft::Initialize(L, top);
	ModApiEnvMod::Initialize(L, top);
	ModApiInventory::Initialize(L, top);
	ModApiItemMod::Initialize(L, top);
	ModApiMapgen::Initialize(L, top);
	ModApiParticles::Initialize(L, top);
	ModApiRollback::Initialize(L, top);
	ModApiServer::Initialize(L, top);
	ModApiUtil::Initialize(L, top);

	// Register reference classes (userdata)
	InvRef::Register(L);
	LuaItemStack::Register(L);
	LuaPerlinNoise::Register(L);
	LuaPerlinNoiseMap::Register(L);
	LuaPseudoRandom::Register(L);
	LuaVoxelManip::Register(L);
	NodeMetaRef::Register(L);
	NodeTimerRef::Register(L);
	ObjectRef::Register(L);
	LuaSettings::Register(L);
}

void log_deprecated(std::string message)
{
	log_deprecated(NULL,message);
}
6vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev package:debian-10: extends: .debpkg_template image: debian:10 needs: - build:debian-10 variables: LEVELDB_PKG: libleveldb1d deploy:debian-10: extends: .debpkg_install image: debian:10 needs: - package:debian-10 ## ## Ubuntu ## # Xenial build:ubuntu-16.04: extends: .build_template image: ubuntu:xenial before_script: - apt-get update -y - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev package:ubuntu-16.04: extends: .debpkg_template image: ubuntu:xenial needs: - build:ubuntu-16.04 variables: LEVELDB_PKG: libleveldb1v5 deploy:ubuntu-16.04: extends: .debpkg_install image: ubuntu:xenial needs: - package:ubuntu-16.04 # Bionic build:ubuntu-18.04: extends: .build_template image: ubuntu:bionic before_script: - apt-get update -y - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev package:ubuntu-18.04: extends: .debpkg_template image: ubuntu:bionic needs: - build:ubuntu-18.04 variables: LEVELDB_PKG: libleveldb1v5 deploy:ubuntu-18.04: extends: .debpkg_install image: ubuntu:bionic needs: - package:ubuntu-18.04 ## ## Fedora ## # Fedora 28 <-> RHEL 8 build:fedora-28: extends: .build_template image: fedora:28 before_script: - dnf -y install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libvorbis-devel libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel spatialindex-devel ## ## MinGW for Windows ## .generic_win_template: image: ubuntu:bionic before_script: - apt-get update -y - apt-get install -y wget xz-utils unzip git cmake gettext - wget -nv http://minetest.kitsunemimi.pw/mingw-w64-${WIN_ARCH}_9.2.0_ubuntu18.04.tar.xz -O mingw.tar.xz - tar -xaf mingw.tar.xz -C /usr .build_win_template: extends: .generic_win_template stage: build artifacts: expire_in: 1h paths: - build/minetest/_build/* .package_win_template: extends: .generic_win_template stage: package script: - unzip build/minetest/_build/minetest-*.zip - cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libgcc*.dll minetest-*-win*/bin/ - cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libstdc++*.dll minetest-*-win*/bin/ - cp -p /usr/${WIN_ARCH}-w64-mingw32/bin/libwinpthread*.dll minetest-*-win*/bin/ artifacts: expire_in: 90 day paths: - minetest-*-win*/* build:win32: extends: .build_win_template script: - ./util/buildbot/buildwin32.sh build variables: WIN_ARCH: "i686" package:win32: extends: .package_win_template needs: - build:win32 variables: WIN_ARCH: "i686" build:win64: extends: .build_win_template script: - ./util/buildbot/buildwin64.sh build variables: WIN_ARCH: "x86_64" package:win64: extends: .package_win_template needs: - build:win64 variables: WIN_ARCH: "x86_64" ## ## Docker ## package:docker: stage: package image: docker:stable services: - docker:dind before_script: - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com script: - docker build . -t ${CONTAINER_IMAGE}/server:$CI_COMMIT_SHA -t ${CONTAINER_IMAGE}/server:$CI_COMMIT_REF_NAME -t ${CONTAINER_IMAGE}/server:latest - docker push ${CONTAINER_IMAGE}/server:$CI_COMMIT_SHA - docker push ${CONTAINER_IMAGE}/server:$CI_COMMIT_REF_NAME - docker push ${CONTAINER_IMAGE}/server:latest ## ## Gitlab Pages (Lua API documentation) ## pages: stage: deploy image: python:3.8 before_script: - pip install git+https://github.com/Python-Markdown/markdown.git - pip install git+https://github.com/mkdocs/mkdocs.git - pip install pygments script: - cd doc/mkdocs && ./build.sh artifacts: paths: - public only: - master ## ## AppImage ## package:appimage-client: stage: package image: appimagecrafters/appimage-builder needs: - build:ubuntu-18.04 before_script: - apt-get update -y - apt-get install -y git wget # Collect files - mkdir AppDir - cp -a artifact/minetest/usr/ AppDir/usr/ - rm AppDir/usr/bin/minetestserver - cp -a clientmods AppDir/usr/share/minetest script: - git clone $MINETEST_GAME_REPO AppDir/usr/share/minetest/games/minetest_game - rm -rf AppDir/usr/share/minetest/games/minetest/.git - export VERSION=$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA # Remove PrefersNonDefaultGPU property due to validation errors - sed -i '/PrefersNonDefaultGPU/d' AppDir/usr/share/applications/net.minetest.minetest.desktop - appimage-builder --skip-test artifacts: expire_in: 90 day paths: - ./*.AppImage