2786
|
1 |
(*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; version 2 of the License
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
17 |
*)
|
|
18 |
|
|
19 |
{$INCLUDE "options.inc"}
|
|
20 |
|
|
21 |
unit uScript;
|
|
22 |
interface
|
|
23 |
|
|
24 |
procedure ScriptPrintStack;
|
|
25 |
procedure ScriptClearStack;
|
|
26 |
|
|
27 |
procedure ScriptLoad(name : string);
|
|
28 |
procedure ScriptOnGameInit;
|
|
29 |
|
|
30 |
procedure ScriptCall(fname : string);
|
|
31 |
function ScriptCall(fname : string; par1: LongInt) : LongInt;
|
|
32 |
function ScriptCall(fname : string; par1, par2: LongInt) : LongInt;
|
|
33 |
function ScriptCall(fname : string; par1, par2, par3: LongInt) : LongInt;
|
|
34 |
function ScriptCall(fname : string; par1, par2, par3, par4 : LongInt) : LongInt;
|
|
35 |
|
|
36 |
procedure init_uScript;
|
|
37 |
procedure free_uScript;
|
|
38 |
|
|
39 |
implementation
|
|
40 |
uses LuaPas in 'LuaPas.pas',
|
|
41 |
uConsole,
|
|
42 |
uMisc,
|
|
43 |
uConsts,
|
|
44 |
uGears,
|
|
45 |
uFloat,
|
|
46 |
uWorld,
|
|
47 |
uAmmos,
|
|
48 |
uSound,
|
|
49 |
uTeams,
|
|
50 |
uKeys,
|
|
51 |
typinfo;
|
|
52 |
|
|
53 |
var luaState : Plua_State;
|
|
54 |
ScriptAmmoStore : string;
|
|
55 |
|
|
56 |
procedure ScriptPrepareAmmoStore; forward;
|
|
57 |
procedure ScriptApplyAmmoStore; forward;
|
|
58 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); forward;
|
|
59 |
|
|
60 |
// wrapped calls //
|
|
61 |
|
|
62 |
// functions called from lua:
|
|
63 |
// function(L : Plua_State) : LongInt; Cdecl;
|
|
64 |
// where L contains the state, returns the number of return values on the stack
|
|
65 |
// call lua_gettop(L) to receive number of parameters passed
|
|
66 |
|
|
67 |
function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl;
|
|
68 |
begin
|
|
69 |
if lua_gettop(L) = 1 then
|
|
70 |
begin
|
|
71 |
WriteLnToConsole('LUA: ' + lua_tostring(L ,1));
|
|
72 |
end
|
|
73 |
else
|
2791
|
74 |
WriteLnToConsole('LUA: Wrong number of parameters passed to WriteLnToConsole!');
|
2786
|
75 |
lc_writelntoconsole:= 0;
|
|
76 |
end;
|
|
77 |
|
|
78 |
function lc_parsecommand(L : Plua_State) : LongInt; Cdecl;
|
|
79 |
begin
|
|
80 |
if lua_gettop(L) = 1 then
|
|
81 |
begin
|
|
82 |
ParseCommand(lua_tostring(L ,1), true);
|
|
83 |
end
|
|
84 |
else
|
2791
|
85 |
WriteLnToConsole('LUA: Wrong number of parameters passed to ParseCommand!');
|
2786
|
86 |
lc_parsecommand:= 0;
|
|
87 |
end;
|
|
88 |
|
|
89 |
function lc_showmission(L : Plua_State) : LongInt; Cdecl;
|
|
90 |
begin
|
|
91 |
if lua_gettop(L) = 5 then
|
|
92 |
begin
|
|
93 |
ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
|
|
94 |
end
|
|
95 |
else
|
2791
|
96 |
WriteLnToConsole('LUA: Wrong number of parameters passed to ShowMission!');
|
2786
|
97 |
lc_showmission:= 0;
|
|
98 |
end;
|
|
99 |
|
|
100 |
function lc_hidemission(L : Plua_State) : LongInt; Cdecl;
|
|
101 |
begin
|
|
102 |
HideMission;
|
|
103 |
lc_hidemission:= 0;
|
|
104 |
end;
|
|
105 |
|
|
106 |
function lc_addgear(L : Plua_State) : LongInt; Cdecl;
|
|
107 |
var gear : PGear;
|
|
108 |
x, y, s, t: LongInt;
|
|
109 |
dx, dy: hwFloat;
|
|
110 |
gt: TGearType;
|
|
111 |
begin
|
|
112 |
if lua_gettop(L) <> 7 then
|
|
113 |
begin
|
2791
|
114 |
WriteLnToConsole('LUA: Wrong number of parameters passed to AddGear!');
|
2786
|
115 |
lua_pushnil(L); // return value on stack (nil)
|
|
116 |
end
|
|
117 |
else
|
|
118 |
begin
|
|
119 |
x:= lua_tointeger(L, 1);
|
|
120 |
y:= lua_tointeger(L, 2);
|
|
121 |
gt:= TGearType(lua_tointeger(L, 3));
|
|
122 |
s:= lua_tointeger(L, 4);
|
|
123 |
dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000;
|
|
124 |
dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000;
|
|
125 |
t:= lua_tointeger(L, 7);
|
|
126 |
|
|
127 |
gear:= AddGear(x, y, gt, s, dx, dy, t);
|
2790
|
128 |
lua_pushnumber(L, gear^.uid)
|
2786
|
129 |
end;
|
|
130 |
lc_addgear:= 1; // 1 return value
|
|
131 |
end;
|
|
132 |
|
|
133 |
function lc_getgeartype(L : Plua_State) : LongInt; Cdecl;
|
2790
|
134 |
var gear : PGear;
|
2786
|
135 |
begin
|
|
136 |
if lua_gettop(L) <> 1 then
|
|
137 |
begin
|
2791
|
138 |
WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearType!');
|
2786
|
139 |
lua_pushnil(L); // return value on stack (nil)
|
|
140 |
end
|
|
141 |
else
|
2790
|
142 |
begin
|
|
143 |
gear:= GearByUID(lua_tointeger(L, 1));
|
|
144 |
if gear <> nil then
|
|
145 |
lua_pushinteger(L, ord(gear^.Kind))
|
|
146 |
end;
|
2786
|
147 |
lc_getgeartype:= 1
|
|
148 |
end;
|
|
149 |
|
|
150 |
function lc_endgame(L : Plua_State) : LongInt; Cdecl;
|
|
151 |
begin
|
|
152 |
GameState:= gsExit;
|
|
153 |
lc_endgame:= 0
|
|
154 |
end;
|
|
155 |
|
|
156 |
function lc_findplace(L : Plua_State) : LongInt; Cdecl;
|
|
157 |
var gear: PGear;
|
|
158 |
fall: boolean;
|
|
159 |
left, right: LongInt;
|
|
160 |
begin
|
|
161 |
if lua_gettop(L) <> 4 then
|
2791
|
162 |
WriteLnToConsole('LUA: Wrong number of parameters passed to FindPlace!')
|
2786
|
163 |
else
|
|
164 |
begin
|
2790
|
165 |
gear:= GearByUID(lua_tointeger(L, 1));
|
2786
|
166 |
fall:= lua_toboolean(L, 2);
|
|
167 |
left:= lua_tointeger(L, 3);
|
|
168 |
right:= lua_tointeger(L, 4);
|
2790
|
169 |
if gear <> nil then
|
|
170 |
FindPlace(gear, fall, left, right)
|
2786
|
171 |
end;
|
|
172 |
lc_findplace:= 0
|
|
173 |
end;
|
|
174 |
|
|
175 |
function lc_playsound(L : Plua_State) : LongInt; Cdecl;
|
|
176 |
begin
|
|
177 |
if lua_gettop(L) <> 1 then
|
2791
|
178 |
WriteLnToConsole('LUA: Wrong number of parameters passed to PlaySound!')
|
2786
|
179 |
else
|
|
180 |
PlaySound(TSound(lua_tointeger(L, 1)));
|
|
181 |
lc_playsound:= 0;
|
|
182 |
end;
|
|
183 |
|
|
184 |
function lc_addteam(L : Plua_State) : LongInt; Cdecl;
|
|
185 |
begin
|
|
186 |
if lua_gettop(L) <> 5 then
|
2791
|
187 |
WriteLnToConsole('LUA: Wrong number of parameters passed to AddTeam!')
|
2786
|
188 |
else
|
|
189 |
begin
|
|
190 |
ParseCommand('addteam ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true);
|
|
191 |
ParseCommand('grave ' + lua_tostring(L, 3), true);
|
|
192 |
ParseCommand('fort ' + lua_tostring(L, 4), true);
|
|
193 |
ParseCommand('voicepack ' + lua_tostring(L, 5), true);
|
|
194 |
CurrentTeam^.Binds:= DefaultBinds;
|
|
195 |
lua_pushinteger(L, LongInt(CurrentTeam));
|
|
196 |
end;
|
|
197 |
lc_addteam:= 1;
|
|
198 |
end;
|
|
199 |
|
|
200 |
function lc_addhog(L : Plua_State) : LongInt; Cdecl;
|
|
201 |
begin
|
|
202 |
if lua_gettop(L) <> 4 then
|
|
203 |
begin
|
2791
|
204 |
WriteLnToConsole('LUA: Wrong number of parameters passed to AddHog!');
|
2786
|
205 |
lua_pushnil(L)
|
|
206 |
end
|
|
207 |
else
|
|
208 |
begin
|
|
209 |
ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true);
|
|
210 |
ParseCommand('hat ' + lua_tostring(L, 4), true);
|
|
211 |
WriteLnToConsole('last hog: ' + inttostr(LongInt(CurrentHedgehog)));
|
|
212 |
lua_pushinteger(L, LongInt(CurrentHedgehog^.Gear));
|
|
213 |
end;
|
|
214 |
lc_addhog:= 1;
|
|
215 |
end;
|
|
216 |
|
|
217 |
function lc_getgearposition(L : Plua_State) : LongInt; Cdecl;
|
|
218 |
var gear: PGear;
|
|
219 |
begin
|
|
220 |
if lua_gettop(L) <> 1 then
|
|
221 |
begin
|
2791
|
222 |
WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearPosition!');
|
2786
|
223 |
lua_pushnil(L);
|
|
224 |
lua_pushnil(L)
|
|
225 |
end
|
|
226 |
else
|
|
227 |
begin
|
2790
|
228 |
gear:= GearByUID(lua_tointeger(L, 1));
|
|
229 |
if gear <> nil then
|
|
230 |
begin
|
|
231 |
lua_pushinteger(L, hwRound(gear^.X));
|
|
232 |
lua_pushinteger(L, hwRound(gear^.Y))
|
|
233 |
end
|
2786
|
234 |
end;
|
|
235 |
lc_getgearposition:= 2;
|
|
236 |
end;
|
|
237 |
|
|
238 |
function lc_setgearposition(L : Plua_State) : LongInt; Cdecl;
|
|
239 |
var gear: PGear;
|
|
240 |
x, y: LongInt;
|
|
241 |
begin
|
|
242 |
if lua_gettop(L) <> 3 then
|
2791
|
243 |
WriteLnToConsole('LUA: Wrong number of parameters passed to SetGearPosition!')
|
2786
|
244 |
else
|
|
245 |
begin
|
2790
|
246 |
gear:= GearByUID(lua_tointeger(L, 1));
|
|
247 |
if gear <> nil then
|
|
248 |
begin
|
|
249 |
x:= lua_tointeger(L, 2);
|
|
250 |
y:= lua_tointeger(L, 3);
|
|
251 |
gear^.X:= int2hwfloat(x);
|
|
252 |
gear^.Y:= int2hwfloat(y);
|
|
253 |
end
|
2786
|
254 |
end;
|
|
255 |
lc_setgearposition:= 0
|
|
256 |
end;
|
|
257 |
|
|
258 |
function lc_setammo(L : Plua_State) : LongInt; Cdecl;
|
|
259 |
begin
|
|
260 |
if lua_gettop(L) <> 3 then
|
2791
|
261 |
WriteLnToConsole('LUA: Wrong number of parameters passed to SetAmmo!')
|
2786
|
262 |
else
|
|
263 |
begin
|
|
264 |
ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3));
|
|
265 |
end;
|
|
266 |
lc_setammo:= 0
|
|
267 |
end;
|
|
268 |
///////////////////
|
|
269 |
|
|
270 |
procedure ScriptPrintStack;
|
|
271 |
var n, i : LongInt;
|
|
272 |
begin
|
|
273 |
n:= lua_gettop(luaState);
|
2791
|
274 |
WriteLnToConsole('LUA: Stack (' + inttostr(n) + ' elements):');
|
2786
|
275 |
for i:= 1 to n do
|
|
276 |
if not lua_isboolean(luaState, i) then
|
2791
|
277 |
WriteLnToConsole('LUA: ' + inttostr(i) + ': ' + lua_tostring(luaState, i))
|
2786
|
278 |
else if lua_toboolean(luaState, i) then
|
2791
|
279 |
WriteLnToConsole('LUA: ' + inttostr(i) + ': true')
|
2786
|
280 |
else
|
2791
|
281 |
WriteLnToConsole('LUA: ' + inttostr(i) + ': false');
|
2786
|
282 |
end;
|
|
283 |
|
|
284 |
procedure ScriptClearStack;
|
|
285 |
begin
|
|
286 |
lua_settop(luaState, 0)
|
|
287 |
end;
|
|
288 |
|
|
289 |
procedure ScriptSetInteger(name : string; value : LongInt);
|
|
290 |
begin
|
|
291 |
lua_pushinteger(luaState, value);
|
|
292 |
lua_setglobal(luaState, Str2PChar(name));
|
|
293 |
end;
|
|
294 |
|
|
295 |
procedure ScriptSetString(name : string; value : string);
|
|
296 |
begin
|
|
297 |
lua_pushstring(luaState, Str2PChar(value));
|
|
298 |
lua_setglobal(luaState, Str2PChar(name));
|
|
299 |
end;
|
|
300 |
|
|
301 |
function ScriptGetInteger(name : string) : LongInt;
|
|
302 |
begin
|
|
303 |
lua_getglobal(luaState, Str2PChar(name));
|
|
304 |
ScriptGetInteger:= lua_tointeger(luaState, -1);
|
|
305 |
lua_pop(luaState, 1);
|
|
306 |
end;
|
|
307 |
|
|
308 |
function ScriptGetString(name : string) : string;
|
|
309 |
begin
|
|
310 |
lua_getglobal(luaState, Str2PChar(name));
|
|
311 |
ScriptGetString:= lua_tostring(luaState, -1);
|
|
312 |
lua_pop(luaState, 1);
|
|
313 |
end;
|
|
314 |
|
|
315 |
procedure ScriptOnGameInit;
|
|
316 |
begin
|
|
317 |
// push game variables so they may be modified by the script
|
|
318 |
ScriptSetInteger('GameFlags', GameFlags);
|
|
319 |
ScriptSetString('Seed', cSeed);
|
|
320 |
ScriptSetInteger('TurnTime', cHedgehogTurnTime);
|
|
321 |
ScriptSetInteger('CaseFreq', cCaseFactor);
|
|
322 |
ScriptSetInteger('LandAdds', cLandAdditions);
|
|
323 |
ScriptSetInteger('Delay', cInactDelay);
|
|
324 |
ScriptSetString('Map', '');
|
|
325 |
ScriptSetString('Theme', '');
|
|
326 |
|
|
327 |
ScriptCall('onGameInit');
|
|
328 |
|
|
329 |
// pop game variables
|
|
330 |
ParseCommand('seed ' + ScriptGetString('Seed'), true);
|
|
331 |
ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true);
|
|
332 |
ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true);
|
|
333 |
ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true);
|
|
334 |
ParseCommand('$landadds ' + ScriptGetString('LandAdds'), true);
|
|
335 |
ParseCommand('$delay ' + ScriptGetString('Delay'), true);
|
|
336 |
if ScriptGetString('Map') <> '' then
|
|
337 |
ParseCommand('map ' + ScriptGetString('Map'), true);
|
|
338 |
if ScriptGetString('Theme') <> '' then
|
|
339 |
ParseCommand('theme ' + ScriptGetString('Theme'), true);
|
|
340 |
|
|
341 |
ScriptPrepareAmmoStore;
|
|
342 |
ScriptCall('onAmmoStoreInit');
|
|
343 |
ScriptApplyAmmoStore;
|
|
344 |
end;
|
|
345 |
|
|
346 |
procedure ScriptLoad(name : string);
|
|
347 |
var ret : LongInt;
|
|
348 |
begin
|
|
349 |
ret:= luaL_loadfile(luaState, Str2PChar(name));
|
|
350 |
if ret <> 0 then
|
2791
|
351 |
WriteLnToConsole('LUA: Failed to load ' + name + '(error ' + IntToStr(ret) + ')')
|
2786
|
352 |
else
|
|
353 |
begin
|
2791
|
354 |
WriteLnToConsole('LUA: ' + name + ' loaded');
|
2786
|
355 |
// call the script file
|
|
356 |
lua_pcall(luaState, 0, 0, 0);
|
|
357 |
end
|
|
358 |
end;
|
|
359 |
|
|
360 |
procedure ScriptCall(fname : string);
|
|
361 |
begin
|
|
362 |
lua_getglobal(luaState, Str2PChar(fname));
|
|
363 |
if lua_pcall(luaState, 0, 0, 0) <> 0 then
|
|
364 |
begin
|
2791
|
365 |
WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
|
2786
|
366 |
lua_pop(luaState, 1)
|
|
367 |
end;
|
|
368 |
end;
|
|
369 |
|
|
370 |
function ScriptCall(fname : string; par1: LongInt) : LongInt;
|
|
371 |
begin
|
|
372 |
ScriptCall:= ScriptCall(fname, par1, 0, 0, 0)
|
|
373 |
end;
|
|
374 |
|
|
375 |
function ScriptCall(fname : string; par1, par2: LongInt) : LongInt;
|
|
376 |
begin
|
|
377 |
ScriptCall:= ScriptCall(fname, par1, par2, 0, 0)
|
|
378 |
end;
|
|
379 |
|
|
380 |
function ScriptCall(fname : string; par1, par2, par3: LongInt) : LongInt;
|
|
381 |
begin
|
|
382 |
ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
|
|
383 |
end;
|
|
384 |
|
|
385 |
function ScriptCall(fname : string; par1, par2, par3, par4 : LongInt) : LongInt;
|
|
386 |
begin
|
|
387 |
lua_getglobal(luaState, Str2PChar(fname));
|
|
388 |
lua_pushinteger(luaState, par1);
|
|
389 |
lua_pushinteger(luaState, par2);
|
|
390 |
lua_pushinteger(luaState, par3);
|
|
391 |
lua_pushinteger(luaState, par4);
|
|
392 |
ScriptCall:= 0;
|
|
393 |
if lua_pcall(luaState, 4, 1, 0) <> 0 then
|
|
394 |
begin
|
2791
|
395 |
WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
|
2786
|
396 |
lua_pop(luaState, 1)
|
|
397 |
end
|
|
398 |
else
|
|
399 |
begin
|
|
400 |
ScriptCall:= lua_tointeger(luaState, -1);
|
|
401 |
lua_pop(luaState, 1)
|
|
402 |
end;
|
|
403 |
end;
|
|
404 |
|
|
405 |
procedure ScriptPrepareAmmoStore;
|
|
406 |
var i: ShortInt;
|
|
407 |
begin
|
|
408 |
ScriptAmmoStore:= '';
|
|
409 |
for i:=1 to ord(High(TAmmoType)) do
|
|
410 |
ScriptAmmoStore:= ScriptAmmoStore + '00';
|
|
411 |
end;
|
|
412 |
|
|
413 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte);
|
|
414 |
begin
|
|
415 |
if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) then
|
|
416 |
exit;
|
|
417 |
ScriptAmmoStore[ord(ammo)]:= inttostr(count)[1];
|
|
418 |
ScriptAmmoStore[ord(ammo) + ord(high(TAmmoType))]:= inttostr(propability)[1];
|
|
419 |
end;
|
|
420 |
|
|
421 |
procedure ScriptApplyAmmoStore;
|
|
422 |
begin
|
|
423 |
AddAmmoStore(ScriptAmmoStore);
|
|
424 |
end;
|
|
425 |
|
|
426 |
// small helper functions making registering enums a lot easier
|
|
427 |
function str(const en : TGearType) : string; overload;
|
|
428 |
begin
|
|
429 |
str:= GetEnumName(TypeInfo(TGearType), ord(en))
|
|
430 |
end;
|
|
431 |
|
|
432 |
function str(const en : TSound) : string; overload;
|
|
433 |
begin
|
|
434 |
str:= GetEnumName(TypeInfo(TSound), ord(en))
|
|
435 |
end;
|
|
436 |
|
|
437 |
function str(const en : TAmmoType) : string; overload;
|
|
438 |
begin
|
|
439 |
str:= GetEnumName(TypeInfo(TAmmoType), ord(en))
|
|
440 |
end;
|
|
441 |
///////////////////
|
|
442 |
|
|
443 |
procedure init_uScript;
|
|
444 |
var at : TGearType;
|
|
445 |
am : TAmmoType;
|
|
446 |
st : TSound;
|
|
447 |
begin
|
|
448 |
// initialize lua
|
|
449 |
luaState:= lua_open;
|
|
450 |
|
|
451 |
// open internal libraries
|
|
452 |
luaopen_base(luaState);
|
|
453 |
luaopen_string(luaState);
|
|
454 |
luaopen_math(luaState);
|
|
455 |
|
|
456 |
// import some variables
|
|
457 |
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
|
|
458 |
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
|
|
459 |
|
|
460 |
// import game flags
|
|
461 |
ScriptSetInteger('gfForts',gfForts);
|
|
462 |
ScriptSetInteger('gfMultiWeapon',gfMultiWeapon);
|
|
463 |
ScriptSetInteger('gfSolidLand',gfSolidLand);
|
|
464 |
ScriptSetInteger('gfBorder',gfBorder);
|
|
465 |
ScriptSetInteger('gfDivideTeams',gfDivideTeams);
|
|
466 |
ScriptSetInteger('gfLowGravity',gfLowGravity);
|
|
467 |
ScriptSetInteger('gfLaserSight',gfLaserSight);
|
|
468 |
ScriptSetInteger('gfInvulnerable',gfInvulnerable);
|
|
469 |
ScriptSetInteger('gfMines',gfMines);
|
|
470 |
ScriptSetInteger('gfVampiric',gfVampiric);
|
|
471 |
ScriptSetInteger('gfKarma',gfKarma);
|
|
472 |
ScriptSetInteger('gfArtillery',gfArtillery);
|
|
473 |
ScriptSetInteger('gfOneClanMode',gfOneClanMode);
|
|
474 |
ScriptSetInteger('gfRandomOrder',gfRandomOrder);
|
|
475 |
ScriptSetInteger('gfKing',gfKing);
|
|
476 |
|
|
477 |
// register gear types
|
|
478 |
for at:= Low(TGearType) to High(TGearType) do
|
|
479 |
ScriptSetInteger(str(at), ord(at));
|
|
480 |
|
|
481 |
// register sounds
|
|
482 |
for st:= Low(TSound) to High(TSound) do
|
|
483 |
ScriptSetInteger(str(st), ord(st));
|
|
484 |
|
|
485 |
// register ammo types
|
|
486 |
for am:= Low(TAmmoType) to High(TAmmoType) do
|
|
487 |
ScriptSetInteger(str(am), ord(am));
|
|
488 |
|
|
489 |
// register functions
|
|
490 |
lua_register(luaState, 'AddGear', @lc_addgear);
|
|
491 |
lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole);
|
|
492 |
lua_register(luaState, 'GetGearType', @lc_getgeartype);
|
|
493 |
lua_register(luaState, 'EndGame', @lc_endgame);
|
|
494 |
lua_register(luaState, 'FindPlace', @lc_findplace);
|
|
495 |
lua_register(luaState, 'SetGearPosition', @lc_setgearposition);
|
|
496 |
lua_register(luaState, 'GetGearPosition', @lc_getgearposition);
|
|
497 |
lua_register(luaState, 'ParseCommand', @lc_parsecommand);
|
|
498 |
lua_register(luaState, 'ShowMission', @lc_showmission);
|
|
499 |
lua_register(luaState, 'HideMission', @lc_hidemission);
|
|
500 |
lua_register(luaState, 'SetAmmo', @lc_setammo);
|
|
501 |
lua_register(luaState, 'PlaySound', @lc_playsound);
|
|
502 |
lua_register(luaState, 'AddTeam', @lc_addteam);
|
|
503 |
lua_register(luaState, 'AddHog', @lc_addhog);
|
|
504 |
|
|
505 |
ScriptClearStack; // just to be sure stack is empty
|
|
506 |
end;
|
|
507 |
|
|
508 |
procedure free_uScript;
|
|
509 |
begin
|
|
510 |
lua_close(luaState);
|
|
511 |
end;
|
|
512 |
|
|
513 |
end.
|