author | smxx |
Sat, 06 Mar 2010 13:56:33 +0000 | |
changeset 2959 | 258218a50df8 |
parent 2949 | d137a9da7701 |
child 2996 | dfc7507a21a0 |
permissions | -rw-r--r-- |
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 |
||
2905 | 27 |
procedure ScriptLoad(name : shortstring); |
2786 | 28 |
procedure ScriptOnGameInit; |
29 |
||
2905 | 30 |
procedure ScriptCall(fname : shortstring); |
31 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
|
32 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
|
33 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
|
34 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
|
2786 | 35 |
|
36 |
procedure init_uScript; |
|
37 |
procedure free_uScript; |
|
38 |
||
39 |
implementation |
|
2798 | 40 |
{$IFNDEF IPHONEOS} |
2786 | 41 |
uses LuaPas in 'LuaPas.pas', |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
42 |
uConsole, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
43 |
uMisc, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
44 |
uConsts, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
45 |
uGears, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
46 |
uFloat, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
47 |
uWorld, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
48 |
uAmmos, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
49 |
uSound, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
50 |
uTeams, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
51 |
uKeys, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
52 |
typinfo; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
53 |
|
2786 | 54 |
var luaState : Plua_State; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
55 |
ScriptAmmoStore : shortstring; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
56 |
ScriptLoaded : boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
57 |
|
2786 | 58 |
procedure ScriptPrepareAmmoStore; forward; |
59 |
procedure ScriptApplyAmmoStore; forward; |
|
60 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); forward; |
|
61 |
||
62 |
// wrapped calls // |
|
63 |
||
64 |
// functions called from lua: |
|
65 |
// function(L : Plua_State) : LongInt; Cdecl; |
|
66 |
// where L contains the state, returns the number of return values on the stack |
|
67 |
// call lua_gettop(L) to receive number of parameters passed |
|
68 |
||
69 |
function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
|
70 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
71 |
if lua_gettop(L) = 1 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
72 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
73 |
WriteLnToConsole('LUA: ' + lua_tostring(L ,1)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
74 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
75 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
76 |
WriteLnToConsole('LUA: Wrong number of parameters passed to WriteLnToConsole!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
77 |
lc_writelntoconsole:= 0; |
2786 | 78 |
end; |
79 |
||
80 |
function lc_parsecommand(L : Plua_State) : LongInt; Cdecl; |
|
81 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
82 |
if lua_gettop(L) = 1 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
83 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
84 |
ParseCommand(lua_tostring(L ,1), true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
85 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
86 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
87 |
WriteLnToConsole('LUA: Wrong number of parameters passed to ParseCommand!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
88 |
lc_parsecommand:= 0; |
2786 | 89 |
end; |
90 |
||
91 |
function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
|
92 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
93 |
if lua_gettop(L) = 5 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
94 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
95 |
ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
96 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
97 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
98 |
WriteLnToConsole('LUA: Wrong number of parameters passed to ShowMission!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
99 |
lc_showmission:= 0; |
2786 | 100 |
end; |
101 |
||
102 |
function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
|
103 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
104 |
HideMission; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
105 |
lc_hidemission:= 0; |
2786 | 106 |
end; |
107 |
||
108 |
function lc_addgear(L : Plua_State) : LongInt; Cdecl; |
|
109 |
var gear : PGear; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
110 |
x, y, s, t: LongInt; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
111 |
dx, dy: hwFloat; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
112 |
gt: TGearType; |
2786 | 113 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
114 |
if lua_gettop(L) <> 7 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
115 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
116 |
WriteLnToConsole('LUA: Wrong number of parameters passed to AddGear!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
117 |
lua_pushnil(L); // return value on stack (nil) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
118 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
119 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
120 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
121 |
x:= lua_tointeger(L, 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
122 |
y:= lua_tointeger(L, 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
123 |
gt:= TGearType(lua_tointeger(L, 3)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
124 |
s:= lua_tointeger(L, 4); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
125 |
dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
126 |
dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
127 |
t:= lua_tointeger(L, 7); |
2786 | 128 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
129 |
gear:= AddGear(x, y, gt, s, dx, dy, t); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
130 |
lua_pushnumber(L, gear^.uid) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
131 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
132 |
lc_addgear:= 1; // 1 return value |
2786 | 133 |
end; |
134 |
||
135 |
function lc_getgeartype(L : Plua_State) : LongInt; Cdecl; |
|
2790 | 136 |
var gear : PGear; |
2786 | 137 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
138 |
if lua_gettop(L) <> 1 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
139 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
140 |
WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearType!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
141 |
lua_pushnil(L); // return value on stack (nil) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
142 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
143 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
144 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
145 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
146 |
if gear <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
147 |
lua_pushinteger(L, ord(gear^.Kind)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
148 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
149 |
lc_getgeartype:= 1 |
2786 | 150 |
end; |
151 |
||
2814 | 152 |
function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
153 |
var gear : PGear; |
|
154 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
155 |
if lua_gettop(L) <> 2 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
156 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
157 |
WriteLnToConsole('LUA: Wrong number of parameters passed to SetHealth!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
158 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
159 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
160 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
161 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
162 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) then gear^.Health:= lua_tointeger(L, 2) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
163 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
164 |
lc_sethealth:= 0 |
2814 | 165 |
end; |
166 |
||
2786 | 167 |
function lc_endgame(L : Plua_State) : LongInt; Cdecl; |
168 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
169 |
GameState:= gsExit; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
170 |
lc_endgame:= 0 |
2786 | 171 |
end; |
172 |
||
173 |
function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
|
174 |
var gear: PGear; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
175 |
fall: boolean; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
176 |
left, right: LongInt; |
2786 | 177 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
178 |
if lua_gettop(L) <> 4 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
179 |
WriteLnToConsole('LUA: Wrong number of parameters passed to FindPlace!') |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
180 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
181 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
182 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
183 |
fall:= lua_toboolean(L, 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
184 |
left:= lua_tointeger(L, 3); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
185 |
right:= lua_tointeger(L, 4); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
186 |
if gear <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
187 |
FindPlace(gear, fall, left, right) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
188 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
189 |
lc_findplace:= 0 |
2786 | 190 |
end; |
191 |
||
192 |
function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
|
193 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
194 |
if lua_gettop(L) <> 1 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
195 |
WriteLnToConsole('LUA: Wrong number of parameters passed to PlaySound!') |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
196 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
197 |
PlaySound(TSound(lua_tointeger(L, 1))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
198 |
lc_playsound:= 0; |
2786 | 199 |
end; |
200 |
||
201 |
function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
|
202 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
203 |
if lua_gettop(L) <> 5 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
204 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
205 |
WriteLnToConsole('LUA: Wrong number of parameters passed to AddTeam!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
206 |
//lua_pushnil(L) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
207 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
208 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
209 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
210 |
ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
211 |
ParseCommand('grave ' + lua_tostring(L, 3), true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
212 |
ParseCommand('fort ' + lua_tostring(L, 4), true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
213 |
ParseCommand('voicepack ' + lua_tostring(L, 5), true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
214 |
CurrentTeam^.Binds:= DefaultBinds; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
215 |
// fails on x64 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
216 |
//lua_pushinteger(L, LongInt(CurrentTeam)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
217 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
218 |
lc_addteam:= 0;//1; |
2786 | 219 |
end; |
220 |
||
221 |
function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
|
222 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
223 |
if lua_gettop(L) <> 4 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
224 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
225 |
WriteLnToConsole('LUA: Wrong number of parameters passed to AddHog!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
226 |
lua_pushnil(L) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
227 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
228 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
229 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
230 |
ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
231 |
ParseCommand('hat ' + lua_tostring(L, 4), true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
232 |
lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
233 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
234 |
lc_addhog:= 1; |
2786 | 235 |
end; |
236 |
||
237 |
function lc_getgearposition(L : Plua_State) : LongInt; Cdecl; |
|
238 |
var gear: PGear; |
|
239 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
240 |
if lua_gettop(L) <> 1 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
241 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
242 |
WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearPosition!'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
243 |
lua_pushnil(L); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
244 |
lua_pushnil(L) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
245 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
246 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
247 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
248 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
249 |
if gear <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
250 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
251 |
lua_pushinteger(L, hwRound(gear^.X)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
252 |
lua_pushinteger(L, hwRound(gear^.Y)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
253 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
254 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
255 |
lc_getgearposition:= 2; |
2786 | 256 |
end; |
257 |
||
258 |
function lc_setgearposition(L : Plua_State) : LongInt; Cdecl; |
|
259 |
var gear: PGear; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
260 |
x, y: LongInt; |
2786 | 261 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
262 |
if lua_gettop(L) <> 3 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
263 |
WriteLnToConsole('LUA: Wrong number of parameters passed to SetGearPosition!') |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
264 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
265 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
266 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
267 |
if gear <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
268 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
269 |
x:= lua_tointeger(L, 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
270 |
y:= lua_tointeger(L, 3); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
271 |
gear^.X:= int2hwfloat(x); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
272 |
gear^.Y:= int2hwfloat(y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
273 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
274 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
275 |
lc_setgearposition:= 0 |
2786 | 276 |
end; |
277 |
||
278 |
function lc_setammo(L : Plua_State) : LongInt; Cdecl; |
|
279 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
280 |
if lua_gettop(L) <> 3 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
281 |
WriteLnToConsole('LUA: Wrong number of parameters passed to SetAmmo!') |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
282 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
283 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
284 |
ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
285 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
286 |
lc_setammo:= 0 |
2786 | 287 |
end; |
288 |
/////////////////// |
|
289 |
||
290 |
procedure ScriptPrintStack; |
|
291 |
var n, i : LongInt; |
|
292 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
293 |
n:= lua_gettop(luaState); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
294 |
WriteLnToConsole('LUA: Stack (' + inttostr(n) + ' elements):'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
295 |
for i:= 1 to n do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
296 |
if not lua_isboolean(luaState, i) then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
297 |
WriteLnToConsole('LUA: ' + inttostr(i) + ': ' + lua_tostring(luaState, i)) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
298 |
else if lua_toboolean(luaState, i) then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
299 |
WriteLnToConsole('LUA: ' + inttostr(i) + ': true') |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
300 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
301 |
WriteLnToConsole('LUA: ' + inttostr(i) + ': false'); |
2786 | 302 |
end; |
303 |
||
304 |
procedure ScriptClearStack; |
|
305 |
begin |
|
306 |
lua_settop(luaState, 0) |
|
307 |
end; |
|
308 |
||
2905 | 309 |
procedure ScriptSetInteger(name : shortstring; value : LongInt); |
2786 | 310 |
begin |
311 |
lua_pushinteger(luaState, value); |
|
312 |
lua_setglobal(luaState, Str2PChar(name)); |
|
313 |
end; |
|
314 |
||
2905 | 315 |
procedure ScriptSetString(name : shortstring; value : shortstring); |
2786 | 316 |
begin |
317 |
lua_pushstring(luaState, Str2PChar(value)); |
|
318 |
lua_setglobal(luaState, Str2PChar(name)); |
|
319 |
end; |
|
320 |
||
2905 | 321 |
function ScriptGetInteger(name : shortstring) : LongInt; |
2786 | 322 |
begin |
323 |
lua_getglobal(luaState, Str2PChar(name)); |
|
324 |
ScriptGetInteger:= lua_tointeger(luaState, -1); |
|
325 |
lua_pop(luaState, 1); |
|
326 |
end; |
|
327 |
||
2905 | 328 |
function ScriptGetString(name : shortstring) : shortstring; |
2786 | 329 |
begin |
330 |
lua_getglobal(luaState, Str2PChar(name)); |
|
331 |
ScriptGetString:= lua_tostring(luaState, -1); |
|
332 |
lua_pop(luaState, 1); |
|
333 |
end; |
|
334 |
||
335 |
procedure ScriptOnGameInit; |
|
2949 | 336 |
var s, t : ansistring; |
2786 | 337 |
begin |
2949 | 338 |
// not required if there's no script to run |
339 |
if not ScriptLoaded then |
|
340 |
exit; |
|
341 |
||
342 |
// push game variables so they may be modified by the script |
|
343 |
ScriptSetInteger('GameFlags', GameFlags); |
|
344 |
ScriptSetString('Seed', cSeed); |
|
345 |
ScriptSetInteger('TurnTime', cHedgehogTurnTime); |
|
346 |
ScriptSetInteger('CaseFreq', cCaseFactor); |
|
347 |
ScriptSetInteger('LandAdds', cLandAdditions); |
|
348 |
ScriptSetInteger('Delay', cInactDelay); |
|
349 |
ScriptSetString('Map', ''); |
|
350 |
ScriptSetString('Theme', ''); |
|
2786 | 351 |
|
2949 | 352 |
// import locale |
353 |
s:= cLocaleFName; |
|
354 |
SplitByChar(s, t, '.'); |
|
355 |
ScriptSetString('L', s); |
|
356 |
||
357 |
ScriptCall('onGameInit'); |
|
2786 | 358 |
|
2949 | 359 |
// pop game variables |
360 |
ParseCommand('seed ' + ScriptGetString('Seed'), true); |
|
361 |
ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true); |
|
362 |
ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true); |
|
363 |
ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true); |
|
364 |
ParseCommand('$landadds ' + ScriptGetString('LandAdds'), true); |
|
365 |
ParseCommand('$delay ' + ScriptGetString('Delay'), true); |
|
366 |
if ScriptGetString('Map') <> '' then |
|
367 |
ParseCommand('map ' + ScriptGetString('Map'), true); |
|
368 |
if ScriptGetString('Theme') <> '' then |
|
369 |
ParseCommand('theme ' + ScriptGetString('Theme'), true); |
|
370 |
||
371 |
ScriptPrepareAmmoStore; |
|
372 |
ScriptCall('onAmmoStoreInit'); |
|
373 |
ScriptApplyAmmoStore; |
|
2786 | 374 |
end; |
375 |
||
2905 | 376 |
procedure ScriptLoad(name : shortstring); |
2786 | 377 |
var ret : LongInt; |
378 |
begin |
|
2949 | 379 |
ret:= luaL_loadfile(luaState, Str2PChar(name)); |
380 |
if ret <> 0 then |
|
381 |
WriteLnToConsole('LUA: Failed to load ' + name + '(error ' + IntToStr(ret) + ')') |
|
382 |
else |
|
383 |
begin |
|
384 |
WriteLnToConsole('LUA: ' + name + ' loaded'); |
|
385 |
// call the script file |
|
386 |
lua_pcall(luaState, 0, 0, 0); |
|
387 |
ScriptLoaded:= true |
|
388 |
end |
|
2786 | 389 |
end; |
390 |
||
2814 | 391 |
procedure SetGlobals; |
392 |
begin |
|
2949 | 393 |
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
2814 | 394 |
end; |
395 |
||
396 |
procedure GetGlobals; |
|
397 |
begin |
|
2949 | 398 |
TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); |
2814 | 399 |
end; |
400 |
||
2905 | 401 |
procedure ScriptCall(fname : shortstring); |
2786 | 402 |
begin |
2949 | 403 |
if not ScriptLoaded then |
404 |
exit; |
|
405 |
SetGlobals; |
|
406 |
lua_getglobal(luaState, Str2PChar(fname)); |
|
407 |
if lua_pcall(luaState, 0, 0, 0) <> 0 then |
|
408 |
begin |
|
409 |
WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
|
410 |
lua_pop(luaState, 1) |
|
411 |
end; |
|
412 |
GetGlobals; |
|
2786 | 413 |
end; |
414 |
||
2905 | 415 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
2786 | 416 |
begin |
417 |
ScriptCall:= ScriptCall(fname, par1, 0, 0, 0) |
|
418 |
end; |
|
419 |
||
2905 | 420 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
2786 | 421 |
begin |
422 |
ScriptCall:= ScriptCall(fname, par1, par2, 0, 0) |
|
423 |
end; |
|
424 |
||
2905 | 425 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
2786 | 426 |
begin |
427 |
ScriptCall:= ScriptCall(fname, par1, par2, par3, 0) |
|
428 |
end; |
|
429 |
||
2905 | 430 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
2786 | 431 |
begin |
2949 | 432 |
if not ScriptLoaded then |
433 |
exit; |
|
434 |
SetGlobals; |
|
435 |
lua_getglobal(luaState, Str2PChar(fname)); |
|
436 |
lua_pushinteger(luaState, par1); |
|
437 |
lua_pushinteger(luaState, par2); |
|
438 |
lua_pushinteger(luaState, par3); |
|
439 |
lua_pushinteger(luaState, par4); |
|
440 |
ScriptCall:= 0; |
|
441 |
if lua_pcall(luaState, 4, 1, 0) <> 0 then |
|
442 |
begin |
|
443 |
WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
|
444 |
lua_pop(luaState, 1) |
|
445 |
end |
|
446 |
else |
|
447 |
begin |
|
448 |
ScriptCall:= lua_tointeger(luaState, -1); |
|
449 |
lua_pop(luaState, 1) |
|
450 |
end; |
|
451 |
GetGlobals; |
|
2786 | 452 |
end; |
453 |
||
454 |
procedure ScriptPrepareAmmoStore; |
|
455 |
var i: ShortInt; |
|
456 |
begin |
|
457 |
ScriptAmmoStore:= ''; |
|
458 |
for i:=1 to ord(High(TAmmoType)) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
459 |
ScriptAmmoStore:= ScriptAmmoStore + '0000'; |
2786 | 460 |
end; |
461 |
||
462 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); |
|
463 |
begin |
|
464 |
if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
465 |
exit; |
2786 | 466 |
ScriptAmmoStore[ord(ammo)]:= inttostr(count)[1]; |
467 |
ScriptAmmoStore[ord(ammo) + ord(high(TAmmoType))]:= inttostr(propability)[1]; |
|
468 |
end; |
|
469 |
||
470 |
procedure ScriptApplyAmmoStore; |
|
471 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
472 |
AddAmmoStore(ScriptAmmoStore); |
2786 | 473 |
end; |
474 |
||
475 |
// small helper functions making registering enums a lot easier |
|
2905 | 476 |
function str(const en : TGearType) : shortstring; overload; |
2786 | 477 |
begin |
478 |
str:= GetEnumName(TypeInfo(TGearType), ord(en)) |
|
479 |
end; |
|
480 |
||
2905 | 481 |
function str(const en : TSound) : shortstring; overload; |
2786 | 482 |
begin |
483 |
str:= GetEnumName(TypeInfo(TSound), ord(en)) |
|
484 |
end; |
|
485 |
||
2905 | 486 |
function str(const en : TAmmoType) : shortstring; overload; |
2786 | 487 |
begin |
488 |
str:= GetEnumName(TypeInfo(TAmmoType), ord(en)) |
|
489 |
end; |
|
490 |
/////////////////// |
|
491 |
||
492 |
procedure init_uScript; |
|
493 |
var at : TGearType; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
494 |
am : TAmmoType; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
495 |
st : TSound; |
2786 | 496 |
begin |
497 |
// initialize lua |
|
498 |
luaState:= lua_open; |
|
499 |
||
500 |
// open internal libraries |
|
501 |
luaopen_base(luaState); |
|
502 |
luaopen_string(luaState); |
|
503 |
luaopen_math(luaState); |
|
504 |
||
505 |
// import some variables |
|
506 |
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
|
507 |
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
|
508 |
||
509 |
// import game flags |
|
2949 | 510 |
ScriptSetInteger('gfForts', gfForts); |
511 |
ScriptSetInteger('gfMultiWeapon', gfMultiWeapon); |
|
512 |
ScriptSetInteger('gfSolidLand', gfSolidLand); |
|
513 |
ScriptSetInteger('gfBorder', gfBorder); |
|
514 |
ScriptSetInteger('gfDivideTeams', gfDivideTeams); |
|
515 |
ScriptSetInteger('gfLowGravity', gfLowGravity); |
|
516 |
ScriptSetInteger('gfLaserSight', gfLaserSight); |
|
517 |
ScriptSetInteger('gfInvulnerable', gfInvulnerable); |
|
518 |
ScriptSetInteger('gfMines', gfMines); |
|
519 |
ScriptSetInteger('gfVampiric', gfVampiric); |
|
520 |
ScriptSetInteger('gfKarma', gfKarma); |
|
521 |
ScriptSetInteger('gfArtillery', gfArtillery); |
|
522 |
ScriptSetInteger('gfOneClanMode', gfOneClanMode); |
|
523 |
ScriptSetInteger('gfRandomOrder', gfRandomOrder); |
|
524 |
ScriptSetInteger('gfKing', gfKing); |
|
525 |
ScriptSetInteger('gfPlaceHog', gfPlaceHog); |
|
526 |
ScriptSetInteger('gfSharedAmmo', gfSharedAmmo); |
|
527 |
ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
|
528 |
ScriptSetInteger('gfExplosives', gfExplosives); |
|
2786 | 529 |
|
530 |
// register gear types |
|
531 |
for at:= Low(TGearType) to High(TGearType) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
532 |
ScriptSetInteger(str(at), ord(at)); |
2786 | 533 |
|
534 |
// register sounds |
|
535 |
for st:= Low(TSound) to High(TSound) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
536 |
ScriptSetInteger(str(st), ord(st)); |
2786 | 537 |
|
538 |
// register ammo types |
|
539 |
for am:= Low(TAmmoType) to High(TAmmoType) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
540 |
ScriptSetInteger(str(am), ord(am)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
541 |
|
2786 | 542 |
// register functions |
543 |
lua_register(luaState, 'AddGear', @lc_addgear); |
|
544 |
lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole); |
|
545 |
lua_register(luaState, 'GetGearType', @lc_getgeartype); |
|
546 |
lua_register(luaState, 'EndGame', @lc_endgame); |
|
547 |
lua_register(luaState, 'FindPlace', @lc_findplace); |
|
548 |
lua_register(luaState, 'SetGearPosition', @lc_setgearposition); |
|
549 |
lua_register(luaState, 'GetGearPosition', @lc_getgearposition); |
|
550 |
lua_register(luaState, 'ParseCommand', @lc_parsecommand); |
|
551 |
lua_register(luaState, 'ShowMission', @lc_showmission); |
|
552 |
lua_register(luaState, 'HideMission', @lc_hidemission); |
|
553 |
lua_register(luaState, 'SetAmmo', @lc_setammo); |
|
554 |
lua_register(luaState, 'PlaySound', @lc_playsound); |
|
555 |
lua_register(luaState, 'AddTeam', @lc_addteam); |
|
556 |
lua_register(luaState, 'AddHog', @lc_addhog); |
|
2814 | 557 |
lua_register(luaState, 'SetHealth', @lc_sethealth); |
2786 | 558 |
|
559 |
ScriptClearStack; // just to be sure stack is empty |
|
2793 | 560 |
ScriptLoaded:= false; |
2786 | 561 |
end; |
562 |
||
563 |
procedure free_uScript; |
|
564 |
begin |
|
565 |
lua_close(luaState); |
|
566 |
end; |
|
567 |
||
2798 | 568 |
{$ELSE} |
569 |
procedure ScriptPrintStack; |
|
570 |
begin |
|
571 |
end; |
|
572 |
||
573 |
procedure ScriptClearStack; |
|
574 |
begin |
|
575 |
end; |
|
576 |
||
2905 | 577 |
procedure ScriptLoad(name : shortstring); |
2798 | 578 |
begin |
579 |
end; |
|
580 |
||
581 |
procedure ScriptOnGameInit; |
|
582 |
begin |
|
583 |
end; |
|
584 |
||
2905 | 585 |
procedure ScriptCall(fname : shortstring); |
2798 | 586 |
begin |
587 |
end; |
|
588 |
||
2905 | 589 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
2798 | 590 |
begin |
2799 | 591 |
ScriptCall:= 0 |
592 |
end; |
|
593 |
||
2905 | 594 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
2799 | 595 |
begin |
596 |
ScriptCall:= 0 |
|
597 |
end; |
|
598 |
||
2905 | 599 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
2799 | 600 |
begin |
601 |
ScriptCall:= 0 |
|
602 |
end; |
|
603 |
||
2905 | 604 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
2799 | 605 |
begin |
606 |
ScriptCall:= 0 |
|
2798 | 607 |
end; |
608 |
||
609 |
procedure init_uScript; |
|
610 |
begin |
|
611 |
end; |
|
612 |
||
613 |
procedure free_uScript; |
|
614 |
begin |
|
615 |
end; |
|
616 |
||
617 |
{$ENDIF} |
|
2786 | 618 |
end. |