author | wuzzy |
Thu, 11 Dec 2014 01:39:29 +0100 | |
changeset 10651 | 7a8e321be3bd |
parent 10634 | 35d059bd0932 |
child 10660 | 79fa79c77c38 |
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 |
9998 | 3 |
* Copyright (c) 2004-2014 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 |
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10078
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
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
|
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); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
38 |
procedure ScriptOnPreviewInit; |
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
|
39 |
procedure ScriptOnGameInit; |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
40 |
procedure ScriptOnScreenResize; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
41 |
procedure ScriptSetInteger(name : shortstring; value : LongInt); |
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9917
diff
changeset
|
42 |
procedure ScriptSetString(name : shortstring; value : 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
|
43 |
|
3acdb4dac6eb
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 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
|
10312 | 51 |
procedure LuaParseString(s: shortString); |
5410 | 52 |
|
7805 | 53 |
//function ParseCommandOverride(key, value : shortstring) : shortstring; This did not work out well |
5577 | 54 |
|
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
|
55 |
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
|
56 |
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
|
57 |
|
3acdb4dac6eb
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 |
implementation |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
59 |
{$IFDEF USE_LUA_SCRIPT} |
9205
abce6011f86c
aaaaand let's not forget about lua, which has also a slightly revised build process
koda
parents:
9180
diff
changeset
|
60 |
|
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6430
diff
changeset
|
61 |
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
|
62 |
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
|
63 |
uConsts, |
6543 | 64 |
uGears, |
6468 | 65 |
uGearsList, |
6543 | 66 |
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
|
67 |
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
|
68 |
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
|
69 |
uAmmos, |
6763 | 70 |
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
|
71 |
uSound, |
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
72 |
uChat, |
4243 | 73 |
uStats, |
4875 | 74 |
uStore, |
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
4319
diff
changeset
|
75 |
uRandom, |
4359 | 76 |
uTypes, |
4373 | 77 |
uVariables, |
4374 | 78 |
uCommands, |
4377 | 79 |
uUtils, |
4403 | 80 |
uCaptions, |
4832 | 81 |
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
|
82 |
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
|
83 |
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
|
84 |
uTextures, |
4985 | 85 |
uLandGraphics, |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
86 |
SysUtils, |
8031 | 87 |
uIO, |
9283
76e68c136a11
Refactoring: VGSHandlers.inc -> uVisualGearsHandlers.pas
unc0rr
parents:
9245
diff
changeset
|
88 |
uVisualGearsList, |
9285 | 89 |
uGearsHandlersMess, |
9952
32f5982604f4
Fix build (no idea what's going on in this branch btw)
unc0rr
parents:
9950
diff
changeset
|
90 |
uPhysFSLayer |
10129
cd2a64a1f4aa
- Pas2C: make use of 'external' function decorator
unc0rr
parents:
10127
diff
changeset
|
91 |
{$IFNDEF PAS2C} |
9952
32f5982604f4
Fix build (no idea what's going on in this branch btw)
unc0rr
parents:
9950
diff
changeset
|
92 |
, typinfo |
9521
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
93 |
{$ENDIF} |
8031 | 94 |
; |
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 |
var luaState : Plua_State; |
3346 | 97 |
ScriptAmmoLoadout : shortstring; |
98 |
ScriptAmmoProbability : shortstring; |
|
99 |
ScriptAmmoDelay : shortstring; |
|
100 |
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
|
101 |
ScriptLoaded : boolean; |
9567
42bc1b58a242
This test is intended to avoid repeatedly calling 5 ScriptSetIntegers each script call, that won't ever change after the map is created.
nemo
parents:
9531
diff
changeset
|
102 |
mapDims : boolean; |
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
103 |
PointsBuffer: shortstring; |
3697 | 104 |
|
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
|
105 |
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
|
106 |
procedure ScriptApplyAmmoStore; forward; |
9750 | 107 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward; |
9751
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
108 |
procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: 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
|
109 |
|
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
110 |
var LuaDebugInfo: lua_Debug; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
111 |
|
10617 | 112 |
procedure SetGlobals; forward; |
10312 | 113 |
procedure LuaParseString(s: shortString); |
114 |
begin |
|
10617 | 115 |
SetGlobals; |
10312 | 116 |
AddFileLog('[Lua] input string: ' + s); |
117 |
AddChatString(#3 + '[Lua] > ' + s); |
|
118 |
if luaL_dostring(luaState, Str2PChar(s)) <> 0 then |
|
119 |
begin |
|
120 |
AddFileLog('[Lua] input string parsing error!'); |
|
121 |
AddChatString(#5 + '[Lua] Error while parsing!'); |
|
122 |
end; |
|
123 |
end; |
|
124 |
||
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
125 |
function LuaUpdateDebugInfo(): Boolean; |
3539 | 126 |
begin |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
127 |
FillChar(LuaDebugInfo, sizeof(LuaDebugInfo), 0); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
128 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
129 |
if lua_getstack(luaState, 1, @LuaDebugInfo) = 0 then |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
130 |
exit(false); // stack not deep enough |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
131 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
132 |
// get source name and line count |
10297 | 133 |
lua_getinfo(luaState, PChar('Sl'), @LuaDebugInfo); |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
134 |
exit(true); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
135 |
end; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
136 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
137 |
procedure LuaError(s: shortstring); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
138 |
var src: shortstring; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
139 |
const |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
140 |
maxsrclen = 20; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
141 |
begin |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
142 |
if LuaUpdateDebugInfo() then |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
143 |
begin |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
144 |
src:= StrPas(LuaDebugInfo.source); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
145 |
s:= 'LUA ERROR [ ... ' |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
146 |
+ copy(src, Length(src) - maxsrclen, maxsrclen - 3) + ':' |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
147 |
+ inttostr(LuaDebugInfo.currentLine) + ']: ' + s; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
148 |
end |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
149 |
else |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
150 |
s:= 'LUA ERROR: ' + s; |
3539 | 151 |
WriteLnToConsole(s); |
152 |
AddChatString(#5 + s); |
|
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9987
diff
changeset
|
153 |
if cTestLua then |
10306 | 154 |
halt(HaltTestLuaError); |
3539 | 155 |
end; |
156 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
157 |
procedure LuaCallError(error, call, paramsyntax: shortstring); |
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
158 |
begin |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
159 |
LuaError(call + ': ' + error); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
160 |
LuaError('-- SYNTAX: ' + call + ' ( ' + paramsyntax + ' )'); |
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
161 |
end; |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
162 |
|
10285 | 163 |
procedure LuaParameterCountError(expected, call, paramsyntax: shortstring; wrongcount: LongInt); inline; |
164 |
begin |
|
165 |
// TODO: i18n? |
|
166 |
LuaCallError('Wrong number of parameters! (is: ' + inttostr(wrongcount) + ', should be: '+ expected + ')', call, paramsyntax); |
|
167 |
end; |
|
168 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
169 |
// compare with allowed count |
10297 | 170 |
function CheckLuaParamCount(L : Plua_State; count: LongInt; call, paramsyntax: shortstring): boolean; inline; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
171 |
var c: LongInt; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
172 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
173 |
c:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
174 |
if c <> count then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
175 |
begin |
10285 | 176 |
LuaParameterCountError('exactly ' + inttostr(count), call, paramsyntax, c); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
177 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
178 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
179 |
|
10297 | 180 |
CheckLuaParamCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
181 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
182 |
|
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
183 |
// check if is either count1 or count2 |
10297 | 184 |
function CheckAndFetchParamCount(L : Plua_State; count1, count2: LongInt; call, paramsyntax: shortstring; out actual: LongInt): boolean; inline; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
185 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
186 |
actual:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
187 |
if (actual <> count1) and (actual <> count2) then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
188 |
begin |
10285 | 189 |
LuaParameterCountError('either ' + inttostr(count1) + ' or ' + inttostr(count2), call, paramsyntax, actual); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
190 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
191 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
192 |
|
10297 | 193 |
CheckAndFetchParamCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
194 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
195 |
|
10611 | 196 |
// check if is in range of count1 and count2 |
197 |
function CheckAndFetchParamCountRange(L : Plua_State; count1, count2: LongInt; call, paramsyntax: shortstring; out actual: LongInt): boolean; inline; |
|
198 |
begin |
|
199 |
actual:= lua_gettop(L); |
|
200 |
if (actual < count1) or (actual > count2) then |
|
201 |
begin |
|
202 |
LuaParameterCountError('at least ' + inttostr(count1) + ', but at most ' + inttostr(count2), call, paramsyntax, actual); |
|
203 |
exit(false); |
|
204 |
end; |
|
205 |
||
206 |
CheckAndFetchParamCountRange:= true; |
|
207 |
end; |
|
208 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
209 |
// check if is same or higher as minCount |
10297 | 210 |
function CheckAndFetchLuaParamMinCount(L : Plua_State; minCount: LongInt; call, paramsyntax: shortstring; out actual: LongInt): boolean; inline; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
211 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
212 |
actual:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
213 |
if (actual < minCount) then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
214 |
begin |
10285 | 215 |
LuaParameterCountError(inttostr(minCount) + ' or more', call, paramsyntax, actual); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
216 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
217 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
218 |
|
10297 | 219 |
CheckAndFetchLuaParamMinCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
220 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
221 |
|
10281 | 222 |
function LuaToGearTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
223 |
begin |
|
224 |
if lua_isnoneornil(L, i) then i:= -1 |
|
225 |
else i:= lua_tointeger(L, i); |
|
226 |
if (i < ord(Low(TGearType))) or (i > ord(High(TGearType))) then |
|
227 |
begin |
|
228 |
LuaCallError('Invalid gearType!', call, paramsyntax); |
|
229 |
LuaToGearTypeOrd:= -1; |
|
230 |
end |
|
231 |
else |
|
232 |
LuaToGearTypeOrd:= i; |
|
233 |
end; |
|
234 |
||
235 |
function LuaToVisualGearTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
236 |
begin |
|
237 |
if lua_isnoneornil(L, i) then i:= -1 |
|
238 |
else i:= lua_tointeger(L, i); |
|
239 |
if (i < ord(Low(TVisualGearType))) or (i > ord(High(TVisualGearType))) then |
|
240 |
begin |
|
241 |
LuaCallError('Invalid visualGearType!', call, paramsyntax); |
|
242 |
LuaToVisualGearTypeOrd:= -1; |
|
243 |
end |
|
244 |
else |
|
245 |
LuaToVisualGearTypeOrd:= i; |
|
246 |
end; |
|
247 |
||
248 |
function LuaToAmmoTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
249 |
begin |
10281 | 250 |
if lua_isnoneornil(L, i) then i:= -1 |
251 |
else i:= lua_tointeger(L, i); |
|
252 |
if (i < ord(Low(TAmmoType))) or (i > ord(High(TAmmoType))) then |
|
253 |
begin |
|
254 |
LuaCallError('Invalid ammoType!', call, paramsyntax); |
|
255 |
LuaToAmmoTypeOrd:= -1; |
|
256 |
end |
|
257 |
else |
|
258 |
LuaToAmmoTypeOrd:= i; |
|
259 |
end; |
|
260 |
||
261 |
function LuaToStatInfoTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
262 |
begin |
|
263 |
if lua_isnoneornil(L, i) then i:= -1 |
|
264 |
else i:= lua_tointeger(L, i); |
|
265 |
if (i < ord(Low(TStatInfoType))) or (i > ord(High(TStatInfoType))) then |
|
266 |
begin |
|
267 |
LuaCallError('Invalid statInfoType!', call, paramsyntax); |
|
268 |
LuaToStatInfoTypeOrd:= -1; |
|
269 |
end |
|
270 |
else |
|
271 |
LuaToStatInfoTypeOrd:= i; |
|
272 |
end; |
|
273 |
||
274 |
function LuaToSoundOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
275 |
begin |
|
276 |
if lua_isnoneornil(L, i) then i:= -1 |
|
277 |
else i:= lua_tointeger(L, i); |
|
278 |
if (i < ord(Low(TSound))) or (i > ord(High(TSound))) then |
|
279 |
begin |
|
280 |
LuaCallError('Invalid soundId!', call, paramsyntax); |
|
281 |
LuaToSoundOrd:= -1; |
|
282 |
end |
|
283 |
else |
|
284 |
LuaToSoundOrd:= i; |
|
285 |
end; |
|
286 |
||
287 |
function LuaToHogEffectOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
288 |
begin |
|
289 |
if lua_isnoneornil(L, i) then i:= -1 |
|
290 |
else i:= lua_tointeger(L, i); |
|
291 |
if (i < ord(Low(THogEffect))) or (i > ord(High(THogEffect))) then |
|
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
292 |
begin |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
293 |
LuaCallError('Invalid gear type!', call, paramsyntax); |
10281 | 294 |
LuaToHogEffectOrd:= -1; |
295 |
end |
|
296 |
else |
|
297 |
LuaToHogEffectOrd:= i; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
298 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
299 |
|
10281 | 300 |
function LuaToCapGroupOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
301 |
begin |
10281 | 302 |
if lua_isnoneornil(L, i) then i:= -1 |
303 |
else i:= lua_tointeger(L, i); |
|
304 |
if (i < ord(Low(TCapGroup))) or (i > ord(High(TCapGroup))) then |
|
305 |
begin |
|
306 |
LuaCallError('Invalid capgroup type!', call, paramsyntax); |
|
307 |
LuaToCapGroupOrd:= -1; |
|
308 |
end |
|
309 |
else |
|
310 |
LuaToCapGroupOrd:= i; |
|
311 |
end; |
|
312 |
||
313 |
function LuaToSpriteOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
314 |
begin |
|
315 |
if lua_isnoneornil(L, i) then i:= -1 |
|
316 |
else i:= lua_tointeger(L, i); |
|
317 |
if (i < ord(Low(TSprite))) or (i > ord(High(TSprite))) then |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
318 |
begin |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
319 |
LuaCallError('Invalid sprite id!', call, paramsyntax); |
10281 | 320 |
LuaToSpriteOrd:= -1; |
321 |
end |
|
322 |
else |
|
323 |
LuaToSpriteOrd:= i; |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
324 |
end; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
325 |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
326 |
function LuaToMapGenOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
327 |
begin |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
328 |
if lua_isnoneornil(L, i) then i:= -1 |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
329 |
else i:= lua_tointeger(L, i); |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
330 |
if (i < ord(Low(TMapGen))) or (i > ord(High(TMapGen))) then |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
331 |
begin |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
332 |
LuaCallError('Invalid mapgen id!', call, paramsyntax); |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
333 |
LuaToMapGenOrd:= -1; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
334 |
end |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
335 |
else |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
336 |
LuaToMapGenOrd:= i; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
337 |
end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
338 |
|
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
|
339 |
// 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
|
340 |
|
3539 | 341 |
// 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
|
342 |
// 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
|
343 |
// where L contains the state, returns the number of return values on the stack |
10297 | 344 |
// call CheckLuaParamCount or CheckAndFetchParamCount |
10287 | 345 |
// to validate/get the number of passed arguments (see their call definitions) |
346 |
// |
|
347 |
// use as return value the number of variables pushed back to the lua script |
|
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
|
348 |
|
4483 | 349 |
function lc_band(L: PLua_State): LongInt; Cdecl; |
350 |
begin |
|
10297 | 351 |
if CheckLuaParamCount(L, 2, 'band', 'value1, value2') then |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
352 |
lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)) |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
353 |
else |
4483 | 354 |
lua_pushnil(L); |
355 |
lc_band := 1; |
|
356 |
end; |
|
357 |
||
358 |
function lc_bor(L: PLua_State): LongInt; Cdecl; |
|
359 |
begin |
|
10297 | 360 |
if CheckLuaParamCount(L, 2, 'bor', 'value1, value2') then |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
361 |
lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)) |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
362 |
else |
4483 | 363 |
lua_pushnil(L); |
364 |
lc_bor := 1; |
|
365 |
end; |
|
366 |
||
367 |
function lc_bnot(L: PLua_State): LongInt; Cdecl; |
|
368 |
begin |
|
10297 | 369 |
if CheckLuaParamCount(L, 1, 'bnot', 'value') then |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
370 |
lua_pushinteger(L, (not lua_tointeger(L, 1))) |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
371 |
else |
4483 | 372 |
lua_pushnil(L); |
373 |
lc_bnot := 1; |
|
374 |
end; |
|
375 |
||
6764 | 376 |
function lc_div(L: PLua_State): LongInt; Cdecl; |
377 |
begin |
|
10297 | 378 |
if CheckLuaParamCount(L, 2, 'div', 'dividend, divisor') then |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
379 |
lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2)) |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
380 |
else |
6764 | 381 |
lua_pushnil(L); |
382 |
lc_div := 1; |
|
383 |
end; |
|
384 |
||
4523 | 385 |
function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
386 |
begin |
|
10297 | 387 |
if CheckLuaParamCount(L, 0, 'GetInputMask', '') then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
388 |
lua_pushinteger(L, InputMask); |
4523 | 389 |
lc_getinputmask:= 1 |
390 |
end; |
|
391 |
||
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
|
392 |
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
|
393 |
begin |
10297 | 394 |
if CheckLuaParamCount(L, 1, 'SetInputMask', 'mask') then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
395 |
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
|
396 |
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
|
397 |
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
|
398 |
|
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
|
399 |
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
|
400 |
begin |
10297 | 401 |
if CheckLuaParamCount(L, 1, 'WriteLnToConsole', 'string') 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
|
402 |
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
|
403 |
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
|
404 |
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
|
405 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
406 |
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
|
407 |
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
|
408 |
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
|
409 |
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
|
410 |
begin |
10297 | 411 |
if CheckLuaParamCount(L, 1, 'ParseCommand', 'string') 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
|
412 |
begin |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10129
diff
changeset
|
413 |
t:= lua_tolstring(L, 1, Psize_t(@c)); |
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
|
414 |
|
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
|
415 |
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
|
416 |
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
|
417 |
|
7805 | 418 |
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
|
419 |
|
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
420 |
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
|
421 |
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
|
422 |
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
|
423 |
|
10291 | 424 |
// sets weapon to the desired ammo type |
10289 | 425 |
function lc_setweapon(L : Plua_State) : LongInt; Cdecl; |
426 |
var at: LongInt; |
|
427 |
const |
|
428 |
call = 'SetWeapon'; |
|
429 |
params = 'ammoType'; |
|
430 |
begin |
|
10291 | 431 |
// no point to run this without any CurrentHedgehog |
10297 | 432 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 1, call, params)) then |
10289 | 433 |
begin |
434 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
435 |
if at >= 0 then |
|
436 |
ParseCommand('setweap ' + char(at), true, true); |
|
437 |
end; |
|
438 |
lc_setweapon:= 0; |
|
439 |
end; |
|
440 |
||
10291 | 441 |
// sets weapon to whatever weapons is next (wraps around, amSkip is skipped) |
442 |
function lc_setnextweapon(L : Plua_State) : LongInt; Cdecl; |
|
443 |
var at : LongInt; |
|
444 |
nextAmmo : TAmmo; |
|
445 |
s, a, cs, fa: LongInt; |
|
446 |
const |
|
447 |
call = 'SetNextWeapon'; |
|
448 |
params = ''; |
|
449 |
begin |
|
10297 | 450 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, call, params)) then |
10291 | 451 |
begin |
452 |
at:= -1; |
|
453 |
with CurrentHedgehog^ do |
|
454 |
begin |
|
455 |
cs:= 0; // current slot |
|
456 |
fa:= 0; // first ammo item to check |
|
457 |
||
458 |
// if something is selected, find it's successor |
|
459 |
if curAmmoType <> amNothing then |
|
460 |
begin |
|
461 |
// get current slot index |
|
462 |
cs:= Ammoz[CurAmmoType].Slot; |
|
463 |
// find current ammo index |
|
464 |
while (fa < cMaxSlotAmmoIndex) |
|
465 |
and (Ammo^[cs, fa].AmmoType <> CurAmmoType) do |
|
466 |
inc(fa); |
|
467 |
// increase once more because we won't successor |
|
468 |
inc(fa); |
|
469 |
end; |
|
470 |
||
471 |
// find first available ammo |
|
472 |
// revisit current slot too (current item might not be first) |
|
473 |
for s:= cs to cs + cMaxSlotIndex + 1 do |
|
474 |
begin |
|
475 |
for a:= fa to cMaxSlotAmmoIndex do |
|
476 |
begin |
|
477 |
// check if we went full circle |
|
478 |
if (a = fa) and (s = cs + cMaxSlotIndex + 1) then |
|
479 |
exit(0); |
|
480 |
||
481 |
// get ammo |
|
482 |
nextAmmo:= Ammo^[s mod (cMaxSlotIndex + 1), a]; |
|
483 |
// only switch to ammos the hog actually has |
|
484 |
if (nextAmmo.AmmoType <> amNothing) |
|
485 |
and (nextAmmo.AmmoType <> amSkip) and (nextAmmo.Count > 0) then |
|
486 |
begin |
|
487 |
at:= ord(nextAmmo.AmmoType); |
|
488 |
break; |
|
489 |
end; |
|
490 |
end; |
|
491 |
// stop slot loop if something was found |
|
492 |
if at >= 0 then |
|
493 |
break; |
|
494 |
// check following slots starting with first item |
|
495 |
fa:= 0; |
|
496 |
end; |
|
497 |
end; |
|
498 |
||
499 |
if at >= 0 then |
|
500 |
ParseCommand('setweap ' + char(at), true, true); |
|
501 |
end; |
|
502 |
lc_setnextweapon:= 0; |
|
503 |
end; |
|
504 |
||
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
|
505 |
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
|
506 |
begin |
10297 | 507 |
if CheckLuaParamCount(L, 5, 'ShowMission', 'caption, subcaption, text, icon, time') then |
10127 | 508 |
ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(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
|
509 |
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
|
510 |
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
|
511 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
512 |
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
|
513 |
begin |
3407 | 514 |
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
|
515 |
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
|
516 |
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
|
517 |
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
|
518 |
|
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
519 |
function lc_enablegameflags(L : Plua_State) : LongInt; Cdecl; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
520 |
var i, n : integer; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
521 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
522 |
// can have 1 or more arguments |
10297 | 523 |
if CheckAndFetchLuaParamMinCount(L, 1, 'EnableGameFlags', 'gameFlag, ... ', n) then |
10035 | 524 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
525 |
for i:= 1 to n do |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
526 |
GameFlags := GameFlags or LongWord(lua_tointeger(L, i)); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
527 |
ScriptSetInteger('GameFlags', GameFlags); |
10035 | 528 |
end; |
8370 | 529 |
lc_enablegameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
530 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
531 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
532 |
function lc_disablegameflags(L : Plua_State) : LongInt; Cdecl; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
533 |
var i , n: integer; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
534 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
535 |
// can have 1 or more arguments |
10297 | 536 |
if CheckAndFetchLuaParamMinCount(L, 1, 'DisableGameFlags', 'gameFlag, ... ', n) then |
10035 | 537 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
538 |
for i:= 1 to n do |
10078 | 539 |
GameFlags := GameFlags and (not LongWord(lua_tointeger(L, i))); |
10035 | 540 |
ScriptSetInteger('GameFlags', GameFlags); |
541 |
end; |
|
8370 | 542 |
lc_disablegameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
543 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
544 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
545 |
function lc_cleargameflags(L : Plua_State) : LongInt; Cdecl; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
546 |
begin |
10297 | 547 |
if CheckLuaParamCount(L, 0, 'ClearGameFlags', '') then |
10035 | 548 |
begin |
549 |
GameFlags:= 0; |
|
550 |
ScriptSetInteger('GameFlags', GameFlags); |
|
551 |
end; |
|
8370 | 552 |
lc_cleargameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
553 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
554 |
|
10035 | 555 |
function lc_getgameflag(L : Plua_State) : LongInt; Cdecl; |
556 |
begin |
|
10297 | 557 |
if CheckLuaParamCount(L, 1, 'GetGameFlag', 'gameflag') then |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
558 |
lua_pushboolean(L, (GameFlags and LongWord(lua_tointeger(L, 1)) <> 0)) |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
559 |
else |
10035 | 560 |
lua_pushnil(L); |
561 |
lc_getgameflag:= 1; |
|
562 |
end; |
|
563 |
||
4243 | 564 |
function lc_addcaption(L : Plua_State) : LongInt; Cdecl; |
10281 | 565 |
var cg: LongInt; |
566 |
const |
|
567 |
call = 'AddCaption'; |
|
568 |
params = 'text [, color, captiongroup]'; |
|
4243 | 569 |
begin |
10297 | 570 |
if CheckAndFetchParamCount(L, 1, 3, call, params, cg) then |
4243 | 571 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
572 |
if cg = 1 then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
573 |
AddCaption(lua_tostringA(L, 1), cWhiteColor, capgrpMessage) |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
574 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
575 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
576 |
cg:= LuaToCapGroupOrd(L, 3, call, params); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
577 |
if cg >= 0 then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
578 |
AddCaption(lua_tostringA(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(cg)); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
579 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
580 |
end; |
4243 | 581 |
lc_addcaption:= 0; |
582 |
end; |
|
583 |
||
3848 | 584 |
function lc_campaignlock(L : Plua_State) : LongInt; Cdecl; |
585 |
begin |
|
10297 | 586 |
if CheckLuaParamCount(L, 1, 'CampaignLock', 'TODO') then |
3848 | 587 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
588 |
// TODO |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
589 |
end; |
3848 | 590 |
lc_campaignlock:= 0; |
591 |
end; |
|
592 |
||
593 |
function lc_campaignunlock(L : Plua_State) : LongInt; Cdecl; |
|
594 |
begin |
|
10297 | 595 |
if CheckLuaParamCount(L, 1, 'CampaignUnlock', 'TODO') then |
3848 | 596 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
597 |
// TODO |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
598 |
end; |
3848 | 599 |
lc_campaignunlock:= 0; |
600 |
end; |
|
601 |
||
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
|
602 |
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
|
603 |
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
|
604 |
begin |
10297 | 605 |
if CheckLuaParamCount(L, 4,'SpawnFakeHealthCrate', 'x, y, explode, poison') then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
606 |
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
|
607 |
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
|
608 |
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
|
609 |
lua_pushinteger(L, gear^.uid); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
610 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
611 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
612 |
lua_pushnil(L); |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
613 |
lc_spawnfakehealthcrate := 1; |
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
|
614 |
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
|
615 |
|
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
|
616 |
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
|
617 |
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
|
618 |
begin |
10297 | 619 |
if CheckLuaParamCount(L, 4,'SpawnFakeAmmoCrate', 'x, y, explode, poison') then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
620 |
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
|
621 |
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
|
622 |
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
|
623 |
lua_pushinteger(L, gear^.uid); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
624 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
625 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
626 |
lua_pushnil(L); |
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
|
627 |
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
|
628 |
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
|
629 |
|
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
|
630 |
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
|
631 |
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
|
632 |
begin |
10297 | 633 |
if CheckLuaParamCount(L, 4,'SpawnFakeUtilityCrate', 'x, y, explode, poison') then |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
634 |
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
|
635 |
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
|
636 |
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
|
637 |
lua_pushinteger(L, gear^.uid); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
638 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
639 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
640 |
lua_pushnil(L); |
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
|
641 |
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
|
642 |
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
|
643 |
|
3730 | 644 |
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
|
645 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
646 |
var health, n: LongInt; |
3730 | 647 |
begin |
10297 | 648 |
if CheckAndFetchParamCount(L, 2, 3, 'SpawnHealthCrate', 'x, y [, health]', n) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
649 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
650 |
if n = 3 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
651 |
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
|
652 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
653 |
health:= cHealthCaseAmount; |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
654 |
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
|
655 |
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
|
656 |
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
|
657 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
658 |
lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
659 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
660 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
661 |
lua_pushnil(L); |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
662 |
lc_spawnhealthcrate := 1; |
3734 | 663 |
end; |
664 |
||
665 |
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
|
666 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
667 |
n : LongInt; |
3734 | 668 |
begin |
10297 | 669 |
if CheckAndFetchParamCount(L, 3, 4, 'SpawnAmmoCrate', 'x, y, content [, amount]', n) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
670 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
671 |
if n = 3 then |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
672 |
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
|
673 |
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
|
674 |
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
|
675 |
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
|
676 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
677 |
lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
678 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
679 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
680 |
lua_pushnil(L); |
3734 | 681 |
lc_spawnammocrate := 1; |
682 |
end; |
|
683 |
||
684 |
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
|
685 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
686 |
n : LongInt; |
3734 | 687 |
begin |
10297 | 688 |
if CheckAndFetchParamCount(L, 3, 4, 'SpawnUtilityCrate', 'x, y, content [, amount]', n) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
689 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
690 |
if n = 3 then |
7337
c224cd2d32f3
Allow script to set number of ammo in a crate. untested.
nemo
parents:
7307
diff
changeset
|
691 |
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
|
692 |
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
|
693 |
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
|
694 |
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
|
695 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
696 |
lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
697 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
698 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
699 |
lua_pushnil(L); |
3734 | 700 |
lc_spawnutilitycrate := 1; |
3730 | 701 |
end; |
702 |
||
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
|
703 |
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
|
704 |
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
|
705 |
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
|
706 |
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
|
707 |
gt: TGearType; |
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
708 |
const |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
709 |
call = 'AddGear'; |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
710 |
params = 'x, y, gearType, state, dx, dy, timer'; |
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
|
711 |
begin |
10297 | 712 |
if CheckLuaParamCount(L, 7, call, params) 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
|
713 |
begin |
10281 | 714 |
t:= LuaToGearTypeOrd(L, 3, call, params); |
715 |
if t >= 0 then |
|
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
716 |
begin |
10281 | 717 |
gt:= TGearType(t); |
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
718 |
x:= lua_tointeger(L, 1); |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
719 |
y:= lua_tointeger(L, 2); |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
720 |
s:= lua_tointeger(L, 4); |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
721 |
dx:= int2hwFloat(lua_tointeger(L, 5)) / 1000000; |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
722 |
dy:= int2hwFloat(lua_tointeger(L, 6)) / 1000000; |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
723 |
t:= lua_tointeger(L, 7); |
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
|
724 |
|
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
725 |
gear:= AddGear(x, y, gt, s, dx, dy, t); |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
726 |
lastGearByUID:= gear; |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
727 |
lua_pushinteger(L, gear^.uid) |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
728 |
end |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
729 |
else |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
730 |
lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
731 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
732 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
733 |
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
|
734 |
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
|
735 |
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
|
736 |
|
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
|
737 |
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
|
738 |
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
|
739 |
begin |
10297 | 740 |
if CheckLuaParamCount(L, 1, 'DeleteGear', 'gearUid') 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
|
741 |
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
|
742 |
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
|
743 |
if gear <> nil then |
7517 | 744 |
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
|
745 |
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
|
746 |
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
|
747 |
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
|
748 |
|
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
|
749 |
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
|
750 |
var vg : PVisualGear; |
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
751 |
x, y, s, n, layer: LongInt; |
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
|
752 |
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
|
753 |
vgt: TVisualGearType; |
10281 | 754 |
uid: Longword; |
755 |
const |
|
756 |
call = 'AddVisualGear'; |
|
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
757 |
params = 'x, y, visualGearType, state, critical [, layer]'; |
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
|
758 |
begin |
10281 | 759 |
uid:= 0; |
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
760 |
if CheckAndFetchParamCount(L, 5, 6, call, params, n) 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
|
761 |
begin |
10281 | 762 |
s:= LuaToVisualGearTypeOrd(L, 3, call, params); |
763 |
if s >= 0 then |
|
764 |
begin |
|
765 |
vgt:= TVisualGearType(s); |
|
766 |
x:= lua_tointeger(L, 1); |
|
767 |
y:= lua_tointeger(L, 2); |
|
768 |
s:= lua_tointeger(L, 4); |
|
769 |
c:= lua_toboolean(L, 5); |
|
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
|
770 |
|
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
771 |
if n = 6 then |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
772 |
begin |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
773 |
layer:= lua_tointeger(L, 6); |
10347 | 774 |
vg:= AddVisualGear(x, y, vgt, s, c, layer); |
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
775 |
end |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
776 |
else |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
777 |
vg:= AddVisualGear(x, y, vgt, s, c); |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
778 |
|
10281 | 779 |
if vg <> nil then |
780 |
begin |
|
781 |
lastVisualGearByUID:= vg; |
|
782 |
uid:= vg^.uid; |
|
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
783 |
lua_pushinteger(L, uid); |
10281 | 784 |
end; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
785 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
786 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
787 |
lua_pushnil(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
788 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
789 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
790 |
lua_pushnil(L); // return value on stack (nil) |
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
|
791 |
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
|
792 |
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
|
793 |
|
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
|
794 |
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
|
795 |
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
|
796 |
begin |
10281 | 797 |
vg:= nil; |
10297 | 798 |
if CheckLuaParamCount(L, 1, 'DeleteVisualGear', 'vgUid') 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
|
799 |
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
|
800 |
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
|
801 |
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
|
802 |
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
|
803 |
end; |
10281 | 804 |
// allow caller to know whether there was something to delete |
805 |
lua_pushboolean(L, vg <> nil); |
|
806 |
lc_deletevisualgear:= 1 |
|
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
|
807 |
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
|
808 |
|
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
|
809 |
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
|
810 |
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
|
811 |
begin |
10297 | 812 |
if CheckLuaParamCount(L, 1, 'GetVisualGearValues', 'vgUid') 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
|
813 |
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
|
814 |
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
|
815 |
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
|
816 |
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
|
817 |
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
|
818 |
lua_pushinteger(L, round(vg^.Y)); |
5075
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
819 |
lua_pushnumber(L, vg^.dX); |
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
820 |
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
|
821 |
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
|
822 |
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
|
823 |
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
|
824 |
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
|
825 |
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
|
826 |
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
|
827 |
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
|
828 |
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
|
829 |
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
|
830 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
10287 | 831 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
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
|
832 |
end |
10287 | 833 |
end |
834 |
else |
|
835 |
begin |
|
836 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
837 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
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
|
838 |
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
|
839 |
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
|
840 |
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
|
841 |
|
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
|
842 |
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
|
843 |
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
|
844 |
begin |
10297 | 845 |
if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') 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
|
846 |
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
|
847 |
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
|
848 |
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
|
849 |
begin |
4450 | 850 |
vg^.X:= lua_tointeger(L, 2); |
851 |
vg^.Y:= lua_tointeger(L, 3); |
|
5075
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
852 |
vg^.dX:= lua_tonumber(L, 4); |
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
853 |
vg^.dY:= lua_tonumber(L, 5); |
4450 | 854 |
vg^.Angle:= lua_tonumber(L, 6); |
855 |
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
|
856 |
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
|
857 |
vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. |
4450 | 858 |
vg^.State:= lua_tointeger(L, 9); |
859 |
vg^.Timer:= lua_tointeger(L, 10); |
|
860 |
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
|
861 |
end |
10287 | 862 |
end |
863 |
else |
|
864 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
865 |
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
|
866 |
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
|
867 |
|
3058 | 868 |
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
869 |
begin |
|
10297 | 870 |
if CheckLuaParamCount(L, 0, 'GetFollowGear', '') then |
3058 | 871 |
begin |
872 |
if FollowGear = nil then |
|
873 |
lua_pushnil(L) |
|
874 |
else |
|
4484 | 875 |
lua_pushinteger(L, FollowGear^.uid); |
10287 | 876 |
end |
877 |
else |
|
878 |
lua_pushnil(L); |
|
3058 | 879 |
lc_getfollowgear:= 1; // 1 return value |
880 |
end; |
|
881 |
||
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
|
882 |
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
|
883 |
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
|
884 |
begin |
10297 | 885 |
if CheckLuaParamCount(L, 1, 'GetGearType', 'gearUid') 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
|
886 |
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
|
887 |
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
|
888 |
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
|
889 |
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
|
890 |
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
|
891 |
lua_pushnil(L); |
10287 | 892 |
end |
893 |
else |
|
894 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
895 |
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
|
896 |
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
|
897 |
|
3892 | 898 |
function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
899 |
var gear : PGear; |
|
900 |
begin |
|
10297 | 901 |
if CheckLuaParamCount(L, 1, 'GetGearMessage', 'gearUid') then |
3892 | 902 |
begin |
903 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
904 |
if gear <> nil then |
|
905 |
lua_pushinteger(L, gear^.message) |
|
906 |
else |
|
907 |
lua_pushnil(L); |
|
10287 | 908 |
end |
909 |
else |
|
910 |
lua_pushnil(L); // return value on stack (nil) |
|
3892 | 911 |
lc_getgearmessage:= 1 |
912 |
end; |
|
913 |
||
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
|
914 |
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
|
915 |
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
|
916 |
begin |
10297 | 917 |
if CheckLuaParamCount(L, 1, 'GetGearElasticity', 'gearUid') then |
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
|
918 |
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
|
919 |
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
|
920 |
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
|
921 |
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
|
922 |
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
|
923 |
lua_pushnil(L); |
10287 | 924 |
end |
925 |
else |
|
926 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
927 |
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
|
928 |
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
|
929 |
|
3896 | 930 |
function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
931 |
var gear : PGear; |
|
932 |
begin |
|
10297 | 933 |
if CheckLuaParamCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
3896 | 934 |
begin |
935 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
936 |
if gear <> nil then |
|
937 |
gear^.message:= lua_tointeger(L, 2); |
|
938 |
end; |
|
939 |
lc_setgearmessage:= 0 |
|
940 |
end; |
|
941 |
||
6523 | 942 |
function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
943 |
var gear : PGear; |
|
944 |
begin |
|
10297 | 945 |
if CheckLuaParamCount(L, 1, 'GetGearPos', 'gearUid') then |
6523 | 946 |
begin |
947 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
948 |
if gear <> nil then |
|
949 |
lua_pushinteger(L, gear^.Pos) |
|
950 |
else |
|
951 |
lua_pushnil(L); |
|
10287 | 952 |
end |
953 |
else |
|
954 |
lua_pushnil(L); // return value on stack (nil) |
|
6523 | 955 |
lc_getgearpos:= 1 |
956 |
end; |
|
957 |
||
958 |
function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
|
959 |
var gear : PGear; |
|
960 |
begin |
|
10297 | 961 |
if CheckLuaParamCount(L, 2, 'SetGearPos', 'gearUid, value') then |
6523 | 962 |
begin |
963 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
964 |
if gear <> nil then |
|
965 |
gear^.Pos:= lua_tointeger(L, 2); |
|
966 |
end; |
|
967 |
lc_setgearpos:= 0 |
|
968 |
end; |
|
969 |
||
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
|
970 |
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
|
971 |
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
|
972 |
begin |
10297 | 973 |
if CheckLuaParamCount(L, 1, 'GetGearCollisionMask', 'gearUid') then |
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
|
974 |
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
|
975 |
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
|
976 |
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
|
977 |
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
|
978 |
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
|
979 |
lua_pushnil(L); |
10287 | 980 |
end |
981 |
else |
|
982 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
983 |
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
|
984 |
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
|
985 |
|
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
|
986 |
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
|
987 |
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
|
988 |
begin |
10297 | 989 |
if CheckLuaParamCount(L, 2, 'SetGearCollisionMask', 'gearUid, mask') then |
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
|
990 |
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
|
991 |
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
|
992 |
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
|
993 |
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
|
994 |
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
|
995 |
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
|
996 |
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
|
997 |
|
3755 | 998 |
function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
999 |
var gear : PGear; |
|
1000 |
begin |
|
10297 | 1001 |
if CheckLuaParamCount(L, 1, 'GetHogLevel', 'gearUid') then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1002 |
begin |
3755 | 1003 |
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
|
1004 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4372 | 1005 |
lua_pushinteger(L, gear^.Hedgehog^.BotLevel) |
3755 | 1006 |
else |
1007 |
lua_pushnil(L); |
|
1008 |
end; |
|
1009 |
lc_gethoglevel := 1; |
|
1010 |
end; |
|
1011 |
||
4496 | 1012 |
function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
1013 |
var gear : PGear; |
|
1014 |
begin |
|
10297 | 1015 |
if CheckLuaParamCount(L, 2, 'SetHogLevel', 'gearUid, level') then |
4496 | 1016 |
begin |
1017 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1018 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1019 |
gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2); |
|
1020 |
end; |
|
1021 |
lc_sethoglevel:= 0 |
|
1022 |
end; |
|
1023 |
||
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
|
1024 |
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
|
1025 |
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
|
1026 |
begin |
10297 | 1027 |
if CheckLuaParamCount(L, 1, 'GetHogClan', 'gearUid') 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
|
1028 |
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
|
1029 |
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
|
1030 |
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
|
1031 |
begin |
4372 | 1032 |
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
|
1033 |
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
|
1034 |
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
|
1035 |
lua_pushnil(L); |
10287 | 1036 |
end |
1037 |
else |
|
1038 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
1039 |
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
|
1040 |
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
|
1041 |
|
4498 | 1042 |
function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
1043 |
begin |
|
10297 | 1044 |
if CheckLuaParamCount(L, 1, 'GetClanColor', 'clan') then |
10287 | 1045 |
lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF) |
1046 |
else |
|
4498 | 1047 |
lua_pushnil(L); // return value on stack (nil) |
1048 |
lc_getclancolor:= 1 |
|
1049 |
end; |
|
1050 |
||
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1051 |
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
|
1052 |
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
|
1053 |
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
|
1054 |
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
|
1055 |
i, j : LongInt; |
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1056 |
begin |
10297 | 1057 |
if CheckLuaParamCount(L, 2, 'SetClanColor', 'clan, color') 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
|
1058 |
begin |
10581 | 1059 |
i:= lua_tointeger(L,1); |
1060 |
if i >= ClansCount then exit(0); |
|
1061 |
clan := ClansArray[i]; |
|
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
|
1062 |
clan^.Color:= lua_tointeger(L, 2) shr 8; |
9656 | 1063 |
|
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
|
1064 |
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
|
1065 |
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
|
1066 |
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
|
1067 |
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
|
1068 |
begin |
4891 | 1069 |
hh:= team^.Hedgehogs[j]; |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1070 |
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
|
1071 |
begin |
10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10618
diff
changeset
|
1072 |
FreeAndNilTexture(hh.NameTagTex); |
10127 | 1073 |
hh.NameTagTex:= RenderStringTex(ansistring(hh.Name), clan^.Color, fnt16); |
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
|
1074 |
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
|
1075 |
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
|
1076 |
end; |
10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10618
diff
changeset
|
1077 |
FreeAndNilTexture(team^.NameTagTex); |
10127 | 1078 |
team^.NameTagTex:= RenderStringTex(ansistring(clan^.Teams[i]^.TeamName), clan^.Color, fnt16); |
9656 | 1079 |
end; |
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
|
1080 |
|
10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10618
diff
changeset
|
1081 |
FreeAndNilTexture(clan^.HealthTex); |
9656 | 1082 |
clan^.HealthTex:= makeHealthBarTexture(cTeamHealthWidth + 5, clan^.Teams[0]^.NameTagTex^.h, clan^.Color); |
1083 |
end; |
|
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
|
1084 |
|
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1085 |
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
|
1086 |
end; |
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1087 |
|
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1088 |
function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1089 |
var gear : PGear; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1090 |
begin |
10297 | 1091 |
if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1092 |
begin |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1093 |
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
|
1094 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4372 | 1095 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1096 |
else |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1097 |
lua_pushnil(L); |
10287 | 1098 |
end |
1099 |
else |
|
1100 |
lua_pushnil(L); // return value on stack (nil) |
|
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1101 |
lc_gethogteamname:= 1 |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1102 |
end; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1103 |
|
9788 | 1104 |
function lc_sethogteamname(L : Plua_State) : LongInt; Cdecl; |
1105 |
var gear : PGear; |
|
1106 |
begin |
|
10297 | 1107 |
if CheckLuaParamCount(L, 2, 'SetHogTeamName', 'gearUid, name') then |
9788 | 1108 |
begin |
1109 |
gear := GearByUID(lua_tointeger(L, 1)); |
|
1110 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
|
1111 |
begin |
|
1112 |
gear^.Hedgehog^.Team^.TeamName := lua_tostring(L, 2); |
|
1113 |
||
10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10618
diff
changeset
|
1114 |
FreeAndNilTexture(gear^.Hedgehog^.Team^.NameTagTex); |
10127 | 1115 |
gear^.Hedgehog^.Team^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Team^.TeamName), gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
9788 | 1116 |
end |
1117 |
else |
|
1118 |
lua_pushnil(L); |
|
10287 | 1119 |
end |
1120 |
else |
|
1121 |
lua_pushnil(L); // return value on stack (nil) |
|
9788 | 1122 |
lc_sethogteamname:= 1 |
1123 |
end; |
|
1124 |
||
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
|
1125 |
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
|
1126 |
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
|
1127 |
begin |
10297 | 1128 |
if CheckLuaParamCount(L, 1, 'GetHogName', 'gearUid') 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
|
1129 |
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
|
1130 |
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
|
1131 |
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
|
1132 |
begin |
4372 | 1133 |
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
|
1134 |
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
|
1135 |
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
|
1136 |
lua_pushnil(L); |
10287 | 1137 |
end |
1138 |
else |
|
1139 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
1140 |
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
|
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 |
|
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1143 |
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
|
1144 |
var gear : PGear; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1145 |
begin |
10297 | 1146 |
if CheckLuaParamCount(L, 2, 'SetHogName', 'gearUid, name') then |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1147 |
begin |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1148 |
gear:= GearByUID(lua_tointeger(L, 1)); |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1149 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
1150 |
begin |
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
1151 |
gear^.Hedgehog^.Name:= lua_tostring(L, 2); |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1152 |
|
10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10618
diff
changeset
|
1153 |
FreeAndNilTexture(gear^.Hedgehog^.NameTagTex); |
10127 | 1154 |
gear^.Hedgehog^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Name), gear^.Hedgehog^.Team^.Clan^.Color, fnt16) |
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
1155 |
end |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1156 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1157 |
lc_sethogname:= 0; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1158 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1159 |
|
3722 | 1160 |
function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
1161 |
var gear : PGear; |
|
1162 |
begin |
|
10297 | 1163 |
if CheckLuaParamCount(L, 1, 'GetTimer', 'gearUid') then |
3722 | 1164 |
begin |
1165 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1166 |
if gear <> nil then |
|
4484 | 1167 |
lua_pushinteger(L, gear^.Timer) |
3722 | 1168 |
else |
1169 |
lua_pushnil(L); |
|
10287 | 1170 |
end |
1171 |
else |
|
1172 |
lua_pushnil(L); // return value on stack (nil) |
|
3722 | 1173 |
lc_gettimer:= 1 |
1174 |
end; |
|
1175 |
||
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1176 |
function lc_getflighttime(L : Plua_State) : LongInt; Cdecl; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1177 |
var gear : PGear; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1178 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1179 |
if CheckLuaParamCount(L, 1, 'GetFlightTime', 'gearUid') then |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1180 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1181 |
gear:= GearByUID(lua_tointeger(L, 1)); |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1182 |
if gear <> nil then |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1183 |
lua_pushinteger(L, gear^.FlightTime) |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1184 |
else |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1185 |
lua_pushnil(L); |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1186 |
end |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1187 |
else |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1188 |
lua_pushnil(L); // return value on stack (nil) |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1189 |
lc_getflighttime:= 1 |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1190 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1191 |
|
3722 | 1192 |
function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
1193 |
var gear : PGear; |
|
1194 |
begin |
|
10297 | 1195 |
if CheckLuaParamCount(L, 1, 'GetHealth', 'gearUid') then |
3722 | 1196 |
begin |
1197 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1198 |
if gear <> nil then |
|
4484 | 1199 |
lua_pushinteger(L, gear^.Health) |
3722 | 1200 |
else |
1201 |
lua_pushnil(L); |
|
10287 | 1202 |
end |
1203 |
else |
|
1204 |
lua_pushnil(L); // return value on stack (nil) |
|
3722 | 1205 |
lc_gethealth:= 1 |
1206 |
end; |
|
1207 |
||
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
|
1208 |
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
|
1209 |
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
|
1210 |
begin |
10297 | 1211 |
if CheckLuaParamCount(L, 1, 'GetX', 'gearUid') 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
|
1212 |
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
|
1213 |
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
|
1214 |
if gear <> nil then |
4484 | 1215 |
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
|
1216 |
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
|
1217 |
lua_pushnil(L); |
10287 | 1218 |
end |
1219 |
else |
|
1220 |
lua_pushnil(L); // return value on stack (nil) |
|
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 |
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
|
1222 |
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
|
1223 |
|
3acdb4dac6eb
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 |
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
|
1225 |
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
|
1226 |
begin |
10297 | 1227 |
if CheckLuaParamCount(L, 1, 'GetY', 'gearUid') 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
|
1228 |
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
|
1229 |
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
|
1230 |
if gear <> nil then |
4484 | 1231 |
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
|
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 |
lua_pushnil(L); |
10287 | 1234 |
end |
1235 |
else |
|
1236 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
1237 |
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
|
1238 |
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
|
1239 |
|
3acdb4dac6eb
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 |
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
|
1241 |
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
|
1242 |
begin |
10297 | 1243 |
if CheckLuaParamCount(L, 2, 'CopyPV', 'fromGearUid, toGearUid') 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
|
1244 |
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
|
1245 |
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
|
1246 |
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
|
1247 |
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
|
1248 |
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
|
1249 |
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
|
1250 |
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
|
1251 |
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
|
1252 |
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
|
1253 |
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
|
1254 |
end; |
10287 | 1255 |
lc_copypv:= 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
|
1256 |
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
|
1257 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1258 |
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
|
1259 |
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
|
1260 |
begin |
10297 | 1261 |
if CheckLuaParamCount(L, 1, 'FollowGear', 'gearUid') 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
|
1262 |
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
|
1263 |
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
|
1264 |
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
|
1265 |
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
|
1266 |
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
|
1267 |
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
|
1268 |
|
3761 | 1269 |
function lc_hogsay(L : Plua_State) : LongInt; Cdecl; |
1270 |
var gear : PGear; |
|
1271 |
vgear : PVisualGear; |
|
4533 | 1272 |
s : LongWord; |
10287 | 1273 |
n : LongInt; |
3761 | 1274 |
begin |
10297 | 1275 |
if CheckAndFetchParamCount(L, 3, 4, 'HogSay', 'gearUid, text, manner [, vgState]', n) then |
3761 | 1276 |
begin |
1277 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1278 |
if gear <> nil then |
|
1279 |
begin |
|
10287 | 1280 |
// state defaults to 0 if state param is given |
1281 |
if n = 4 then |
|
1282 |
s:= lua_tointeger(L, 4) |
|
1283 |
else |
|
1284 |
s:= 0; |
|
4533 | 1285 |
vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
3761 | 1286 |
if vgear <> nil then |
1287 |
begin |
|
10518
dbbe2f6c0a96
make gear ability to speak somewhat less ironic
sheepluva
parents:
10516
diff
changeset
|
1288 |
vgear^.Text:= lua_tostring(L, 2); |
10210
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1289 |
if Gear^.Kind = gtHedgehog then |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1290 |
begin |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1291 |
AddChatString(#1+'[' + gear^.Hedgehog^.Name + '] '+vgear^.text); |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1292 |
vgear^.Hedgehog:= gear^.Hedgehog |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1293 |
end |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1294 |
else vgear^.Frame:= gear^.uid; |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1295 |
|
3761 | 1296 |
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
|
1297 |
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
|
1298 |
vgear^.FrameTicks:= 1; |
9764
8dc9d268330f
revert r938d1c08d0d1 in favour of putting it in the chat log. I think this addresses main concern about missing text. There've been complaints in past too about conversation in bubbles not being visible in history. If the objection is that r938d1c08d0d1 offers a more æsthetic solution, I think it should augment this, be flagged, and fix the visual issues first.
nemo
parents:
9752
diff
changeset
|
1299 |
lua_pushinteger(L, vgear^.Uid); |
5529 | 1300 |
end |
3761 | 1301 |
end |
10289 | 1302 |
else |
1303 |
lua_pushnil(L) |
|
4533 | 1304 |
end |
10287 | 1305 |
else |
1306 |
lua_pushnil(L); |
|
5529 | 1307 |
lc_hogsay:= 1 |
3761 | 1308 |
end; |
1309 |
||
4851 | 1310 |
function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1311 |
var gear, prevgear : PGear; |
|
1312 |
begin |
|
10297 | 1313 |
if CheckLuaParamCount(L, 1, 'SwitchHog', 'gearUid') then |
4851 | 1314 |
begin |
1315 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1316 |
// should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
|
1317 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
|
1318 |
begin |
|
1319 |
prevgear := CurrentHedgehog^.Gear; |
|
7573 | 1320 |
if prevgear <> nil then |
1321 |
begin |
|
1322 |
prevgear^.Active := false; |
|
1323 |
prevgear^.State:= prevgear^.State and (not gstHHDriven); |
|
1324 |
prevgear^.Z := cHHZ; |
|
1325 |
prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
|
1326 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1327 |
|
7270
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1328 |
SwitchCurrentHedgehog(gear^.Hedgehog); |
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1329 |
CurrentTeam:= CurrentHedgehog^.Team; |
4851 | 1330 |
|
1331 |
gear^.State:= gear^.State or gstHHDriven; |
|
1332 |
gear^.Active := true; |
|
1333 |
gear^.Z := cCurrHHZ; |
|
7401 | 1334 |
gear^.Message:= gear^.Message or gmRemoveFromList or gmAddToList; |
4851 | 1335 |
end |
1336 |
end; |
|
1337 |
lc_switchhog:= 0 |
|
1338 |
end; |
|
1339 |
||
4481 | 1340 |
function lc_addammo(L : Plua_State) : LongInt; Cdecl; |
1341 |
var gear : PGear; |
|
10287 | 1342 |
at, n: LongInt; |
10281 | 1343 |
const |
1344 |
call = 'AddAmmo'; |
|
1345 |
params = 'gearUid, ammoType [, ammoCount]'; |
|
4481 | 1346 |
begin |
10297 | 1347 |
if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
4481 | 1348 |
begin |
10281 | 1349 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1350 |
if at >= 0 then |
|
1351 |
begin |
|
1352 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1353 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
|
10287 | 1354 |
if n = 2 then |
10281 | 1355 |
AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1356 |
else |
|
1357 |
SetAmmo(gear^.Hedgehog^, TAmmoType(at), lua_tointeger(L, 3)) |
|
1358 |
end; |
|
10287 | 1359 |
end; |
4481 | 1360 |
lc_addammo:= 0 |
1361 |
end; |
|
1362 |
||
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
|
1363 |
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
|
1364 |
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
|
1365 |
ammo : PAmmo; |
10281 | 1366 |
at : LongInt; |
1367 |
const |
|
1368 |
call = 'GetAmmoCount'; |
|
1369 |
params = 'gearUid, ammoType'; |
|
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
|
1370 |
begin |
10297 | 1371 |
if CheckLuaParamCount(L, 2, call, params) then |
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
|
1372 |
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
|
1373 |
gear:= GearByUID(lua_tointeger(L, 1)); |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1374 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
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
|
1375 |
begin |
10281 | 1376 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1377 |
if at >= 0 then |
|
1378 |
begin |
|
1379 |
ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
|
1380 |
if ammo^.AmmoType = amNothing then |
|
1381 |
lua_pushinteger(L, 0) |
|
1382 |
else |
|
1383 |
lua_pushinteger(L, ammo^.Count); |
|
1384 |
end; |
|
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
|
1385 |
end |
10281 | 1386 |
else lua_pushinteger(L, 0); |
10287 | 1387 |
end |
1388 |
else |
|
1389 |
lua_pushnil(L); |
|
6046 | 1390 |
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
|
1391 |
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
|
1392 |
|
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 |
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
|
1394 |
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
|
1395 |
begin |
10297 | 1396 |
if CheckLuaParamCount(L, 2, 'SetHealth', 'gearUid, health') 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
|
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)); |
3723 | 1399 |
if gear <> nil then |
1400 |
begin |
|
1401 |
gear^.Health:= lua_tointeger(L, 2); |
|
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1402 |
|
9914 | 1403 |
if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1404 |
begin |
|
1405 |
RenderHealth(gear^.Hedgehog^); |
|
1406 |
RecountTeamHealth(gear^.Hedgehog^.Team) |
|
1407 |
end; |
|
1408 |
// Why did this do a "setalltoactive" ? |
|
10015 | 1409 |
//SetAllToActive; |
9914 | 1410 |
Gear^.Active:= true; |
1411 |
AllInactive:= false |
|
3723 | 1412 |
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
|
1413 |
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
|
1414 |
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
|
1415 |
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
|
1416 |
|
3722 | 1417 |
function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1418 |
var gear : PGear; |
|
1419 |
begin |
|
10297 | 1420 |
if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then |
3722 | 1421 |
begin |
1422 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1423 |
if gear <> nil then gear^.Timer:= lua_tointeger(L, 2) |
|
1424 |
end; |
|
1425 |
lc_settimer:= 0 |
|
1426 |
end; |
|
1427 |
||
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1428 |
function lc_setflighttime(L : Plua_State) : LongInt; Cdecl; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1429 |
var gear : PGear; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1430 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1431 |
if CheckLuaParamCount(L, 2, 'SetFlightTime', 'gearUid, flighttime') then |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1432 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1433 |
gear:= GearByUID(lua_tointeger(L, 1)); |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1434 |
if gear <> nil then gear^.FlightTime:= lua_tointeger(L, 2) |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1435 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1436 |
lc_setflighttime:= 0 |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1437 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1438 |
|
3756 | 1439 |
function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1440 |
var gear: PGear; |
|
10281 | 1441 |
t : LongInt; |
1442 |
const |
|
1443 |
call = 'SetEffect'; |
|
1444 |
params = 'gearUid, effect, effectState'; |
|
3756 | 1445 |
begin |
10297 | 1446 |
if CheckLuaParamCount(L, 3, call, params) then |
10281 | 1447 |
begin |
1448 |
t:= LuaToHogEffectOrd(L, 2, call, params); |
|
1449 |
if t >= 0 then |
|
1450 |
begin |
|
1451 |
gear := GearByUID(lua_tointeger(L, 1)); |
|
1452 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
|
1453 |
gear^.Hedgehog^.Effects[THogEffect(t)]:= lua_tointeger(L, 3); |
|
1454 |
end; |
|
1455 |
end; |
|
3756 | 1456 |
lc_seteffect := 0; |
1457 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1458 |
|
5489 | 1459 |
function lc_geteffect(L : Plua_State) : LongInt; Cdecl; |
1460 |
var gear : PGear; |
|
10281 | 1461 |
t : LongInt; |
1462 |
const |
|
1463 |
call = 'GetEffect'; |
|
1464 |
params = 'gearUid, effect'; |
|
5489 | 1465 |
begin |
10297 | 1466 |
if CheckLuaParamCount(L, 2, call, params) then |
5489 | 1467 |
begin |
10281 | 1468 |
t:= LuaToHogEffectOrd(L, 2, call, params); |
1469 |
if t >= 0 then |
|
1470 |
begin |
|
1471 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1472 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
|
1473 |
lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
|
1474 |
else |
|
1475 |
lua_pushinteger(L, 0) |
|
1476 |
end; |
|
10287 | 1477 |
end |
1478 |
else |
|
1479 |
lua_pushinteger(L, 0); |
|
5489 | 1480 |
lc_geteffect:= 1 |
1481 |
end; |
|
3756 | 1482 |
|
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
|
1483 |
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
|
1484 |
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
|
1485 |
begin |
10297 | 1486 |
if CheckLuaParamCount(L, 2, 'SetState', 'gearUid, state') 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
|
1487 |
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
|
1488 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3723 | 1489 |
if gear <> nil then |
1490 |
begin |
|
1491 |
gear^.State:= lua_tointeger(L, 2); |
|
1492 |
SetAllToActive; |
|
1493 |
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
|
1494 |
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
|
1495 |
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
|
1496 |
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
|
1497 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1498 |
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
|
1499 |
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
|
1500 |
begin |
10297 | 1501 |
if CheckLuaParamCount(L, 1, 'GetState', 'gearUid') 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
|
1502 |
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
|
1503 |
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
|
1504 |
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
|
1505 |
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
|
1506 |
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
|
1507 |
lua_pushnil(L) |
10287 | 1508 |
end |
1509 |
else |
|
1510 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
1511 |
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
|
1512 |
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
|
1513 |
|
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1514 |
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
|
1515 |
var gear : PGear; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1516 |
begin |
10297 | 1517 |
if CheckLuaParamCount(L, 1, 'GetTag', 'gearUid') then |
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1518 |
begin |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1519 |
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
|
1520 |
if gear <> nil then |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1521 |
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
|
1522 |
else |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1523 |
lua_pushnil(L); |
10287 | 1524 |
end |
1525 |
else |
|
1526 |
lua_pushnil(L); // return value on stack (nil) |
|
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1527 |
lc_gettag:= 1 |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1528 |
end; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1529 |
|
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
|
1530 |
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
|
1531 |
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
|
1532 |
begin |
10297 | 1533 |
if CheckLuaParamCount(L, 2, 'SetTag', 'gearUid, tag') 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
|
1534 |
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
|
1535 |
gear:= GearByUID(lua_tointeger(L, 1)); |
3723 | 1536 |
if gear <> nil then |
1537 |
begin |
|
1538 |
gear^.Tag:= lua_tointeger(L, 2); |
|
1539 |
SetAllToActive; |
|
1540 |
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
|
1541 |
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
|
1542 |
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
|
1543 |
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
|
1544 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1545 |
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
|
1546 |
begin |
3407 | 1547 |
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
|
1548 |
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
|
1549 |
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
|
1550 |
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
|
1551 |
|
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
1552 |
function lc_sendstat(L : Plua_State) : LongInt; Cdecl; |
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
1553 |
var statInfo : TStatInfoType; |
10287 | 1554 |
i, n : LongInt; |
1555 |
color, tn: shortstring; |
|
1556 |
needsTn : boolean; |
|
10281 | 1557 |
const |
1558 |
call = 'SendStat'; |
|
1559 |
params = 'statInfoType, color [, teamname]'; |
|
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
1560 |
begin |
10297 | 1561 |
if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1562 |
begin |
10281 | 1563 |
i:= LuaToStatInfoTypeOrd(L, 1, call, params); |
1564 |
if i >= 0 then |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1565 |
begin |
10287 | 1566 |
statInfo:= TStatInfoType(i); |
1567 |
needsTn:= ((statInfo = siPlayerKills) or (statInfo = siClanHealth)); |
|
1568 |
// check if param count is correct for the used statInfo |
|
1569 |
if (n = 3) <> needsTn then |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1570 |
begin |
10287 | 1571 |
if n = 3 then |
1572 |
LuaCallError(EnumToStr(statInfo) + ' does not support the teamname parameter', call, params) |
|
1573 |
else |
|
1574 |
LuaCallError(EnumToStr(statInfo) + ' requires the teamname parameter', call, params); |
|
10281 | 1575 |
end |
10287 | 1576 |
else // count is correct! |
10281 | 1577 |
begin |
10542 | 1578 |
if needsTn then |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1579 |
begin |
10281 | 1580 |
// 3: team name |
1581 |
for i:= 0 to Pred(TeamsCount) do |
|
1582 |
begin |
|
10282 | 1583 |
color:= _S'0'; |
10281 | 1584 |
tn:= lua_tostring(L, 3); |
1585 |
with TeamsArray[i]^ do |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1586 |
begin |
10281 | 1587 |
if TeamName = tn then |
1588 |
begin |
|
1589 |
color := uUtils.IntToStr(Clan^.Color); |
|
1590 |
Break; |
|
1591 |
end |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1592 |
end |
10281 | 1593 |
end; |
1594 |
if (statInfo = siPlayerKills) then |
|
1595 |
begin |
|
1596 |
SendStat(siPlayerKills, color + ' ' + |
|
1597 |
lua_tostring(L, 2) + ' ' + tn); |
|
1598 |
end |
|
1599 |
else if (statInfo = siClanHealth) then |
|
1600 |
begin |
|
1601 |
SendStat(siClanHealth, color + ' ' + |
|
1602 |
lua_tostring(L, 2)); |
|
1603 |
end |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1604 |
end |
10281 | 1605 |
else |
1606 |
begin |
|
1607 |
SendStat(statInfo,lua_tostring(L, 2)); |
|
1608 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1609 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1610 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1611 |
end; |
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
1612 |
lc_sendstat:= 0 |
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
1613 |
end; |
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
1614 |
|
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
1615 |
function lc_sendhealthstatsoff(L : Plua_State) : LongInt; Cdecl; |
9174
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
1616 |
begin |
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
1617 |
L:= L; // avoid compiler hint |
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
1618 |
uStats.SendHealthStatsOn := false; |
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
1619 |
lc_sendhealthstatsoff:= 0 |
9174
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
1620 |
end; |
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
1621 |
|
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
|
1622 |
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
|
1623 |
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
|
1624 |
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
|
1625 |
tryhard: boolean; |
10287 | 1626 |
left, right, n: 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
|
1627 |
begin |
10297 | 1628 |
if CheckAndFetchParamCount(L, 4, 5, 'FindPlace', 'gearUid, fall, left, right [, tryHarder]', n) 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
|
1629 |
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
|
1630 |
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
|
1631 |
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
|
1632 |
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
|
1633 |
right:= lua_tointeger(L, 4); |
10287 | 1634 |
if n = 5 then |
10496 | 1635 |
tryhard:= lua_toboolean(L, 5) |
1636 |
else |
|
1637 |
tryhard:= 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
|
1638 |
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
|
1639 |
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
|
1640 |
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
|
1641 |
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
|
1642 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1643 |
lua_pushnil(L); |
10287 | 1644 |
end |
1645 |
else |
|
1646 |
lua_pushnil(L); // return value on stack (nil) |
|
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
|
1647 |
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
|
1648 |
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
|
1649 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1650 |
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
|
1651 |
var gear: PGear; |
10281 | 1652 |
n, s: LongInt; |
1653 |
const |
|
1654 |
call = 'PlaySound'; |
|
1655 |
params = 'soundId [, hhGearUid]'; |
|
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
|
1656 |
begin |
10297 | 1657 |
if CheckAndFetchParamCount(L, 1, 2, call, params, n) then |
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
|
1658 |
begin |
10281 | 1659 |
s:= LuaToSoundOrd(L, 1, call, params); |
1660 |
if s >= 0 then |
|
1661 |
begin |
|
1662 |
// no gear specified |
|
1663 |
if n = 1 then |
|
1664 |
PlaySound(TSound(s)) |
|
10287 | 1665 |
else |
10281 | 1666 |
begin |
1667 |
gear:= GearByUID(lua_tointeger(L, 2)); |
|
1668 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1669 |
AddVoice(TSound(s),gear^.Hedgehog^.Team^.Voicepack) |
|
1670 |
end; |
|
1671 |
end; |
|
1672 |
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
|
1673 |
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
|
1674 |
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
|
1675 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1676 |
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
|
1677 |
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
|
1678 |
begin |
10297 | 1679 |
if CheckAndFetchParamCount(L, 5, 6, 'AddTeam', 'teamname, color, grave, fort, voicepack [, flag]', np) 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
|
1680 |
begin |
7805 | 1681 |
ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); |
1682 |
ParseCommand('grave ' + lua_tostring(L, 3), true, true); |
|
1683 |
ParseCommand('fort ' + lua_tostring(L, 4), true, true); |
|
1684 |
ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); |
|
1685 |
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
|
1686 |
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
|
1687 |
// 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
|
1688 |
//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
|
1689 |
end; |
10287 | 1690 |
//else |
1691 |
//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
|
1692 |
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
|
1693 |
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
|
1694 |
|
10290 | 1695 |
function lc_dismissteam(L : Plua_State) : LongInt; Cdecl; |
10553
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1696 |
var HHGear: PGear; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1697 |
i, h : LongInt; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1698 |
hidden: boolean; |
10290 | 1699 |
begin |
10297 | 1700 |
if CheckLuaParamCount(L, 1, 'DismissTeam', 'teamname') then |
10553
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1701 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1702 |
if TeamsCount > 0 then |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1703 |
for i:= 0 to Pred(TeamsCount) do |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1704 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1705 |
// skip teams that don't have matching name |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1706 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1707 |
continue; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1708 |
|
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1709 |
// destroy all hogs of matching team, including the hidden ones |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1710 |
for h:= 0 to cMaxHHIndex do |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1711 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1712 |
hidden:= (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil); |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1713 |
if hidden then |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1714 |
RestoreHog(@TeamsArray[i]^.Hedgehogs[h]); |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1715 |
// destroy hedgehog gear, if any |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1716 |
HHGear:= TeamsArray[i]^.Hedgehogs[h].Gear; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1717 |
if HHGear <> nil then |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1718 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1719 |
// smoke effect |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1720 |
if (not hidden) then |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1721 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1722 |
AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtSmokeWhite); |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1723 |
AddVisualGear(hwRound(HHGear^.X) - 16 + Random(32), hwRound(HHGear^.Y) - 16 + Random(32), vgtSmokeWhite); |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1724 |
AddVisualGear(hwRound(HHGear^.X) - 16 + Random(32), hwRound(HHGear^.Y) - 16 + Random(32), vgtSmokeWhite); |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1725 |
AddVisualGear(hwRound(HHGear^.X) - 16 + Random(32), hwRound(HHGear^.Y) - 16 + Random(32), vgtSmokeWhite); |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1726 |
AddVisualGear(hwRound(HHGear^.X) - 16 + Random(32), hwRound(HHGear^.Y) - 16 + Random(32), vgtSmokeWhite); |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1727 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1728 |
HHGear^.Message:= HHGear^.Message or gmDestroy; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1729 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1730 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1731 |
// can't dismiss more than one team |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1732 |
break; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1733 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1734 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
1735 |
lc_dismissteam:= 0; |
10290 | 1736 |
end; |
1737 |
||
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
|
1738 |
function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
3271 | 1739 |
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
|
1740 |
begin |
10297 | 1741 |
if CheckLuaParamCount(L, 4, 'AddHog', 'hogname, botlevel, health, hat') 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
|
1742 |
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
|
1743 |
temp:= lua_tostring(L, 4); |
7805 | 1744 |
ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
1745 |
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
|
1746 |
lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); |
10287 | 1747 |
end |
1748 |
else |
|
1749 |
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
|
1750 |
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
|
1751 |
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
|
1752 |
|
3761 | 1753 |
function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
1754 |
var gear: PGear; |
|
1755 |
begin |
|
10297 | 1756 |
if CheckLuaParamCount(L, 2, 'HogTurnLeft', 'gearUid, boolean') then |
3761 | 1757 |
begin |
1758 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1759 |
if gear <> nil then |
|
1760 |
gear^.dX.isNegative:= lua_toboolean(L, 2); |
|
1761 |
end; |
|
1762 |
lc_hogturnleft:= 0; |
|
1763 |
end; |
|
1764 |
||
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
|
1765 |
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
|
1766 |
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
|
1767 |
begin |
10297 | 1768 |
if CheckLuaParamCount(L, 1, 'GetGearPosition', 'gearUid') 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
|
1769 |
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
|
1770 |
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
|
1771 |
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
|
1772 |
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
|
1773 |
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
|
1774 |
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
|
1775 |
end |
5964 | 1776 |
else |
1777 |
begin |
|
1778 |
lua_pushnil(L); |
|
1779 |
lua_pushnil(L) |
|
1780 |
end; |
|
10287 | 1781 |
end |
1782 |
else |
|
1783 |
begin |
|
1784 |
lua_pushnil(L); |
|
1785 |
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
|
1786 |
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
|
1787 |
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
|
1788 |
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
|
1789 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1790 |
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
|
1791 |
var gear: PGear; |
4832 | 1792 |
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
|
1793 |
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
|
1794 |
begin |
10297 | 1795 |
if CheckLuaParamCount(L, 3, 'SetGearPosition', 'gearUid, x, y') 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
|
1796 |
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
|
1797 |
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
|
1798 |
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
|
1799 |
begin |
4832 | 1800 |
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
|
1801 |
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
|
1802 |
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
|
1803 |
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
|
1804 |
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
|
1805 |
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
|
1806 |
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
|
1807 |
if col then |
9291
15f7bb217b66
Make add/delete consistent (this has bugged me for so long)
nemo
parents:
9285
diff
changeset
|
1808 |
AddCI(gear); |
4832 | 1809 |
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
|
1810 |
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
|
1811 |
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
|
1812 |
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
|
1813 |
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
|
1814 |
|
5517 | 1815 |
function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl; |
1816 |
var gear: PGear; |
|
1817 |
begin |
|
10297 | 1818 |
if CheckLuaParamCount(L, 1, 'GetGearTarget', 'gearUid') then |
5517 | 1819 |
begin |
1820 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1821 |
if gear <> nil then |
|
1822 |
begin |
|
5612
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1823 |
lua_pushinteger(L, gear^.Target.X); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1824 |
lua_pushinteger(L, gear^.Target.Y) |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1825 |
end |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1826 |
else |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1827 |
begin |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1828 |
lua_pushnil(L); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1829 |
lua_pushnil(L) |
5517 | 1830 |
end |
10287 | 1831 |
end |
1832 |
else |
|
1833 |
begin |
|
1834 |
lua_pushnil(L); |
|
1835 |
lua_pushnil(L) |
|
5517 | 1836 |
end; |
1837 |
lc_getgeartarget:= 2; |
|
1838 |
end; |
|
1839 |
||
1840 |
function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl; |
|
1841 |
var gear: PGear; |
|
1842 |
begin |
|
10297 | 1843 |
if CheckLuaParamCount(L, 3, 'SetGearTarget', 'gearUid, x, y') then |
5517 | 1844 |
begin |
1845 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
1846 |
if gear <> nil then |
|
1847 |
begin |
|
5612
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1848 |
gear^.Target.X:= lua_tointeger(L, 2); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
1849 |
gear^.Target.Y:= lua_tointeger(L, 3) |
5517 | 1850 |
end |
1851 |
end; |
|
1852 |
lc_setgeartarget:= 0 |
|
1853 |
end; |
|
1854 |
||
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
|
1855 |
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
|
1856 |
var gear: PGear; |
6780 | 1857 |
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
|
1858 |
begin |
10297 | 1859 |
if CheckLuaParamCount(L, 1, 'GetGearVelocity', 'gearUid') then |
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
|
1860 |
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
|
1861 |
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
|
1862 |
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
|
1863 |
begin |
6780 | 1864 |
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
|
1865 |
// gear dX determines hog orientation |
6780 | 1866 |
if (gear^.dX.isNegative) and (t = 0) then t:= -1; |
1867 |
lua_pushinteger(L, t); |
|
5074 | 1868 |
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
|
1869 |
end |
10287 | 1870 |
end |
1871 |
else |
|
1872 |
begin |
|
1873 |
lua_pushnil(L); |
|
1874 |
lua_pushnil(L); |
|
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
|
1875 |
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
|
1876 |
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
|
1877 |
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
|
1878 |
|
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
|
1879 |
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
|
1880 |
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
|
1881 |
begin |
10297 | 1882 |
if CheckLuaParamCount(L, 3, 'SetGearVelocity', 'gearUid, dx, dy') then |
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
|
1883 |
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
|
1884 |
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
|
1885 |
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
|
1886 |
begin |
5074 | 1887 |
gear^.dX:= int2hwFloat(lua_tointeger(L, 2)) / 1000000; |
1888 |
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
|
1889 |
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
|
1890 |
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
|
1891 |
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
|
1892 |
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
|
1893 |
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
|
1894 |
|
3736 | 1895 |
function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
1896 |
begin |
|
10297 | 1897 |
if CheckLuaParamCount(L, 1, 'SetZoom', 'zoomLevel') then |
3736 | 1898 |
begin |
1899 |
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
|
1900 |
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
|
1901 |
ZoomValue:= cMaxZoomLevel; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
1902 |
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
|
1903 |
ZoomValue:= cMinZoomLevel; |
3736 | 1904 |
end; |
1905 |
lc_setzoom:= 0 |
|
1906 |
end; |
|
1907 |
||
1908 |
function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
|
1909 |
begin |
|
10297 | 1910 |
if CheckLuaParamCount(L, 0, 'GetZoom', '') then |
10287 | 1911 |
lua_pushnumber(L, ZoomValue) |
3736 | 1912 |
else |
10287 | 1913 |
lua_pushnil(L); |
3736 | 1914 |
lc_getzoom:= 1 |
1915 |
end; |
|
1916 |
||
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
|
1917 |
function lc_setammo(L : Plua_State) : LongInt; Cdecl; |
10281 | 1918 |
var np, at: LongInt; |
1919 |
const |
|
1920 |
call = 'SetAmmo'; |
|
1921 |
params = 'ammoType, count, probability, delay [, numberInCrate]'; |
|
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
|
1922 |
begin |
10297 | 1923 |
if CheckAndFetchParamCount(L, 4, 5, call, params, np) then |
10281 | 1924 |
begin |
1925 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
1926 |
if at >= 0 then |
|
1927 |
begin |
|
1928 |
if np = 4 then |
|
1929 |
ScriptSetAmmo(TAmmoType(at), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 1) |
|
1930 |
else |
|
1931 |
ScriptSetAmmo(TAmmoType(at), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); |
|
1932 |
end; |
|
1933 |
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
|
1934 |
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
|
1935 |
end; |
4243 | 1936 |
|
9751
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
1937 |
function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; |
10287 | 1938 |
var at: LongInt; |
10281 | 1939 |
const |
1940 |
call = 'SetAmmoDelay'; |
|
1941 |
params = 'ammoType, delay'; |
|
9751
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
1942 |
begin |
10297 | 1943 |
if CheckLuaParamCount(L, 2, call, params) then |
10281 | 1944 |
begin |
10287 | 1945 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
1946 |
if at >= 0 then |
|
1947 |
ScriptSetAmmoDelay(TAmmoType(at), lua_tointeger(L, 2)); |
|
10281 | 1948 |
end; |
9751
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
1949 |
lc_setammodelay:= 0 |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
1950 |
end; |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
1951 |
|
6529 | 1952 |
function lc_setammostore(L : Plua_State) : LongInt; Cdecl; |
1953 |
begin |
|
10297 | 1954 |
if CheckLuaParamCount(L, 4, 'SetAmmoStore', 'loadouts, probabilities, delays, reinforments') then |
6529 | 1955 |
begin |
1956 |
ScriptAmmoLoadout:= lua_tostring(L, 1); |
|
1957 |
ScriptAmmoProbability:= lua_tostring(L, 2); |
|
1958 |
ScriptAmmoDelay:= lua_tostring(L, 3); |
|
1959 |
ScriptAmmoReinforcement:= lua_tostring(L, 4); |
|
1960 |
end; |
|
1961 |
lc_setammostore:= 0 |
|
1962 |
end; |
|
1963 |
||
4243 | 1964 |
function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
1965 |
var m : LongInt; |
|
1966 |
begin |
|
10297 | 1967 |
if CheckLuaParamCount(L, 1, 'GetRandom', 'number') then |
4243 | 1968 |
begin |
1969 |
m:= lua_tointeger(L, 1); |
|
1970 |
if (m > 0) then |
|
1971 |
lua_pushinteger(L, GetRandom(m)) |
|
1972 |
else |
|
1973 |
begin |
|
1974 |
LuaError('Lua: Tried to pass 0 to GetRandom!'); |
|
1975 |
lua_pushnil(L); |
|
1976 |
end |
|
10287 | 1977 |
end |
1978 |
else |
|
1979 |
lua_pushnil(L); // return value on stack (nil) |
|
4243 | 1980 |
lc_getrandom:= 1 |
1981 |
end; |
|
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1982 |
|
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1983 |
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
|
1984 |
begin |
10297 | 1985 |
if CheckLuaParamCount(L, 1, 'SetWind', 'windSpeed') then |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1986 |
begin |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1987 |
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
|
1988 |
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
|
1989 |
if cWindSpeed.isNegative then |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1990 |
CWindSpeedf := -cWindSpeedf; |
5357
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5313
diff
changeset
|
1991 |
AddVisualGear(0, 0, vgtSmoothWindBar); |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1992 |
end; |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1993 |
lc_setwind:= 0 |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
1994 |
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
|
1995 |
|
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
|
1996 |
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
|
1997 |
begin |
10297 | 1998 |
if CheckLuaParamCount(L, 0, 'GetDataPath', '') then |
10287 | 1999 |
lua_pushstring(L, str2pchar(cPathz[ptData])) |
2000 |
else |
|
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
|
2001 |
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
|
2002 |
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
|
2003 |
end; |
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2004 |
|
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
|
2005 |
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
|
2006 |
begin |
10297 | 2007 |
if CheckLuaParamCount(L, 0, 'GetUserDataPath', '') then |
10287 | 2008 |
lua_pushstring(L, str2pchar(cPathz[ptData])) |
2009 |
else |
|
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
|
2010 |
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
|
2011 |
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
|
2012 |
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
|
2013 |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2014 |
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
|
2015 |
begin |
10297 | 2016 |
if CheckLuaParamCount(L, 0, 'MapHasBorder', '') then |
10287 | 2017 |
lua_pushboolean(L, hasBorder) |
2018 |
else |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2019 |
lua_pushnil(L); |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2020 |
lc_maphasborder:= 1 |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2021 |
end; |
4869 | 2022 |
|
2023 |
function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
|
2024 |
var gear : PGear; |
|
2025 |
begin |
|
10297 | 2026 |
if CheckLuaParamCount(L, 1, 'GetGearRadius', 'gearUid') then |
4869 | 2027 |
begin |
2028 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
2029 |
if gear <> nil then |
|
2030 |
lua_pushinteger(L, gear^.Radius) |
|
2031 |
else |
|
2032 |
lua_pushnil(L); |
|
10287 | 2033 |
end |
2034 |
else |
|
2035 |
lua_pushnil(L); // return value on stack (nil) |
|
4869 | 2036 |
lc_getgearradius:= 1 |
2037 |
end; |
|
4875 | 2038 |
|
2039 |
function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
|
2040 |
var gear : PGear; |
|
2041 |
begin |
|
10297 | 2042 |
if CheckLuaParamCount(L, 1, 'GetHogHat', 'gearUid') then |
10287 | 2043 |
begin |
4875 | 2044 |
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
|
2045 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4875 | 2046 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
2047 |
else |
|
2048 |
lua_pushnil(L); |
|
10287 | 2049 |
end |
2050 |
else |
|
2051 |
lua_pushnil(L); |
|
4875 | 2052 |
lc_gethoghat := 1; |
2053 |
end; |
|
2054 |
||
2055 |
function lc_sethoghat(L : Plua_State) : LongInt; Cdecl; |
|
2056 |
var gear : PGear; |
|
2057 |
hat: ShortString; |
|
2058 |
begin |
|
10297 | 2059 |
if CheckLuaParamCount(L, 2, 'SetHogHat', 'gearUid, hat') then |
4875 | 2060 |
begin |
2061 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
2062 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
2063 |
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
|
2064 |
hat:= lua_tostring(L, 2); |
4875 | 2065 |
gear^.Hedgehog^.Hat:= hat; |
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
2066 |
AddFileLog('Changed hat to: '+hat); |
7887 | 2067 |
if (Length(hat) > 39) and (Copy(hat,1,8) = 'Reserved') and (Copy(hat,9,32) = gear^.Hedgehog^.Team^.PlayerHash) then |
2068 |
LoadHedgehogHat(gear^.Hedgehog^, 'Reserved/' + Copy(hat,9,Length(hat)-8)) |
|
2069 |
else |
|
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
2070 |
LoadHedgehogHat(gear^.Hedgehog^, hat) |
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
2071 |
end |
4875 | 2072 |
end; |
2073 |
lc_sethoghat:= 0; |
|
2074 |
end; |
|
4985 | 2075 |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2076 |
function lc_placesprite(L : Plua_State) : LongInt; Cdecl; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2077 |
var spr : TSprite; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2078 |
lf : Word; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2079 |
i, n : LongInt; |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2080 |
placed: boolean; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2081 |
const |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2082 |
call = 'PlaceSprite'; |
10516 | 2083 |
params = 'x, y, sprite, frameIdx [, landFlag, ... ]'; |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2084 |
begin |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2085 |
placed:= false; |
10297 | 2086 |
if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2087 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2088 |
lf:= 0; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2089 |
|
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2090 |
// accept any amount of landflags, loop is never executed if n>5 |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2091 |
for i:= 5 to n do |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2092 |
lf:= lf or lua_tointeger(L, i); |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2093 |
|
10281 | 2094 |
n:= LuaToSpriteOrd(L, 3, call, params); |
2095 |
if n >= 0 then |
|
2096 |
begin |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2097 |
spr:= TSprite(n); |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2098 |
if SpritesData[spr].Surface = nil then |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2099 |
LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2100 |
else |
10368
7ebb71a36e95
Forced sprites placing mode, exposed to scripts (not tested at all)
unc0rr
parents:
10347
diff
changeset
|
2101 |
placed:= ForcePlaceOnLand( |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2102 |
lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2103 |
lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
10368
7ebb71a36e95
Forced sprites placing mode, exposed to scripts (not tested at all)
unc0rr
parents:
10347
diff
changeset
|
2104 |
spr, lua_tointeger(L, 4), lf); |
10281 | 2105 |
end; |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2106 |
end; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2107 |
|
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2108 |
lua_pushboolean(L, placed); |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2109 |
lc_placesprite:= 1 |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2110 |
end; |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2111 |
|
4985 | 2112 |
function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2113 |
var placed: boolean; |
4985 | 2114 |
begin |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2115 |
placed:= false; |
10297 | 2116 |
if CheckLuaParamCount(L, 3, 'PlaceGirder', 'x, y, frameIdx') then |
10295 | 2117 |
placed:= TryPlaceOnLandSimple( |
4985 | 2118 |
lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
2119 |
lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
|
2120 |
sprAmGirder, lua_tointeger(L, 3), true, false); |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2121 |
|
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2122 |
lua_pushboolean(L, placed); |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2123 |
lc_placegirder:= 1 |
4985 | 2124 |
end; |
5013 | 2125 |
|
2126 |
function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
|
2127 |
begin |
|
10297 | 2128 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, 'GetCurAmmoType', '')) then |
10291 | 2129 |
lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)) |
2130 |
else |
|
2131 |
lua_pushinteger(L, ord(amNothing)); |
|
5013 | 2132 |
lc_getcurammotype := 1; |
2133 |
end; |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2134 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2135 |
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
|
2136 |
begin |
10297 | 2137 |
if CheckLuaParamCount(L, 2, 'SaveCampaignVar', 'varname, value') then |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2138 |
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
|
2139 |
lc_savecampaignvar := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2140 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2141 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2142 |
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
|
2143 |
begin |
10297 | 2144 |
if CheckLuaParamCount(L, 1, 'GetCampaignVar', 'varname') then |
9718
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9670
diff
changeset
|
2145 |
SendIPCAndWaitReply('V?' + lua_tostring(L, 1) + #0); |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2146 |
lua_pushstring(L, str2pchar(CampaignVariable)); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2147 |
lc_getcampaignvar := 1; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2148 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2149 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2150 |
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
|
2151 |
var gear: PGear; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2152 |
begin |
10297 | 2153 |
if CheckLuaParamCount(L, 1, 'HideHog', 'gearUid') then |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2154 |
begin |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2155 |
gear:= GearByUID(lua_tointeger(L, 1)); |
8012 | 2156 |
HideHog(gear^.hedgehog) |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2157 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2158 |
lc_hidehog := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2159 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2160 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2161 |
function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
8370 | 2162 |
var i, h: LongInt; |
8012 | 2163 |
uid: LongWord; |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2164 |
begin |
10297 | 2165 |
if CheckLuaParamCount(L, 1, 'RestoreHog', 'gearUid') then |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2166 |
begin |
8012 | 2167 |
uid:= LongWord(lua_tointeger(L, 1)); |
2168 |
if TeamsCount > 0 then |
|
2169 |
for i:= 0 to Pred(TeamsCount) do |
|
2170 |
for h:= 0 to cMaxHHIndex do |
|
2171 |
if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
|
2172 |
begin |
|
2173 |
RestoreHog(@TeamsArray[i]^.Hedgehogs[h]); |
|
2174 |
exit(0) |
|
2175 |
end |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2176 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2177 |
lc_restorehog := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2178 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2179 |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2180 |
// boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2181 |
function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2182 |
var rtn: Boolean; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2183 |
begin |
10297 | 2184 |
if CheckLuaParamCount(L, 5, 'TestRectForObstacle', 'x1, y1, x2, y2, landOnly') then |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2185 |
begin |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2186 |
rtn:= TestRectancleForObstacle( |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2187 |
lua_tointeger(L, 1), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2188 |
lua_tointeger(L, 2), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2189 |
lua_tointeger(L, 3), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2190 |
lua_tointeger(L, 4), |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2191 |
lua_toboolean(L, 5) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2192 |
); |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2193 |
lua_pushboolean(L, rtn); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2194 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2195 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2196 |
lua_pushnil(L); // return value on stack (nil) |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2197 |
lc_testrectforobstacle:= 1 |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2198 |
end; |
7996 | 2199 |
|
2200 |
||
9815 | 2201 |
function lc_getgravity(L : Plua_State) : LongInt; Cdecl; |
2202 |
begin |
|
10297 | 2203 |
if CheckLuaParamCount(L, 0, 'GetGravity', '') then |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2204 |
lua_pushinteger(L, hwRound(SignAs(_0_5, cGravity) + (cGravity * 50 / cMaxWindSpeed))); |
9815 | 2205 |
lc_getgravity:= 1 |
2206 |
end; |
|
2207 |
||
2208 |
function lc_setgravity(L : Plua_State) : LongInt; Cdecl; |
|
2209 |
begin |
|
10297 | 2210 |
if CheckLuaParamCount(L, 1, 'SetGravity', 'percent') then |
9815 | 2211 |
begin |
10030
f40fdc566e94
* fix divbyzero found by GetGravity test (cWindSpeed was used where cMaxWindSpeed should have been)
sheepluva
parents:
10009
diff
changeset
|
2212 |
cGravity:= _0_02 * lua_tointeger(L, 1) * cMaxWindSpeed; |
9815 | 2213 |
cGravityf:= 0.00025 * lua_tointeger(L, 1) * 0.02 |
2214 |
end; |
|
2215 |
lc_setgravity:= 0 |
|
2216 |
end; |
|
2217 |
||
9914 | 2218 |
function lc_setwaterline(L : Plua_State) : LongInt; Cdecl; |
2219 |
var iterator: PGear; |
|
2220 |
begin |
|
10297 | 2221 |
if CheckLuaParamCount(L, 1, 'SetWaterLine', 'waterline') then |
9914 | 2222 |
begin |
2223 |
cWaterLine:= lua_tointeger(L,1); |
|
2224 |
AllInactive:= false; |
|
2225 |
iterator:= GearsList; |
|
2226 |
while iterator <> nil do |
|
2227 |
begin |
|
9917 | 2228 |
if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then |
9914 | 2229 |
begin |
2230 |
iterator^.Active:= true; |
|
2231 |
if iterator^.dY.QWordValue = 0 then iterator^.dY.isNegative:= false; |
|
2232 |
iterator^.State:= iterator^.State or gstMoving; |
|
2233 |
DeleteCI(iterator) |
|
2234 |
end; |
|
2235 |
iterator:= iterator^.NextGear |
|
2236 |
end |
|
2237 |
end; |
|
2238 |
lc_setwaterline:= 0 |
|
2239 |
end; |
|
9815 | 2240 |
|
7996 | 2241 |
function lc_setaihintsongear(L : Plua_State) : LongInt; Cdecl; |
2242 |
var gear: PGear; |
|
2243 |
begin |
|
10297 | 2244 |
if CheckLuaParamCount(L, 2, 'SetAIHintOnGear', 'gearUid, aiHints') then |
7996 | 2245 |
begin |
2246 |
gear:= GearByUID(lua_tointeger(L, 1)); |
|
2247 |
if gear <> nil then |
|
2248 |
gear^.aihints:= lua_tointeger(L, 2); |
|
2249 |
end; |
|
2250 |
lc_setaihintsongear:= 0 |
|
2251 |
end; |
|
2252 |
||
8043 | 2253 |
|
2254 |
function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
|
2255 |
begin |
|
10297 | 2256 |
if CheckLuaParamCount(L, 1, 'HedgewarsScriptLoad', 'scriptPath') then |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2257 |
ScriptLoad(lua_tostring(L, 1)) |
8043 | 2258 |
else |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2259 |
lua_pushnil(L); |
8043 | 2260 |
lc_hedgewarsscriptload:= 0; |
2261 |
end; |
|
9397 | 2262 |
|
2263 |
||
2264 |
function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
|
2265 |
begin |
|
10297 | 2266 |
if CheckLuaParamCount(L, 4, 'DeclareAchievement', 'achievementId, teamname, location, value') then |
9409 | 2267 |
declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4)); |
9397 | 2268 |
lc_declareachievement:= 0 |
2269 |
end; |
|
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9987
diff
changeset
|
2270 |
|
10611 | 2271 |
|
2272 |
procedure ScriptFlushPoints(); |
|
2273 |
begin |
|
2274 |
ParseCommand('draw ' + PointsBuffer, true, true); |
|
2275 |
PointsBuffer:= ''; |
|
2276 |
end; |
|
2277 |
||
2278 |
||
2279 |
function lc_addPoint(L : Plua_State) : LongInt; Cdecl; |
|
2280 |
var np, param: integer; |
|
2281 |
begin |
|
10613 | 2282 |
if CheckAndFetchParamCountRange(L, 2, 4, 'AddPoint', 'x, y [, width [, erase] ]', np) then |
10611 | 2283 |
begin |
2284 |
// x |
|
2285 |
param:= lua_tointeger(L,1); |
|
2286 |
PointsBuffer:= PointsBuffer + char((param and $FF00) shr 8); |
|
2287 |
PointsBuffer:= PointsBuffer + char((param and $FF)); |
|
2288 |
// y |
|
2289 |
param:= lua_tointeger(L,2); |
|
2290 |
PointsBuffer:= PointsBuffer + char((param and $FF00) shr 8); |
|
2291 |
PointsBuffer:= PointsBuffer + char((param and $FF)); |
|
2292 |
// width |
|
2293 |
if np > 2 then |
|
2294 |
begin |
|
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
2295 |
param:= lua_tointeger(L,3); |
10611 | 2296 |
param:= (param or $80); |
2297 |
// erase |
|
2298 |
if (np > 3) and lua_toboolean(L, 4) then |
|
2299 |
param:= (param or $40); |
|
2300 |
PointsBuffer:= PointsBuffer + char(param); |
|
2301 |
end |
|
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
2302 |
// no width defined |
10611 | 2303 |
else |
2304 |
PointsBuffer:= PointsBuffer + char(0); |
|
2305 |
||
2306 |
// flush before shortstring limit length is reached |
|
2307 |
if length(PointsBuffer) > 245 then |
|
2308 |
ScriptFlushPoints(); |
|
2309 |
end; |
|
2310 |
lc_addPoint:= 0 |
|
2311 |
end; |
|
2312 |
||
2313 |
||
2314 |
function lc_flushPoints(L : Plua_State) : LongInt; Cdecl; |
|
2315 |
begin |
|
2316 |
if CheckLuaParamCount(L, 0, 'FlushPoints', '') then |
|
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
2317 |
if length(PointsBuffer) > 0 then |
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
2318 |
ScriptFlushPoints(); |
10611 | 2319 |
lc_flushPoints:= 0 |
2320 |
end; |
|
2321 |
||
10618 | 2322 |
// stuff for lua tests |
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9987
diff
changeset
|
2323 |
function lc_endluatest(L : Plua_State) : LongInt; Cdecl; |
10618 | 2324 |
var rstring: shortstring; |
2325 |
const |
|
2326 |
call = 'EndLuaTest'; |
|
2327 |
params = 'TEST_SUCCESSFUL or TEST_FAILED'; |
|
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9987
diff
changeset
|
2328 |
begin |
10618 | 2329 |
if CheckLuaParamCount(L, 1, call, params) then |
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9987
diff
changeset
|
2330 |
begin |
10618 | 2331 |
|
2332 |
case lua_tointeger(L, 1) of |
|
2333 |
HaltTestSuccess : rstring:= 'Success'; |
|
2334 |
HaltTestLuaError: rstring:= 'FAILED'; |
|
2335 |
else |
|
2336 |
begin |
|
2337 |
LuaCallError('Parameter must be either ' + params, call, params); |
|
2338 |
exit(0); |
|
2339 |
end; |
|
2340 |
end; |
|
2341 |
||
2342 |
if cTestLua then |
|
2343 |
begin |
|
2344 |
WriteLnToConsole('Lua test finished, result: ' + rstring); |
|
2345 |
halt(lua_tointeger(L, 1)); |
|
2346 |
end |
|
2347 |
else LuaError('Not in lua test mode, engine will keep running. Reported test result: ' + rstring); |
|
2348 |
||
2349 |
end; |
|
2350 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2351 |
lc_endluatest:= 0; |
9988
317d46a2afd2
simple mechanism to run lua-based test cases. experimental - I will back it out if it turns out to be nonsense
sheepluva
parents:
9987
diff
changeset
|
2352 |
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
|
2353 |
/////////////////// |
3acdb4dac6eb
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 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2355 |
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
|
2356 |
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
|
2357 |
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
|
2358 |
n:= lua_gettop(luaState); |
3539 | 2359 |
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
|
2360 |
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
|
2361 |
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
|
2362 |
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
|
2363 |
else if lua_toboolean(luaState, i) then |
3539 | 2364 |
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
|
2365 |
else |
3539 | 2366 |
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
|
2367 |
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
|
2368 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2369 |
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
|
2370 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2371 |
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
|
2372 |
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
|
2373 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2374 |
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
|
2375 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2376 |
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
|
2377 |
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
|
2378 |
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
|
2379 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2380 |
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
|
2381 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2382 |
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
|
2383 |
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
|
2384 |
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
|
2385 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2386 |
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
|
2387 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2388 |
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
|
2389 |
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
|
2390 |
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
|
2391 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2392 |
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
|
2393 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2394 |
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
|
2395 |
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
|
2396 |
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
|
2397 |
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
|
2398 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2399 |
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
|
2400 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2401 |
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
|
2402 |
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
|
2403 |
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
|
2404 |
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
|
2405 |
|
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2406 |
procedure ScriptOnPreviewInit; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2407 |
begin |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2408 |
// not required if there is no script to run |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2409 |
if not ScriptLoaded then |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2410 |
exit; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2411 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2412 |
ScriptSetString('Seed', cSeed); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2413 |
ScriptSetInteger('TemplateFilter', cTemplateFilter); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2414 |
ScriptSetInteger('TemplateNumber', LuaTemplateNumber); |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
2415 |
ScriptSetInteger('MapGen', ord(cMapGen)); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2416 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2417 |
ScriptCall('onPreviewInit'); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2418 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2419 |
// pop game variables |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2420 |
ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2421 |
cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2422 |
LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
2423 |
cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2424 |
end; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2425 |
|
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
|
2426 |
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
|
2427 |
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
|
2428 |
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
|
2429 |
// 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
|
2430 |
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
|
2431 |
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
|
2432 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2433 |
// push game variables so they may be modified by the script |
6982 | 2434 |
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
|
2435 |
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
|
2436 |
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
|
2437 |
ScriptSetInteger('TemplateFilter', cTemplateFilter); |
7567 | 2438 |
ScriptSetInteger('TemplateNumber', LuaTemplateNumber); |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
2439 |
ScriptSetInteger('MapGen', ord(cMapGen)); |
5583
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
2440 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
2441 |
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
|
2442 |
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
|
2443 |
ScriptSetInteger('CaseFreq', cCaseFactor); |
4162 | 2444 |
ScriptSetInteger('HealthCaseProb', cHealthCaseProb); |
2445 |
ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount); |
|
4221 | 2446 |
ScriptSetInteger('DamagePercent', cDamagePercent); |
6557 | 2447 |
ScriptSetInteger('RopePercent', cRopePercent); |
4003
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
3999
diff
changeset
|
2448 |
ScriptSetInteger('MinesNum', cLandMines); |
4221 | 2449 |
ScriptSetInteger('MinesTime', cMinesTime); |
2450 |
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
|
2451 |
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
|
2452 |
ScriptSetInteger('Delay', cInactDelay); |
3774 | 2453 |
ScriptSetInteger('Ready', cReadyDelay); |
3197 | 2454 |
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
4162 | 2455 |
ScriptSetInteger('WaterRise', cWaterRise); |
2456 |
ScriptSetInteger('HealthDecrease', cHealthDecrease); |
|
9836 | 2457 |
ScriptSetInteger('GetAwayTime', cGetAwayTime); |
6828
6a5d33bff0b0
At mikade's request. give scripting access to the map name prior to override.
nemo
parents:
6790
diff
changeset
|
2458 |
ScriptSetString('Map', cMapName); |
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
|
2459 |
ScriptSetString('Theme', ''); |
4883
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
2460 |
ScriptSetString('Goals', ''); |
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
2461 |
|
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
|
2462 |
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
|
2463 |
|
3acdb4dac6eb
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 |
// pop game variables |
7805 | 2465 |
ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2466 |
cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
7567 | 2467 |
LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
2468 |
cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2469 |
GameFlags := ScriptGetInteger('GameFlags'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2470 |
cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2471 |
cCaseFactor := ScriptGetInteger('CaseFreq'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2472 |
cHealthCaseProb := ScriptGetInteger('HealthCaseProb'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2473 |
cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2474 |
cDamagePercent := ScriptGetInteger('DamagePercent'); |
6523 | 2475 |
cRopePercent := ScriptGetInteger('RopePercent'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2476 |
cLandMines := ScriptGetInteger('MinesNum'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2477 |
cMinesTime := ScriptGetInteger('MinesTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2478 |
cMineDudPercent := ScriptGetInteger('MineDudPercent'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2479 |
cExplosives := ScriptGetInteger('Explosives'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2480 |
cInactDelay := ScriptGetInteger('Delay'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2481 |
cReadyDelay := ScriptGetInteger('Ready'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2482 |
cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2483 |
cWaterRise := ScriptGetInteger('WaterRise'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2484 |
cHealthDecrease := ScriptGetInteger('HealthDecrease'); |
9836 | 2485 |
cGetAwayTime := ScriptGetInteger('GetAwayTime'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
2486 |
|
7771 | 2487 |
if cMapName <> ScriptGetString('Map') then |
7805 | 2488 |
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
|
2489 |
if ScriptGetString('Theme') <> '' then |
7805 | 2490 |
ParseCommand('theme ' + ScriptGetString('Theme'), true, true); |
4883
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
2491 |
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
|
2492 |
|
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
2493 |
// 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
|
2494 |
k:= 0; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
2495 |
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
|
2496 |
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
|
2497 |
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
|
2498 |
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
|
2499 |
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
|
2500 |
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
|
2501 |
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
|
2502 |
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
|
2503 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
2504 |
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
|
2505 |
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
|
2506 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
2507 |
end |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2508 |
else |
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
2509 |
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
|
2510 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
2511 |
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
|
2512 |
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
|
2513 |
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
|
2514 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
2515 |
end; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
2516 |
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
|
2517 |
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
|
2518 |
// 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
|
2519 |
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
|
2520 |
uAmmos.initModule; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
2521 |
if ScriptExists('onAmmoStoreInit') then |
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
2522 |
begin |
6752 | 2523 |
ScriptPrepareAmmoStore; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
2524 |
ScriptCall('onAmmoStoreInit'); |
6746 | 2525 |
SetAmmoLoadout(ScriptAmmoLoadout); |
2526 |
SetAmmoProbability(ScriptAmmoProbability); |
|
2527 |
SetAmmoDelay(ScriptAmmoDelay); |
|
2528 |
SetAmmoReinforcement(ScriptAmmoReinforcement) |
|
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
2529 |
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
|
2530 |
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
|
2531 |
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
|
2532 |
|
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
2533 |
ScriptSetInteger('ClansCount', ClansCount); |
9567
42bc1b58a242
This test is intended to avoid repeatedly calling 5 ScriptSetIntegers each script call, that won't ever change after the map is created.
nemo
parents:
9531
diff
changeset
|
2534 |
ScriptSetInteger('TeamsCount', TeamsCount); |
42bc1b58a242
This test is intended to avoid repeatedly calling 5 ScriptSetIntegers each script call, that won't ever change after the map is created.
nemo
parents:
9531
diff
changeset
|
2535 |
mapDims:= 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
|
2536 |
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
|
2537 |
|
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2538 |
|
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2539 |
// 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
|
2540 |
procedure ScriptOnScreenResize(); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2541 |
begin |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2542 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2543 |
ScriptSetInteger('ScreenWidth', cScreenWidth); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2544 |
ScriptCall('onScreenResize'); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2545 |
end; |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2546 |
|
8031 | 2547 |
// custom script loader via physfs, passed to lua_load |
8034 | 2548 |
const BUFSIZE = 1024; |
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
2549 |
|
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
|
2550 |
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
|
2551 |
var ret : LongInt; |
5243 | 2552 |
s : shortstring; |
8031 | 2553 |
f : PFSFile; |
8034 | 2554 |
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
|
2555 |
begin |
8031 | 2556 |
s:= cPathz[ptData] + name; |
2557 |
if not pfsExists(s) then |
|
9531
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
2558 |
begin |
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
2559 |
AddFileLog('[LUA] Script not found: ' + name); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2560 |
exit; |
9531
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
2561 |
end; |
6088 | 2562 |
|
8031 | 2563 |
f:= pfsOpenRead(s); |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2564 |
if f = nil then |
8031 | 2565 |
exit; |
2566 |
||
8073 | 2567 |
physfsReaderSetBuffer(@buf); |
8031 | 2568 |
ret:= lua_load(luaState, @physfsReader, f, Str2PChar(s)); |
2569 |
pfsClose(f); |
|
2570 |
||
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
|
2571 |
if ret <> 0 then |
3774 | 2572 |
begin |
10312 | 2573 |
LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
2574 |
LuaError(lua_tostring(luaState, -1)); |
|
3774 | 2575 |
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
|
2576 |
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
|
2577 |
begin |
3539 | 2578 |
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
|
2579 |
// 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
|
2580 |
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
|
2581 |
ScriptLoaded:= true |
8978
e6ef8fe314bd
suggestion of unc0rr's to fix issue w/ random maps in campaign. load sidecar packages in physfs for lua. should be useful also for lua that does custom layouts
nemo
parents:
8473
diff
changeset
|
2582 |
end; |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
2583 |
hedgewarsMountPackage(Str2PChar(copy(s, 1, length(s)-4)+'.hwp')); |
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
|
2584 |
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
|
2585 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2586 |
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
|
2587 |
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
|
2588 |
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
3761 | 2589 |
ScriptSetInteger('GameTime', GameTicks); |
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
2590 |
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
|
2591 |
ScriptSetInteger('WaterLine', cWaterLine); |
9567
42bc1b58a242
This test is intended to avoid repeatedly calling 5 ScriptSetIntegers each script call, that won't ever change after the map is created.
nemo
parents:
9531
diff
changeset
|
2592 |
if not mapDims then |
7650 | 2593 |
begin |
9567
42bc1b58a242
This test is intended to avoid repeatedly calling 5 ScriptSetIntegers each script call, that won't ever change after the map is created.
nemo
parents:
9531
diff
changeset
|
2594 |
mapDims:= true; |
7650 | 2595 |
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
2596 |
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
|
2597 |
ScriptSetInteger('LeftX', leftX); |
|
2598 |
ScriptSetInteger('RightX', rightX); |
|
2599 |
ScriptSetInteger('TopY', topY) |
|
2600 |
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
|
2601 |
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
|
2602 |
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
|
2603 |
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
|
2604 |
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
|
2605 |
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
|
2606 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2607 |
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
|
2608 |
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
|
2609 |
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
|
2610 |
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
|
2611 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2612 |
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
|
2613 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8012
diff
changeset
|
2614 |
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
|
2615 |
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
|
2616 |
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
|
2617 |
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
|
2618 |
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
|
2619 |
begin |
10312 | 2620 |
LuaError('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
|
2621 |
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
|
2622 |
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
|
2623 |
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
|
2624 |
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
|
2625 |
|
7805 | 2626 |
(* |
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
|
2627 |
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
|
2628 |
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
|
2629 |
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
|
2630 |
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
|
2631 |
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
|
2632 |
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
|
2633 |
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
|
2634 |
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
|
2635 |
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
|
2636 |
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
|
2637 |
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
|
2638 |
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
|
2639 |
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
|
2640 |
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
|
2641 |
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
|
2642 |
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
|
2643 |
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
|
2644 |
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
|
2645 |
end; |
7805 | 2646 |
*) |
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
|
2647 |
|
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
|
2648 |
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
|
2649 |
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
|
2650 |
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
|
2651 |
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
|
2652 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2653 |
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
|
2654 |
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
|
2655 |
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
|
2656 |
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
|
2657 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2658 |
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
|
2659 |
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
|
2660 |
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
|
2661 |
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
|
2662 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2663 |
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
|
2664 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8012
diff
changeset
|
2665 |
if (not ScriptLoaded) or (not ScriptExists(fname)) then |
10560 | 2666 |
exit(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
|
2667 |
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
|
2668 |
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
|
2669 |
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
|
2670 |
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
|
2671 |
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
|
2672 |
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
|
2673 |
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
|
2674 |
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
|
2675 |
begin |
10312 | 2676 |
LuaError('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
|
2677 |
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
|
2678 |
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
|
2679 |
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
|
2680 |
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
|
2681 |
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
|
2682 |
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
|
2683 |
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
|
2684 |
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
|
2685 |
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
|
2686 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2687 |
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
|
2688 |
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
|
2689 |
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
|
2690 |
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
|
2691 |
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
|
2692 |
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
|
2693 |
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
|
2694 |
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
|
2695 |
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
|
2696 |
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
|
2697 |
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
|
2698 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2699 |
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
|
2700 |
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
|
2701 |
begin |
3346 | 2702 |
ScriptAmmoLoadout:= ''; |
2703 |
ScriptAmmoDelay:= ''; |
|
2704 |
ScriptAmmoProbability:= ''; |
|
2705 |
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
|
2706 |
for i:=1 to ord(High(TAmmoType)) do |
3346 | 2707 |
begin |
2708 |
ScriptAmmoLoadout:= ScriptAmmoLoadout + '0'; |
|
2709 |
ScriptAmmoProbability:= ScriptAmmoProbability + '0'; |
|
2710 |
ScriptAmmoDelay:= ScriptAmmoDelay + '0'; |
|
2711 |
ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0'; |
|
2712 |
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
|
2713 |
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
|
2714 |
|
9750 | 2715 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, 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
|
2716 |
begin |
9750 | 2717 |
//if (ord(ammo) < 1) or (count > 9) or (count < 0) or (probability < 0) or (probability > 8) or (delay < 0) or (delay > 9) or (reinforcement < 0) or (reinforcement > 8) then |
2718 |
if (ord(ammo) < 1) or (count > 9) or (probability > 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
|
2719 |
exit; |
3346 | 2720 |
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1]; |
9750 | 2721 |
ScriptAmmoProbability[ord(ammo)]:= inttostr(probability)[1]; |
9751
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2722 |
ScriptSetAmmoDelay(ammo, delay); |
3346 | 2723 |
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
|
2724 |
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
|
2725 |
|
9751
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2726 |
procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: Byte); |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2727 |
begin |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2728 |
// change loadout string if ammo store hasn't been initialized yet |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2729 |
if (StoreCnt = 0) then |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2730 |
begin |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2731 |
if (delay <= 9) then |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2732 |
ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1]; |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2733 |
end |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2734 |
// change "live" delay values |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2735 |
else if (CurrentTeam <> nil) then |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2736 |
ammoz[ammo].SkipTurns:= CurrentTeam^.Clan^.TurnNumber + delay; |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2737 |
end; |
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2738 |
|
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
|
2739 |
procedure ScriptApplyAmmoStore; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2740 |
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
|
2741 |
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
|
2742 |
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
|
2743 |
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
|
2744 |
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
|
2745 |
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
|
2746 |
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
|
2747 |
ScriptPrepareAmmoStore; |
6746 | 2748 |
ScriptCall('onNewAmmoStore',i,-1); |
2749 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
2750 |
SetAmmoProbability(ScriptAmmoProbability); |
|
2751 |
SetAmmoDelay(ScriptAmmoDelay); |
|
2752 |
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
|
2753 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2754 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2755 |
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
|
2756 |
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
|
2757 |
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
|
2758 |
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
|
2759 |
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
|
2760 |
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
|
2761 |
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
|
2762 |
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
|
2763 |
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
|
2764 |
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
|
2765 |
ScriptPrepareAmmoStore; |
6746 | 2766 |
ScriptCall('onNewAmmoStore',i,j); |
2767 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
2768 |
SetAmmoProbability(ScriptAmmoProbability); |
|
2769 |
SetAmmoDelay(ScriptAmmoDelay); |
|
2770 |
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
|
2771 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2772 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2773 |
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
|
2774 |
end |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2775 |
else |
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
|
2776 |
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
|
2777 |
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
|
2778 |
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
|
2779 |
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
|
2780 |
ScriptPrepareAmmoStore; |
6746 | 2781 |
ScriptCall('onNewAmmoStore',i,-1); |
2782 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
2783 |
SetAmmoProbability(ScriptAmmoProbability); |
|
2784 |
SetAmmoDelay(ScriptAmmoDelay); |
|
2785 |
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
|
2786 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2787 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
2788 |
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
|
2789 |
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
|
2790 |
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
|
2791 |
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
|
2792 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2793 |
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
|
2794 |
var at : TGearType; |
4453 | 2795 |
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
|
2796 |
am : TAmmoType; |
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
2797 |
si : TStatInfoType; |
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
|
2798 |
st : TSound; |
5118 | 2799 |
he : THogEffect; |
2800 |
cg : TCapGroup; |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2801 |
spr: TSprite; |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
2802 |
mg : TMapGen; |
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
|
2803 |
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
|
2804 |
// initialize lua |
10239 | 2805 |
luaState:= lua_open; |
2806 |
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
|
2807 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2808 |
// open internal libraries |
10239 | 2809 |
luaopen_base(luaState); |
2810 |
luaopen_string(luaState); |
|
2811 |
luaopen_math(luaState); |
|
2812 |
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
|
2813 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2814 |
// import some variables |
7072 | 2815 |
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
|
2816 |
|
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
|
2817 |
// 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
|
2818 |
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
|
2819 |
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
|
2820 |
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
|
2821 |
ScriptSetInteger('gfBorder', gfBorder); |
8980
37f4cdd9cd2c
don't draw a border if there's already a bottom border, avoid placing objects over gaps in the floor
nemo
parents:
8978
diff
changeset
|
2822 |
ScriptSetInteger('gfBottomBorder', gfBottomBorder); |
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
|
2823 |
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
|
2824 |
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
|
2825 |
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
|
2826 |
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
|
2827 |
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
|
2828 |
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
|
2829 |
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
|
2830 |
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
|
2831 |
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
|
2832 |
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
|
2833 |
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
|
2834 |
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
|
2835 |
ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
4162 | 2836 |
ScriptSetInteger('gfDisableLandObjects', gfDisableLandObjects); |
2837 |
ScriptSetInteger('gfAISurvival', gfAISurvival); |
|
2838 |
ScriptSetInteger('gfInfAttack', gfInfAttack); |
|
2839 |
ScriptSetInteger('gfResetWeps', gfResetWeps); |
|
2840 |
ScriptSetInteger('gfPerHogAmmo', gfPerHogAmmo); |
|
4219 | 2841 |
ScriptSetInteger('gfDisableWind', gfDisableWind); |
4319 | 2842 |
ScriptSetInteger('gfMoreWind', gfMoreWind); |
5016
9347d82a26cc
added game mode Tag Team, mostly untested, please test :)
Henek
parents:
5013
diff
changeset
|
2843 |
ScriptSetInteger('gfTagTeam', gfTagTeam); |
9387 | 2844 |
ScriptSetInteger('gfShoppaBorder', gfShoppaBorder); |
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
|
2845 |
|
3894 | 2846 |
ScriptSetInteger('gmLeft', gmLeft); |
2847 |
ScriptSetInteger('gmRight', gmRight); |
|
2848 |
ScriptSetInteger('gmUp', gmUp); |
|
2849 |
ScriptSetInteger('gmDown', gmDown); |
|
2850 |
ScriptSetInteger('gmSwitch', gmSwitch); |
|
2851 |
ScriptSetInteger('gmAttack', gmAttack); |
|
2852 |
ScriptSetInteger('gmLJump', gmLJump); |
|
2853 |
ScriptSetInteger('gmHJump', gmHJump); |
|
2854 |
ScriptSetInteger('gmDestroy', gmDestroy); |
|
2855 |
ScriptSetInteger('gmSlot', gmSlot); |
|
2856 |
ScriptSetInteger('gmWeapon', gmWeapon); |
|
2857 |
ScriptSetInteger('gmTimer', gmTimer); |
|
2858 |
ScriptSetInteger('gmAnimate', gmAnimate); |
|
2859 |
ScriptSetInteger('gmPrecise', gmPrecise); |
|
3892 | 2860 |
ScriptSetInteger('gmAllStoppable', gmAllStoppable); |
2861 |
||
3761 | 2862 |
// speech bubbles |
2863 |
ScriptSetInteger('SAY_SAY', 1); |
|
2864 |
ScriptSetInteger('SAY_THINK', 2); |
|
2865 |
ScriptSetInteger('SAY_SHOUT', 3); |
|
2866 |
||
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
|
2867 |
// 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
|
2868 |
for at:= Low(TGearType) to High(TGearType) do |
3337 | 2869 |
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
|
2870 |
|
4453 | 2871 |
for vgt:= Low(TVisualGearType) to High(TVisualGearType) do |
2872 |
ScriptSetInteger(EnumToStr(vgt), ord(vgt)); |
|
2873 |
||
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
|
2874 |
// 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
|
2875 |
for st:= Low(TSound) to High(TSound) do |
3337 | 2876 |
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
|
2877 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2878 |
// 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
|
2879 |
for am:= Low(TAmmoType) to High(TAmmoType) do |
3337 | 2880 |
ScriptSetInteger(EnumToStr(am), ord(am)); |
3697 | 2881 |
|
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
2882 |
for si:= Low(TStatInfoType) to High(TStatInfoType) do |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
2883 |
ScriptSetInteger(EnumToStr(si), ord(si)); |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
2884 |
|
3756 | 2885 |
for he:= Low(THogEffect) to High(THogEffect) do |
2886 |
ScriptSetInteger(EnumToStr(he), ord(he)); |
|
2887 |
||
5118 | 2888 |
for cg:= Low(TCapGroup) to High(TCapGroup) do |
2889 |
ScriptSetInteger(EnumToStr(cg), ord(cg)); |
|
2890 |
||
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2891 |
for spr:= Low(TSprite) to High(TSprite) do |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2892 |
ScriptSetInteger(EnumToStr(spr), ord(spr)); |
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2893 |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
2894 |
for mg:= Low(TMapGen) to High(TMapGen) do |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
2895 |
ScriptSetInteger(EnumToStr(mg), ord(mg)); |
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
2896 |
|
10289 | 2897 |
ScriptSetInteger('gstDrowning' , gstDrowning); |
2898 |
ScriptSetInteger('gstHHDriven' , gstHHDriven); |
|
2899 |
ScriptSetInteger('gstMoving' , gstMoving); |
|
2900 |
ScriptSetInteger('gstAttacked' , gstAttacked); |
|
2901 |
ScriptSetInteger('gstAttacking' , gstAttacking); |
|
2902 |
ScriptSetInteger('gstCollision' , gstCollision); |
|
2903 |
ScriptSetInteger('gstHHChooseTarget', gstHHChooseTarget); |
|
2904 |
ScriptSetInteger('gstHHJumping' , gstHHJumping); |
|
2905 |
ScriptSetInteger('gsttmpFlag' , gsttmpFlag); |
|
2906 |
ScriptSetInteger('gstHHThinking' , gstHHThinking); |
|
2907 |
ScriptSetInteger('gstNoDamage' , gstNoDamage); |
|
2908 |
ScriptSetInteger('gstHHHJump' , gstHHHJump); |
|
2909 |
ScriptSetInteger('gstAnimation' , gstAnimation); |
|
2910 |
ScriptSetInteger('gstHHDeath' , gstHHDeath); |
|
2911 |
ScriptSetInteger('gstWinner' , gstWinner); |
|
2912 |
ScriptSetInteger('gstWait' , gstWait); |
|
2913 |
ScriptSetInteger('gstNotKickable' , gstNotKickable); |
|
2914 |
ScriptSetInteger('gstLoser' , gstLoser); |
|
2915 |
ScriptSetInteger('gstHHGone' , gstHHGone); |
|
2916 |
ScriptSetInteger('gstInvisible' , gstInvisible); |
|
5527 | 2917 |
|
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8077
diff
changeset
|
2918 |
// ai hints |
10289 | 2919 |
ScriptSetInteger('aihUsualProcessing', aihUsualProcessing); |
2920 |
ScriptSetInteger('aihDoesntMatter' , aihDoesntMatter); |
|
7996 | 2921 |
|
10283 | 2922 |
// land flags |
2923 |
ScriptSetInteger('lfIndestructible', lfIndestructible); |
|
10421 | 2924 |
ScriptSetInteger('lfIce' , lfIce); |
2925 |
ScriptSetInteger('lfBouncy' , lfBouncy); |
|
2926 |
||
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
|
2927 |
// register functions |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2928 |
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
|
2929 |
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
|
2930 |
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
|
2931 |
lua_register(luaState, _P'GetCampaignVar', @lc_getcampaignvar); |
7072 | 2932 |
lua_register(luaState, _P'band', @lc_band); |
2933 |
lua_register(luaState, _P'bor', @lc_bor); |
|
2934 |
lua_register(luaState, _P'bnot', @lc_bnot); |
|
2935 |
lua_register(luaState, _P'div', @lc_div); |
|
2936 |
lua_register(luaState, _P'GetInputMask', @lc_getinputmask); |
|
2937 |
lua_register(luaState, _P'SetInputMask', @lc_setinputmask); |
|
2938 |
lua_register(luaState, _P'AddGear', @lc_addgear); |
|
10290 | 2939 |
lua_register(luaState, _P'DismissTeam', @lc_dismissteam); |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
2940 |
lua_register(luaState, _P'EnableGameFlags', @lc_enablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
2941 |
lua_register(luaState, _P'DisableGameFlags', @lc_disablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
2942 |
lua_register(luaState, _P'ClearGameFlags', @lc_cleargameflags); |
10035 | 2943 |
lua_register(luaState, _P'GetGameFlag', @lc_getgameflag); |
7072 | 2944 |
lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
2945 |
lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
|
2946 |
lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
|
2947 |
lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
|
2948 |
lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); |
|
2949 |
lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
|
2950 |
lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
|
2951 |
lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
|
2952 |
lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
|
2953 |
lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
|
2954 |
lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); |
|
2955 |
lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
|
2956 |
lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
|
2957 |
lua_register(luaState, _P'EndGame', @lc_endgame); |
|
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2958 |
lua_register(luaState, _P'SendStat', @lc_sendstat); |
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
2959 |
lua_register(luaState, _P'SendHealthStatsOff', @lc_sendhealthstatsoff); |
7072 | 2960 |
lua_register(luaState, _P'FindPlace', @lc_findplace); |
2961 |
lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
|
2962 |
lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
|
2963 |
lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
|
2964 |
lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget); |
|
2965 |
lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity); |
|
2966 |
lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity); |
|
2967 |
lua_register(luaState, _P'ParseCommand', @lc_parsecommand); |
|
2968 |
lua_register(luaState, _P'ShowMission', @lc_showmission); |
|
2969 |
lua_register(luaState, _P'HideMission', @lc_hidemission); |
|
2970 |
lua_register(luaState, _P'AddCaption', @lc_addcaption); |
|
2971 |
lua_register(luaState, _P'SetAmmo', @lc_setammo); |
|
9751
7a6038c3faa2
lua call SetAmmoDelay(ammotype, delay). note: as the engine does not yet support per-clan/team/hog ammo delay values, lua scripters will have to keep track of individual delays and set them accordingly before a hedgehog's turn (if they want usage cool-down behavior)
sheepluva
parents:
9750
diff
changeset
|
2972 |
lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay); |
7072 | 2973 |
lua_register(luaState, _P'SetAmmoStore', @lc_setammostore); |
2974 |
lua_register(luaState, _P'PlaySound', @lc_playsound); |
|
2975 |
lua_register(luaState, _P'AddTeam', @lc_addteam); |
|
2976 |
lua_register(luaState, _P'AddHog', @lc_addhog); |
|
2977 |
lua_register(luaState, _P'AddAmmo', @lc_addammo); |
|
2978 |
lua_register(luaState, _P'GetAmmoCount', @lc_getammocount); |
|
2979 |
lua_register(luaState, _P'SetHealth', @lc_sethealth); |
|
2980 |
lua_register(luaState, _P'GetHealth', @lc_gethealth); |
|
2981 |
lua_register(luaState, _P'SetEffect', @lc_seteffect); |
|
2982 |
lua_register(luaState, _P'GetEffect', @lc_geteffect); |
|
2983 |
lua_register(luaState, _P'GetHogClan', @lc_gethogclan); |
|
2984 |
lua_register(luaState, _P'GetClanColor', @lc_getclancolor); |
|
2985 |
lua_register(luaState, _P'SetClanColor', @lc_setclancolor); |
|
2986 |
lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname); |
|
9788 | 2987 |
lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname); |
7072 | 2988 |
lua_register(luaState, _P'GetHogName', @lc_gethogname); |
2989 |
lua_register(luaState, _P'SetHogName', @lc_sethogname); |
|
2990 |
lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel); |
|
2991 |
lua_register(luaState, _P'SetHogLevel', @lc_sethoglevel); |
|
2992 |
lua_register(luaState, _P'GetX', @lc_getx); |
|
2993 |
lua_register(luaState, _P'GetY', @lc_gety); |
|
2994 |
lua_register(luaState, _P'CopyPV', @lc_copypv); |
|
2995 |
lua_register(luaState, _P'FollowGear', @lc_followgear); |
|
2996 |
lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear); |
|
2997 |
lua_register(luaState, _P'SetState', @lc_setstate); |
|
2998 |
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
|
2999 |
lua_register(luaState, _P'GetTag', @lc_gettag); |
7072 | 3000 |
lua_register(luaState, _P'SetTag', @lc_settag); |
3001 |
lua_register(luaState, _P'SetTimer', @lc_settimer); |
|
3002 |
lua_register(luaState, _P'GetTimer', @lc_gettimer); |
|
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
3003 |
lua_register(luaState, _P'SetFlightTime', @lc_setflighttime); |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
3004 |
lua_register(luaState, _P'GetFlightTime', @lc_getflighttime); |
7072 | 3005 |
lua_register(luaState, _P'SetZoom', @lc_setzoom); |
3006 |
lua_register(luaState, _P'GetZoom', @lc_getzoom); |
|
3007 |
lua_register(luaState, _P'HogSay', @lc_hogsay); |
|
3008 |
lua_register(luaState, _P'SwitchHog', @lc_switchhog); |
|
3009 |
lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
|
3010 |
lua_register(luaState, _P'CampaignLock', @lc_campaignlock); |
|
3011 |
lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock); |
|
3012 |
lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); |
|
3013 |
lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
|
3014 |
lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
|
3015 |
lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
|
3016 |
lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |
|
3017 |
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
|
3018 |
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
|
3019 |
lua_register(luaState, _P'SetGearCollisionMask', @lc_setgearcollisionmask); |
7072 | 3020 |
lua_register(luaState, _P'GetRandom', @lc_getrandom); |
3021 |
lua_register(luaState, _P'SetWind', @lc_setwind); |
|
3022 |
lua_register(luaState, _P'GetDataPath', @lc_getdatapath); |
|
3023 |
lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath); |
|
3024 |
lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
|
3025 |
lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
|
3026 |
lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
|
10280
762c256552e9
WIP: PlaceSprite for lua API. also changed PlaceGirder so that it will return true/false for whether placing was successful too
sheepluva
parents:
10279
diff
changeset
|
3027 |
lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
7072 | 3028 |
lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
3029 |
lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
|
3030 |
lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
|
9815 | 3031 |
lua_register(luaState, _P'GetGravity', @lc_getgravity); |
3032 |
lua_register(luaState, _P'SetGravity', @lc_setgravity); |
|
9914 | 3033 |
lua_register(luaState, _P'SetWaterLine', @lc_setwaterline); |
10291 | 3034 |
lua_register(luaState, _P'SetNextWeapon', @lc_setnextweapon); |
10289 | 3035 |
lua_register(luaState, _P'SetWeapon', @lc_setweapon); |
10611 | 3036 |
// drawn map functions |
3037 |
lua_register(luaState, _P'AddPoint', @lc_addPoint); |
|
3038 |
lua_register(luaState, _P'FlushPoints', @lc_flushPoints); |
|
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
|
3039 |
|
7996 | 3040 |
lua_register(luaState, _P'SetGearAIHints', @lc_setaihintsongear); |
8043 | 3041 |
lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload); |
9397 | 3042 |
lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement); |
7996 | 3043 |
|
10618 | 3044 |
ScriptSetInteger('TEST_SUCCESSFUL' , HaltTestSuccess); |
3045 |
ScriptSetInteger('TEST_FAILED' , HaltTestFailed); |
|
3046 |
lua_register(luaState, _P'EndLuaTest', @lc_endluatest); |
|
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
|
3047 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3048 |
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
|
3049 |
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
|
3050 |
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
|
3051 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3052 |
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
|
3053 |
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
|
3054 |
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
|
3055 |
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
|
3056 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3057 |
{$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
|
3058 |
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
|
3059 |
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
|
3060 |
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
|
3061 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3062 |
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
|
3063 |
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
|
3064 |
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
|
3065 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3066 |
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
|
3067 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3068 |
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
|
3069 |
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
|
3070 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3071 |
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
|
3072 |
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
|
3073 |
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
|
3074 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3075 |
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
|
3076 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3077 |
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
|
3078 |
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
|
3079 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3080 |
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
|
3081 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3082 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3083 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3084 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3085 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3086 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3087 |
par4:= par4; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3088 |
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
|
3089 |
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
|
3090 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3091 |
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
|
3092 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3093 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3094 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3095 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3096 |
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
|
3097 |
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
|
3098 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3099 |
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
|
3100 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3101 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3102 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3103 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3104 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3105 |
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
|
3106 |
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
|
3107 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3108 |
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
|
3109 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3110 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3111 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3112 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3113 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3114 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3115 |
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
|
3116 |
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
|
3117 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3118 |
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
|
3119 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3120 |
fname:= fname; // avoid hint |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3121 |
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
|
3122 |
end; |
7805 | 3123 |
(* |
5410 | 3124 |
function ParseCommandOverride(key, value : shortstring) : shortstring; |
3125 |
begin |
|
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3126 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3127 |
key:= key; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3128 |
value:= value; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
3129 |
ParseCommandOverride:= '' |
5410 | 3130 |
end; |
7805 | 3131 |
*) |
5410 | 3132 |
|
6430 | 3133 |
procedure ScriptOnScreenResize; |
3134 |
begin |
|
3135 |
end; |
|
3136 |
||
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
|
3137 |
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
|
3138 |
begin |
9567
42bc1b58a242
This test is intended to avoid repeatedly calling 5 ScriptSetIntegers each script call, that won't ever change after the map is created.
nemo
parents:
9531
diff
changeset
|
3139 |
mapDims:= false; |
10611 | 3140 |
PointsBuffer:= ''; |
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
|
3141 |
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
|
3142 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3143 |
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
|
3144 |
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
|
3145 |
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
|
3146 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3147 |
{$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
|
3148 |
end. |