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 std::string_view filename;
46 sq_getstring(vm, 2, filename);
50 sq_stackinfos(vm, 1, &si);
53 std::string path{si.source};
54 auto p = path.find_last_of(PATHSEPCHAR);
56 if (p != std::string::npos) path.erase(p + 1);
58#if (PATHSEPCHAR != '/')
59 std::transform(path.begin(), path.end(), path.begin(), [](
char &c) { return c ==
'/' ? PATHSEPCHAR : c; });
68 return ret ? 0 : SQ_ERROR;
75 if (sq_gettop(vm) >= 1) {
76 if (SQ_SUCCEEDED(sq_getbool(vm, -1, &b))) {
77 sq_notifyallexceptions(vm, b);
100 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.
HSQUIRRELVM GetVM()
Get the squirrel VM.
void AddMethod(std::string_view method_name, SQFUNCTION proc, std::string_view params={}, void *userdata=nullptr, int size=0)
Adds a function to the stack.
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