-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaWrapper.h
More file actions
77 lines (47 loc) · 1.22 KB
/
LuaWrapper.h
File metadata and controls
77 lines (47 loc) · 1.22 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* LuaWrapper.h
*
* Created on: 2015-12-02
* Author: 11110305
*/
#ifndef LUAWRAPPER_H_
#define LUAWRAPPER_H_
#include <vector>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <iostream>
struct WrapperData
{
char type; // Look below
const char* name; // Name of the variable in lua
void * WrapperValue;
bool output; // In or out
};
const char Lua_TypeInt = 0;
const char Lua_TypeFloat = 1;
const char Lua_TypeBool = 2;
const char Lua_TypeString = 3;
const int LUAFlag_ResetGyro = 0;
const int LUAFlag_ResetEncoder = 1;
class LuaWrapper {
public:
LuaWrapper();
virtual ~LuaWrapper();
void LoadFile(const char * file);
void Update();
void PushData(char, const char*, void*, bool);
void PushVariable(const char * name, const char* value); // Strings
void PushVariable(const char * name, int value); // Ints
void PushVariable(const char * name, float value); // Floats
void PushVariable(const char * name, bool value); // Bools
std::vector<int> * GetActions();
private:
lua_State * L;
void WriteAllData();
void ReadAllData();
void WriteData(const char*, void*, char);
void ReadData(const char*, void*, char);
std::vector<WrapperData*> data;
};
#endif /* LUAWRAPPER_H_ */