10 #include "../stdafx.h"
12 #include <sqstdmath.h>
15 #include "../core/math_func.hpp"
16 #include "../string_func.h"
18 #include "../safeguards.h"
25 sq_getinteger(vm, 2, &tmp1);
26 sq_getinteger(vm, 3, &tmp2);
27 sq_pushinteger(vm, std::min(tmp1, tmp2));
35 sq_getinteger(vm, 2, &tmp1);
36 sq_getinteger(vm, 3, &tmp2);
37 sq_pushinteger(vm, std::max(tmp1, tmp2));
43 SQInteger top = sq_gettop(vm);
44 const SQChar *filename;
46 sq_getstring(vm, 2, &filename);
50 sq_stackinfos(vm, 1, &si);
51 if (si.source ==
nullptr) {
52 Debug(misc, 0,
"[squirrel] Couldn't detect the script-name of the 'require'-caller; this should never happen!");
57 std::string path = si.source;
58 auto p = path.find_last_of(PATHSEPCHAR);
60 if (p != std::string::npos) path.erase(p + 1);
62 #if (PATHSEPCHAR != '/')
63 std::transform(path.begin(), path.end(), path.begin(), [](
char &c) { return c ==
'/' ? PATHSEPCHAR : c; });
72 return ret ? 0 : SQ_ERROR;
79 if (sq_gettop(vm) >= 1) {
80 if (SQ_SUCCEEDED(sq_getbool(vm, -1, &b))) {
81 sq_notifyallexceptions(vm, b);
104 sqstd_register_mathlib(engine->
GetVM());
static SQInteger max(HSQUIRRELVM vm)
Get the highest of two integers.
static SQInteger require(HSQUIRRELVM vm)
Load another file on runtime.
static SQInteger notifyallexceptions(HSQUIRRELVM vm)
Enable/disable stack trace showing for handled exceptions.
static SQInteger min(HSQUIRRELVM vm)
Get the lowest of two integers.
bool LoadScript(const std::string &script)
Load a script.
void AddMethod(const char *method_name, SQFUNCTION proc, uint nparam=0, const char *params=nullptr, void *userdata=nullptr, int size=0)
Adds a function to the stack.
HSQUIRRELVM GetVM()
Get the squirrel VM.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
void squirrel_register_std(Squirrel *engine)
Register all standard functions we want to give to a script.
void squirrel_register_global_std(Squirrel *engine)
Register all standard functions that are available on first startup.
defines the Squirrel Standard Function class