BARE2D
LuaFunctions.cpp
Go to the documentation of this file.
1
#include "
LuaFunctions.hpp
"
2
3
#include <string>
4
5
#include "
Logger.hpp
"
6
7
namespace
BARE2D::LuaFunctions
{
8
9
int
delay
(lua_State* L) {
10
// The delay duration (the first and only variable) is on the top of the stack. Let's keep it that way so that we can retrieve it from there for the continuation function
11
// This will cause the thread to yield until lua_resume is called
12
lua_yield(L, 0);
13
return
0;
14
}
15
16
int
print
(lua_State* L) {
17
std::string parameter0 = lua_tostring(L, -1);
18
lua_pop(L, 1);
19
20
std::string output =
"Lua Output: "
;
21
22
for
(
char
c : parameter0) {
23
output += c;
24
if
(c ==
'\n'
)
25
output +=
"Lua Output: "
;
26
}
27
28
Logger::getInstance
()->
log
(output);
29
return
0;
30
}
31
}
BARE2D::Logger::getInstance
static Logger * getInstance()
Definition:
Logger.cpp:34
BARE2D::LuaFunctions::delay
int delay(lua_State *L)
A custom function which calls a lua_yield. Takes one argument, an integer representing how many updat...
Definition:
LuaFunctions.cpp:9
BARE2D::LuaFunctions
Definition:
LuaFunctions.cpp:7
BARE2D::Logger::log
void log(std::string message, bool important=false)
Logs a message to a file and the terminal.
Definition:
Logger.cpp:42
LuaFunctions.hpp
BARE2D::LuaFunctions::print
int print(lua_State *L)
Uses the Logger to print to the screen and log. Takes one argument, a string to print.
Definition:
LuaFunctions.cpp:16
Logger.hpp
Source
LuaFunctions.cpp
Generated by
1.8.17