summaryrefslogtreecommitdiff
path: root/scripting.h
blob: 4b0bacf11e658a102e44954167cf415ffe5a2dff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef SCRIPTING_H
#define SCRIPTING_H

#include <lua.hpp>
#include <boost/function.hpp>

#include <string>
#include <stdexcept>

class LuaError : public std::runtime_error {
	public:
		LuaError(const std::string& s) : std::runtime_error(s) {};
};

class Lua {
	protected:
		lua_State *L;
		boost::function<void (const char*)> log_func;
		boost::function<void (const char*)> say_func;

	public:
		Lua();
		virtual ~Lua();

		void set_log_func(boost::function<void (const char*)> log_func);
		void set_say_func(boost::function<void (const char*)> say_func);
		void print(const char *s);
		void say(const char *s);

		void dostring(std::string s);
};

#endif