Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
scripting.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2025 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <spdlog/sinks/ringbuffer_sink.h>
20#include <spdlog/spdlog.h>
21
22#include <memory>
23#include <string>
24#include <string_view>
25#include <vector>
26
27#include <sol/sol.hpp>
28
29namespace cqsp::scripting {
30class ScriptInterface : public sol::state {
31 public:
32 using sol::state::state;
34 void RunScript(std::string_view str);
35 void ParseResult(const sol::protected_function_result&);
36 void RegisterDataGroup(std::string_view name);
37 void Init();
38 int GetLength(std::string_view);
39
40 std::vector<std::string> values;
41
42 std::vector<std::string> GetLogs();
43
44 private:
45 std::shared_ptr<spdlog::logger> logger;
46 std::shared_ptr<spdlog::sinks::ringbuffer_sink_mt> ringbuffer_sink;
47};
48} // namespace cqsp::scripting
Definition: scripting.h:30
void RegisterDataGroup(std::string_view name)
Definition: scripting.cpp:55
ScriptInterface()
Definition: scripting.cpp:29
int GetLength(std::string_view)
Definition: scripting.cpp:75
std::vector< std::string > values
Definition: scripting.h:40
void ParseResult(const sol::protected_function_result &)
Definition: scripting.cpp:44
void Init()
Definition: scripting.cpp:68
std::vector< std::string > GetLogs()
Definition: scripting.cpp:77
std::shared_ptr< spdlog::logger > logger
Definition: scripting.h:45
std::shared_ptr< spdlog::sinks::ringbuffer_sink_mt > ringbuffer_sink
Definition: scripting.h:46
void RunScript(std::string_view str)
Definition: scripting.cpp:53
Definition: luafunctions.h:22