author | smxx |
Sun, 14 Mar 2010 22:55:46 +0000 | |
changeset 2996 | dfc7507a21a0 |
parent 2949 | d137a9da7701 |
child 2997 | ca60b5638fff |
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; |
|
2996 | 60 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay: Byte); forward; |
2786 | 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); |
2996 | 214 |
CurrentTeam^.Binds:= DefaultBinds |
2948
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 |
|
2996 | 280 |
if lua_gettop(L) <> 4 then |
2948
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 |
2996 | 284 |
ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4)); |
2948
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); |
|
2996 | 348 |
ScriptSetInteger('Explosives', cExplosives); |
2949 | 349 |
ScriptSetInteger('Delay', cInactDelay); |
350 |
ScriptSetString('Map', ''); |
|
351 |
ScriptSetString('Theme', ''); |
|
2786 | 352 |
|
2949 | 353 |
// import locale |
354 |
s:= cLocaleFName; |
|
355 |
SplitByChar(s, t, '.'); |
|
356 |
ScriptSetString('L', s); |
|
357 |
||
358 |
ScriptCall('onGameInit'); |
|
2786 | 359 |
|
2949 | 360 |
// pop game variables |
361 |
ParseCommand('seed ' + ScriptGetString('Seed'), true); |
|
362 |
ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true); |
|
363 |
ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true); |
|
364 |
ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true); |
|
365 |
ParseCommand('$landadds ' + ScriptGetString('LandAdds'), true); |
|
2996 | 366 |
ParseCommand('$explosives ' + ScriptGetString('Explosives'), true); |
2949 | 367 |
ParseCommand('$delay ' + ScriptGetString('Delay'), true); |
368 |
if ScriptGetString('Map') <> '' then |
|
369 |
ParseCommand('map ' + ScriptGetString('Map'), true); |
|
370 |
if ScriptGetString('Theme') <> '' then |
|
371 |
ParseCommand('theme ' + ScriptGetString('Theme'), true); |
|
372 |
||
373 |
ScriptPrepareAmmoStore; |
|
374 |
ScriptCall('onAmmoStoreInit'); |
|
2996 | 375 |
ScriptApplyAmmoStore; // doing 6 times - this is just temporary for now |
376 |
ScriptApplyAmmoStore; |
|
377 |
ScriptApplyAmmoStore; |
|
378 |
ScriptApplyAmmoStore; |
|
379 |
ScriptApplyAmmoStore; |
|
2949 | 380 |
ScriptApplyAmmoStore; |
2786 | 381 |
end; |
382 |
||
2905 | 383 |
procedure ScriptLoad(name : shortstring); |
2786 | 384 |
var ret : LongInt; |
385 |
begin |
|
2949 | 386 |
ret:= luaL_loadfile(luaState, Str2PChar(name)); |
387 |
if ret <> 0 then |
|
388 |
WriteLnToConsole('LUA: Failed to load ' + name + '(error ' + IntToStr(ret) + ')') |
|
389 |
else |
|
390 |
begin |
|
391 |
WriteLnToConsole('LUA: ' + name + ' loaded'); |
|
392 |
// call the script file |
|
393 |
lua_pcall(luaState, 0, 0, 0); |
|
394 |
ScriptLoaded:= true |
|
395 |
end |
|
2786 | 396 |
end; |
397 |
||
2814 | 398 |
procedure SetGlobals; |
399 |
begin |
|
2949 | 400 |
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
2814 | 401 |
end; |
402 |
||
403 |
procedure GetGlobals; |
|
404 |
begin |
|
2949 | 405 |
TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); |
2814 | 406 |
end; |
407 |
||
2905 | 408 |
procedure ScriptCall(fname : shortstring); |
2786 | 409 |
begin |
2949 | 410 |
if not ScriptLoaded then |
411 |
exit; |
|
412 |
SetGlobals; |
|
413 |
lua_getglobal(luaState, Str2PChar(fname)); |
|
414 |
if lua_pcall(luaState, 0, 0, 0) <> 0 then |
|
415 |
begin |
|
416 |
WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
|
417 |
lua_pop(luaState, 1) |
|
418 |
end; |
|
419 |
GetGlobals; |
|
2786 | 420 |
end; |
421 |
||
2905 | 422 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
2786 | 423 |
begin |
424 |
ScriptCall:= ScriptCall(fname, par1, 0, 0, 0) |
|
425 |
end; |
|
426 |
||
2905 | 427 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
2786 | 428 |
begin |
429 |
ScriptCall:= ScriptCall(fname, par1, par2, 0, 0) |
|
430 |
end; |
|
431 |
||
2905 | 432 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
2786 | 433 |
begin |
434 |
ScriptCall:= ScriptCall(fname, par1, par2, par3, 0) |
|
435 |
end; |
|
436 |
||
2905 | 437 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
2786 | 438 |
begin |
2949 | 439 |
if not ScriptLoaded then |
440 |
exit; |
|
441 |
SetGlobals; |
|
442 |
lua_getglobal(luaState, Str2PChar(fname)); |
|
443 |
lua_pushinteger(luaState, par1); |
|
444 |
lua_pushinteger(luaState, par2); |
|
445 |
lua_pushinteger(luaState, par3); |
|
446 |
lua_pushinteger(luaState, par4); |
|
447 |
ScriptCall:= 0; |
|
448 |
if lua_pcall(luaState, 4, 1, 0) <> 0 then |
|
449 |
begin |
|
450 |
WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
|
451 |
lua_pop(luaState, 1) |
|
452 |
end |
|
453 |
else |
|
454 |
begin |
|
455 |
ScriptCall:= lua_tointeger(luaState, -1); |
|
456 |
lua_pop(luaState, 1) |
|
457 |
end; |
|
458 |
GetGlobals; |
|
2786 | 459 |
end; |
460 |
||
461 |
procedure ScriptPrepareAmmoStore; |
|
462 |
var i: ShortInt; |
|
463 |
begin |
|
464 |
ScriptAmmoStore:= ''; |
|
465 |
for i:=1 to ord(High(TAmmoType)) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
466 |
ScriptAmmoStore:= ScriptAmmoStore + '0000'; |
2786 | 467 |
end; |
468 |
||
2996 | 469 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay: Byte); |
2786 | 470 |
begin |
2996 | 471 |
if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) or (delay < 0) or (delay > 9)then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
472 |
exit; |
2786 | 473 |
ScriptAmmoStore[ord(ammo)]:= inttostr(count)[1]; |
474 |
ScriptAmmoStore[ord(ammo) + ord(high(TAmmoType))]:= inttostr(propability)[1]; |
|
2996 | 475 |
ScriptAmmoStore[ord(ammo) + 2 * ord(high(TAmmoType))]:= inttostr(delay)[1]; |
2786 | 476 |
end; |
477 |
||
478 |
procedure ScriptApplyAmmoStore; |
|
479 |
begin |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
480 |
AddAmmoStore(ScriptAmmoStore); |
2786 | 481 |
end; |
482 |
||
483 |
// small helper functions making registering enums a lot easier |
|
2905 | 484 |
function str(const en : TGearType) : shortstring; overload; |
2786 | 485 |
begin |
486 |
str:= GetEnumName(TypeInfo(TGearType), ord(en)) |
|
487 |
end; |
|
488 |
||
2905 | 489 |
function str(const en : TSound) : shortstring; overload; |
2786 | 490 |
begin |
491 |
str:= GetEnumName(TypeInfo(TSound), ord(en)) |
|
492 |
end; |
|
493 |
||
2905 | 494 |
function str(const en : TAmmoType) : shortstring; overload; |
2786 | 495 |
begin |
496 |
str:= GetEnumName(TypeInfo(TAmmoType), ord(en)) |
|
497 |
end; |
|
498 |
/////////////////// |
|
499 |
||
500 |
procedure init_uScript; |
|
501 |
var at : TGearType; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
502 |
am : TAmmoType; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
503 |
st : TSound; |
2786 | 504 |
begin |
505 |
// initialize lua |
|
506 |
luaState:= lua_open; |
|
507 |
||
508 |
// open internal libraries |
|
509 |
luaopen_base(luaState); |
|
510 |
luaopen_string(luaState); |
|
511 |
luaopen_math(luaState); |
|
512 |
||
513 |
// import some variables |
|
514 |
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
|
515 |
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
|
516 |
||
517 |
// import game flags |
|
2949 | 518 |
ScriptSetInteger('gfForts', gfForts); |
519 |
ScriptSetInteger('gfMultiWeapon', gfMultiWeapon); |
|
520 |
ScriptSetInteger('gfSolidLand', gfSolidLand); |
|
521 |
ScriptSetInteger('gfBorder', gfBorder); |
|
522 |
ScriptSetInteger('gfDivideTeams', gfDivideTeams); |
|
523 |
ScriptSetInteger('gfLowGravity', gfLowGravity); |
|
524 |
ScriptSetInteger('gfLaserSight', gfLaserSight); |
|
525 |
ScriptSetInteger('gfInvulnerable', gfInvulnerable); |
|
526 |
ScriptSetInteger('gfMines', gfMines); |
|
527 |
ScriptSetInteger('gfVampiric', gfVampiric); |
|
528 |
ScriptSetInteger('gfKarma', gfKarma); |
|
529 |
ScriptSetInteger('gfArtillery', gfArtillery); |
|
530 |
ScriptSetInteger('gfOneClanMode', gfOneClanMode); |
|
531 |
ScriptSetInteger('gfRandomOrder', gfRandomOrder); |
|
532 |
ScriptSetInteger('gfKing', gfKing); |
|
533 |
ScriptSetInteger('gfPlaceHog', gfPlaceHog); |
|
534 |
ScriptSetInteger('gfSharedAmmo', gfSharedAmmo); |
|
535 |
ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
|
536 |
ScriptSetInteger('gfExplosives', gfExplosives); |
|
2786 | 537 |
|
538 |
// register gear types |
|
539 |
for at:= Low(TGearType) to High(TGearType) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
540 |
ScriptSetInteger(str(at), ord(at)); |
2786 | 541 |
|
542 |
// register sounds |
|
543 |
for st:= Low(TSound) to High(TSound) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
544 |
ScriptSetInteger(str(st), ord(st)); |
2786 | 545 |
|
546 |
// register ammo types |
|
547 |
for am:= Low(TAmmoType) to High(TAmmoType) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
548 |
ScriptSetInteger(str(am), ord(am)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2924
diff
changeset
|
549 |
|
2786 | 550 |
// register functions |
551 |
lua_register(luaState, 'AddGear', @lc_addgear); |
|
552 |
lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole); |
|
553 |
lua_register(luaState, 'GetGearType', @lc_getgeartype); |
|
554 |
lua_register(luaState, 'EndGame', @lc_endgame); |
|
555 |
lua_register(luaState, 'FindPlace', @lc_findplace); |
|
556 |
lua_register(luaState, 'SetGearPosition', @lc_setgearposition); |
|
557 |
lua_register(luaState, 'GetGearPosition', @lc_getgearposition); |
|
558 |
lua_register(luaState, 'ParseCommand', @lc_parsecommand); |
|
559 |
lua_register(luaState, 'ShowMission', @lc_showmission); |
|
560 |
lua_register(luaState, 'HideMission', @lc_hidemission); |
|
561 |
lua_register(luaState, 'SetAmmo', @lc_setammo); |
|
562 |
lua_register(luaState, 'PlaySound', @lc_playsound); |
|
563 |
lua_register(luaState, 'AddTeam', @lc_addteam); |
|
564 |
lua_register(luaState, 'AddHog', @lc_addhog); |
|
2814 | 565 |
lua_register(luaState, 'SetHealth', @lc_sethealth); |
2786 | 566 |
|
567 |
ScriptClearStack; // just to be sure stack is empty |
|
2793 | 568 |
ScriptLoaded:= false; |
2786 | 569 |
end; |
570 |
||
571 |
procedure free_uScript; |
|
572 |
begin |
|
573 |
lua_close(luaState); |
|
574 |
end; |
|
575 |
||
2798 | 576 |
{$ELSE} |
577 |
procedure ScriptPrintStack; |
|
578 |
begin |
|
579 |
end; |
|
580 |
||
581 |
procedure ScriptClearStack; |
|
582 |
begin |
|
583 |
end; |
|
584 |
||
2905 | 585 |
procedure ScriptLoad(name : shortstring); |
2798 | 586 |
begin |
587 |
end; |
|
588 |
||
589 |
procedure ScriptOnGameInit; |
|
590 |
begin |
|
591 |
end; |
|
592 |
||
2905 | 593 |
procedure ScriptCall(fname : shortstring); |
2798 | 594 |
begin |
595 |
end; |
|
596 |
||
2905 | 597 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
2798 | 598 |
begin |
2799 | 599 |
ScriptCall:= 0 |
600 |
end; |
|
601 |
||
2905 | 602 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
2799 | 603 |
begin |
604 |
ScriptCall:= 0 |
|
605 |
end; |
|
606 |
||
2905 | 607 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
2799 | 608 |
begin |
609 |
ScriptCall:= 0 |
|
610 |
end; |
|
611 |
||
2905 | 612 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
2799 | 613 |
begin |
614 |
ScriptCall:= 0 |
|
2798 | 615 |
end; |
616 |
||
617 |
procedure init_uScript; |
|
618 |
begin |
|
619 |
end; |
|
620 |
||
621 |
procedure free_uScript; |
|
622 |
begin |
|
623 |
end; |
|
624 |
||
625 |
{$ENDIF} |
|
2786 | 626 |
end. |