36 lines
No EOL
723 B
C++
36 lines
No EOL
723 B
C++
#ifndef _H_SCRIPT_H
|
|
#define _H_SCRIPT_H
|
|
|
|
#define SOL_ALL_SAFETIES_ON 1
|
|
|
|
#include <sol/sol.hpp>
|
|
#include <memory>
|
|
|
|
class Script {
|
|
public:
|
|
sol::state lua;
|
|
Script(const std::string& path);
|
|
virtual ~Script() {};
|
|
private:
|
|
bool loadScript(const std::string& path) {
|
|
auto result = lua.script_file(path);
|
|
if (!result.valid())
|
|
{
|
|
sol::error err = result;
|
|
std::cerr << "Failed to load script ( " << path << " ) Error: " << err.what() << std::endl;
|
|
}
|
|
return result.valid();
|
|
}
|
|
virtual void registerUserTypes() {};
|
|
};
|
|
|
|
class AIScript : public Script {
|
|
public:
|
|
AIScript(const std::string& path) : Script(path) { registerUserTypes(); }
|
|
|
|
private:
|
|
|
|
virtual void registerUserTypes() override;
|
|
};
|
|
|
|
#endif // _H_SCRIPT_H
|