CSEngine
Loading...
Searching...
No Matches
CSE::ScriptMgr Class Reference
Inheritance diagram for CSE::ScriptMgr:
CSE::SContainerList< Sqrat::Object * > CSE::CoreBase CSE::SIContainer< S, T, M >

Public Member Functions

void Init () override
 
- Public Member Functions inherited from CSE::SContainerList< Sqrat::Object * >
void Register (Sqrat::Object * object) override
 
void Remove (Sqrat::Object * object) override
 
Sqrat::Object * Get (int index) const override
 
std::list< Sqrat::Object * > GetAll () const override
 
int GetID (Sqrat::Object * object) const override
 
int GetSize () const override
 
- Public Member Functions inherited from CSE::SIContainer< S, T, M >
virtual void Register (T object)=0
 
virtual void Remove (T object)=0
 
virtual T Get (M index) const =0
 
virtual M GetID (T object) const =0
 
- Public Member Functions inherited from CSE::CoreBase
virtual void Update (float elapsedTime)
 

Static Public Member Functions

static void RegisterScript (const std::string &script)
 

Additional Inherited Members

- Protected Attributes inherited from CSE::SContainerList< Sqrat::Object * >
std::list< Sqrat::Object * > m_objects
 
int m_size
 

Detailed Description

Definition at line 9 of file ScriptMgr.h.

Constructor & Destructor Documentation

◆ ~ScriptMgr()

ScriptMgr::~ScriptMgr ( )
override

Definition at line 54 of file ScriptMgr.cpp.

54 {
55 ReleaseSqratObject();
56 sq_close(DefaultVM::Get());
57}

Member Function Documentation

◆ Init()

void ScriptMgr::Init ( )
overridevirtual

Implements CSE::CoreBase.

Definition at line 60 of file ScriptMgr.cpp.

60 {
61 HSQUIRRELVM vm;
62// Sqrat::SqratVM vm = Sqrat::SqratVM();
63 vm = sq_open(1024);
64 Sqrat::DefaultVM::Set(vm);
65// Sqrat::DefaultVM::Set(vm.GetVM());
66 sq_pushroottable(vm);
67 sqstd_register_mathlib(vm);
68 sq_pop(vm, 1);
69 //SquirrelVM::Init();
70 DefineClasses();
71 ReadScriptList();
72}

◆ RegisterScript()

void ScriptMgr::RegisterScript ( const std::string &  script)
static

Definition at line 75 of file ScriptMgr.cpp.

75 {
76
77 HSQUIRRELVM vm = DefaultVM::Get();
78
79 //register script
80 if (!script.empty()) {
81 Script compiledScript;
82 compiledScript.CompileString(script);
83 if (Sqrat::Error::Occurred(vm)) {
84 SafeLog::Log((_SC("Compile Failed: ") + Error::Message(vm)).c_str());
85 }
86
87 compiledScript.Run();
88 if (Sqrat::Error::Occurred(vm)) {
89 SafeLog::Log((_SC("Run Failed: ") + Error::Message(vm)).c_str());
90 }
91
92 compiledScript.Release();
93 }
94
95}

The documentation for this class was generated from the following files: