forked from cheat-engine/cheat-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LuaCheatComponent.pas
206 lines (163 loc) · 5.32 KB
/
LuaCheatComponent.pas
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
unit LuaCheatComponent;
{$mode delphi}
interface
uses
Classes, SysUtils,lua, lualib, lauxlib, LuaHandler, LuaCaller,
ExtCtrls, StdCtrls, ExtraTrainerComponents;
procedure initializeLuaCheatComponent;
implementation
uses LuaClass, LuaWinControl;
function cheatcomponent_getActive(L: PLua_State): integer; cdecl;
var
cheatcomponent: TCheat;
begin
cheatcomponent:=luaclass_getClassObject(L);
lua_pushboolean(L, cheatcomponent.activated);
result:=1;
end;
function cheatcomponent_setActive(L: PLua_State): integer; cdecl;
var
paramstart, paramcount: integer;
cheatcomponent: TCheat;
deactivatetime: integer;
t: TTimer;
begin
result:=0;
cheatcomponent:=luaclass_getClassObject(L, @paramstart, @paramcount);
if paramcount>=1 then
begin
cheatcomponent.activated:=lua_toboolean(L,paramstart);
if paramcount=2 then
begin
deactivatetime:=lua_tointeger(L,paramstart+1);
if cheatcomponent.activated then
cheatcomponent.setDeactivateTimer(deactivatetime);
end;
end;
end;
function cheatcomponent_getDescription(L: PLua_State): integer; cdecl;
var
parameters: integer;
cheatcomponent: TCheat;
begin
cheatcomponent:=luaclass_getClassObject(L);
lua_pushstring(L, cheatcomponent.Description);
result:=1;
end;
function cheatcomponent_setDescription(L: PLua_State): integer; cdecl;
var
parameters: integer;
cheatcomponent: TCheat;
deactivatetime: integer;
t: TTimer;
begin
result:=0;
cheatcomponent:=luaclass_getClassObject(L);
if lua_gettop(L)>=1 then
cheatcomponent.Description:=Lua_ToString(L,-1);
end;
function cheatcomponent_getHotkey(L: PLua_State): integer; cdecl;
var
parameters: integer;
cheatcomponent: TCheat;
begin
result:=0;
cheatcomponent:=luaclass_getClassObject(L);
lua_pushstring(L, cheatcomponent.Hotkey);
result:=1;
end;
function cheatcomponent_setHotkey(L: PLua_State): integer; cdecl;
var
cheatcomponent: TCheat;
deactivatetime: integer;
t: TTimer;
begin
result:=0;
cheatcomponent:=luaclass_getClassObject(L);
if lua_gettop(L)>=1 then
cheatcomponent.Hotkey:=Lua_ToString(L,-1);
end;
function cheatcomponent_getDescriptionLeft(L: PLua_State): integer; cdecl;
var
cheatcomponent: TCheat;
begin
cheatcomponent:=luaclass_getClassObject(L);
lua_pushinteger(L, cheatcomponent.DescriptionLeft);
result:=1;
end;
function cheatcomponent_setDescriptionLeft(L: PLua_State): integer; cdecl;
var
parameters: integer;
cheatcomponent: TCheat;
deactivatetime: integer;
t: TTimer;
begin
result:=0;
cheatcomponent:=luaclass_getClassObject(L);
if lua_gettop(L)>=1 then
cheatcomponent.Descriptionleft:=lua_tointeger(L,-1);
end;
function cheatcomponent_getHotkeyLeft(L: PLua_State): integer; cdecl;
var
parameters: integer;
cheatcomponent: TCheat;
begin
result:=0;
cheatcomponent:=luaclass_getClassObject(L);
lua_pushinteger(L, cheatcomponent.Hotkeyleft);
result:=1;
end;
function cheatcomponent_setHotkeyLeft(L: PLua_State): integer; cdecl;
var
cheatcomponent: TCheat;
deactivatetime: integer;
t: TTimer;
begin
result:=0;
cheatcomponent:=luaclass_getClassObject(L);
if lua_gettop(L)>=1 then
cheatcomponent.Hotkeyleft:=lua_tointeger(L,-1);
end;
function cheatcomponent_getEditValue(L: PLua_State): integer; cdecl;
var
cheatcomponent: TCheat;
begin
cheatcomponent:=luaclass_getClassObject(L);
lua_pushstring(L, cheatcomponent.EditValue);
result:=1;
end;
function cheatcomponent_setEditValue(L: PLua_State): integer; cdecl;
var
parameters: integer;
cheatcomponent: TCheat;
deactivatetime: integer;
t: TTimer;
begin
cheatcomponent:=luaclass_getClassObject(L);
if lua_gettop(L)>=1 then
cheatcomponent.EditValue:=Lua_ToString(L,-1);
end;
procedure cheatcomponent_addMetaData(L: PLua_state; metatable: integer; userdata: integer );
begin
wincontrol_addMetaData(L, metatable, userdata);
luaclass_addClassFunctionToTable(L, metatable, userdata, 'setActive', cheatcomponent_setActive);
luaclass_addClassFunctionToTable(L, metatable, userdata, 'getActive', cheatcomponent_getActive);
end;
procedure initializeLuaCheatComponent;
begin
Lua_register(LuaVM, 'cheatcomponent_setActive', cheatcomponent_setActive);
Lua_register(LuaVM, 'cheatcomponent_getActive', cheatcomponent_getActive);
Lua_register(LuaVM, 'cheatcomponent_setDescription', cheatcomponent_setDescription);
Lua_register(LuaVM, 'cheatcomponent_getDescription', cheatcomponent_getDescription);
Lua_register(LuaVM, 'cheatcomponent_setHotkey', cheatcomponent_setHotkey);
Lua_register(LuaVM, 'cheatcomponent_getHotkey', cheatcomponent_getHotkey);
Lua_register(LuaVM, 'cheatcomponent_setDescriptionLeft', cheatcomponent_setDescriptionLeft);
Lua_register(LuaVM, 'cheatcomponent_getDescriptionLeft', cheatcomponent_getDescriptionLeft);
Lua_register(LuaVM, 'cheatcomponent_setHotkeyLeft', cheatcomponent_setHotkeyLeft);
Lua_register(LuaVM, 'cheatcomponent_getHotkeyLeft', cheatcomponent_getHotkeyLeft);
Lua_register(LuaVM, 'cheatcomponent_setEditValue', cheatcomponent_setEditValue);
Lua_register(LuaVM, 'cheatcomponent_getEditValue', cheatcomponent_getEditValue);
end;
initialization
luaclass_register(TCheat, cheatcomponent_addMetaData);
end.