author | koda |
Sun, 17 Mar 2013 01:26:40 +0100 | |
changeset 8739 | bbab7e35eaf2 |
parent 8473 | 555235e90010 |
child 8833 | c13ebed437cb |
child 8978 | e6ef8fe314bd |
permissions | -rw-r--r-- |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1 |
(* |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
6700 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4 |
* |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
8 |
* |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
12 |
* GNU General Public License for more details. |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
13 |
* |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
17 |
*) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
18 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
19 |
{$INCLUDE "options.inc"} |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
20 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
21 |
unit uScript; |
5124 | 22 |
(* |
23 |
* This unit defines, implements and registers functions and |
|
24 |
* variables/constants bindings for usage in Lua scripts. |
|
25 |
* |
|
26 |
* Please keep http://code.google.com/p/hedgewars/wiki/LuaAPI up to date! |
|
27 |
* |
|
28 |
* Note: If you add a new function, make sure to test if _all_ parameters |
|
29 |
* work as intended! (Especially conversions errors can sneak in |
|
30 |
* unnoticed and render the parameter useless!) |
|
31 |
*) |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
32 |
interface |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
33 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
34 |
procedure ScriptPrintStack; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
35 |
procedure ScriptClearStack; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
36 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
37 |
procedure ScriptLoad(name : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
38 |
procedure ScriptOnGameInit; |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
39 |
procedure ScriptOnScreenResize; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
40 |
procedure ScriptSetInteger(name : shortstring; value : LongInt); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
41 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
42 |
procedure ScriptCall(fname : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
43 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
44 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
45 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
46 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
47 |
function ScriptExists(fname : shortstring) : boolean; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
48 |
|
5410 | 49 |
|
7805 | 50 |
//function ParseCommandOverride(key, value : shortstring) : shortstring; This did not work out well |
5577 | 51 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
52 |
procedure initModule; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
53 |
procedure freeModule; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
54 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
55 |
implementation |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
56 |
{$IFDEF USE_LUA_SCRIPT} |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6430
diff
changeset
|
57 |
uses LuaPas, |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
58 |
uConsole, |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
59 |
uConsts, |
3761 | 60 |
uVisualGears, |
6543 | 61 |
uGears, |
6468 | 62 |
uGearsList, |
6543 | 63 |
uGearsUtils, |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
64 |
uFloat, |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
65 |
uWorld, |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
66 |
uAmmos, |
6763 | 67 |
uTeams, |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
68 |
uSound, |
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
69 |
uChat, |
4243 | 70 |
uStats, |
4875 | 71 |
uStore, |
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
4319
diff
changeset
|
72 |
uRandom, |
4359 | 73 |
uTypes, |
4373 | 74 |
uVariables, |
4374 | 75 |
uCommands, |
4377 | 76 |
uUtils, |
4403 | 77 |
uCaptions, |
4832 | 78 |
uDebug, |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
79 |
uCollisions, |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
80 |
uRenderUtils, |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
81 |
uTextures, |
4985 | 82 |
uLandGraphics, |
5243 | 83 |
SDLh, |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
84 |
SysUtils, |
8031 | 85 |
uIO, |
86 |
uPhysFSLayer |
|
87 |
; |
|
3697 | 88 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
89 |
var luaState : Plua_State; |
3346 | 90 |
ScriptAmmoLoadout : shortstring; |
91 |
ScriptAmmoProbability : shortstring; |
|
92 |
ScriptAmmoDelay : shortstring; |
|
93 |
ScriptAmmoReinforcement : shortstring; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
94 |
ScriptLoaded : boolean; |
3697 | 95 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
96 |
procedure ScriptPrepareAmmoStore; forward; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
97 |
procedure ScriptApplyAmmoStore; forward; |
3346 | 98 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay, reinforcement: Byte); forward; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
99 |
|
3539 | 100 |
procedure LuaError(s: shortstring); |
101 |
begin |
|
102 |
WriteLnToConsole(s); |
|
103 |
AddChatString(#5 + s); |
|
104 |
end; |
|
105 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
106 |
// wrapped calls // |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
107 |
|
3539 | 108 |
// functions called from Lua: |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
109 |
// function(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
110 |
// where L contains the state, returns the number of return values on the stack |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
111 |
// call lua_gettop(L) to receive number of parameters passed |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
112 |
|
4483 | 113 |
function lc_band(L: PLua_State): LongInt; Cdecl; |
114 |
begin |
|
115 |
if lua_gettop(L) <> 2 then |
|
116 |
begin |
|
117 |
LuaError('Lua: Wrong number of parameters passed to band!'); |
|
118 |
lua_pushnil(L); |
|
119 |
end |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
120 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
121 |
lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); |
4483 | 122 |
lc_band := 1; |
123 |
end; |
|
124 |
||
125 |
function lc_bor(L: PLua_State): LongInt; Cdecl; |
|
126 |
begin |
|
127 |
if lua_gettop(L) <> 2 then |
|
128 |
begin |
|
129 |
LuaError('Lua: Wrong number of parameters passed to bor!'); |
|
130 |
lua_pushnil(L); |
|
131 |
end |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
132 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
133 |
lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); |
4483 | 134 |
lc_bor := 1; |
135 |
end; |
|
136 |
||
137 |
function lc_bnot(L: PLua_State): LongInt; Cdecl; |
|
138 |
begin |
|
139 |
if lua_gettop(L) <> 1 then |
|
140 |
begin |
|
141 |
LuaError('Lua: Wrong number of parameters passed to bnot!'); |
|
142 |
lua_pushnil(L); |
|
143 |
end |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
144 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
145 |
lua_pushinteger(L, not lua_tointeger(L, 1)); |
4483 | 146 |
lc_bnot := 1; |
147 |
end; |
|
148 |
||
6764 | 149 |
function lc_div(L: PLua_State): LongInt; Cdecl; |
150 |
begin |
|
151 |
if lua_gettop(L) <> 2 then |
|
152 |
begin |
|
153 |
LuaError('Lua: Wrong number of parameters passed to div!'); |
|
154 |
lua_pushnil(L); |
|
155 |
end |
|
156 |
else |
|
7135
4d863aadd0b2
Add onGameTick20 to try and encourage lua to be a bit more efficient. Rewrite Space Invasion to use it. Top speed of aliens is 25% higher now, although that could be changed, I kinda liked it. Change parameter order of div().
nemo
parents:
7072
diff
changeset
|
157 |
lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2)); |
6764 | 158 |
lc_div := 1; |
159 |
end; |
|
160 |
||
4523 | 161 |
function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
162 |
begin |
|
163 |
if lua_gettop(L) <> 0 then |
|
164 |
LuaError('Lua: Wrong number of parameters passed to GetInputMask!') |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
165 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
166 |
lua_pushinteger(L, InputMask); |
4523 | 167 |
lc_getinputmask:= 1 |
168 |
end; |
|
169 |
||
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4517
diff
changeset
|
170 |
function lc_setinputmask(L : Plua_State) : LongInt; Cdecl; |
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4517
diff
changeset
|
171 |
begin |
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4517
diff
changeset
|
172 |
if lua_gettop(L) <> 1 then |
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4517
diff
changeset
|
173 |
LuaError('Lua: Wrong number of parameters passed to SetInputMask!') |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
174 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
175 |
InputMask:= lua_tointeger(L, 1); |
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4517
diff
changeset
|
176 |
lc_setinputmask:= 0 |
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4517
diff
changeset
|
177 |
end; |
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4517
diff
changeset
|
178 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
179 |
function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
180 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
181 |
if lua_gettop(L) = 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
182 |
begin |
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
183 |
WriteLnToConsole('Lua: ' + lua_tostring(L ,1)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
184 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
185 |
else |
3539 | 186 |
LuaError('Lua: Wrong number of parameters passed to WriteLnToConsole!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
187 |
lc_writelntoconsole:= 0; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
188 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
189 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
190 |
function lc_parsecommand(L : Plua_State) : LongInt; Cdecl; |
7307
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
191 |
var t: PChar; |
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
192 |
i,c: LongWord; |
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
193 |
s: shortstring; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
194 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
195 |
if lua_gettop(L) = 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
196 |
begin |
7307
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
197 |
t:= lua_tolstring(L,1,@c); |
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
198 |
|
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
199 |
for i:= 1 to c do s[i]:= t[i-1]; |
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
200 |
s[0]:= char(c); |
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
201 |
|
7805 | 202 |
ParseCommand(s, true, true); |
7307
f830a65d6a6d
This is necessary because commands can contain 0s, and StrPas used by LuaPas halts at the first 0. It might be necessary to change the base string handling.
nemo
parents:
7270
diff
changeset
|
203 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
204 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
205 |
else |
3539 | 206 |
LuaError('Lua: Wrong number of parameters passed to ParseCommand!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
207 |
lc_parsecommand:= 0; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
208 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
209 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
210 |
function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
211 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
212 |
if lua_gettop(L) = 5 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
213 |
begin |
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
214 |
ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
215 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
216 |
else |
3539 | 217 |
LuaError('Lua: Wrong number of parameters passed to ShowMission!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
218 |
lc_showmission:= 0; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
219 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
220 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
221 |
function lc_hidemission(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
222 |
begin |
3407 | 223 |
L:= L; // avoid compiler hint |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
224 |
HideMission; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
225 |
lc_hidemission:= 0; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
226 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
227 |
|
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
228 |
function lc_enablegameflags(L : Plua_State) : LongInt; Cdecl; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
229 |
var i : integer; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
230 |
begin |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
231 |
for i:= 1 to lua_gettop(L) do |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
232 |
if (GameFlags and lua_tointeger(L, i)) = 0 then |
8370 | 233 |
GameFlags := GameFlags + LongWord(lua_tointeger(L, i)); |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
234 |
ScriptSetInteger('GameFlags', GameFlags); |
8370 | 235 |
lc_enablegameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
236 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
237 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
238 |
function lc_disablegameflags(L : Plua_State) : LongInt; Cdecl; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
239 |
var i : integer; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
240 |
begin |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
241 |
for i:= 1 to lua_gettop(L) do |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
242 |
if (GameFlags and lua_tointeger(L, i)) <> 0 then |
8370 | 243 |
GameFlags := GameFlags - LongWord(lua_tointeger(L, i)); |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
244 |
ScriptSetInteger('GameFlags', GameFlags); |
8370 | 245 |
lc_disablegameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
246 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
247 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
248 |
function lc_cleargameflags(L : Plua_State) : LongInt; Cdecl; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
249 |
begin |
8370 | 250 |
// Silence hint |
251 |
L:= L; |
|
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
252 |
GameFlags:= 0; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
253 |
ScriptSetInteger('GameFlags', GameFlags); |
8370 | 254 |
lc_cleargameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
255 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
256 |
|
4243 | 257 |
function lc_addcaption(L : Plua_State) : LongInt; Cdecl; |
258 |
begin |
|
259 |
if lua_gettop(L) = 1 then |
|
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
260 |
AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage) |
5118 | 261 |
else if lua_gettop(L) = 3 then |
4243 | 262 |
begin |
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
263 |
AddCaption(lua_tostring(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3))); |
4243 | 264 |
end |
265 |
else |
|
266 |
LuaError('Lua: Wrong number of parameters passed to AddCaption!'); |
|
267 |
lc_addcaption:= 0; |
|
268 |
end; |
|
269 |
||
3848 | 270 |
function lc_campaignlock(L : Plua_State) : LongInt; Cdecl; |
271 |
begin |
|
272 |
if lua_gettop(L) = 1 then |
|
273 |
begin |
|
274 |
// to be done |
|
275 |
end |
|
276 |
else |
|
277 |
LuaError('Lua: Wrong number of parameters passed to CampaignLock!'); |
|
278 |
lc_campaignlock:= 0; |
|
279 |
end; |
|
280 |
||
281 |
function lc_campaignunlock(L : Plua_State) : LongInt; Cdecl; |
|
282 |
begin |
|
283 |
if lua_gettop(L) = 1 then |
|
284 |
begin |
|
285 |
// to be done |
|
286 |
end |
|
287 |
else |
|
288 |
LuaError('Lua: Wrong number of parameters passed to CampaignUnlock!'); |
|
289 |
lc_campaignunlock:= 0; |
|
290 |
end; |
|
291 |
||
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
292 |
function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
293 |
var gear: PGear; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
294 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
295 |
if lua_gettop(L) <> 4 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
296 |
begin |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
297 |
LuaError('Lua: Wrong number of parameters passed to SpawnFakeHealthCrate!'); |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
298 |
lua_pushnil(L); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
299 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
300 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
301 |
begin |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
302 |
gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
303 |
HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
304 |
lua_pushinteger(L, gear^.uid); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
305 |
end; |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
306 |
lc_spawnfakehealthcrate := 1; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
307 |
end; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
308 |
|
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
309 |
function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
310 |
var gear: PGear; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
311 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
312 |
if lua_gettop(L) <> 4 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
313 |
begin |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
314 |
LuaError('Lua: Wrong number of parameters passed to SpawnFakeAmmoCrate!'); |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
315 |
lua_pushnil(L); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
316 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
317 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
318 |
begin |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
319 |
gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
320 |
AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
321 |
lua_pushinteger(L, gear^.uid); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
322 |
end; |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
323 |
lc_spawnfakeammocrate := 1; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
324 |
end; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
325 |
|
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
326 |
function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
327 |
var gear: PGear; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
328 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
329 |
if lua_gettop(L) <> 4 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
330 |
begin |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
331 |
LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!'); |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
332 |
lua_pushnil(L); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
333 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
334 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
335 |
begin |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
336 |
gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
337 |
UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
338 |
lua_pushinteger(L, gear^.uid); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
339 |
end; |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
340 |
lc_spawnfakeutilitycrate := 1; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
341 |
end; |
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
342 |
|
3730 | 343 |
function lc_spawnhealthcrate(L: Plua_State) : LongInt; Cdecl; |
3750
3aa85b5f3318
SpawnCustomCrateAt: spawn crate at random position for x=y=0, also let it return the gear, and luabindings the gear uid
burp
parents:
3736
diff
changeset
|
344 |
var gear: PGear; |
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5277
diff
changeset
|
345 |
var health: LongInt; |
3730 | 346 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
347 |
if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
348 |
begin |
3730 | 349 |
LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!'); |
350 |
lua_pushnil(L); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
351 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
352 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
353 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
354 |
if lua_gettop(L) = 3 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
355 |
health:= lua_tointeger(L, 3) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
356 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
357 |
health:= cHealthCaseAmount; |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
358 |
gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health, 0); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
359 |
if gear <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
360 |
lua_pushinteger(L, gear^.uid) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
361 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
362 |
lua_pushnil(L); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
363 |
end; |
3734 | 364 |
lc_spawnhealthcrate := 1; |
365 |
end; |
|
366 |
||
367 |
function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; |
|
3750
3aa85b5f3318
SpawnCustomCrateAt: spawn crate at random position for x=y=0, also let it return the gear, and luabindings the gear uid
burp
parents:
3736
diff
changeset
|
368 |
var gear: PGear; |
3734 | 369 |
begin |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
370 |
if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
371 |
begin |
3734 | 372 |
LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!'); |
373 |
lua_pushnil(L); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
374 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
375 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
376 |
begin |
7339 | 377 |
if (lua_gettop(L) = 3) then |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
378 |
gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) |
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
379 |
else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
380 |
if gear <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
381 |
lua_pushinteger(L, gear^.uid) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
382 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
383 |
lua_pushnil(L); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
384 |
end; |
3734 | 385 |
lc_spawnammocrate := 1; |
386 |
end; |
|
387 |
||
388 |
function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl; |
|
3750
3aa85b5f3318
SpawnCustomCrateAt: spawn crate at random position for x=y=0, also let it return the gear, and luabindings the gear uid
burp
parents:
3736
diff
changeset
|
389 |
var gear: PGear; |
3734 | 390 |
begin |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
391 |
if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
392 |
begin |
3734 | 393 |
LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!'); |
394 |
lua_pushnil(L); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
395 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
396 |
else |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
397 |
begin |
7339 | 398 |
if (lua_gettop(L) = 3) then |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
399 |
gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0) |
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
400 |
else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
401 |
if gear <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
402 |
lua_pushinteger(L, gear^.uid) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
403 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
404 |
lua_pushnil(L); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
405 |
end; |
3734 | 406 |
lc_spawnutilitycrate := 1; |
3730 | 407 |
end; |
408 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
409 |
function lc_addgear(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
410 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
411 |
x, y, s, t: LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
412 |
dx, dy: hwFloat; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
413 |
gt: TGearType; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
414 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
415 |
if lua_gettop(L) <> 7 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
416 |
begin |
3539 | 417 |
LuaError('Lua: Wrong number of parameters passed to AddGear!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
418 |
lua_pushnil(L); // return value on stack (nil) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
419 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
420 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
421 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
422 |
x:= lua_tointeger(L, 1); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
423 |
y:= lua_tointeger(L, 2); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
424 |
gt:= TGearType(lua_tointeger(L, 3)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
425 |
s:= lua_tointeger(L, 4); |
5074 | 426 |
dx:= int2hwFloat(lua_tointeger(L, 5)) / 1000000; |
427 |
dy:= int2hwFloat(lua_tointeger(L, 6)) / 1000000; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
428 |
t:= lua_tointeger(L, 7); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
429 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
430 |
gear:= AddGear(x, y, gt, s, dx, dy, t); |
4780
8571151411b3
add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents:
4767
diff
changeset
|
431 |
lastGearByUID:= gear; |
4484 | 432 |
lua_pushinteger(L, gear^.uid) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
433 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
434 |
lc_addgear:= 1; // 1 return value |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
435 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
436 |
|
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
437 |
function lc_deletegear(L : Plua_State) : LongInt; Cdecl; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
438 |
var gear : PGear; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
439 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
440 |
if lua_gettop(L) <> 1 then |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
441 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
442 |
LuaError('Lua: Wrong number of parameters passed to DeleteGear!'); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
443 |
end |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
444 |
else |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
445 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
446 |
gear:= GearByUID(lua_tointeger(L, 1)); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
447 |
if gear <> nil then |
7517 | 448 |
gear^.Message:= gear^.Message or gmDelete; |
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
449 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
450 |
lc_deletegear:= 0 |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
451 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
452 |
|
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
453 |
function lc_addvisualgear(L : Plua_State) : LongInt; Cdecl; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
454 |
var vg : PVisualGear; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
455 |
x, y, s: LongInt; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
456 |
c: Boolean; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
457 |
vgt: TVisualGearType; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
458 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
459 |
if lua_gettop(L) <> 5 then |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
460 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
461 |
LuaError('Lua: Wrong number of parameters passed to AddVisualGear!'); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
462 |
lua_pushnil(L); // return value on stack (nil) |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
463 |
end |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
464 |
else |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
465 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
466 |
x:= lua_tointeger(L, 1); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
467 |
y:= lua_tointeger(L, 2); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
468 |
vgt:= TVisualGearType(lua_tointeger(L, 3)); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
469 |
s:= lua_tointeger(L, 4); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
470 |
c:= lua_toboolean(L, 5); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
471 |
|
4780
8571151411b3
add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents:
4767
diff
changeset
|
472 |
vg:= AddVisualGear(x, y, vgt, s, c); |
8571151411b3
add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents:
4767
diff
changeset
|
473 |
if vg <> nil then |
8571151411b3
add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents:
4767
diff
changeset
|
474 |
begin |
8571151411b3
add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents:
4767
diff
changeset
|
475 |
lastVisualGearByUID:= vg; |
8571151411b3
add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents:
4767
diff
changeset
|
476 |
lua_pushinteger(L, vg^.uid) |
8571151411b3
add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents:
4767
diff
changeset
|
477 |
end |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
478 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
479 |
lua_pushinteger(L, 0) |
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
480 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
481 |
lc_addvisualgear:= 1; // 1 return value |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
482 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
483 |
|
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
484 |
function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
485 |
var vg : PVisualGear; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
486 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
487 |
if lua_gettop(L) <> 1 then |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
488 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
489 |
LuaError('Lua: Wrong number of parameters passed to DeleteVisualGear!'); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
490 |
end |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
491 |
else |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
492 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
493 |
vg:= VisualGearByUID(lua_tointeger(L, 1)); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
494 |
if vg <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
495 |
DeleteVisualGear(vg); |
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
496 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
497 |
lc_deletevisualgear:= 0 |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
498 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
499 |
|
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
500 |
function lc_getvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
501 |
var vg: PVisualGear; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
502 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
503 |
if lua_gettop(L) <> 1 then |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
504 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
505 |
LuaError('Lua: Wrong number of parameters passed to GetVisualGearValues!'); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
506 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
507 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L) |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
508 |
end |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
509 |
else |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
510 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
511 |
vg:= VisualGearByUID(lua_tointeger(L, 1)); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
512 |
if vg <> nil then |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
513 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
514 |
lua_pushinteger(L, round(vg^.X)); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
515 |
lua_pushinteger(L, round(vg^.Y)); |
5075
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
516 |
lua_pushnumber(L, vg^.dX); |
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
517 |
lua_pushnumber(L, vg^.dY); |
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
518 |
lua_pushnumber(L, vg^.Angle); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
519 |
lua_pushinteger(L, vg^.Frame); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
520 |
lua_pushinteger(L, vg^.FrameTicks); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
521 |
lua_pushinteger(L, vg^.State); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
522 |
lua_pushinteger(L, vg^.Timer); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
523 |
lua_pushinteger(L, vg^.Tint); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
524 |
end |
4767
4ee4a49549e2
return nil values if an invalid visual gear is passed to the get, add a check in Control map lua
nemo
parents:
4682
diff
changeset
|
525 |
else |
4ee4a49549e2
return nil values if an invalid visual gear is passed to the get, add a check in Control map lua
nemo
parents:
4682
diff
changeset
|
526 |
begin |
4ee4a49549e2
return nil values if an invalid visual gear is passed to the get, add a check in Control map lua
nemo
parents:
4682
diff
changeset
|
527 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
4ee4a49549e2
return nil values if an invalid visual gear is passed to the get, add a check in Control map lua
nemo
parents:
4682
diff
changeset
|
528 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L) |
4ee4a49549e2
return nil values if an invalid visual gear is passed to the get, add a check in Control map lua
nemo
parents:
4682
diff
changeset
|
529 |
end |
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
530 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
531 |
lc_getvisualgearvalues:= 10; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
532 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
533 |
|
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
534 |
function lc_setvisualgearvalues(L : Plua_State) : LongInt; Cdecl; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
535 |
var vg : PVisualGear; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
536 |
begin |
4450 | 537 |
if lua_gettop(L) <> 11 then |
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
538 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
539 |
LuaError('Lua: Wrong number of parameters passed to SetVisualGearValues!'); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
540 |
lua_pushnil(L); // return value on stack (nil) |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
541 |
end |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
542 |
else |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
543 |
begin |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
544 |
vg:= VisualGearByUID(lua_tointeger(L, 1)); |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
545 |
if vg <> nil then |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
546 |
begin |
4450 | 547 |
vg^.X:= lua_tointeger(L, 2); |
548 |
vg^.Y:= lua_tointeger(L, 3); |
|
5075
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
549 |
vg^.dX:= lua_tonumber(L, 4); |
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
550 |
vg^.dY:= lua_tonumber(L, 5); |
4450 | 551 |
vg^.Angle:= lua_tonumber(L, 6); |
552 |
vg^.Frame:= lua_tointeger(L, 7); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
553 |
if lua_tointeger(L, 8) <> 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
554 |
vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. |
4450 | 555 |
vg^.State:= lua_tointeger(L, 9); |
556 |
vg^.Timer:= lua_tointeger(L, 10); |
|
557 |
vg^.Tint:= lua_tointeger(L, 11); |
|
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
558 |
end |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
559 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
560 |
lc_setvisualgearvalues:= 0; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
561 |
end; |
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
562 |
|
3058 | 563 |
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
564 |
begin |
|
565 |
if lua_gettop(L) <> 0 then |
|
566 |
begin |
|
3539 | 567 |
LuaError('Lua: Wrong number of parameters passed to GetFollowGear!'); |
3058 | 568 |
lua_pushnil(L); // return value on stack (nil) |
569 |
end |
|
570 |
else |
|
571 |
if FollowGear = nil then |
|
572 |
lua_pushnil(L) |
|
573 |
else |
|
4484 | 574 |
lua_pushinteger(L, FollowGear^.uid); |
3058 | 575 |
lc_getfollowgear:= 1; // 1 return value |
576 |
end; |
|
577 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
578 |
function lc_getgeartype(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
579 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
580 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
581 |
if lua_gettop(L) <> 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
582 |
begin |
3539 | 583 |
LuaError('Lua: Wrong number of parameters passed to GetGearType!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
584 |
lua_pushnil(L); // return value on stack (nil) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
585 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
586 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
587 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
588 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
589 |
if gear <> nil then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
590 |
lua_pushinteger(L, ord(gear^.Kind)) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
591 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
592 |
lua_pushnil(L); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
593 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
594 |
lc_getgeartype:= 1 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
595 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
596 |
|
3892 | 597 |
function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
598 |
var gear : PGear; |
|
599 |
begin |
|
600 |
if lua_gettop(L) <> 1 then |
|
601 |
begin |
|
602 |
LuaError('Lua: Wrong number of parameters passed to GetGearMessage!'); |
|
603 |
lua_pushnil(L); // return value on stack (nil) |
|
604 |
end |
|
605 |
else |
|
606 |
begin |
|
607 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
608 |
if gear <> nil then |
|
609 |
lua_pushinteger(L, gear^.message) |
|
610 |
else |
|
611 |
lua_pushnil(L); |
|
612 |
end; |
|
613 |
lc_getgearmessage:= 1 |
|
614 |
end; |
|
615 |
||
4682
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
616 |
function lc_getgearelasticity(L : Plua_State) : LongInt; Cdecl; |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
617 |
var gear : PGear; |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
618 |
begin |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
619 |
if lua_gettop(L) <> 1 then |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
620 |
begin |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
621 |
LuaError('Lua: Wrong number of parameters passed to GetGearElasticity!'); |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
622 |
lua_pushnil(L); // return value on stack (nil) |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
623 |
end |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
624 |
else |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
625 |
begin |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
626 |
gear:= GearByUID(lua_tointeger(L, 1)); |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
627 |
if gear <> nil then |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
628 |
lua_pushinteger(L, hwRound(gear^.elasticity * _10000)) |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
629 |
else |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
630 |
lua_pushnil(L); |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
631 |
end; |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
632 |
lc_getgearelasticity:= 1 |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
633 |
end; |
0fc1ff341482
add a GetGearElasticity since Mikade kept asking for it. (actually return *10000 to handle it being an hwFloat - I assume large values will just overflow to negative)
nemo
parents:
4629
diff
changeset
|
634 |
|
3896 | 635 |
function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
636 |
var gear : PGear; |
|
637 |
begin |
|
638 |
if lua_gettop(L) <> 2 then |
|
639 |
LuaError('Lua: Wrong number of parameters passed to SetGearMessage!') |
|
640 |
else |
|
641 |
begin |
|
642 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
643 |
if gear <> nil then |
|
644 |
gear^.message:= lua_tointeger(L, 2); |
|
645 |
end; |
|
646 |
lc_setgearmessage:= 0 |
|
647 |
end; |
|
648 |
||
6523 | 649 |
function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
650 |
var gear : PGear; |
|
651 |
begin |
|
652 |
if lua_gettop(L) <> 1 then |
|
653 |
begin |
|
654 |
LuaError('Lua: Wrong number of parameters passed to GetGearPos!'); |
|
655 |
lua_pushnil(L); // return value on stack (nil) |
|
656 |
end |
|
657 |
else |
|
658 |
begin |
|
659 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
660 |
if gear <> nil then |
|
661 |
lua_pushinteger(L, gear^.Pos) |
|
662 |
else |
|
663 |
lua_pushnil(L); |
|
664 |
end; |
|
665 |
lc_getgearpos:= 1 |
|
666 |
end; |
|
667 |
||
668 |
function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
|
669 |
var gear : PGear; |
|
670 |
begin |
|
671 |
if lua_gettop(L) <> 2 then |
|
672 |
LuaError('Lua: Wrong number of parameters passed to SetGearPos!') |
|
673 |
else |
|
674 |
begin |
|
675 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
676 |
if gear <> nil then |
|
677 |
gear^.Pos:= lua_tointeger(L, 2); |
|
678 |
end; |
|
679 |
lc_setgearpos:= 0 |
|
680 |
end; |
|
681 |
||
7726
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
682 |
function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
683 |
var gear : PGear; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
684 |
begin |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
685 |
if lua_gettop(L) <> 1 then |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
686 |
begin |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
687 |
LuaError('Lua: Wrong number of parameters passed to GetGearCollisionMask!'); |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
688 |
lua_pushnil(L); // return value on stack (nil) |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
689 |
end |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
690 |
else |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
691 |
begin |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
692 |
gear:= GearByUID(lua_tointeger(L, 1)); |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
693 |
if gear <> nil then |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
694 |
lua_pushinteger(L, gear^.CollisionMask) |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
695 |
else |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
696 |
lua_pushnil(L); |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
697 |
end; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
698 |
lc_getgearcollisionmask:= 1 |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
699 |
end; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
700 |
|
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
701 |
function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
702 |
var gear : PGear; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
703 |
begin |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
704 |
if lua_gettop(L) <> 2 then |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
705 |
LuaError('Lua: Wrong number of parameters passed to SetGearCollisionMask!') |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
706 |
else |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
707 |
begin |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
708 |
gear:= GearByUID(lua_tointeger(L, 1)); |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
709 |
if gear <> nil then |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
710 |
gear^.CollisionMask:= lua_tointeger(L, 2); |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
711 |
end; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
712 |
lc_setgearcollisionmask:= 0 |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
713 |
end; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
714 |
|
3755 | 715 |
function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
716 |
var gear : PGear; |
|
717 |
begin |
|
718 |
if lua_gettop(L) <> 1 then |
|
719 |
LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
720 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
721 |
begin |
3755 | 722 |
gear := GearByUID(lua_tointeger(L, 1)); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
723 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4372 | 724 |
lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
3755 | 725 |
else |
726 |
lua_pushnil(L); |
|
727 |
end; |
|
728 |
lc_gethoglevel := 1; |
|
729 |
end; |
|
730 |
||
4496 | 731 |
function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
732 |
var gear : PGear; |
|
733 |
begin |
|
734 |
if lua_gettop(L) <> 2 then |
|
735 |
LuaError('Lua: Wrong number of parameters passed to SetHogLevel!') |
|
736 |
else |
|
737 |
begin |
|
738 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
739 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
740 |
gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2); |
|
741 |
end; |
|
742 |
lc_sethoglevel:= 0 |
|
743 |
end; |
|
744 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
745 |
function lc_gethogclan(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
746 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
747 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
748 |
if lua_gettop(L) <> 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
749 |
begin |
3539 | 750 |
LuaError('Lua: Wrong number of parameters passed to GetHogClan!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
751 |
lua_pushnil(L); // return value on stack (nil) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
752 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
753 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
754 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
755 |
gear:= GearByUID(lua_tointeger(L, 1)); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
756 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
757 |
begin |
4372 | 758 |
lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
759 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
760 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
761 |
lua_pushnil(L); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
762 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
763 |
lc_gethogclan:= 1 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
764 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
765 |
|
4498 | 766 |
function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
767 |
begin |
|
768 |
if lua_gettop(L) <> 1 then |
|
769 |
begin |
|
770 |
LuaError('Lua: Wrong number of parameters passed to GetClanColor!'); |
|
771 |
lua_pushnil(L); // return value on stack (nil) |
|
772 |
end |
|
4499 | 773 |
else lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF); |
4498 | 774 |
lc_getclancolor:= 1 |
775 |
end; |
|
776 |
||
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
777 |
function lc_setclancolor(L : Plua_State) : LongInt; Cdecl; |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
778 |
var clan : PClan; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
779 |
team : PTeam; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
780 |
hh : THedgehog; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
781 |
i, j : LongInt; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
782 |
r, rr: TSDL_Rect; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
783 |
texsurf: PSDL_Surface; |
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
784 |
begin |
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
785 |
if lua_gettop(L) <> 2 then |
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
786 |
LuaError('Lua: Wrong number of parameters passed to SetClanColor!') |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
787 |
else |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
788 |
begin |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
789 |
clan := ClansArray[lua_tointeger(L, 1)]; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
790 |
clan^.Color:= lua_tointeger(L, 2) shr 8; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
791 |
for i:= 0 to Pred(clan^.TeamsNumber) do |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
792 |
begin |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
793 |
team:= clan^.Teams[i]; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
794 |
for j:= 0 to 7 do |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
795 |
begin |
4891 | 796 |
hh:= team^.Hedgehogs[j]; |
4890 | 797 |
if (hh.Gear <> nil) or (hh.GearHidden <> nil) then |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
798 |
begin |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
799 |
FreeTexture(hh.NameTagTex); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
800 |
hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
801 |
RenderHealth(hh); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
802 |
end; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
803 |
end; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
804 |
FreeTexture(team^.NameTagTex); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
805 |
team^.NameTagTex:= RenderStringTex(clan^.Teams[i]^.TeamName, clan^.Color, fnt16); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
806 |
r.w:= cTeamHealthWidth + 5; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
807 |
r.h:= team^.NameTagTex^.h; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
808 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
809 |
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
810 |
TryDo(texsurf <> nil, errmsgCreateSurface, true); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
811 |
TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
812 |
|
7546
b50556f2a0e8
This union hasn't been needed for 5 years, and makes using other headers harder.
nemo
parents:
7517
diff
changeset
|
813 |
DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); |
4889
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
814 |
rr:= r; |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
815 |
inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
816 |
DrawRoundRect(@rr, clan^.Color, clan^.Color, texsurf, false); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
817 |
|
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
818 |
FreeTexture(team^.HealthTex); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
819 |
team^.HealthTex:= Surface2Tex(texsurf, false); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
820 |
SDL_FreeSurface(texsurf); |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
821 |
MakeCrossHairs |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
822 |
end |
f71e30eb1d37
Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents:
4883
diff
changeset
|
823 |
end; |
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
824 |
lc_setclancolor:= 0 |
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
825 |
end; |
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
826 |
|
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
827 |
function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
828 |
var gear : PGear; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
829 |
begin |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
830 |
if lua_gettop(L) <> 1 then |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
831 |
begin |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
832 |
LuaError('Lua: Wrong number of parameters passed to GetHogTeamName!'); |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
833 |
lua_pushnil(L); // return value on stack (nil) |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
834 |
end |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
835 |
else |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
836 |
begin |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
837 |
gear:= GearByUID(lua_tointeger(L, 1)); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
838 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
839 |
begin |
4372 | 840 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
841 |
end |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
842 |
else |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
843 |
lua_pushnil(L); |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
844 |
end; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
845 |
lc_gethogteamname:= 1 |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
846 |
end; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
847 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
848 |
function lc_gethogname(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
849 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
850 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
851 |
if lua_gettop(L) <> 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
852 |
begin |
3539 | 853 |
LuaError('Lua: Wrong number of parameters passed to GetHogName!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
854 |
lua_pushnil(L); // return value on stack (nil) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
855 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
856 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
857 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
858 |
gear:= GearByUID(lua_tointeger(L, 1)); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
859 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
860 |
begin |
4372 | 861 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Name)) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
862 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
863 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
864 |
lua_pushnil(L); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
865 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
866 |
lc_gethogname:= 1 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
867 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
868 |
|
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
869 |
function lc_sethogname(L : Plua_State) : LongInt; Cdecl; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
870 |
var gear : PGear; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
871 |
hogName: ShortString; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
872 |
begin |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
873 |
if lua_gettop(L) <> 2 then |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
874 |
begin |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
875 |
LuaError('Lua: Wrong number of parameters passed to SetHogName!'); |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
876 |
lua_pushnil(L) |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
877 |
end |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
878 |
else |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
879 |
begin |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
880 |
gear:= GearByUID(lua_tointeger(L, 1)); |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
881 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
882 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
883 |
hogName:= lua_tostring(L, 2); |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
884 |
gear^.Hedgehog^.Name:= hogName; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
885 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
886 |
FreeTexture(gear^.Hedgehog^.NameTagTex); |
6380
1ff5ad1d771b
Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents:
6358
diff
changeset
|
887 |
gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
888 |
|
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
889 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
890 |
lc_sethogname:= 0; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
891 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
892 |
|
3722 | 893 |
function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
894 |
var gear : PGear; |
|
895 |
begin |
|
896 |
if lua_gettop(L) <> 1 then |
|
897 |
begin |
|
898 |
LuaError('Lua: Wrong number of parameters passed to GetTimer!'); |
|
899 |
lua_pushnil(L); // return value on stack (nil) |
|
900 |
end |
|
901 |
else |
|
902 |
begin |
|
903 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
904 |
if gear <> nil then |
|
4484 | 905 |
lua_pushinteger(L, gear^.Timer) |
3722 | 906 |
else |
907 |
lua_pushnil(L); |
|
908 |
end; |
|
909 |
lc_gettimer:= 1 |
|
910 |
end; |
|
911 |
||
912 |
function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
|
913 |
var gear : PGear; |
|
914 |
begin |
|
915 |
if lua_gettop(L) <> 1 then |
|
916 |
begin |
|
917 |
LuaError('Lua: Wrong number of parameters passed to GetHealth!'); |
|
918 |
lua_pushnil(L); // return value on stack (nil) |
|
919 |
end |
|
920 |
else |
|
921 |
begin |
|
922 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
923 |
if gear <> nil then |
|
4484 | 924 |
lua_pushinteger(L, gear^.Health) |
3722 | 925 |
else |
926 |
lua_pushnil(L); |
|
927 |
end; |
|
928 |
lc_gethealth:= 1 |
|
929 |
end; |
|
930 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
931 |
function lc_getx(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
932 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
933 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
934 |
if lua_gettop(L) <> 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
935 |
begin |
3539 | 936 |
LuaError('Lua: Wrong number of parameters passed to GetX!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
937 |
lua_pushnil(L); // return value on stack (nil) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
938 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
939 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
940 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
941 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
942 |
if gear <> nil then |
4484 | 943 |
lua_pushinteger(L, hwRound(gear^.X)) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
944 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
945 |
lua_pushnil(L); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
946 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
947 |
lc_getx:= 1 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
948 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
949 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
950 |
function lc_gety(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
951 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
952 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
953 |
if lua_gettop(L) <> 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
954 |
begin |
3539 | 955 |
LuaError('Lua: Wrong number of parameters passed to GetY!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
956 |
lua_pushnil(L); // return value on stack (nil) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
957 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
958 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
959 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
960 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
961 |
if gear <> nil then |
4484 | 962 |
lua_pushinteger(L, hwRound(gear^.Y)) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
963 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
964 |
lua_pushnil(L); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
965 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
966 |
lc_gety:= 1 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
967 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
968 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
969 |
function lc_copypv(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
970 |
var gears, geard : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
971 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
972 |
if lua_gettop(L) <> 2 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
973 |
begin |
3539 | 974 |
LuaError('Lua: Wrong number of parameters passed to CopyPV!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
975 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
976 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
977 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
978 |
gears:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
979 |
geard:= GearByUID(lua_tointeger(L, 2)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
980 |
if (gears <> nil) and (geard <> nil) then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
981 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
982 |
geard^.X:= gears^.X; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
983 |
geard^.Y:= gears^.Y; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
984 |
geard^.dX:= gears^.dX; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
985 |
geard^.dY:= gears^.dY; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
986 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
987 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
988 |
lc_copypv:= 1 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
989 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
990 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
991 |
function lc_followgear(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
992 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
993 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
994 |
if lua_gettop(L) <> 1 then |
3539 | 995 |
LuaError('Lua: Wrong number of parameters passed to FollowGear!') |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
996 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
997 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
998 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
999 |
if gear <> nil then FollowGear:= gear |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1000 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1001 |
lc_followgear:= 0 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1002 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1003 |
|
3761 | 1004 |
function lc_hogsay(L : Plua_State) : LongInt; Cdecl; |
1005 |
var gear : PGear; |
|
1006 |
vgear : PVisualGear; |
|
4533 | 1007 |
s : LongWord; |
3761 | 1008 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1009 |
if lua_gettop(L) = 4 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1010 |
s:= lua_tointeger(L, 4) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1011 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1012 |
s:= 0; |
4533 | 1013 |
|
1014 |
if (lua_gettop(L) = 4) or (lua_gettop(L) = 3) then |
|
3761 | 1015 |
begin |
1016 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1017 |
if gear <> nil then |
|
1018 |
begin |
|
4533 | 1019 |
vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
3761 | 1020 |
if vgear <> nil then |
1021 |
begin |
|
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
1022 |
vgear^.Text:= lua_tostring(L, 2); |
3761 | 1023 |
vgear^.Hedgehog:= gear^.Hedgehog; |
1024 |
vgear^.FrameTicks:= lua_tointeger(L, 3); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1025 |
if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1026 |
vgear^.FrameTicks:= 1; |
5529 | 1027 |
lua_pushinteger(L, vgear^.Uid) |
1028 |
end |
|
3761 | 1029 |
end |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1030 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1031 |
lua_pushnil(L) |
4533 | 1032 |
end |
1033 |
else LuaError('Lua: Wrong number of parameters passed to HogSay!'); |
|
5529 | 1034 |
lc_hogsay:= 1 |
3761 | 1035 |
end; |
1036 |
||
4851 | 1037 |
function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1038 |
var gear, prevgear : PGear; |
|
1039 |
begin |
|
1040 |
if lua_gettop(L) <> 1 then |
|
1041 |
LuaError('Lua: Wrong number of parameters passed to SwitchHog!') |
|
1042 |
else |
|
1043 |
begin |
|
1044 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1045 |
// should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
|
1046 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
|
1047 |
begin |
|
1048 |
prevgear := CurrentHedgehog^.Gear; |
|
7573 | 1049 |
if prevgear <> nil then |
1050 |
begin |
|
1051 |
prevgear^.Active := false; |
|
1052 |
prevgear^.State:= prevgear^.State and (not gstHHDriven); |
|
1053 |
prevgear^.Z := cHHZ; |
|
1054 |
prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
|
1055 |
end; |
|
7270
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1056 |
|
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1057 |
SwitchCurrentHedgehog(gear^.Hedgehog); |
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1058 |
CurrentTeam:= CurrentHedgehog^.Team; |
4851 | 1059 |
|
1060 |
gear^.State:= gear^.State or gstHHDriven; |
|
1061 |
gear^.Active := true; |
|
1062 |
gear^.Z := cCurrHHZ; |
|
7401 | 1063 |
gear^.Message:= gear^.Message or gmRemoveFromList or gmAddToList; |
4851 | 1064 |
end |
1065 |
end; |
|
1066 |
lc_switchhog:= 0 |
|
1067 |
end; |
|
1068 |
||
5277 | 1069 |
{function lc_addammo(L : Plua_State) : LongInt; Cdecl; |
1070 |
var gear : PGear; |
|
1071 |
begin |
|
1072 |
||
1073 |
if lua_gettop(L) = 3 then |
|
1074 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1075 |
gear:= GearByUID(lua_tointeger(L, 1)); |
5277 | 1076 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1077 |
AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); |
|
1078 |
end else |
|
1079 |
||
1080 |
if lua_gettop(L) = 2 then |
|
1081 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1082 |
gear:= GearByUID(lua_tointeger(L, 1)); |
5277 | 1083 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
1084 |
AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
|
1085 |
end else |
|
1086 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1087 |
LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
5277 | 1088 |
end; |
1089 |
||
1090 |
lc_addammo:= 0; |
|
1091 |
||
1092 |
end;} |
|
1093 |
||
4481 | 1094 |
function lc_addammo(L : Plua_State) : LongInt; Cdecl; |
1095 |
var gear : PGear; |
|
1096 |
begin |
|
5272 | 1097 |
if (lua_gettop(L) = 3) or (lua_gettop(L) = 2) then |
4481 | 1098 |
begin |
1099 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1100 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1101 |
if lua_gettop(L) = 2 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1102 |
AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1103 |
else |
6924 | 1104 |
SetAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3)) |
5272 | 1105 |
end |
1106 |
else LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); |
|
4481 | 1107 |
lc_addammo:= 0 |
1108 |
end; |
|
1109 |
||
5676
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1110 |
function lc_getammocount(L : Plua_State) : LongInt; Cdecl; |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1111 |
var gear : PGear; |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1112 |
ammo : PAmmo; |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1113 |
begin |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1114 |
if (lua_gettop(L) = 2) then |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1115 |
begin |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1116 |
gear:= GearByUID(lua_tointeger(L, 1)); |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1117 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1118 |
begin |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1119 |
ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1120 |
if ammo^.AmmoType = amNothing then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1121 |
lua_pushinteger(L, 0) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1122 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1123 |
lua_pushinteger(L, ammo^.Count) |
5676
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1124 |
end |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1125 |
else lua_pushinteger(L, 0) |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1126 |
end |
6046 | 1127 |
else |
1128 |
begin |
|
1129 |
LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!'); |
|
1130 |
lua_pushnil(L) |
|
1131 |
end; |
|
1132 |
lc_getammocount:= 1 |
|
5676
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1133 |
end; |
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1134 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1135 |
function lc_sethealth(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1136 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1137 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1138 |
if lua_gettop(L) <> 2 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1139 |
begin |
3539 | 1140 |
LuaError('Lua: Wrong number of parameters passed to SetHealth!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1141 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1142 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1143 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1144 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3723 | 1145 |
if gear <> nil then |
1146 |
begin |
|
1147 |
gear^.Health:= lua_tointeger(L, 2); |
|
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1148 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1149 |
if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1150 |
begin |
6763 | 1151 |
RenderHealth(gear^.Hedgehog^); |
1152 |
RecountTeamHealth(gear^.Hedgehog^.Team) |
|
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1153 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1154 |
|
3723 | 1155 |
SetAllToActive; |
1156 |
end |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1157 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1158 |
lc_sethealth:= 0 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1159 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1160 |
|
3722 | 1161 |
function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1162 |
var gear : PGear; |
|
1163 |
begin |
|
1164 |
if lua_gettop(L) <> 2 then |
|
1165 |
begin |
|
1166 |
LuaError('Lua: Wrong number of parameters passed to SetTimer!'); |
|
1167 |
end |
|
1168 |
else |
|
1169 |
begin |
|
1170 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1171 |
if gear <> nil then gear^.Timer:= lua_tointeger(L, 2) |
|
1172 |
end; |
|
1173 |
lc_settimer:= 0 |
|
1174 |
end; |
|
1175 |
||
3756 | 1176 |
function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1177 |
var gear: PGear; |
|
1178 |
begin |
|
1179 |
if lua_gettop(L) <> 3 then |
|
1180 |
LuaError('Lua: Wrong number of parameters passed to SetEffect!') |
|
1181 |
else begin |
|
1182 |
gear := GearByUID(lua_tointeger(L, 1)); |
|
5489 | 1183 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6982
diff
changeset
|
1184 |
gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3); |
3756 | 1185 |
end; |
1186 |
lc_seteffect := 0; |
|
1187 |
end; |
|
5489 | 1188 |
function lc_geteffect(L : Plua_State) : LongInt; Cdecl; |
1189 |
var gear : PGear; |
|
1190 |
begin |
|
1191 |
if lua_gettop(L) <> 2 then |
|
1192 |
begin |
|
1193 |
LuaError('Lua: Wrong number of parameters passed to GetEffect!'); |
|
1194 |
end |
|
1195 |
else |
|
1196 |
begin |
|
1197 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1198 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6982
diff
changeset
|
1199 |
lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]) |
5489 | 1200 |
else |
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6982
diff
changeset
|
1201 |
lua_pushinteger(L, 0) |
5489 | 1202 |
end; |
1203 |
lc_geteffect:= 1 |
|
1204 |
end; |
|
3756 | 1205 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1206 |
function lc_setstate(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1207 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1208 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1209 |
if lua_gettop(L) <> 2 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1210 |
begin |
3539 | 1211 |
LuaError('Lua: Wrong number of parameters passed to SetState!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1212 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1213 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1214 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1215 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3723 | 1216 |
if gear <> nil then |
1217 |
begin |
|
1218 |
gear^.State:= lua_tointeger(L, 2); |
|
1219 |
SetAllToActive; |
|
1220 |
end |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1221 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1222 |
lc_setstate:= 0 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1223 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1224 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1225 |
function lc_getstate(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1226 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1227 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1228 |
if lua_gettop(L) <> 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1229 |
begin |
3539 | 1230 |
LuaError('Lua: Wrong number of parameters passed to GetState!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1231 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1232 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1233 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1234 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1235 |
if gear <> nil then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1236 |
lua_pushinteger(L, gear^.State) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1237 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1238 |
lua_pushnil(L) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1239 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1240 |
lc_getstate:= 1 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1241 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1242 |
|
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1243 |
function lc_gettag(L : Plua_State) : LongInt; Cdecl; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1244 |
var gear : PGear; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1245 |
begin |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1246 |
if lua_gettop(L) <> 1 then |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1247 |
begin |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1248 |
LuaError('Lua: Wrong number of parameters passed to GetX!'); |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1249 |
lua_pushnil(L); // return value on stack (nil) |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1250 |
end |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1251 |
else |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1252 |
begin |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1253 |
gear:= GearByUID(lua_tointeger(L, 1)); |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1254 |
if gear <> nil then |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1255 |
lua_pushinteger(L, gear^.Tag) |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1256 |
else |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1257 |
lua_pushnil(L); |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1258 |
end; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1259 |
lc_gettag:= 1 |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1260 |
end; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1261 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1262 |
function lc_settag(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1263 |
var gear : PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1264 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1265 |
if lua_gettop(L) <> 2 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1266 |
begin |
3539 | 1267 |
LuaError('Lua: Wrong number of parameters passed to SetTag!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1268 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1269 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1270 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1271 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3723 | 1272 |
if gear <> nil then |
1273 |
begin |
|
1274 |
gear^.Tag:= lua_tointeger(L, 2); |
|
1275 |
SetAllToActive; |
|
1276 |
end |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1277 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1278 |
lc_settag:= 0 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1279 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1280 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1281 |
function lc_endgame(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1282 |
begin |
3407 | 1283 |
L:= L; // avoid compiler hint |
8460
75e771c3c039
fix EndGame call. w/o a proper exit, demos weren't being saved
nemo
parents:
8370
diff
changeset
|
1284 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1285 |
lc_endgame:= 0 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1286 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1287 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1288 |
function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1289 |
var gear: PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1290 |
fall: boolean; |
4629
b5d726bc4f8d
FindPlace in lua now returns null for failure to find a place, and accepts a 5th parameter to try finding a place without considering proximity (note that this can place a gear right next to mines).
nemo
parents:
4590
diff
changeset
|
1291 |
tryhard: boolean; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1292 |
left, right: LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1293 |
begin |
4629
b5d726bc4f8d
FindPlace in lua now returns null for failure to find a place, and accepts a 5th parameter to try finding a place without considering proximity (note that this can place a gear right next to mines).
nemo
parents:
4590
diff
changeset
|
1294 |
tryhard:= false; |
b5d726bc4f8d
FindPlace in lua now returns null for failure to find a place, and accepts a 5th parameter to try finding a place without considering proximity (note that this can place a gear right next to mines).
nemo
parents:
4590
diff
changeset
|
1295 |
if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then |
3539 | 1296 |
LuaError('Lua: Wrong number of parameters passed to FindPlace!') |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1297 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1298 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1299 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1300 |
fall:= lua_toboolean(L, 2); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1301 |
left:= lua_tointeger(L, 3); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1302 |
right:= lua_tointeger(L, 4); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1303 |
if lua_gettop(L) = 5 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1304 |
tryhard:= lua_toboolean(L, 5); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1305 |
if gear <> nil then |
4629
b5d726bc4f8d
FindPlace in lua now returns null for failure to find a place, and accepts a 5th parameter to try finding a place without considering proximity (note that this can place a gear right next to mines).
nemo
parents:
4590
diff
changeset
|
1306 |
FindPlace(gear, fall, left, right, tryhard); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1307 |
if gear <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1308 |
lua_pushinteger(L, gear^.uid) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1309 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1310 |
lua_pushnil(L); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1311 |
end; |
4629
b5d726bc4f8d
FindPlace in lua now returns null for failure to find a place, and accepts a 5th parameter to try finding a place without considering proximity (note that this can place a gear right next to mines).
nemo
parents:
4590
diff
changeset
|
1312 |
lc_findplace:= 1 |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1313 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1314 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1315 |
function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
4516
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1316 |
var gear: PGear; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1317 |
begin |
4516
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1318 |
if lua_gettop(L) = 1 then |
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1319 |
PlaySound(TSound(lua_tointeger(L, 1))) |
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1320 |
else if lua_gettop(L) = 2 then |
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1321 |
begin |
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1322 |
gear:= GearByUID(lua_tointeger(L, 2)); |
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1323 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
5638
e35ba2a400d8
Try to avoid overlapping voices for major statements (not things like byebye or oof)
nemo
parents:
5612
diff
changeset
|
1324 |
AddVoice(TSound(lua_tointeger(L, 1)),gear^.Hedgehog^.Team^.Voicepack) |
4516
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1325 |
end |
ecf012a762d8
add PlaySound(soundType, hogGearUID) -- this roundabout way to reference a team seems to be how things are done in lua right now. might need changing in future
nemo
parents:
4502
diff
changeset
|
1326 |
else LuaError('Lua: Wrong number of parameters passed to PlaySound!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1327 |
lc_playsound:= 0; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1328 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1329 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1330 |
function lc_addteam(L : Plua_State) : LongInt; Cdecl; |
4517
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1331 |
var np: LongInt; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1332 |
begin |
4517
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1333 |
np:= lua_gettop(L); |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1334 |
if (np < 5) or (np > 6) then |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1335 |
begin |
3539 | 1336 |
LuaError('Lua: Wrong number of parameters passed to AddTeam!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1337 |
//lua_pushnil(L) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1338 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1339 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1340 |
begin |
7805 | 1341 |
ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); |
1342 |
ParseCommand('grave ' + lua_tostring(L, 3), true, true); |
|
1343 |
ParseCommand('fort ' + lua_tostring(L, 4), true, true); |
|
1344 |
ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); |
|
1345 |
if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true); |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1346 |
CurrentTeam^.Binds:= DefaultBinds |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1347 |
// fails on x64 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1348 |
//lua_pushinteger(L, LongInt(CurrentTeam)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1349 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1350 |
lc_addteam:= 0;//1; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1351 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1352 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1353 |
function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
3271 | 1354 |
var temp: ShortString; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1355 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1356 |
if lua_gettop(L) <> 4 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1357 |
begin |
3539 | 1358 |
LuaError('Lua: Wrong number of parameters passed to AddHog!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1359 |
lua_pushnil(L) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1360 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1361 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1362 |
begin |
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
1363 |
temp:= lua_tostring(L, 4); |
7805 | 1364 |
ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
1365 |
ParseCommand('hat ' + temp, true, true); |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1366 |
lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1367 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1368 |
lc_addhog:= 1; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1369 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1370 |
|
3761 | 1371 |
function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
1372 |
var gear: PGear; |
|
1373 |
begin |
|
1374 |
if lua_gettop(L) <> 2 then |
|
1375 |
begin |
|
1376 |
LuaError('Lua: Wrong number of parameters passed to HogTurnLeft!'); |
|
1377 |
end |
|
1378 |
else |
|
1379 |
begin |
|
1380 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1381 |
if gear <> nil then |
|
1382 |
gear^.dX.isNegative:= lua_toboolean(L, 2); |
|
1383 |
end; |
|
1384 |
lc_hogturnleft:= 0; |
|
1385 |
end; |
|
1386 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1387 |
function lc_getgearposition(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1388 |
var gear: PGear; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1389 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1390 |
if lua_gettop(L) <> 1 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1391 |
begin |
3539 | 1392 |
LuaError('Lua: Wrong number of parameters passed to GetGearPosition!'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1393 |
lua_pushnil(L); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1394 |
lua_pushnil(L) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1395 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1396 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1397 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1398 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1399 |
if gear <> nil then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1400 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1401 |
lua_pushinteger(L, hwRound(gear^.X)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1402 |
lua_pushinteger(L, hwRound(gear^.Y)) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1403 |
end |
5964 | 1404 |
else |
1405 |
begin |
|
1406 |
lua_pushnil(L); |
|
1407 |
lua_pushnil(L) |
|
1408 |
end; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1409 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1410 |
lc_getgearposition:= 2; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1411 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1412 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1413 |
function lc_setgearposition(L : Plua_State) : LongInt; Cdecl; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1414 |
var gear: PGear; |
4832 | 1415 |
col: boolean; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1416 |
x, y: LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1417 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1418 |
if lua_gettop(L) <> 3 then |
3539 | 1419 |
LuaError('Lua: Wrong number of parameters passed to SetGearPosition!') |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1420 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1421 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1422 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1423 |
if gear <> nil then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1424 |
begin |
4832 | 1425 |
col:= gear^.CollisionIndex >= 0; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1426 |
x:= lua_tointeger(L, 2); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1427 |
y:= lua_tointeger(L, 3); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1428 |
if col then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1429 |
DeleteCI(gear); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1430 |
gear^.X:= int2hwfloat(x); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1431 |
gear^.Y:= int2hwfloat(y); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1432 |
if col then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1433 |
AddGearCI(gear); |
4832 | 1434 |
SetAllToActive |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1435 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1436 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1437 |
lc_setgearposition:= 0 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1438 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1439 |
|
5517 | 1440 |
function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl; |
1441 |
var gear: PGear; |
|
1442 |
begin |
|
1443 |
if lua_gettop(L) <> 1 then |
|
1444 |
begin |
|
1445 |
LuaError('Lua: Wrong number of parameters passed to GetGearTarget!'); |
|
1446 |
lua_pushnil(L); |
|
1447 |
lua_pushnil(L) |
|
1448 |
end |
|
1449 |
else |
|
1450 |
begin |
|
1451 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1452 |
if gear <> nil then |
|
1453 |
begin |
|
5612
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1454 |
lua_pushinteger(L, gear^.Target.X); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1455 |
lua_pushinteger(L, gear^.Target.Y) |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1456 |
end |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1457 |
else |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1458 |
begin |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1459 |
lua_pushnil(L); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1460 |
lua_pushnil(L) |
5517 | 1461 |
end |
1462 |
end; |
|
1463 |
lc_getgeartarget:= 2; |
|
1464 |
end; |
|
1465 |
||
1466 |
function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl; |
|
1467 |
var gear: PGear; |
|
1468 |
begin |
|
1469 |
if lua_gettop(L) <> 3 then |
|
1470 |
LuaError('Lua: Wrong number of parameters passed to SetGearTarget!') |
|
1471 |
else |
|
1472 |
begin |
|
1473 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1474 |
if gear <> nil then |
|
1475 |
begin |
|
5612
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1476 |
gear^.Target.X:= lua_tointeger(L, 2); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1477 |
gear^.Target.Y:= lua_tointeger(L, 3) |
5517 | 1478 |
end |
1479 |
end; |
|
1480 |
lc_setgeartarget:= 0 |
|
1481 |
end; |
|
1482 |
||
4517
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1483 |
function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1484 |
var gear: PGear; |
6780 | 1485 |
var t: LongInt; |
4517
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1486 |
begin |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1487 |
if lua_gettop(L) <> 1 then |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1488 |
begin |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1489 |
LuaError('Lua: Wrong number of parameters passed to GetGearVelocity!'); |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1490 |
lua_pushnil(L); |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1491 |
lua_pushnil(L) |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1492 |
end |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1493 |
else |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1494 |
begin |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1495 |
gear:= GearByUID(lua_tointeger(L, 1)); |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1496 |
if gear <> nil then |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1497 |
begin |
6780 | 1498 |
t:= hwRound(gear^.dX * 1000000); |
6779
ccd8aecaff6d
Small tweak to return something more useful in the negative 0 case on dX
nemo
parents:
6764
diff
changeset
|
1499 |
// gear dX determines hog orientation |
6780 | 1500 |
if (gear^.dX.isNegative) and (t = 0) then t:= -1; |
1501 |
lua_pushinteger(L, t); |
|
5074 | 1502 |
lua_pushinteger(L, hwRound(gear^.dY * 1000000)) |
4517
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1503 |
end |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1504 |
end; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1505 |
lc_getgearvelocity:= 2; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1506 |
end; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1507 |
|
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1508 |
function lc_setgearvelocity(L : Plua_State) : LongInt; Cdecl; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1509 |
var gear: PGear; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1510 |
begin |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1511 |
if lua_gettop(L) <> 3 then |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1512 |
LuaError('Lua: Wrong number of parameters passed to SetGearVelocity!') |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1513 |
else |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1514 |
begin |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1515 |
gear:= GearByUID(lua_tointeger(L, 1)); |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1516 |
if gear <> nil then |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1517 |
begin |
5074 | 1518 |
gear^.dX:= int2hwFloat(lua_tointeger(L, 2)) / 1000000; |
1519 |
gear^.dY:= int2hwFloat(lua_tointeger(L, 3)) / 1000000; |
|
4517
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1520 |
SetAllToActive; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1521 |
end |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1522 |
end; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1523 |
lc_setgearvelocity:= 0 |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1524 |
end; |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4516
diff
changeset
|
1525 |
|
3736 | 1526 |
function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
1527 |
begin |
|
1528 |
if lua_gettop(L) <> 1 then |
|
1529 |
LuaError('Lua: Wrong number of parameters passed to SetZoom!') |
|
1530 |
else |
|
1531 |
begin |
|
1532 |
ZoomValue:= lua_tonumber(L, 1); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1533 |
if ZoomValue < cMaxZoomLevel then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1534 |
ZoomValue:= cMaxZoomLevel; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1535 |
if ZoomValue > cMinZoomLevel then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1536 |
ZoomValue:= cMinZoomLevel; |
3736 | 1537 |
end; |
1538 |
lc_setzoom:= 0 |
|
1539 |
end; |
|
1540 |
||
1541 |
function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
|
1542 |
begin |
|
1543 |
if lua_gettop(L) <> 0 then |
|
1544 |
begin |
|
1545 |
LuaError('Lua: Wrong number of parameters passed to GetZoom!'); |
|
1546 |
lua_pushnil(L) |
|
1547 |
end |
|
1548 |
else |
|
1549 |
lua_pushnumber(L, ZoomValue); |
|
1550 |
lc_getzoom:= 1 |
|
1551 |
end; |
|
1552 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1553 |
function lc_setammo(L : Plua_State) : LongInt; Cdecl; |
3368 | 1554 |
var np: LongInt; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1555 |
begin |
3368 | 1556 |
np:= lua_gettop(L); |
1557 |
if (np < 4) or (np > 5) then |
|
3539 | 1558 |
LuaError('Lua: Wrong number of parameters passed to SetAmmo!') |
3368 | 1559 |
else if np = 4 then |
1560 |
ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 1) |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1561 |
else |
3346 | 1562 |
ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1563 |
lc_setammo:= 0 |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1564 |
end; |
4243 | 1565 |
|
6529 | 1566 |
function lc_setammostore(L : Plua_State) : LongInt; Cdecl; |
1567 |
var np: LongInt; |
|
1568 |
begin |
|
1569 |
np:= lua_gettop(L); |
|
1570 |
if (np <> 4) then |
|
1571 |
LuaError('Lua: Wrong number of parameters passed to SetAmmoStore!') |
|
1572 |
else |
|
1573 |
begin |
|
1574 |
ScriptAmmoLoadout:= lua_tostring(L, 1); |
|
1575 |
ScriptAmmoProbability:= lua_tostring(L, 2); |
|
1576 |
ScriptAmmoDelay:= lua_tostring(L, 3); |
|
1577 |
ScriptAmmoReinforcement:= lua_tostring(L, 4); |
|
1578 |
end; |
|
1579 |
lc_setammostore:= 0 |
|
1580 |
end; |
|
1581 |
||
4243 | 1582 |
function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
1583 |
var m : LongInt; |
|
1584 |
begin |
|
1585 |
if lua_gettop(L) <> 1 then |
|
1586 |
begin |
|
1587 |
LuaError('Lua: Wrong number of parameters passed to GetRandom!'); |
|
1588 |
lua_pushnil(L); // return value on stack (nil) |
|
1589 |
end |
|
1590 |
else |
|
1591 |
begin |
|
1592 |
m:= lua_tointeger(L, 1); |
|
1593 |
if (m > 0) then |
|
1594 |
lua_pushinteger(L, GetRandom(m)) |
|
1595 |
else |
|
1596 |
begin |
|
1597 |
LuaError('Lua: Tried to pass 0 to GetRandom!'); |
|
1598 |
lua_pushnil(L); |
|
1599 |
end |
|
1600 |
end; |
|
1601 |
lc_getrandom:= 1 |
|
1602 |
end; |
|
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1603 |
|
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1604 |
function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1605 |
begin |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1606 |
if lua_gettop(L) <> 1 then |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1607 |
LuaError('Lua: Wrong number of parameters passed to SetWind!') |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1608 |
else |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1609 |
begin |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1610 |
cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed; |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1611 |
cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1612 |
if cWindSpeed.isNegative then |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1613 |
CWindSpeedf := -cWindSpeedf; |
5357
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5313
diff
changeset
|
1614 |
AddVisualGear(0, 0, vgtSmoothWindBar); |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1615 |
end; |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1616 |
lc_setwind:= 0 |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1617 |
end; |
4502
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1618 |
|
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1619 |
function lc_getdatapath(L : Plua_State) : LongInt; Cdecl; |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1620 |
begin |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1621 |
if lua_gettop(L) <> 0 then |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1622 |
begin |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1623 |
LuaError('Lua: Wrong number of parameters passed to GetDataPath!'); |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1624 |
lua_pushnil(L); |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1625 |
end |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1626 |
else |
8025 | 1627 |
lua_pushstring(L, str2pchar(cPathz[ptData])); |
4502
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1628 |
lc_getdatapath:= 1 |
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
1629 |
end; |
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1630 |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1631 |
function lc_getuserdatapath(L : Plua_State) : LongInt; Cdecl; |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1632 |
begin |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1633 |
if lua_gettop(L) <> 0 then |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1634 |
begin |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1635 |
LuaError('Lua: Wrong number of parameters passed to GetUserDataPath!'); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1636 |
lua_pushnil(L); |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1637 |
end |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1638 |
else |
8025 | 1639 |
lua_pushstring(L, str2pchar(cPathz[ptData])); |
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1640 |
lc_getuserdatapath:= 1 |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1641 |
end; |
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5124
diff
changeset
|
1642 |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1643 |
function lc_maphasborder(L : Plua_State) : LongInt; Cdecl; |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1644 |
begin |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1645 |
if lua_gettop(L) <> 0 then |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1646 |
begin |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1647 |
LuaError('Lua: Wrong number of parameters passed to MapHasBorder!'); |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1648 |
lua_pushnil(L); |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1649 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1650 |
else |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1651 |
lua_pushboolean(L, hasBorder); |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1652 |
lc_maphasborder:= 1 |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
1653 |
end; |
4869 | 1654 |
|
1655 |
function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
|
1656 |
var gear : PGear; |
|
1657 |
begin |
|
1658 |
if lua_gettop(L) <> 1 then |
|
1659 |
begin |
|
1660 |
LuaError('Lua: Wrong number of parameters passed to GetGearRadius!'); |
|
1661 |
lua_pushnil(L); // return value on stack (nil) |
|
1662 |
end |
|
1663 |
else |
|
1664 |
begin |
|
1665 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1666 |
if gear <> nil then |
|
1667 |
lua_pushinteger(L, gear^.Radius) |
|
1668 |
else |
|
1669 |
lua_pushnil(L); |
|
1670 |
end; |
|
1671 |
lc_getgearradius:= 1 |
|
1672 |
end; |
|
4875 | 1673 |
|
1674 |
function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
|
1675 |
var gear : PGear; |
|
1676 |
begin |
|
1677 |
if lua_gettop(L) <> 1 then |
|
1678 |
LuaError('Lua: Wrong number of parameters passed to GetHogHat!') |
|
1679 |
else begin |
|
1680 |
gear := GearByUID(lua_tointeger(L, 1)); |
|
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
1681 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4875 | 1682 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
1683 |
else |
|
1684 |
lua_pushnil(L); |
|
1685 |
end; |
|
1686 |
lc_gethoghat := 1; |
|
1687 |
end; |
|
1688 |
||
1689 |
function lc_sethoghat(L : Plua_State) : LongInt; Cdecl; |
|
1690 |
var gear : PGear; |
|
1691 |
hat: ShortString; |
|
1692 |
begin |
|
1693 |
if lua_gettop(L) <> 2 then |
|
1694 |
begin |
|
1695 |
LuaError('Lua: Wrong number of parameters passed to SetHogHat!'); |
|
1696 |
lua_pushnil(L) |
|
1697 |
end |
|
1698 |
else |
|
1699 |
begin |
|
1700 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1701 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
1702 |
hat:= lua_tostring(L, 2); |
4875 | 1703 |
gear^.Hedgehog^.Hat:= hat; |
7889 | 1704 |
AddFileLog('Changed hat to: '+hat); |
7887 | 1705 |
if (Length(hat) > 39) and (Copy(hat,1,8) = 'Reserved') and (Copy(hat,9,32) = gear^.Hedgehog^.Team^.PlayerHash) then |
1706 |
LoadHedgehogHat(gear^.Hedgehog^, 'Reserved/' + Copy(hat,9,Length(hat)-8)) |
|
1707 |
else |
|
1708 |
LoadHedgehogHat(gear^.Hedgehog^, hat); |
|
4875 | 1709 |
end; |
1710 |
lc_sethoghat:= 0; |
|
1711 |
end; |
|
4985 | 1712 |
|
1713 |
function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
|
1714 |
begin |
|
1715 |
if lua_gettop(L) <> 3 then |
|
1716 |
LuaError('Lua: Wrong number of parameters passed to PlaceGirder!') |
|
1717 |
else |
|
1718 |
TryPlaceOnLand( |
|
1719 |
lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
|
1720 |
lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
|
1721 |
sprAmGirder, lua_tointeger(L, 3), true, false); |
|
1722 |
lc_placegirder:= 0 |
|
1723 |
end; |
|
5013 | 1724 |
|
1725 |
function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
|
1726 |
begin |
|
1727 |
if lua_gettop(L) <> 0 then |
|
1728 |
LuaError('Lua: Wrong number of parameters passed to GetCurAmmoType!') |
|
1729 |
else |
|
1730 |
lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)); |
|
1731 |
lc_getcurammotype := 1; |
|
1732 |
end; |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1733 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1734 |
function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1735 |
begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1736 |
if lua_gettop(L) <> 2 then |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1737 |
LuaError('Lua: Wrong number of parameters passed to SaveCampaignVar!') |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1738 |
else begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1739 |
SendIPC('V!' + lua_tostring(L, 1) + ' ' + lua_tostring(L, 2) + #0); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1740 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1741 |
lc_savecampaignvar := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1742 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1743 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1744 |
function lc_getcampaignvar(L : Plua_State): LongInt; Cdecl; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1745 |
begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1746 |
if (lua_gettop(L) <> 1) then |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1747 |
LuaError('Lua: Wrong number of parameters passed to GetCampaignVar!') |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1748 |
else |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1749 |
SendIPCAndWaitReply('V?' + lua_tostring(L, 1)); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1750 |
lua_pushstring(L, str2pchar(CampaignVariable)); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1751 |
lc_getcampaignvar := 1; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1752 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1753 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1754 |
function lc_hidehog(L: Plua_State): LongInt; Cdecl; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1755 |
var gear: PGear; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1756 |
begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1757 |
if lua_gettop(L) <> 1 then |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1758 |
LuaError('Lua: Wrong number of parameters passed to HideHog!') |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1759 |
else |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1760 |
begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1761 |
gear:= GearByUID(lua_tointeger(L, 1)); |
8012 | 1762 |
HideHog(gear^.hedgehog) |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1763 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1764 |
lc_hidehog := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1765 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1766 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1767 |
function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
8370 | 1768 |
var i, h: LongInt; |
8012 | 1769 |
uid: LongWord; |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1770 |
begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1771 |
if lua_gettop(L) <> 1 then |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1772 |
LuaError('Lua: Wrong number of parameters passed to RestoreHog!') |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1773 |
else |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1774 |
begin |
8012 | 1775 |
uid:= LongWord(lua_tointeger(L, 1)); |
1776 |
if TeamsCount > 0 then |
|
1777 |
for i:= 0 to Pred(TeamsCount) do |
|
1778 |
for h:= 0 to cMaxHHIndex do |
|
1779 |
if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
|
1780 |
begin |
|
1781 |
RestoreHog(@TeamsArray[i]^.Hedgehogs[h]); |
|
1782 |
exit(0) |
|
1783 |
end |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1784 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1785 |
lc_restorehog := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1786 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
1787 |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1788 |
// boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1789 |
function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1790 |
var rtn: Boolean; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1791 |
begin |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1792 |
if lua_gettop(L) <> 5 then |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1793 |
begin |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1794 |
LuaError('Lua: Wrong number of parameters passed to TestRectForObstacle!'); |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1795 |
lua_pushnil(L); // return value on stack (nil) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1796 |
end |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1797 |
else |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1798 |
begin |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1799 |
rtn:= TestRectancleForObstacle( |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1800 |
lua_tointeger(L, 1), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1801 |
lua_tointeger(L, 2), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1802 |
lua_tointeger(L, 3), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1803 |
lua_tointeger(L, 4), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1804 |
lua_toboolean(L, 5) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1805 |
); |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1806 |
lua_pushboolean(L, rtn); |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1807 |
end; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1808 |
lc_testrectforobstacle:= 1 |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
1809 |
end; |
7996 | 1810 |
|
1811 |
||
1812 |
function lc_setaihintsongear(L : Plua_State) : LongInt; Cdecl; |
|
1813 |
var gear: PGear; |
|
1814 |
begin |
|
1815 |
if lua_gettop(L) <> 2 then |
|
1816 |
LuaError('Lua: Wrong number of parameters passed to SetAIHintOnGear!') |
|
1817 |
else |
|
1818 |
begin |
|
1819 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1820 |
if gear <> nil then |
|
1821 |
gear^.aihints:= lua_tointeger(L, 2); |
|
1822 |
end; |
|
1823 |
lc_setaihintsongear:= 0 |
|
1824 |
end; |
|
1825 |
||
8043 | 1826 |
|
1827 |
function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
|
1828 |
begin |
|
1829 |
if lua_gettop(L) <> 1 then |
|
1830 |
begin |
|
1831 |
LuaError('Lua: Wrong number of parameters passed to HedgewarsScriptLoad!'); |
|
1832 |
lua_pushnil(L) |
|
1833 |
end |
|
1834 |
else |
|
1835 |
ScriptLoad(lua_tostring(L, 1)); |
|
1836 |
lc_hedgewarsscriptload:= 0; |
|
1837 |
end; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1838 |
/////////////////// |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1839 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1840 |
procedure ScriptPrintStack; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1841 |
var n, i : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1842 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1843 |
n:= lua_gettop(luaState); |
3539 | 1844 |
WriteLnToConsole('Lua: Stack (' + inttostr(n) + ' elements):'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1845 |
for i:= 1 to n do |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1846 |
if not lua_isboolean(luaState, i) then |
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
1847 |
WriteLnToConsole('Lua: ' + inttostr(i) + ': ' + lua_tostring(luaState, i)) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1848 |
else if lua_toboolean(luaState, i) then |
3539 | 1849 |
WriteLnToConsole('Lua: ' + inttostr(i) + ': true') |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1850 |
else |
3539 | 1851 |
WriteLnToConsole('Lua: ' + inttostr(i) + ': false'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1852 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1853 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1854 |
procedure ScriptClearStack; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1855 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1856 |
lua_settop(luaState, 0) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1857 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1858 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1859 |
procedure ScriptSetNil(name : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1860 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1861 |
lua_pushnil(luaState); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1862 |
lua_setglobal(luaState, Str2PChar(name)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1863 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1864 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1865 |
procedure ScriptSetInteger(name : shortstring; value : LongInt); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1866 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1867 |
lua_pushinteger(luaState, value); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1868 |
lua_setglobal(luaState, Str2PChar(name)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1869 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1870 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1871 |
procedure ScriptSetString(name : shortstring; value : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1872 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1873 |
lua_pushstring(luaState, Str2PChar(value)); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1874 |
lua_setglobal(luaState, Str2PChar(name)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1875 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1876 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1877 |
function ScriptGetInteger(name : shortstring) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1878 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1879 |
lua_getglobal(luaState, Str2PChar(name)); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1880 |
ScriptGetInteger:= lua_tointeger(luaState, -1); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1881 |
lua_pop(luaState, 1); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1882 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1883 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1884 |
function ScriptGetString(name : shortstring) : shortstring; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1885 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1886 |
lua_getglobal(luaState, Str2PChar(name)); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1887 |
ScriptGetString:= lua_tostring(luaState, -1); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1888 |
lua_pop(luaState, 1); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1889 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1890 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1891 |
procedure ScriptOnGameInit; |
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1892 |
var i, j, k: LongInt; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1893 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1894 |
// not required if there is no script to run |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1895 |
if not ScriptLoaded then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1896 |
exit; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1897 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1898 |
// push game variables so they may be modified by the script |
6982 | 1899 |
ScriptSetInteger('BorderColor', ExplosionBorderColor); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1900 |
ScriptSetInteger('GameFlags', GameFlags); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1901 |
ScriptSetString('Seed', cSeed); |
5676
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1902 |
ScriptSetInteger('TemplateFilter', cTemplateFilter); |
7567 | 1903 |
ScriptSetInteger('TemplateNumber', LuaTemplateNumber); |
5676
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
1904 |
ScriptSetInteger('MapGen', cMapGen); |
5583
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
1905 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
1906 |
ScriptSetInteger('ScreenWidth', cScreenWidth); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1907 |
ScriptSetInteger('TurnTime', cHedgehogTurnTime); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1908 |
ScriptSetInteger('CaseFreq', cCaseFactor); |
4162 | 1909 |
ScriptSetInteger('HealthCaseProb', cHealthCaseProb); |
1910 |
ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount); |
|
4221 | 1911 |
ScriptSetInteger('DamagePercent', cDamagePercent); |
6557 | 1912 |
ScriptSetInteger('RopePercent', cRopePercent); |
4003
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
3999
diff
changeset
|
1913 |
ScriptSetInteger('MinesNum', cLandMines); |
4221 | 1914 |
ScriptSetInteger('MinesTime', cMinesTime); |
1915 |
ScriptSetInteger('MineDudPercent', cMineDudPercent); |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1916 |
ScriptSetInteger('Explosives', cExplosives); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1917 |
ScriptSetInteger('Delay', cInactDelay); |
3774 | 1918 |
ScriptSetInteger('Ready', cReadyDelay); |
3197 | 1919 |
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
4162 | 1920 |
ScriptSetInteger('WaterRise', cWaterRise); |
1921 |
ScriptSetInteger('HealthDecrease', cHealthDecrease); |
|
6828
6a5d33bff0b0
At mikade's request. give scripting access to the map name prior to override.
nemo
parents:
6790
diff
changeset
|
1922 |
ScriptSetString('Map', cMapName); |
6a5d33bff0b0
At mikade's request. give scripting access to the map name prior to override.
nemo
parents:
6790
diff
changeset
|
1923 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1924 |
ScriptSetString('Theme', ''); |
4883
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
1925 |
ScriptSetString('Goals', ''); |
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
1926 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1927 |
ScriptCall('onGameInit'); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1928 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1929 |
// pop game variables |
7805 | 1930 |
ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1931 |
cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
7567 | 1932 |
LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1933 |
cMapGen := ScriptGetInteger('MapGen'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1934 |
GameFlags := ScriptGetInteger('GameFlags'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1935 |
cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1936 |
cCaseFactor := ScriptGetInteger('CaseFreq'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1937 |
cHealthCaseProb := ScriptGetInteger('HealthCaseProb'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1938 |
cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1939 |
cDamagePercent := ScriptGetInteger('DamagePercent'); |
6523 | 1940 |
cRopePercent := ScriptGetInteger('RopePercent'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1941 |
cLandMines := ScriptGetInteger('MinesNum'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1942 |
cMinesTime := ScriptGetInteger('MinesTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1943 |
cMineDudPercent := ScriptGetInteger('MineDudPercent'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1944 |
cExplosives := ScriptGetInteger('Explosives'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1945 |
cInactDelay := ScriptGetInteger('Delay'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1946 |
cReadyDelay := ScriptGetInteger('Ready'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1947 |
cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1948 |
cWaterRise := ScriptGetInteger('WaterRise'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1949 |
cHealthDecrease := ScriptGetInteger('HealthDecrease'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
1950 |
|
7771 | 1951 |
if cMapName <> ScriptGetString('Map') then |
7805 | 1952 |
ParseCommand('map ' + ScriptGetString('Map'), true, true); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1953 |
if ScriptGetString('Theme') <> '' then |
7805 | 1954 |
ParseCommand('theme ' + ScriptGetString('Theme'), true, true); |
4883
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
1955 |
LuaGoals:= ScriptGetString('Goals'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1956 |
|
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1957 |
// Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around. |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1958 |
k:= 0; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1959 |
if (GameFlags and gfSharedAmmo) <> 0 then |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1960 |
for i:= 0 to Pred(ClansCount) do |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1961 |
for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1962 |
for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1963 |
ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= i |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1964 |
else if (GameFlags and gfPerHogAmmo) <> 0 then |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1965 |
for i:= 0 to Pred(TeamsCount) do |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1966 |
for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1967 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1968 |
TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1969 |
if StoreCnt-1 < k then AddAmmoStore; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1970 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1971 |
end |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1972 |
else |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1973 |
for i:= 0 to Pred(TeamsCount) do |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1974 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1975 |
for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1976 |
TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1977 |
if StoreCnt-1 < k then AddAmmoStore; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1978 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
1979 |
end; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
1980 |
if ScriptExists('onAmmoStoreInit') or ScriptExists('onNewAmmoStore') then |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1981 |
begin |
6740
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
1982 |
// reset ammostore (quite unclean, but works?) |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
1983 |
uAmmos.freeModule; |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
1984 |
uAmmos.initModule; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
1985 |
if ScriptExists('onAmmoStoreInit') then |
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
1986 |
begin |
6752 | 1987 |
ScriptPrepareAmmoStore; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
1988 |
ScriptCall('onAmmoStoreInit'); |
6746 | 1989 |
SetAmmoLoadout(ScriptAmmoLoadout); |
1990 |
SetAmmoProbability(ScriptAmmoProbability); |
|
1991 |
SetAmmoDelay(ScriptAmmoDelay); |
|
1992 |
SetAmmoReinforcement(ScriptAmmoReinforcement) |
|
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
1993 |
end; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1994 |
ScriptApplyAmmoStore |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1995 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1996 |
|
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
1997 |
ScriptSetInteger('ClansCount', ClansCount); |
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
1998 |
ScriptSetInteger('TeamsCount', TeamsCount) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1999 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2000 |
|
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2001 |
|
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2002 |
// Update values of screen dimensions and allow script to react to resolution change |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2003 |
procedure ScriptOnScreenResize(); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2004 |
begin |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2005 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2006 |
ScriptSetInteger('ScreenWidth', cScreenWidth); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2007 |
ScriptCall('onScreenResize'); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2008 |
end; |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2009 |
|
8031 | 2010 |
// custom script loader via physfs, passed to lua_load |
8034 | 2011 |
const BUFSIZE = 1024; |
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2012 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2013 |
procedure ScriptLoad(name : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2014 |
var ret : LongInt; |
5243 | 2015 |
s : shortstring; |
8031 | 2016 |
f : PFSFile; |
8034 | 2017 |
buf : array[0..Pred(BUFSIZE)] of byte; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2018 |
begin |
8031 | 2019 |
s:= cPathz[ptData] + name; |
2020 |
if not pfsExists(s) then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2021 |
exit; |
6088 | 2022 |
|
8031 | 2023 |
f:= pfsOpenRead(s); |
2024 |
if f = nil then |
|
2025 |
exit; |
|
2026 |
||
8073 | 2027 |
physfsReaderSetBuffer(@buf); |
8031 | 2028 |
ret:= lua_load(luaState, @physfsReader, f, Str2PChar(s)); |
2029 |
pfsClose(f); |
|
2030 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2031 |
if ret <> 0 then |
3774 | 2032 |
begin |
2033 |
LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
|
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
2034 |
LuaError('Lua: ' + lua_tostring(luaState, -1)); |
3774 | 2035 |
end |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2036 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2037 |
begin |
3539 | 2038 |
WriteLnToConsole('Lua: ' + name + ' loaded'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2039 |
// call the script file |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2040 |
lua_pcall(luaState, 0, 0, 0); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2041 |
ScriptLoaded:= true |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2042 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2043 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2044 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2045 |
procedure SetGlobals; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2046 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2047 |
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
3761 | 2048 |
ScriptSetInteger('GameTime', GameTicks); |
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
2049 |
ScriptSetInteger('TotalRounds', TotalRounds); |
5676
a655dfab27d7
Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents:
5638
diff
changeset
|
2050 |
ScriptSetInteger('WaterLine', cWaterLine); |
7650 | 2051 |
if GameTicks = 0 then |
2052 |
begin |
|
2053 |
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
|
2054 |
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
|
2055 |
ScriptSetInteger('LeftX', leftX); |
|
2056 |
ScriptSetInteger('RightX', rightX); |
|
2057 |
ScriptSetInteger('TopY', topY) |
|
2058 |
end; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2059 |
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2060 |
ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2061 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2062 |
ScriptSetNil('CurrentHedgehog'); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2063 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2064 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2065 |
procedure GetGlobals; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2066 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2067 |
TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2068 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2069 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2070 |
procedure ScriptCall(fname : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2071 |
begin |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6430
diff
changeset
|
2072 |
if not ScriptLoaded or (not ScriptExists(fname)) then |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2073 |
exit; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2074 |
SetGlobals; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2075 |
lua_getglobal(luaState, Str2PChar(fname)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2076 |
if lua_pcall(luaState, 0, 0, 0) <> 0 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2077 |
begin |
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
2078 |
LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2079 |
lua_pop(luaState, 1) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2080 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2081 |
GetGlobals; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2082 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2083 |
|
7805 | 2084 |
(* |
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2085 |
function ParseCommandOverride(key, value : shortstring) : shortstring; |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2086 |
begin |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2087 |
ParseCommandOverride:= value; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2088 |
if not ScriptExists('ParseCommandOverride') then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2089 |
exit; |
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2090 |
lua_getglobal(luaState, Str2PChar('ParseCommandOverride')); |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2091 |
lua_pushstring(luaState, Str2PChar(key)); |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2092 |
lua_pushstring(luaState, Str2PChar(value)); |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2093 |
if lua_pcall(luaState, 2, 1, 0) <> 0 then |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2094 |
begin |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2095 |
LuaError('Lua: Error while calling ParseCommandOverride: ' + lua_tostring(luaState, -1)); |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2096 |
lua_pop(luaState, 1) |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2097 |
end |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2098 |
else |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2099 |
begin |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2100 |
ParseCommandOverride:= lua_tostring(luaState, -1); |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2101 |
lua_pop(luaState, 1) |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2102 |
end; |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2103 |
end; |
7805 | 2104 |
*) |
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2105 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2106 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2107 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2108 |
ScriptCall:= ScriptCall(fname, par1, 0, 0, 0) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2109 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2110 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2111 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2112 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2113 |
ScriptCall:= ScriptCall(fname, par1, par2, 0, 0) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2114 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2115 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2116 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2117 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2118 |
ScriptCall:= ScriptCall(fname, par1, par2, par3, 0) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2119 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2120 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2121 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2122 |
begin |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6430
diff
changeset
|
2123 |
if not ScriptLoaded or (not ScriptExists(fname)) then |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2124 |
exit; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2125 |
SetGlobals; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2126 |
lua_getglobal(luaState, Str2PChar(fname)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2127 |
lua_pushinteger(luaState, par1); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2128 |
lua_pushinteger(luaState, par2); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2129 |
lua_pushinteger(luaState, par3); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2130 |
lua_pushinteger(luaState, par4); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2131 |
ScriptCall:= 0; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2132 |
if lua_pcall(luaState, 4, 1, 0) <> 0 then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2133 |
begin |
5549
ccfb9b8ab9d1
sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents:
5547
diff
changeset
|
2134 |
LuaError('Lua: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2135 |
lua_pop(luaState, 1) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2136 |
end |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2137 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2138 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2139 |
ScriptCall:= lua_tointeger(luaState, -1); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2140 |
lua_pop(luaState, 1) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2141 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2142 |
GetGlobals; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2143 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2144 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2145 |
function ScriptExists(fname : shortstring) : boolean; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2146 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2147 |
if not ScriptLoaded then |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2148 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2149 |
ScriptExists:= false; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2150 |
exit |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2151 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2152 |
lua_getglobal(luaState, Str2PChar(fname)); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2153 |
ScriptExists:= not lua_isnoneornil(luaState, -1); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2154 |
lua_pop(luaState, -1) |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2155 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2156 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2157 |
procedure ScriptPrepareAmmoStore; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2158 |
var i: ShortInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2159 |
begin |
3346 | 2160 |
ScriptAmmoLoadout:= ''; |
2161 |
ScriptAmmoDelay:= ''; |
|
2162 |
ScriptAmmoProbability:= ''; |
|
2163 |
ScriptAmmoReinforcement:= ''; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2164 |
for i:=1 to ord(High(TAmmoType)) do |
3346 | 2165 |
begin |
2166 |
ScriptAmmoLoadout:= ScriptAmmoLoadout + '0'; |
|
2167 |
ScriptAmmoProbability:= ScriptAmmoProbability + '0'; |
|
2168 |
ScriptAmmoDelay:= ScriptAmmoDelay + '0'; |
|
2169 |
ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0'; |
|
2170 |
end; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2171 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2172 |
|
3346 | 2173 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay, reinforcement: Byte); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2174 |
begin |
6019 | 2175 |
//if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) or (delay < 0) or (delay > 9) or (reinforcement < 0) or (reinforcement > 8) then |
2176 |
if (ord(ammo) < 1) or (count > 9) or (propability > 8) or (delay > 9) or (reinforcement > 8) then |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2177 |
exit; |
3346 | 2178 |
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1]; |
2179 |
ScriptAmmoProbability[ord(ammo)]:= inttostr(propability)[1]; |
|
2180 |
ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1]; |
|
2181 |
ScriptAmmoReinforcement[ord(ammo)]:= inttostr(reinforcement)[1]; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2182 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2183 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2184 |
procedure ScriptApplyAmmoStore; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2185 |
var i, j, k : LongInt; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2186 |
begin |
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2187 |
if (GameFlags and gfSharedAmmo) <> 0 then |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2188 |
for i:= 0 to Pred(ClansCount) do |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2189 |
begin |
6740
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2190 |
if ScriptExists('onNewAmmoStore') then |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2191 |
begin |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2192 |
ScriptPrepareAmmoStore; |
6746 | 2193 |
ScriptCall('onNewAmmoStore',i,-1); |
2194 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
2195 |
SetAmmoProbability(ScriptAmmoProbability); |
|
2196 |
SetAmmoDelay(ScriptAmmoDelay); |
|
2197 |
SetAmmoReinforcement(ScriptAmmoReinforcement) |
|
6740
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2198 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2199 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2200 |
for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2201 |
for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2202 |
ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= StoreCnt - 1 |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2203 |
end |
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2204 |
else if (GameFlags and gfPerHogAmmo) <> 0 then |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2205 |
for i:= 0 to Pred(TeamsCount) do |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2206 |
for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2207 |
begin |
6740
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2208 |
if ScriptExists('onNewAmmoStore') then |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2209 |
begin |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2210 |
ScriptPrepareAmmoStore; |
6746 | 2211 |
ScriptCall('onNewAmmoStore',i,j); |
2212 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
2213 |
SetAmmoProbability(ScriptAmmoProbability); |
|
2214 |
SetAmmoDelay(ScriptAmmoDelay); |
|
2215 |
SetAmmoReinforcement(ScriptAmmoReinforcement) |
|
6740
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2216 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2217 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2218 |
TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2219 |
end |
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2220 |
else |
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5343
diff
changeset
|
2221 |
for i:= 0 to Pred(TeamsCount) do |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2222 |
begin |
6740
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2223 |
if ScriptExists('onNewAmmoStore') then |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2224 |
begin |
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2225 |
ScriptPrepareAmmoStore; |
6746 | 2226 |
ScriptCall('onNewAmmoStore',i,-1); |
2227 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
2228 |
SetAmmoProbability(ScriptAmmoProbability); |
|
2229 |
SetAmmoDelay(ScriptAmmoDelay); |
|
2230 |
SetAmmoReinforcement(ScriptAmmoReinforcement) |
|
6740
4167ebd563d9
Add a new script hook. onNewAmmoStore. This will allow scripts like The Specialists to define separate ammo sets for each hog
nemo
parents:
6700
diff
changeset
|
2231 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2232 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2233 |
for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2234 |
TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2235 |
end |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2236 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2237 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2238 |
procedure initModule; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2239 |
var at : TGearType; |
4453 | 2240 |
vgt: TVisualGearType; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2241 |
am : TAmmoType; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2242 |
st : TSound; |
5118 | 2243 |
he : THogEffect; |
2244 |
cg : TCapGroup; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2245 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2246 |
// initialize lua |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2247 |
luaState:= lua_open; |
3045 | 2248 |
TryDo(luaState <> nil, 'lua_open failed', true); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2249 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2250 |
// open internal libraries |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2251 |
luaopen_base(luaState); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2252 |
luaopen_string(luaState); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2253 |
luaopen_math(luaState); |
3724 | 2254 |
luaopen_table(luaState); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2255 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2256 |
// import some variables |
7072 | 2257 |
ScriptSetString(_S'L', cLocale); |
4502
759c1a3bb156
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents:
4499
diff
changeset
|
2258 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2259 |
// import game flags |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2260 |
ScriptSetInteger('gfForts', gfForts); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2261 |
ScriptSetInteger('gfMultiWeapon', gfMultiWeapon); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2262 |
ScriptSetInteger('gfSolidLand', gfSolidLand); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2263 |
ScriptSetInteger('gfBorder', gfBorder); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2264 |
ScriptSetInteger('gfDivideTeams', gfDivideTeams); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2265 |
ScriptSetInteger('gfLowGravity', gfLowGravity); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2266 |
ScriptSetInteger('gfLaserSight', gfLaserSight); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2267 |
ScriptSetInteger('gfInvulnerable', gfInvulnerable); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2268 |
ScriptSetInteger('gfVampiric', gfVampiric); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2269 |
ScriptSetInteger('gfKarma', gfKarma); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2270 |
ScriptSetInteger('gfArtillery', gfArtillery); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2271 |
ScriptSetInteger('gfOneClanMode', gfOneClanMode); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2272 |
ScriptSetInteger('gfRandomOrder', gfRandomOrder); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2273 |
ScriptSetInteger('gfKing', gfKing); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2274 |
ScriptSetInteger('gfPlaceHog', gfPlaceHog); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2275 |
ScriptSetInteger('gfSharedAmmo', gfSharedAmmo); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2276 |
ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
4162 | 2277 |
ScriptSetInteger('gfDisableLandObjects', gfDisableLandObjects); |
2278 |
ScriptSetInteger('gfAISurvival', gfAISurvival); |
|
2279 |
ScriptSetInteger('gfInfAttack', gfInfAttack); |
|
2280 |
ScriptSetInteger('gfResetWeps', gfResetWeps); |
|
2281 |
ScriptSetInteger('gfPerHogAmmo', gfPerHogAmmo); |
|
4219 | 2282 |
ScriptSetInteger('gfDisableWind', gfDisableWind); |
4319 | 2283 |
ScriptSetInteger('gfMoreWind', gfMoreWind); |
5016
9347d82a26cc
added game mode Tag Team, mostly untested, please test :)
Henek
parents:
5013
diff
changeset
|
2284 |
ScriptSetInteger('gfTagTeam', gfTagTeam); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2285 |
|
3894 | 2286 |
ScriptSetInteger('gmLeft', gmLeft); |
2287 |
ScriptSetInteger('gmRight', gmRight); |
|
2288 |
ScriptSetInteger('gmUp', gmUp); |
|
2289 |
ScriptSetInteger('gmDown', gmDown); |
|
2290 |
ScriptSetInteger('gmSwitch', gmSwitch); |
|
2291 |
ScriptSetInteger('gmAttack', gmAttack); |
|
2292 |
ScriptSetInteger('gmLJump', gmLJump); |
|
2293 |
ScriptSetInteger('gmHJump', gmHJump); |
|
2294 |
ScriptSetInteger('gmDestroy', gmDestroy); |
|
2295 |
ScriptSetInteger('gmSlot', gmSlot); |
|
2296 |
ScriptSetInteger('gmWeapon', gmWeapon); |
|
2297 |
ScriptSetInteger('gmTimer', gmTimer); |
|
2298 |
ScriptSetInteger('gmAnimate', gmAnimate); |
|
2299 |
ScriptSetInteger('gmPrecise', gmPrecise); |
|
3892 | 2300 |
ScriptSetInteger('gmAllStoppable', gmAllStoppable); |
2301 |
||
2302 |
||
3761 | 2303 |
// speech bubbles |
2304 |
ScriptSetInteger('SAY_SAY', 1); |
|
2305 |
ScriptSetInteger('SAY_THINK', 2); |
|
2306 |
ScriptSetInteger('SAY_SHOUT', 3); |
|
2307 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2308 |
// register gear types |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2309 |
for at:= Low(TGearType) to High(TGearType) do |
3337 | 2310 |
ScriptSetInteger(EnumToStr(at), ord(at)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2311 |
|
4453 | 2312 |
for vgt:= Low(TVisualGearType) to High(TVisualGearType) do |
2313 |
ScriptSetInteger(EnumToStr(vgt), ord(vgt)); |
|
2314 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2315 |
// register sounds |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2316 |
for st:= Low(TSound) to High(TSound) do |
3337 | 2317 |
ScriptSetInteger(EnumToStr(st), ord(st)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2318 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2319 |
// register ammo types |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2320 |
for am:= Low(TAmmoType) to High(TAmmoType) do |
3337 | 2321 |
ScriptSetInteger(EnumToStr(am), ord(am)); |
3697 | 2322 |
|
3756 | 2323 |
for he:= Low(THogEffect) to High(THogEffect) do |
2324 |
ScriptSetInteger(EnumToStr(he), ord(he)); |
|
2325 |
||
5118 | 2326 |
for cg:= Low(TCapGroup) to High(TCapGroup) do |
2327 |
ScriptSetInteger(EnumToStr(cg), ord(cg)); |
|
2328 |
||
5527 | 2329 |
ScriptSetInteger('gstDrowning' ,$00000001); |
2330 |
ScriptSetInteger('gstHHDriven' ,$00000002); |
|
2331 |
ScriptSetInteger('gstMoving' ,$00000004); |
|
2332 |
ScriptSetInteger('gstAttacked' ,$00000008); |
|
2333 |
ScriptSetInteger('gstAttacking' ,$00000010); |
|
2334 |
ScriptSetInteger('gstCollision' ,$00000020); |
|
2335 |
ScriptSetInteger('gstHHChooseTarget' ,$00000040); |
|
2336 |
ScriptSetInteger('gstHHJumping' ,$00000100); |
|
2337 |
ScriptSetInteger('gsttmpFlag' ,$00000200); |
|
2338 |
ScriptSetInteger('gstHHThinking' ,$00000800); |
|
2339 |
ScriptSetInteger('gstNoDamage' ,$00001000); |
|
2340 |
ScriptSetInteger('gstHHHJump' ,$00002000); |
|
2341 |
ScriptSetInteger('gstAnimation' ,$00004000); |
|
2342 |
ScriptSetInteger('gstHHDeath' ,$00008000); |
|
2343 |
ScriptSetInteger('gstWinner' ,$00010000); |
|
2344 |
ScriptSetInteger('gstWait' ,$00020000); |
|
2345 |
ScriptSetInteger('gstNotKickable' ,$00040000); |
|
2346 |
ScriptSetInteger('gstLoser' ,$00080000); |
|
2347 |
ScriptSetInteger('gstHHGone' ,$00100000); |
|
2348 |
ScriptSetInteger('gstInvisible' ,$00200000); |
|
2349 |
||
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8077
diff
changeset
|
2350 |
// ai hints |
7996 | 2351 |
ScriptSetInteger('aihUsualProcessing' ,$00000000); |
2352 |
ScriptSetInteger('aihDoesntMatter' ,$00000001); |
|
2353 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2354 |
// register functions |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2355 |
lua_register(luaState, _P'HideHog', @lc_hidehog); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2356 |
lua_register(luaState, _P'RestoreHog', @lc_restorehog); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2357 |
lua_register(luaState, _P'SaveCampaignVar', @lc_savecampaignvar); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2358 |
lua_register(luaState, _P'GetCampaignVar', @lc_getcampaignvar); |
7072 | 2359 |
lua_register(luaState, _P'band', @lc_band); |
2360 |
lua_register(luaState, _P'bor', @lc_bor); |
|
2361 |
lua_register(luaState, _P'bnot', @lc_bnot); |
|
2362 |
lua_register(luaState, _P'div', @lc_div); |
|
2363 |
lua_register(luaState, _P'GetInputMask', @lc_getinputmask); |
|
2364 |
lua_register(luaState, _P'SetInputMask', @lc_setinputmask); |
|
2365 |
lua_register(luaState, _P'AddGear', @lc_addgear); |
|
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
2366 |
lua_register(luaState, _P'EnableGameFlags', @lc_enablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
2367 |
lua_register(luaState, _P'DisableGameFlags', @lc_disablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
2368 |
lua_register(luaState, _P'ClearGameFlags', @lc_cleargameflags); |
7072 | 2369 |
lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
2370 |
lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
|
2371 |
lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
|
2372 |
lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
|
2373 |
lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); |
|
2374 |
lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
|
2375 |
lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
|
2376 |
lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
|
2377 |
lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
|
2378 |
lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
|
2379 |
lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); |
|
2380 |
lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
|
2381 |
lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
|
2382 |
lua_register(luaState, _P'EndGame', @lc_endgame); |
|
2383 |
lua_register(luaState, _P'FindPlace', @lc_findplace); |
|
2384 |
lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
|
2385 |
lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
|
2386 |
lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
|
2387 |
lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget); |
|
2388 |
lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity); |
|
2389 |
lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity); |
|
2390 |
lua_register(luaState, _P'ParseCommand', @lc_parsecommand); |
|
2391 |
lua_register(luaState, _P'ShowMission', @lc_showmission); |
|
2392 |
lua_register(luaState, _P'HideMission', @lc_hidemission); |
|
2393 |
lua_register(luaState, _P'AddCaption', @lc_addcaption); |
|
2394 |
lua_register(luaState, _P'SetAmmo', @lc_setammo); |
|
2395 |
lua_register(luaState, _P'SetAmmoStore', @lc_setammostore); |
|
2396 |
lua_register(luaState, _P'PlaySound', @lc_playsound); |
|
2397 |
lua_register(luaState, _P'AddTeam', @lc_addteam); |
|
2398 |
lua_register(luaState, _P'AddHog', @lc_addhog); |
|
2399 |
lua_register(luaState, _P'AddAmmo', @lc_addammo); |
|
2400 |
lua_register(luaState, _P'GetAmmoCount', @lc_getammocount); |
|
2401 |
lua_register(luaState, _P'SetHealth', @lc_sethealth); |
|
2402 |
lua_register(luaState, _P'GetHealth', @lc_gethealth); |
|
2403 |
lua_register(luaState, _P'SetEffect', @lc_seteffect); |
|
2404 |
lua_register(luaState, _P'GetEffect', @lc_geteffect); |
|
2405 |
lua_register(luaState, _P'GetHogClan', @lc_gethogclan); |
|
2406 |
lua_register(luaState, _P'GetClanColor', @lc_getclancolor); |
|
2407 |
lua_register(luaState, _P'SetClanColor', @lc_setclancolor); |
|
2408 |
lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname); |
|
2409 |
lua_register(luaState, _P'GetHogName', @lc_gethogname); |
|
2410 |
lua_register(luaState, _P'SetHogName', @lc_sethogname); |
|
2411 |
lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel); |
|
2412 |
lua_register(luaState, _P'SetHogLevel', @lc_sethoglevel); |
|
2413 |
lua_register(luaState, _P'GetX', @lc_getx); |
|
2414 |
lua_register(luaState, _P'GetY', @lc_gety); |
|
2415 |
lua_register(luaState, _P'CopyPV', @lc_copypv); |
|
2416 |
lua_register(luaState, _P'FollowGear', @lc_followgear); |
|
2417 |
lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear); |
|
2418 |
lua_register(luaState, _P'SetState', @lc_setstate); |
|
2419 |
lua_register(luaState, _P'GetState', @lc_getstate); |
|
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
2420 |
lua_register(luaState, _P'GetTag', @lc_gettag); |
7072 | 2421 |
lua_register(luaState, _P'SetTag', @lc_settag); |
2422 |
lua_register(luaState, _P'SetTimer', @lc_settimer); |
|
2423 |
lua_register(luaState, _P'GetTimer', @lc_gettimer); |
|
2424 |
lua_register(luaState, _P'SetZoom', @lc_setzoom); |
|
2425 |
lua_register(luaState, _P'GetZoom', @lc_getzoom); |
|
2426 |
lua_register(luaState, _P'HogSay', @lc_hogsay); |
|
2427 |
lua_register(luaState, _P'SwitchHog', @lc_switchhog); |
|
2428 |
lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
|
2429 |
lua_register(luaState, _P'CampaignLock', @lc_campaignlock); |
|
2430 |
lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock); |
|
2431 |
lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); |
|
2432 |
lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
|
2433 |
lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
|
2434 |
lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
|
2435 |
lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |
|
2436 |
lua_register(luaState, _P'SetGearPos', @lc_setgearpos); |
|
7726
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
2437 |
lua_register(luaState, _P'GetGearCollisionMask', @lc_getgearcollisionmask); |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
2438 |
lua_register(luaState, _P'SetGearCollisionMask', @lc_setgearcollisionmask); |
7072 | 2439 |
lua_register(luaState, _P'GetRandom', @lc_getrandom); |
2440 |
lua_register(luaState, _P'SetWind', @lc_setwind); |
|
2441 |
lua_register(luaState, _P'GetDataPath', @lc_getdatapath); |
|
2442 |
lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath); |
|
2443 |
lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
|
2444 |
lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
|
2445 |
lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
|
2446 |
lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
|
2447 |
lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
|
2448 |
lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2449 |
|
7996 | 2450 |
lua_register(luaState, _P'SetGearAIHints', @lc_setaihintsongear); |
8043 | 2451 |
lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload); |
7996 | 2452 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2453 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2454 |
ScriptClearStack; // just to be sure stack is empty |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2455 |
ScriptLoaded:= false; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2456 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2457 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2458 |
procedure freeModule; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2459 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2460 |
lua_close(luaState); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2461 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2462 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2463 |
{$ELSE} |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2464 |
procedure ScriptPrintStack; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2465 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2466 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2467 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2468 |
procedure ScriptClearStack; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2469 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2470 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2471 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2472 |
procedure ScriptLoad(name : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2473 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2474 |
name:= name; // avoid hint |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2475 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2476 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2477 |
procedure ScriptOnGameInit; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2478 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2479 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2480 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2481 |
procedure ScriptCall(fname : shortstring); |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2482 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2483 |
fname:= fname; // avoid hint |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2484 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2485 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2486 |
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2487 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2488 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2489 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2490 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2491 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2492 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2493 |
par4:= par4; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2494 |
ScriptCall:= 0 |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2495 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2496 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2497 |
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2498 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2499 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2500 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2501 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2502 |
ScriptCall:= 0 |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2503 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2504 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2505 |
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2506 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2507 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2508 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2509 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2510 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2511 |
ScriptCall:= 0 |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2512 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2513 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2514 |
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2515 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2516 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2517 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2518 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2519 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2520 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2521 |
ScriptCall:= 0 |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2522 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2523 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2524 |
function ScriptExists(fname : shortstring) : boolean; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2525 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2526 |
fname:= fname; // avoid hint |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2527 |
ScriptExists:= false |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2528 |
end; |
7805 | 2529 |
(* |
5410 | 2530 |
function ParseCommandOverride(key, value : shortstring) : shortstring; |
2531 |
begin |
|
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2532 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2533 |
key:= key; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2534 |
value:= value; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
2535 |
ParseCommandOverride:= '' |
5410 | 2536 |
end; |
7805 | 2537 |
*) |
5410 | 2538 |
|
6430 | 2539 |
procedure ScriptOnScreenResize; |
2540 |
begin |
|
2541 |
end; |
|
2542 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2543 |
procedure initModule; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2544 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2545 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2546 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2547 |
procedure freeModule; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2548 |
begin |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2549 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2550 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2551 |
{$ENDIF} |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2552 |
end. |