author | Wuzzy <Wuzzy2@mail.ru> |
Wed, 08 Aug 2018 18:36:12 +0200 | |
changeset 13649 | 1b536e268519 |
parent 13647 | 3d14950641a4 |
child 13656 | 56a925256039 |
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 |
11046 | 3 |
* Copyright (c) 2004-2015 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 |
* |
|
12112
0695302f3f5f
Fix ScriptExists() destroying lua stack (fixes Bug #146)
sheepluva
parents:
12095
diff
changeset
|
26 |
* Please keep https://hedgewars.org/kb/LuaAPI up to date! |
5124 | 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 |
9205
abce6011f86c
aaaaand let's not forget about lua, which has also a slightly revised build process
koda
parents:
9180
diff
changeset
|
59 |
|
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6430
diff
changeset
|
60 |
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
|
61 |
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
|
62 |
uConsts, |
6543 | 63 |
uGears, |
6468 | 64 |
uGearsList, |
6543 | 65 |
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
|
66 |
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
|
67 |
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
|
68 |
uAmmos, |
6763 | 69 |
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
|
70 |
uSound, |
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
71 |
uChat, |
4243 | 72 |
uStats, |
4875 | 73 |
uStore, |
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
4319
diff
changeset
|
74 |
uRandom, |
4359 | 75 |
uTypes, |
4373 | 76 |
uVariables, |
4374 | 77 |
uCommands, |
4403 | 78 |
uCaptions, |
4832 | 79 |
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
|
80 |
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
|
81 |
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
|
82 |
uTextures, |
4985 | 83 |
uLandGraphics, |
11826 | 84 |
uUtils, |
8031 | 85 |
uIO, |
9283
76e68c136a11
Refactoring: VGSHandlers.inc -> uVisualGearsHandlers.pas
unc0rr
parents:
9245
diff
changeset
|
86 |
uVisualGearsList, |
9285 | 87 |
uGearsHandlersMess, |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
88 |
uPhysFSLayer, |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
89 |
SDLh |
10129
cd2a64a1f4aa
- Pas2C: make use of 'external' function decorator
unc0rr
parents:
10127
diff
changeset
|
90 |
{$IFNDEF PAS2C} |
9952
32f5982604f4
Fix build (no idea what's going on in this branch btw)
unc0rr
parents:
9950
diff
changeset
|
91 |
, 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
|
92 |
{$ENDIF} |
8031 | 93 |
; |
3697 | 94 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
95 |
var luaState : Plua_State; |
3346 | 96 |
ScriptAmmoLoadout : shortstring; |
97 |
ScriptAmmoProbability : shortstring; |
|
98 |
ScriptAmmoDelay : shortstring; |
|
99 |
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
|
100 |
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
|
101 |
mapDims : boolean; |
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
102 |
PointsBuffer: shortstring; |
13221
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
103 |
PrevCursorX, PrevCursorY: LongInt; |
3697 | 104 |
|
11683
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
105 |
{$IFDEF USE_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
|
106 |
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
|
107 |
procedure ScriptApplyAmmoStore; forward; |
9750 | 108 |
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
|
109 |
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
|
110 |
|
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
111 |
var LuaDebugInfo: lua_Debug; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
112 |
|
10617 | 113 |
procedure SetGlobals; forward; |
10312 | 114 |
procedure LuaParseString(s: shortString); |
115 |
begin |
|
10617 | 116 |
SetGlobals; |
10312 | 117 |
AddFileLog('[Lua] input string: ' + s); |
118 |
AddChatString(#3 + '[Lua] > ' + s); |
|
119 |
if luaL_dostring(luaState, Str2PChar(s)) <> 0 then |
|
120 |
begin |
|
121 |
AddFileLog('[Lua] input string parsing error!'); |
|
122 |
AddChatString(#5 + '[Lua] Error while parsing!'); |
|
123 |
end; |
|
124 |
end; |
|
125 |
||
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
126 |
function LuaUpdateDebugInfo(): Boolean; |
3539 | 127 |
begin |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
128 |
FillChar(LuaDebugInfo, sizeof(LuaDebugInfo), 0); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
129 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
130 |
if lua_getstack(luaState, 1, @LuaDebugInfo) = 0 then |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
131 |
exit(false); // stack not deep enough |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
132 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
133 |
// get source name and line count |
10297 | 134 |
lua_getinfo(luaState, PChar('Sl'), @LuaDebugInfo); |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
135 |
exit(true); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
136 |
end; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
137 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
138 |
procedure LuaError(s: shortstring); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
139 |
var src: shortstring; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
140 |
const |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
141 |
maxsrclen = 20; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
142 |
begin |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
143 |
if LuaUpdateDebugInfo() then |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
144 |
begin |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
145 |
src:= StrPas(LuaDebugInfo.source); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
146 |
s:= 'LUA ERROR [ ... ' |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
147 |
+ copy(src, Length(src) - maxsrclen, maxsrclen - 3) + ':' |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
148 |
+ inttostr(LuaDebugInfo.currentLine) + ']: ' + s; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
149 |
end |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
150 |
else |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
151 |
s:= 'LUA ERROR: ' + s; |
3539 | 152 |
WriteLnToConsole(s); |
153 |
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
|
154 |
if cTestLua then |
10306 | 155 |
halt(HaltTestLuaError); |
3539 | 156 |
end; |
157 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
158 |
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
|
159 |
begin |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
160 |
LuaError(call + ': ' + error); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
161 |
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
|
162 |
end; |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
163 |
|
10285 | 164 |
procedure LuaParameterCountError(expected, call, paramsyntax: shortstring; wrongcount: LongInt); inline; |
165 |
begin |
|
166 |
// TODO: i18n? |
|
167 |
LuaCallError('Wrong number of parameters! (is: ' + inttostr(wrongcount) + ', should be: '+ expected + ')', call, paramsyntax); |
|
168 |
end; |
|
169 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
170 |
// compare with allowed count |
10297 | 171 |
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
|
172 |
var c: LongInt; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
173 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
174 |
c:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
175 |
if c <> count then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
176 |
begin |
10285 | 177 |
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
|
178 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
179 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
180 |
|
10297 | 181 |
CheckLuaParamCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
182 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
183 |
|
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
184 |
// check if is either count1 or count2 |
10297 | 185 |
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
|
186 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
187 |
actual:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
188 |
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
|
189 |
begin |
10285 | 190 |
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
|
191 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
192 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
193 |
|
10297 | 194 |
CheckAndFetchParamCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
195 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
196 |
|
10611 | 197 |
// check if is in range of count1 and count2 |
198 |
function CheckAndFetchParamCountRange(L : Plua_State; count1, count2: LongInt; call, paramsyntax: shortstring; out actual: LongInt): boolean; inline; |
|
199 |
begin |
|
200 |
actual:= lua_gettop(L); |
|
201 |
if (actual < count1) or (actual > count2) then |
|
202 |
begin |
|
203 |
LuaParameterCountError('at least ' + inttostr(count1) + ', but at most ' + inttostr(count2), call, paramsyntax, actual); |
|
204 |
exit(false); |
|
205 |
end; |
|
206 |
||
207 |
CheckAndFetchParamCountRange:= true; |
|
208 |
end; |
|
209 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
210 |
// check if is same or higher as minCount |
10297 | 211 |
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
|
212 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
213 |
actual:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
214 |
if (actual < minCount) then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
215 |
begin |
10285 | 216 |
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
|
217 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
218 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
219 |
|
10297 | 220 |
CheckAndFetchLuaParamMinCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
221 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
222 |
|
10281 | 223 |
function LuaToGearTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
224 |
begin |
|
225 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
226 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 227 |
if (i < ord(Low(TGearType))) or (i > ord(High(TGearType))) then |
228 |
begin |
|
229 |
LuaCallError('Invalid gearType!', call, paramsyntax); |
|
230 |
LuaToGearTypeOrd:= -1; |
|
231 |
end |
|
232 |
else |
|
233 |
LuaToGearTypeOrd:= i; |
|
234 |
end; |
|
235 |
||
236 |
function LuaToVisualGearTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
237 |
begin |
|
238 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
239 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 240 |
if (i < ord(Low(TVisualGearType))) or (i > ord(High(TVisualGearType))) then |
241 |
begin |
|
242 |
LuaCallError('Invalid visualGearType!', call, paramsyntax); |
|
243 |
LuaToVisualGearTypeOrd:= -1; |
|
244 |
end |
|
245 |
else |
|
246 |
LuaToVisualGearTypeOrd:= i; |
|
247 |
end; |
|
248 |
||
249 |
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
|
250 |
begin |
10281 | 251 |
if lua_isnoneornil(L, i) then i:= -1 |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
252 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 253 |
if (i < ord(Low(TAmmoType))) or (i > ord(High(TAmmoType))) then |
254 |
begin |
|
255 |
LuaCallError('Invalid ammoType!', call, paramsyntax); |
|
256 |
LuaToAmmoTypeOrd:= -1; |
|
257 |
end |
|
258 |
else |
|
259 |
LuaToAmmoTypeOrd:= i; |
|
260 |
end; |
|
261 |
||
262 |
function LuaToStatInfoTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
263 |
begin |
|
264 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
265 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 266 |
if (i < ord(Low(TStatInfoType))) or (i > ord(High(TStatInfoType))) then |
267 |
begin |
|
268 |
LuaCallError('Invalid statInfoType!', call, paramsyntax); |
|
269 |
LuaToStatInfoTypeOrd:= -1; |
|
270 |
end |
|
271 |
else |
|
272 |
LuaToStatInfoTypeOrd:= i; |
|
273 |
end; |
|
274 |
||
275 |
function LuaToSoundOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
276 |
begin |
|
277 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
278 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 279 |
if (i < ord(Low(TSound))) or (i > ord(High(TSound))) then |
280 |
begin |
|
281 |
LuaCallError('Invalid soundId!', call, paramsyntax); |
|
282 |
LuaToSoundOrd:= -1; |
|
283 |
end |
|
284 |
else |
|
285 |
LuaToSoundOrd:= i; |
|
286 |
end; |
|
287 |
||
288 |
function LuaToHogEffectOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
289 |
begin |
|
290 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
291 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 292 |
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
|
293 |
begin |
11849
a784866c91ad
Lua API: fix incorrect error message. thanks to TheAnachron and rhino for pointing this out
sheepluva
parents:
11828
diff
changeset
|
294 |
LuaCallError('Invalid effect type!', call, paramsyntax); |
10281 | 295 |
LuaToHogEffectOrd:= -1; |
296 |
end |
|
297 |
else |
|
298 |
LuaToHogEffectOrd:= i; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
299 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
300 |
|
10281 | 301 |
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
|
302 |
begin |
10281 | 303 |
if lua_isnoneornil(L, i) then i:= -1 |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
304 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 305 |
if (i < ord(Low(TCapGroup))) or (i > ord(High(TCapGroup))) then |
306 |
begin |
|
307 |
LuaCallError('Invalid capgroup type!', call, paramsyntax); |
|
308 |
LuaToCapGroupOrd:= -1; |
|
309 |
end |
|
310 |
else |
|
311 |
LuaToCapGroupOrd:= i; |
|
312 |
end; |
|
313 |
||
314 |
function LuaToSpriteOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
315 |
begin |
|
316 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
317 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 318 |
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
|
319 |
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
|
320 |
LuaCallError('Invalid sprite id!', call, paramsyntax); |
10281 | 321 |
LuaToSpriteOrd:= -1; |
322 |
end |
|
323 |
else |
|
324 |
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
|
325 |
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
|
326 |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
327 |
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
|
328 |
begin |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
329 |
if lua_isnoneornil(L, i) then i:= -1 |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
330 |
else i:= Trunc(lua_tonumber(L, i)); |
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
331 |
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
|
332 |
begin |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
end |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
336 |
else |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
337 |
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
|
338 |
end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
339 |
|
11682 | 340 |
// wrapped calls |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
341 |
|
3539 | 342 |
// 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
|
343 |
// 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
|
344 |
// where L contains the state, returns the number of return values on the stack |
10297 | 345 |
// call CheckLuaParamCount or CheckAndFetchParamCount |
10287 | 346 |
// to validate/get the number of passed arguments (see their call definitions) |
347 |
// |
|
348 |
// 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
|
349 |
|
4483 | 350 |
function lc_band(L: PLua_State): LongInt; Cdecl; |
351 |
begin |
|
10297 | 352 |
if CheckLuaParamCount(L, 2, 'band', 'value1, value2') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
353 |
lua_pushnumber(L, Trunc(lua_tonumber(L, 2)) and Trunc(lua_tonumber(L, 1))) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
354 |
else |
4483 | 355 |
lua_pushnil(L); |
356 |
lc_band := 1; |
|
357 |
end; |
|
358 |
||
359 |
function lc_bor(L: PLua_State): LongInt; Cdecl; |
|
360 |
begin |
|
10297 | 361 |
if CheckLuaParamCount(L, 2, 'bor', 'value1, value2') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
362 |
lua_pushnumber(L, Trunc(lua_tonumber(L, 2)) or Trunc(lua_tonumber(L, 1))) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
363 |
else |
4483 | 364 |
lua_pushnil(L); |
365 |
lc_bor := 1; |
|
366 |
end; |
|
367 |
||
368 |
function lc_bnot(L: PLua_State): LongInt; Cdecl; |
|
369 |
begin |
|
10297 | 370 |
if CheckLuaParamCount(L, 1, 'bnot', 'value') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
371 |
lua_pushnumber(L, (not Trunc(lua_tonumber(L, 1)))) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
372 |
else |
4483 | 373 |
lua_pushnil(L); |
374 |
lc_bnot := 1; |
|
375 |
end; |
|
376 |
||
6764 | 377 |
function lc_div(L: PLua_State): LongInt; Cdecl; |
378 |
begin |
|
10297 | 379 |
if CheckLuaParamCount(L, 2, 'div', 'dividend, divisor') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
380 |
lua_pushnumber(L, Trunc(lua_tonumber(L, 1)) div Trunc(lua_tonumber(L, 2))) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
381 |
else |
6764 | 382 |
lua_pushnil(L); |
383 |
lc_div := 1; |
|
384 |
end; |
|
385 |
||
4523 | 386 |
function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
387 |
begin |
|
10297 | 388 |
if CheckLuaParamCount(L, 0, 'GetInputMask', '') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
389 |
lua_pushnumber(L, InputMask); |
4523 | 390 |
lc_getinputmask:= 1 |
391 |
end; |
|
392 |
||
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
|
393 |
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
|
394 |
begin |
10297 | 395 |
if CheckLuaParamCount(L, 1, 'SetInputMask', 'mask') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
396 |
InputMask:= Trunc(lua_tonumber(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
|
397 |
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
|
398 |
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
|
399 |
|
3043
3acdb4dac6eb
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 |
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
|
401 |
begin |
10297 | 402 |
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
|
403 |
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
|
404 |
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
|
405 |
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
|
406 |
|
12915 | 407 |
function lc_writelntochat(L : Plua_State) : LongInt; Cdecl; |
408 |
begin |
|
409 |
if CheckLuaParamCount(L, 1, 'WriteLnToChat', 'string') then |
|
410 |
AddChatString(#2 + lua_tostring(L, 1)); |
|
411 |
lc_writelntochat:= 0; |
|
412 |
end; |
|
413 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
414 |
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
|
415 |
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
|
416 |
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
|
417 |
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
|
418 |
begin |
10297 | 419 |
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
|
420 |
begin |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10129
diff
changeset
|
421 |
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
|
422 |
|
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
|
423 |
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
|
424 |
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
|
425 |
|
7805 | 426 |
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
|
427 |
|
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
428 |
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
|
429 |
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
|
430 |
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
|
431 |
|
10291 | 432 |
// sets weapon to the desired ammo type |
10289 | 433 |
function lc_setweapon(L : Plua_State) : LongInt; Cdecl; |
434 |
var at: LongInt; |
|
435 |
const |
|
436 |
call = 'SetWeapon'; |
|
437 |
params = 'ammoType'; |
|
438 |
begin |
|
10291 | 439 |
// no point to run this without any CurrentHedgehog |
10297 | 440 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 1, call, params)) then |
10289 | 441 |
begin |
442 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
443 |
if at >= 0 then |
|
444 |
ParseCommand('setweap ' + char(at), true, true); |
|
445 |
end; |
|
446 |
lc_setweapon:= 0; |
|
447 |
end; |
|
448 |
||
11525 | 449 |
// enable/disable cinematic effects |
450 |
function lc_setcinematicmode(L : Plua_State) : LongInt; Cdecl; |
|
451 |
const |
|
452 |
call = 'SetCinematicMode'; |
|
453 |
params = 'enable'; |
|
454 |
begin |
|
455 |
if (CheckLuaParamCount(L, 1, call, params)) then |
|
456 |
begin |
|
457 |
CinematicScript:= lua_toboolean(L, 1); |
|
458 |
end; |
|
459 |
lc_setcinematicmode:= 0; |
|
460 |
end; |
|
461 |
||
11058
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
462 |
// no parameter means reset to default (and 0 means unlimited) |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
463 |
function lc_setmaxbuilddistance(L : Plua_State) : LongInt; Cdecl; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
464 |
var np: LongInt; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
465 |
const |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
466 |
call = 'SetMaxBuildDistance'; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
467 |
params = '[ distInPx ]'; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
468 |
begin |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
469 |
if CheckAndFetchParamCountRange(L, 0, 1, call, params, np) then |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
470 |
begin |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
471 |
if np = 0 then |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
472 |
begin |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
473 |
// no args? reset |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
474 |
cBuildMaxDist:= cDefaultBuildMaxDist; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
475 |
end |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
476 |
else |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
477 |
CBuildMaxDist:= Trunc(lua_tonumber(L, 1)); |
11058
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
478 |
end; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
479 |
lc_setmaxbuilddistance:= 0; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
480 |
end; |
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
481 |
|
10291 | 482 |
// sets weapon to whatever weapons is next (wraps around, amSkip is skipped) |
483 |
function lc_setnextweapon(L : Plua_State) : LongInt; Cdecl; |
|
484 |
var at : LongInt; |
|
485 |
nextAmmo : TAmmo; |
|
486 |
s, a, cs, fa: LongInt; |
|
487 |
const |
|
488 |
call = 'SetNextWeapon'; |
|
489 |
params = ''; |
|
490 |
begin |
|
10297 | 491 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, call, params)) then |
10291 | 492 |
begin |
493 |
at:= -1; |
|
494 |
with CurrentHedgehog^ do |
|
495 |
begin |
|
496 |
cs:= 0; // current slot |
|
497 |
fa:= 0; // first ammo item to check |
|
498 |
||
11682 | 499 |
// if something is selected, find it is successor |
10291 | 500 |
if curAmmoType <> amNothing then |
501 |
begin |
|
502 |
// get current slot index |
|
503 |
cs:= Ammoz[CurAmmoType].Slot; |
|
504 |
// find current ammo index |
|
505 |
while (fa < cMaxSlotAmmoIndex) |
|
506 |
and (Ammo^[cs, fa].AmmoType <> CurAmmoType) do |
|
507 |
inc(fa); |
|
11682 | 508 |
// increase once more because we will not successor |
10291 | 509 |
inc(fa); |
510 |
end; |
|
511 |
||
512 |
// find first available ammo |
|
513 |
// revisit current slot too (current item might not be first) |
|
514 |
for s:= cs to cs + cMaxSlotIndex + 1 do |
|
515 |
begin |
|
516 |
for a:= fa to cMaxSlotAmmoIndex do |
|
517 |
begin |
|
518 |
// check if we went full circle |
|
519 |
if (a = fa) and (s = cs + cMaxSlotIndex + 1) then |
|
520 |
exit(0); |
|
521 |
||
522 |
// get ammo |
|
523 |
nextAmmo:= Ammo^[s mod (cMaxSlotIndex + 1), a]; |
|
524 |
// only switch to ammos the hog actually has |
|
525 |
if (nextAmmo.AmmoType <> amNothing) |
|
526 |
and (nextAmmo.AmmoType <> amSkip) and (nextAmmo.Count > 0) then |
|
527 |
begin |
|
528 |
at:= ord(nextAmmo.AmmoType); |
|
529 |
break; |
|
530 |
end; |
|
531 |
end; |
|
532 |
// stop slot loop if something was found |
|
533 |
if at >= 0 then |
|
534 |
break; |
|
535 |
// check following slots starting with first item |
|
536 |
fa:= 0; |
|
537 |
end; |
|
538 |
end; |
|
539 |
||
540 |
if at >= 0 then |
|
541 |
ParseCommand('setweap ' + char(at), true, true); |
|
542 |
end; |
|
543 |
lc_setnextweapon:= 0; |
|
544 |
end; |
|
545 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
546 |
function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
13466
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13460
diff
changeset
|
547 |
var 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
|
548 |
begin |
13466
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13460
diff
changeset
|
549 |
if CheckAndFetchParamCount(L, 5, 6, 'ShowMission', 'caption, subcaption, text, icon, time [, forceDisplay]', n) then |
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13460
diff
changeset
|
550 |
if n = 5 then |
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13460
diff
changeset
|
551 |
ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(L, 3), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5))) |
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13460
diff
changeset
|
552 |
else |
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13460
diff
changeset
|
553 |
ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(L, 3), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5)), lua_toboolean(L, 6)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
554 |
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
|
555 |
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
|
556 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
557 |
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
|
558 |
begin |
3407 | 559 |
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
|
560 |
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
|
561 |
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
|
562 |
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
|
563 |
|
11944
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
564 |
function lc_setammotexts(L : Plua_State) : LongInt; Cdecl; |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
565 |
const |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
566 |
call = 'SetAmmoTexts'; |
13375
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
567 |
params = 'ammoType, name, caption, description [, showExtra]'; |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
568 |
var n: integer; |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
569 |
showExtra: boolean; |
11944
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
570 |
begin |
13375
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
571 |
if CheckAndFetchParamCount(L, 4, 5, call, params, n) then |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
572 |
begin |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
573 |
if n = 5 then |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
574 |
showExtra:= lua_toboolean(L, 5) |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
575 |
else |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
576 |
showExtra:= true; |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
577 |
SetAmmoTexts(TAmmoType(LuaToAmmoTypeOrd(L, 1, call, params)), lua_tostringA(L, 2), lua_tostringA(L, 3), lua_tostringA(L, 4), showExtra); |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13354
diff
changeset
|
578 |
end; |
11944
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
579 |
lc_setammotexts:= 0; |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
580 |
end; |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
581 |
|
11946
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
582 |
function lc_setammodescriptionappendix(L : Plua_State) : LongInt; Cdecl; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
583 |
const |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
584 |
call = 'SetAmmoDescriptionAppendix'; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
585 |
params = 'ammoType, descAppend'; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
586 |
var |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
587 |
ammoType: TAmmoType; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
588 |
descAppend: ansistring; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
589 |
begin |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
590 |
if CheckLuaParamCount(L, 2, call, params) then |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
591 |
begin |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
592 |
ammoType := TAmmoType(LuaToAmmoTypeOrd(L, 1, call, params)); |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
593 |
descAppend := lua_tostringA(L, 2); |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
594 |
trluaammoa[Ammoz[ammoType].NameId] := descAppend; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
595 |
end; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
596 |
lc_setammodescriptionappendix := 0; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
597 |
end; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
598 |
|
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
599 |
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
|
600 |
var i, n : integer; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
601 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
602 |
// can have 1 or more arguments |
10297 | 603 |
if CheckAndFetchLuaParamMinCount(L, 1, 'EnableGameFlags', 'gameFlag, ... ', n) then |
10035 | 604 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
605 |
for i:= 1 to n do |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
606 |
GameFlags := GameFlags or LongWord(Trunc(lua_tonumber(L, i))); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
607 |
ScriptSetInteger('GameFlags', GameFlags); |
10035 | 608 |
end; |
8370 | 609 |
lc_enablegameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
610 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
611 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
612 |
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
|
613 |
var i , n: integer; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
614 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
615 |
// can have 1 or more arguments |
10297 | 616 |
if CheckAndFetchLuaParamMinCount(L, 1, 'DisableGameFlags', 'gameFlag, ... ', n) then |
10035 | 617 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
618 |
for i:= 1 to n do |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
619 |
GameFlags := GameFlags and (not LongWord(Trunc(lua_tonumber(L, i)))); |
10035 | 620 |
ScriptSetInteger('GameFlags', GameFlags); |
621 |
end; |
|
8370 | 622 |
lc_disablegameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
623 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
624 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
625 |
function lc_cleargameflags(L : Plua_State) : LongInt; Cdecl; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
626 |
begin |
10297 | 627 |
if CheckLuaParamCount(L, 0, 'ClearGameFlags', '') then |
10035 | 628 |
begin |
629 |
GameFlags:= 0; |
|
630 |
ScriptSetInteger('GameFlags', GameFlags); |
|
631 |
end; |
|
8370 | 632 |
lc_cleargameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
633 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
634 |
|
10035 | 635 |
function lc_getgameflag(L : Plua_State) : LongInt; Cdecl; |
636 |
begin |
|
10297 | 637 |
if CheckLuaParamCount(L, 1, 'GetGameFlag', 'gameflag') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
638 |
lua_pushboolean(L, (GameFlags and LongWord(Trunc(lua_tonumber(L, 1))) <> 0)) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
639 |
else |
10035 | 640 |
lua_pushnil(L); |
641 |
lc_getgameflag:= 1; |
|
642 |
end; |
|
643 |
||
4243 | 644 |
function lc_addcaption(L : Plua_State) : LongInt; Cdecl; |
10281 | 645 |
var cg: LongInt; |
646 |
const |
|
647 |
call = 'AddCaption'; |
|
648 |
params = 'text [, color, captiongroup]'; |
|
4243 | 649 |
begin |
10297 | 650 |
if CheckAndFetchParamCount(L, 1, 3, call, params, cg) then |
4243 | 651 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
652 |
if cg = 1 then |
13647
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13632
diff
changeset
|
653 |
AddCaption(lua_tostringA(L, 1), capcolDefault, capgrpMessage) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
654 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
655 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
656 |
cg:= LuaToCapGroupOrd(L, 3, call, params); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
657 |
if cg >= 0 then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
658 |
AddCaption(lua_tostringA(L, 1), Trunc(lua_tonumber(L, 2)) shr 8, TCapGroup(cg)); |
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 |
end; |
4243 | 661 |
lc_addcaption:= 0; |
662 |
end; |
|
663 |
||
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
|
664 |
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
|
665 |
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
|
666 |
begin |
10297 | 667 |
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
|
668 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
669 |
gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(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
|
670 |
HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
11200
f4cf2cdea8e5
Add nil check in fake crate spawn for if crate fails to spawn
nemo
parents:
11183
diff
changeset
|
671 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
672 |
lua_pushnumber(L, gear^.uid) |
11200
f4cf2cdea8e5
Add nil check in fake crate spawn for if crate fails to spawn
nemo
parents:
11183
diff
changeset
|
673 |
else lua_pushnil(L) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
674 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
675 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
676 |
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
|
677 |
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
|
678 |
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
|
679 |
|
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
|
680 |
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
|
681 |
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
|
682 |
begin |
10297 | 683 |
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
|
684 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
685 |
gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(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
|
686 |
AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
11255 | 687 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
688 |
lua_pushnumber(L, gear^.uid) |
11255 | 689 |
else lua_pushnil(L) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
690 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
691 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
692 |
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
|
693 |
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
|
694 |
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
|
695 |
|
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
|
696 |
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
|
697 |
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
|
698 |
begin |
10297 | 699 |
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
|
700 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
701 |
gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(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
|
702 |
UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); |
11255 | 703 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
704 |
lua_pushnumber(L, gear^.uid) |
11255 | 705 |
else lua_pushnil(L) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
706 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
707 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
708 |
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
|
709 |
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
|
710 |
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
|
711 |
|
3730 | 712 |
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
|
713 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
714 |
var health, n: LongInt; |
3730 | 715 |
begin |
10297 | 716 |
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
|
717 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
718 |
if n = 3 then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
719 |
health:= Trunc(lua_tonumber(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
|
720 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
721 |
health:= cHealthCaseAmount; |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
722 |
gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(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
|
723 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
724 |
lua_pushnumber(L, gear^.uid) |
11255 | 725 |
else lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
726 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
727 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
728 |
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
|
729 |
lc_spawnhealthcrate := 1; |
3734 | 730 |
end; |
731 |
||
732 |
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
|
733 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
734 |
n : LongInt; |
3734 | 735 |
begin |
10297 | 736 |
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
|
737 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
738 |
if n = 3 then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
739 |
gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), AmmoCrate, Trunc(lua_tonumber(L, 3)), 0) |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
740 |
else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), AmmoCrate, Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(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
|
741 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
742 |
lua_pushnumber(L, gear^.uid) |
11255 | 743 |
else lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
744 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
745 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
746 |
lua_pushnil(L); |
3734 | 747 |
lc_spawnammocrate := 1; |
748 |
end; |
|
749 |
||
750 |
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
|
751 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
752 |
n : LongInt; |
3734 | 753 |
begin |
10297 | 754 |
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
|
755 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
756 |
if n = 3 then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
757 |
gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), UtilityCrate, Trunc(lua_tonumber(L, 3)), 0) |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
758 |
else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), UtilityCrate, Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(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
|
759 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
760 |
lua_pushnumber(L, gear^.uid) |
11255 | 761 |
else lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
762 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
763 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
764 |
lua_pushnil(L); |
3734 | 765 |
lc_spawnutilitycrate := 1; |
3730 | 766 |
end; |
767 |
||
12937 | 768 |
function lc_spawnsupplycrate(L: PLua_State): LongInt; Cdecl; |
769 |
var gear: PGear; |
|
770 |
n, at:LongInt; |
|
771 |
t: TCrateType; |
|
772 |
begin |
|
773 |
if CheckAndFetchParamCount(L, 3, 4, 'SpawnSupplyCrate', 'x, y, content [, amount]', n) then |
|
774 |
begin |
|
775 |
// Get crate type (ammo or utility) |
|
776 |
at:= Trunc(lua_tonumber(L, 3)); |
|
777 |
if (Ammoz[TAmmoType(at)].Ammo.Propz and ammoprop_Utility) <> 0 then |
|
778 |
t:= UtilityCrate |
|
779 |
else |
|
780 |
t:= AmmoCrate; |
|
781 |
if n = 3 then |
|
782 |
gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), t, at, 0) |
|
783 |
else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), t, at, Trunc(lua_tonumber(L, 4))); |
|
784 |
if gear <> nil then |
|
785 |
lua_pushnumber(L, gear^.uid) |
|
786 |
else lua_pushnil(L); |
|
787 |
end |
|
788 |
else |
|
789 |
lua_pushnil(L); |
|
790 |
lc_spawnsupplycrate := 1; |
|
791 |
end; |
|
792 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
793 |
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
|
794 |
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
|
795 |
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
|
796 |
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
|
797 |
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
|
798 |
const |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
799 |
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
|
800 |
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
|
801 |
begin |
10297 | 802 |
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
|
803 |
begin |
10281 | 804 |
t:= LuaToGearTypeOrd(L, 3, call, params); |
805 |
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
|
806 |
begin |
10281 | 807 |
gt:= TGearType(t); |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
808 |
x:= Trunc(lua_tonumber(L, 1)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
809 |
y:= Trunc(lua_tonumber(L, 2)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
810 |
s:= Trunc(lua_tonumber(L, 4)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
811 |
dx:= int2hwFloat(Trunc(lua_tonumber(L, 5))) / 1000000; |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
812 |
dy:= int2hwFloat(Trunc(lua_tonumber(L, 6))) / 1000000; |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
813 |
t:= Trunc(lua_tonumber(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
|
814 |
|
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
815 |
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
|
816 |
lastGearByUID:= gear; |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
817 |
lua_pushnumber(L, gear^.uid) |
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
818 |
end |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
819 |
else |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
820 |
lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
821 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
822 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
823 |
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
|
824 |
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
|
825 |
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
|
826 |
|
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
|
827 |
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
|
828 |
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
|
829 |
begin |
10297 | 830 |
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
|
831 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
832 |
gear:= GearByUID(Trunc(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
|
833 |
if gear <> nil then |
7517 | 834 |
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
|
835 |
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
|
836 |
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
|
837 |
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
|
838 |
|
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 |
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
|
840 |
var vg : PVisualGear; |
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
841 |
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
|
842 |
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
|
843 |
vgt: TVisualGearType; |
10281 | 844 |
uid: Longword; |
845 |
const |
|
846 |
call = 'AddVisualGear'; |
|
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
847 |
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
|
848 |
begin |
10281 | 849 |
uid:= 0; |
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
850 |
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
|
851 |
begin |
10281 | 852 |
s:= LuaToVisualGearTypeOrd(L, 3, call, params); |
853 |
if s >= 0 then |
|
854 |
begin |
|
855 |
vgt:= TVisualGearType(s); |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
856 |
x:= Trunc(lua_tonumber(L, 1)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
857 |
y:= Trunc(lua_tonumber(L, 2)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
858 |
s:= Trunc(lua_tonumber(L, 4)); |
10281 | 859 |
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
|
860 |
|
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
861 |
if n = 6 then |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
862 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
863 |
layer:= Trunc(lua_tonumber(L, 6)); |
10347 | 864 |
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
|
865 |
end |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
866 |
else |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
867 |
vg:= AddVisualGear(x, y, vgt, s, c); |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
868 |
|
10281 | 869 |
if vg <> nil then |
870 |
begin |
|
871 |
lastVisualGearByUID:= vg; |
|
872 |
uid:= vg^.uid; |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
873 |
lua_pushnumber(L, uid); |
10281 | 874 |
end; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
875 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
876 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
877 |
lua_pushnil(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
878 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
879 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
880 |
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
|
881 |
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
|
882 |
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
|
883 |
|
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
|
884 |
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
|
885 |
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
|
886 |
begin |
10281 | 887 |
vg:= nil; |
10297 | 888 |
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
|
889 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
890 |
vg:= VisualGearByUID(Trunc(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
|
891 |
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
|
892 |
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
|
893 |
end; |
10281 | 894 |
// allow caller to know whether there was something to delete |
895 |
lua_pushboolean(L, vg <> nil); |
|
896 |
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
|
897 |
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
|
898 |
|
11885
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
899 |
function lc_getvisualgeartype(L : Plua_State) : LongInt; Cdecl; |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
900 |
var vg : PVisualGear; |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
901 |
begin |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
902 |
if CheckLuaParamCount(L, 1, 'GetVisualGearType', 'vgUid') then |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
903 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
904 |
vg := VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
11885
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
905 |
if vg <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
906 |
lua_pushnumber(L, ord(vg^.Kind)) |
11885
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
907 |
else |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
908 |
lua_pushnil(L); |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
909 |
end |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
910 |
else |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
911 |
lua_pushnil(L); // return value on stack (nil) |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
912 |
lc_getvisualgeartype:= 1 |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
913 |
end; |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
914 |
|
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
915 |
|
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
|
916 |
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
|
917 |
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
|
918 |
begin |
10297 | 919 |
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
|
920 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
921 |
vg:= VisualGearByUID(Trunc(lua_tonumber(L, 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
|
922 |
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
|
923 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
924 |
lua_pushnumber(L, round(vg^.X)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
925 |
lua_pushnumber(L, round(vg^.Y)); |
5075
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
926 |
lua_pushnumber(L, vg^.dX); |
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
927 |
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
|
928 |
lua_pushnumber(L, vg^.Angle); |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
929 |
lua_pushnumber(L, vg^.Frame); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
930 |
lua_pushnumber(L, vg^.FrameTicks); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
931 |
lua_pushnumber(L, vg^.State); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
932 |
lua_pushnumber(L, vg^.Timer); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
933 |
lua_pushnumber(L, vg^.Tint); |
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
|
934 |
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
|
935 |
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
|
936 |
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
|
937 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
10287 | 938 |
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
|
939 |
end |
10287 | 940 |
end |
941 |
else |
|
942 |
begin |
|
943 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
944 |
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
|
945 |
end; |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
946 |
lc_getvisualgearvalues:= 10 |
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
|
947 |
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
|
948 |
|
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
|
949 |
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
|
950 |
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
|
951 |
begin |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
952 |
// Param count can be 1-11 at present |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
953 |
// if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint') then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
954 |
// begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
955 |
vg:= VisualGearByUID(Trunc(lua_tonumber(L, 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
|
956 |
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
|
957 |
begin |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
958 |
if not lua_isnoneornil(L, 2) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
959 |
vg^.X:= Trunc(lua_tonumber(L, 2)); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
960 |
if not lua_isnoneornil(L, 3) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
961 |
vg^.Y:= Trunc(lua_tonumber(L, 3)); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
962 |
if not lua_isnoneornil(L, 4) then |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
963 |
vg^.dX:= lua_tonumber(L, 4); |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
964 |
if not lua_isnoneornil(L, 5) then |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
965 |
vg^.dY:= lua_tonumber(L, 5); |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
966 |
if not lua_isnoneornil(L, 6) then |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
967 |
vg^.Angle:= lua_tonumber(L, 6); |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
968 |
if not lua_isnoneornil(L, 7) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
969 |
vg^.Frame:= Trunc(lua_tonumber(L, 7)); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
970 |
if not lua_isnoneornil(L, 8) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
971 |
vg^.FrameTicks:= Trunc(lua_tonumber(L, 8)); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
972 |
if not lua_isnoneornil(L, 9) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
973 |
vg^.State:= Trunc(lua_tonumber(L, 9)); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
974 |
if not lua_isnoneornil(L, 10) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
975 |
vg^.Timer:= Trunc(lua_tonumber(L, 10)); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
976 |
if not lua_isnoneornil(L, 11) then |
13439
745e9174038e
somehow scale was omitted from this catch-all VG init. late addition to the struct perhaps.
nemo
parents:
13399
diff
changeset
|
977 |
vg^.Tint:= Trunc(lua_tonumber(L, 11)); |
745e9174038e
somehow scale was omitted from this catch-all VG init. late addition to the struct perhaps.
nemo
parents:
13399
diff
changeset
|
978 |
if not lua_isnoneornil(L, 12) then |
745e9174038e
somehow scale was omitted from this catch-all VG init. late addition to the struct perhaps.
nemo
parents:
13399
diff
changeset
|
979 |
vg^.Scale:= Trunc(lua_tonumber(L, 12)) |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
980 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
981 |
// end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
982 |
// else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
983 |
// lua_pushnil(L); // return value on stack (nil) |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
984 |
lc_setvisualgearvalues:= 0 |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
985 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
986 |
|
11682 | 987 |
// so. going to use this to get/set some of the more obscure gear values which were not already exposed elsewhere |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
988 |
// can keep adding things in the future. isnoneornil makes it safe |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
989 |
function lc_getgearvalues(L : Plua_State) : LongInt; Cdecl; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
990 |
var gear: PGear; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
991 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
992 |
if CheckLuaParamCount(L, 1, 'GetGearValues', 'gearUid') then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
993 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
994 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
995 |
if gear <> nil then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
996 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
997 |
lua_pushnumber(L, gear^.Angle); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
998 |
lua_pushnumber(L, gear^.Power); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
999 |
lua_pushnumber(L, gear^.WDTimer); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1000 |
lua_pushnumber(L, gear^.Radius); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1001 |
lua_pushnumber(L, hwRound(gear^.Density * _10000)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1002 |
lua_pushnumber(L, gear^.Karma); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1003 |
lua_pushnumber(L, gear^.DirAngle); |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1004 |
lua_pushnumber(L, gear^.AdvBounce); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1005 |
lua_pushnumber(L, Integer(gear^.ImpactSound)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1006 |
lua_pushnumber(L, gear^.nImpactSounds); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1007 |
lua_pushnumber(L, gear^.Tint); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1008 |
lua_pushnumber(L, gear^.Damage); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1009 |
lua_pushnumber(L, gear^.Boom) |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1010 |
end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1011 |
else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1012 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1013 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1014 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
11473
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11317
diff
changeset
|
1015 |
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
|
1016 |
end |
10287 | 1017 |
end |
1018 |
else |
|
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1019 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1020 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1021 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
11473
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11317
diff
changeset
|
1022 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L) |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1023 |
end; |
11473
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11317
diff
changeset
|
1024 |
lc_getgearvalues:= 13 |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1025 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1026 |
|
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1027 |
function lc_setgearvalues(L : Plua_State) : LongInt; Cdecl; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1028 |
var gear : PGear; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1029 |
begin |
11473
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11317
diff
changeset
|
1030 |
// Currently allows 1-14 params |
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11317
diff
changeset
|
1031 |
// if CheckLuaParamCount(L, 14, 'SetGearValues', 'gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, # ImpactSounds, Tint, Damage, Boom') then |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1032 |
// begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1033 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1034 |
if gear <> nil then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1035 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1036 |
if not lua_isnoneornil(L, 2) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1037 |
gear^.Angle := Trunc(lua_tonumber(L, 2)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1038 |
if not lua_isnoneornil(L, 3) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1039 |
gear^.Power := Trunc(lua_tonumber(L, 3)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1040 |
if not lua_isnoneornil(L, 4) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1041 |
gear^.WDTimer := Trunc(lua_tonumber(L, 4)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1042 |
if not lua_isnoneornil(L, 5) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1043 |
gear^.Radius := Trunc(lua_tonumber(L, 5)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1044 |
if not lua_isnoneornil(L, 6) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1045 |
gear^.Density:= int2hwFloat(Trunc(lua_tonumber(L, 6))) / 10000; |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1046 |
if not lua_isnoneornil(L, 7) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1047 |
gear^.Karma := Trunc(lua_tonumber(L, 7)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1048 |
if not lua_isnoneornil(L, 8) then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1049 |
gear^.DirAngle:= lua_tonumber(L, 8); |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1050 |
if not lua_isnoneornil(L, 9) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1051 |
gear^.AdvBounce := Trunc(lua_tonumber(L, 9)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1052 |
if not lua_isnoneornil(L, 10) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1053 |
gear^.ImpactSound := TSound(Trunc(lua_tonumber(L, 10))); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1054 |
if not lua_isnoneornil(L, 11) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1055 |
gear^.nImpactSounds := Trunc(lua_tonumber(L, 11)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1056 |
if not lua_isnoneornil(L, 12) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1057 |
gear^.Tint := Trunc(lua_tonumber(L, 12)); |
11176 | 1058 |
if not lua_isnoneornil(L, 13) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1059 |
gear^.Damage := Trunc(lua_tonumber(L, 13)); |
11473
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11317
diff
changeset
|
1060 |
if not lua_isnoneornil(L, 14) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1061 |
gear^.Boom := Trunc(lua_tonumber(L, 14)); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1062 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1063 |
// end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1064 |
// else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1065 |
// lua_pushnil(L); // return value on stack (nil) |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1066 |
lc_setgearvalues:= 0 |
4443
d393b9ccd328
Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents:
4411
diff
changeset
|
1067 |
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
|
1068 |
|
3058 | 1069 |
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
1070 |
begin |
|
10297 | 1071 |
if CheckLuaParamCount(L, 0, 'GetFollowGear', '') then |
3058 | 1072 |
begin |
1073 |
if FollowGear = nil then |
|
1074 |
lua_pushnil(L) |
|
1075 |
else |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1076 |
lua_pushnumber(L, FollowGear^.uid); |
10287 | 1077 |
end |
1078 |
else |
|
1079 |
lua_pushnil(L); |
|
3058 | 1080 |
lc_getfollowgear:= 1; // 1 return value |
1081 |
end; |
|
1082 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1083 |
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
|
1084 |
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
|
1085 |
begin |
10297 | 1086 |
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
|
1087 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1088 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
1089 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1090 |
lua_pushnumber(L, ord(gear^.Kind)) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1091 |
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
|
1092 |
lua_pushnil(L); |
10287 | 1093 |
end |
1094 |
else |
|
1095 |
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
|
1096 |
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
|
1097 |
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
|
1098 |
|
3892 | 1099 |
function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
1100 |
var gear : PGear; |
|
1101 |
begin |
|
10297 | 1102 |
if CheckLuaParamCount(L, 1, 'GetGearMessage', 'gearUid') then |
3892 | 1103 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1104 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3892 | 1105 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1106 |
lua_pushnumber(L, gear^.message) |
3892 | 1107 |
else |
1108 |
lua_pushnil(L); |
|
10287 | 1109 |
end |
1110 |
else |
|
1111 |
lua_pushnil(L); // return value on stack (nil) |
|
3892 | 1112 |
lc_getgearmessage:= 1 |
1113 |
end; |
|
1114 |
||
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
|
1115 |
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
|
1116 |
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
|
1117 |
begin |
10297 | 1118 |
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
|
1119 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1120 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
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
|
1121 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1122 |
lua_pushnumber(L, hwRound(gear^.elasticity * _10000)) |
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
|
1123 |
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
|
1124 |
lua_pushnil(L); |
10287 | 1125 |
end |
1126 |
else |
|
1127 |
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
|
1128 |
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
|
1129 |
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
|
1130 |
|
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1131 |
function lc_setgearelasticity(L : Plua_State) : LongInt; Cdecl; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1132 |
var gear: PGear; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1133 |
begin |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1134 |
if CheckLuaParamCount(L, 2, 'SetGearElasticity', 'gearUid, Elasticity') then |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1135 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1136 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1137 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1138 |
gear^.Elasticity:= int2hwFloat(Trunc(lua_tonumber(L, 2))) / 10000 |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1139 |
end; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1140 |
lc_setgearelasticity:= 0 |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1141 |
end; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1142 |
|
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1143 |
function lc_getgearfriction(L : Plua_State) : LongInt; Cdecl; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1144 |
var gear : PGear; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1145 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1146 |
if CheckLuaParamCount(L, 1, 'GetGearFriction', 'gearUid') then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1147 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1148 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1149 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1150 |
lua_pushnumber(L, hwRound(gear^.friction * _10000)) |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1151 |
else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1152 |
lua_pushnil(L); |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1153 |
end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1154 |
else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1155 |
lua_pushnil(L); // return value on stack (nil) |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1156 |
lc_getgearfriction:= 1 |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1157 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1158 |
|
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1159 |
function lc_setgearfriction(L : Plua_State) : LongInt; Cdecl; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1160 |
var gear: PGear; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1161 |
begin |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1162 |
if CheckLuaParamCount(L, 2, 'SetGearFriction', 'gearUid, Friction') then |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1163 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1164 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1165 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1166 |
gear^.Friction:= int2hwFloat(Trunc(lua_tonumber(L, 2))) / 10000 |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1167 |
end; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1168 |
lc_setgearfriction:= 0 |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1169 |
end; |
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
1170 |
|
3896 | 1171 |
function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
1172 |
var gear : PGear; |
|
1173 |
begin |
|
10297 | 1174 |
if CheckLuaParamCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
3896 | 1175 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1176 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3896 | 1177 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1178 |
gear^.message:= Trunc(lua_tonumber(L, 2)); |
3896 | 1179 |
end; |
1180 |
lc_setgearmessage:= 0 |
|
1181 |
end; |
|
1182 |
||
6523 | 1183 |
function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
1184 |
var gear : PGear; |
|
1185 |
begin |
|
10297 | 1186 |
if CheckLuaParamCount(L, 1, 'GetGearPos', 'gearUid') then |
6523 | 1187 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1188 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
6523 | 1189 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1190 |
lua_pushnumber(L, gear^.Pos) |
6523 | 1191 |
else |
1192 |
lua_pushnil(L); |
|
10287 | 1193 |
end |
1194 |
else |
|
1195 |
lua_pushnil(L); // return value on stack (nil) |
|
6523 | 1196 |
lc_getgearpos:= 1 |
1197 |
end; |
|
1198 |
||
1199 |
function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
|
1200 |
var gear : PGear; |
|
1201 |
begin |
|
10297 | 1202 |
if CheckLuaParamCount(L, 2, 'SetGearPos', 'gearUid, value') then |
6523 | 1203 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1204 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
6523 | 1205 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1206 |
gear^.Pos:= Trunc(lua_tonumber(L, 2)); |
6523 | 1207 |
end; |
1208 |
lc_setgearpos:= 0 |
|
1209 |
end; |
|
1210 |
||
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
|
1211 |
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
|
1212 |
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
|
1213 |
begin |
10297 | 1214 |
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
|
1215 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1216 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
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
|
1217 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1218 |
lua_pushnumber(L, gear^.CollisionMask) |
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
|
1219 |
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
|
1220 |
lua_pushnil(L); |
10287 | 1221 |
end |
1222 |
else |
|
1223 |
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
|
1224 |
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
|
1225 |
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
|
1226 |
|
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
|
1227 |
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
|
1228 |
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
|
1229 |
begin |
10297 | 1230 |
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
|
1231 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1232 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
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
|
1233 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1234 |
gear^.CollisionMask:= Trunc(lua_tonumber(L, 2)); |
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
|
1235 |
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
|
1236 |
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
|
1237 |
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
|
1238 |
|
3755 | 1239 |
function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
1240 |
var gear : PGear; |
|
1241 |
begin |
|
10297 | 1242 |
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
|
1243 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1244 |
gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
1245 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1246 |
lua_pushnumber(L, gear^.Hedgehog^.BotLevel) |
3755 | 1247 |
else |
1248 |
lua_pushnil(L); |
|
1249 |
end; |
|
1250 |
lc_gethoglevel := 1; |
|
1251 |
end; |
|
1252 |
||
4496 | 1253 |
function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
1254 |
var gear : PGear; |
|
1255 |
begin |
|
10297 | 1256 |
if CheckLuaParamCount(L, 2, 'SetHogLevel', 'gearUid, level') then |
4496 | 1257 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1258 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4496 | 1259 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1260 |
gear^.Hedgehog^.BotLevel:= Trunc(lua_tonumber(L, 2)); |
4496 | 1261 |
end; |
1262 |
lc_sethoglevel:= 0 |
|
1263 |
end; |
|
1264 |
||
3043
3acdb4dac6eb
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 |
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
|
1266 |
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
|
1267 |
begin |
10297 | 1268 |
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
|
1269 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1270 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
1271 |
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
|
1272 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1273 |
lua_pushnumber(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
|
1274 |
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
|
1275 |
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
|
1276 |
lua_pushnil(L); |
10287 | 1277 |
end |
1278 |
else |
|
1279 |
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
|
1280 |
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
|
1281 |
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
|
1282 |
|
4498 | 1283 |
function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
11741
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1284 |
var idx: integer; |
4498 | 1285 |
begin |
11741
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1286 |
if CheckLuaParamCount(L, 1, 'GetClanColor', 'clanIdx') then |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1287 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1288 |
idx:= Trunc(lua_tonumber(L, 1)); |
11741
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1289 |
if (not lua_isnumber(L, 1)) then |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1290 |
begin |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1291 |
LuaError('Argument ''clanIdx'' must be a number!'); |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1292 |
lua_pushnil(L); |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1293 |
end |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1294 |
else if (idx < 0) or (idx >= ClansCount) then |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1295 |
begin |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1296 |
LuaError('Argument ''clanIdx'' out of range! (There are currently ' + IntToStr(ClansCount) + ' clans, so valid range is: 0-' + IntToStr(ClansCount-1) + ')'); |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1297 |
lua_pushnil(L); |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1298 |
end |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1299 |
else |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1300 |
lua_pushnumber(L, ClansArray[idx]^.Color shl 8 or $FF); |
11741
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11683
diff
changeset
|
1301 |
end |
10287 | 1302 |
else |
4498 | 1303 |
lua_pushnil(L); // return value on stack (nil) |
1304 |
lc_getclancolor:= 1 |
|
1305 |
end; |
|
1306 |
||
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1307 |
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
|
1308 |
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
|
1309 |
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
|
1310 |
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
|
1311 |
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
|
1312 |
begin |
10297 | 1313 |
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
|
1314 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1315 |
i:= Trunc(lua_tonumber(L,1)); |
11682 | 1316 |
if i >= ClansCount then exit(0); |
10581 | 1317 |
clan := ClansArray[i]; |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1318 |
clan^.Color:= Trunc(lua_tonumber(L, 2)) shr 8; |
9656 | 1319 |
|
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
|
1320 |
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
|
1321 |
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
|
1322 |
team:= clan^.Teams[i]; |
13623
edffc9b7ad58
Add comments for most hwengine constants
Wuzzy <Wuzzy2@mail.ru>
parents:
13622
diff
changeset
|
1323 |
for j:= 0 to cMaxHHIndex do |
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
|
1324 |
begin |
4891 | 1325 |
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
|
1326 |
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
|
1327 |
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
|
1328 |
FreeAndNilTexture(hh.NameTagTex); |
10127 | 1329 |
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
|
1330 |
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
|
1331 |
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
|
1332 |
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
|
1333 |
FreeAndNilTexture(team^.NameTagTex); |
10127 | 1334 |
team^.NameTagTex:= RenderStringTex(ansistring(clan^.Teams[i]^.TeamName), clan^.Color, fnt16); |
9656 | 1335 |
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
|
1336 |
|
11682 | 1337 |
FreeAndNilTexture(clan^.HealthTex); |
9656 | 1338 |
clan^.HealthTex:= makeHealthBarTexture(cTeamHealthWidth + 5, clan^.Teams[0]^.NameTagTex^.h, clan^.Color); |
1339 |
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
|
1340 |
|
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1341 |
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
|
1342 |
end; |
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1343 |
|
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1344 |
function lc_gethogvoicepack(L : Plua_State) : LongInt; Cdecl; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1345 |
var gear : PGear; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1346 |
begin |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1347 |
if CheckLuaParamCount(L, 1, 'GetHogVoicepack', 'gearUid') then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1348 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1349 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1350 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1351 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Voicepack^.name)) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1352 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1353 |
lua_pushnil(L); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1354 |
end |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1355 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1356 |
lua_pushnil(L); // return value on stack (nil) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1357 |
lc_gethogvoicepack:= 1 |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1358 |
end; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1359 |
|
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1360 |
function lc_gethoggrave(L : Plua_State) : LongInt; Cdecl; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1361 |
var gear : PGear; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1362 |
begin |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1363 |
if CheckLuaParamCount(L, 1, 'GetHogGrave', 'gearUid') then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1364 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1365 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1366 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1367 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.GraveName)) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1368 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1369 |
lua_pushnil(L); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1370 |
end |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1371 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1372 |
lua_pushnil(L); // return value on stack (nil) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1373 |
lc_gethoggrave:= 1 |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1374 |
end; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1375 |
|
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1376 |
function lc_gethogflag(L : Plua_State) : LongInt; Cdecl; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1377 |
var gear : PGear; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1378 |
begin |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1379 |
if CheckLuaParamCount(L, 1, 'GetHogFlag', 'gearUid') then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1380 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1381 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11852 | 1382 |
// TODO error messages |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1383 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1384 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Flag)) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1385 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1386 |
lua_pushnil(L); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1387 |
end |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1388 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1389 |
lua_pushnil(L); // return value on stack (nil) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1390 |
lc_gethogflag:= 1 |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1391 |
end; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1392 |
|
12051 | 1393 |
function lc_gethogfort(L : Plua_State) : LongInt; Cdecl; |
1394 |
var gear : PGear; |
|
1395 |
begin |
|
1396 |
if CheckLuaParamCount(L, 1, 'GetHogFort', 'gearUid') then |
|
1397 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1398 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
12051 | 1399 |
// TODO error messages |
1400 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1401 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.FortName)) |
|
1402 |
else |
|
1403 |
lua_pushnil(L); |
|
1404 |
end |
|
1405 |
else |
|
1406 |
lua_pushnil(L); // return value on stack (nil) |
|
1407 |
lc_gethogfort:= 1 |
|
1408 |
end; |
|
1409 |
||
11852 | 1410 |
function lc_ishoglocal(L : Plua_State) : LongInt; Cdecl; |
1411 |
var gear : PGear; |
|
1412 |
begin |
|
1413 |
if CheckLuaParamCount(L, 1, 'IsHogLocal', 'gearUid') then |
|
1414 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1415 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11852 | 1416 |
// TODO error messages |
1417 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1418 |
lua_pushboolean(L, IsHogLocal(gear^.Hedgehog)) |
|
1419 |
else |
|
1420 |
lua_pushnil(L); |
|
1421 |
end |
|
1422 |
else |
|
1423 |
lua_pushnil(L); // return value on stack (nil) |
|
1424 |
lc_ishoglocal:= 1 |
|
1425 |
end; |
|
1426 |
||
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1427 |
function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1428 |
var gear : PGear; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1429 |
begin |
10297 | 1430 |
if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1431 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1432 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11852 | 1433 |
// TODO error messages |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
1434 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4372 | 1435 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1436 |
else |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1437 |
lua_pushnil(L); |
10287 | 1438 |
end |
1439 |
else |
|
1440 |
lua_pushnil(L); // return value on stack (nil) |
|
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1441 |
lc_gethogteamname:= 1 |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1442 |
end; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1443 |
|
9788 | 1444 |
function lc_sethogteamname(L : Plua_State) : LongInt; Cdecl; |
1445 |
var gear : PGear; |
|
1446 |
begin |
|
10297 | 1447 |
if CheckLuaParamCount(L, 2, 'SetHogTeamName', 'gearUid, name') then |
9788 | 1448 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1449 |
gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
9788 | 1450 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1451 |
begin |
|
1452 |
gear^.Hedgehog^.Team^.TeamName := lua_tostring(L, 2); |
|
1453 |
||
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
|
1454 |
FreeAndNilTexture(gear^.Hedgehog^.Team^.NameTagTex); |
10127 | 1455 |
gear^.Hedgehog^.Team^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Team^.TeamName), gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
9788 | 1456 |
end |
1457 |
else |
|
1458 |
lua_pushnil(L); |
|
10287 | 1459 |
end |
1460 |
else |
|
1461 |
lua_pushnil(L); // return value on stack (nil) |
|
9788 | 1462 |
lc_sethogteamname:= 1 |
1463 |
end; |
|
1464 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1465 |
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
|
1466 |
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
|
1467 |
begin |
10297 | 1468 |
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
|
1469 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1470 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
1471 |
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
|
1472 |
begin |
4372 | 1473 |
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
|
1474 |
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
|
1475 |
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
|
1476 |
lua_pushnil(L); |
10287 | 1477 |
end |
1478 |
else |
|
1479 |
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
|
1480 |
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
|
1481 |
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
|
1482 |
|
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1483 |
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
|
1484 |
var gear : PGear; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1485 |
begin |
10297 | 1486 |
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
|
1487 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1488 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1489 |
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
|
1490 |
begin |
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
1491 |
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
|
1492 |
|
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
|
1493 |
FreeAndNilTexture(gear^.Hedgehog^.NameTagTex); |
10127 | 1494 |
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
|
1495 |
end |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1496 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1497 |
lc_sethogname:= 0; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1498 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1499 |
|
3722 | 1500 |
function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
1501 |
var gear : PGear; |
|
1502 |
begin |
|
10297 | 1503 |
if CheckLuaParamCount(L, 1, 'GetTimer', 'gearUid') then |
3722 | 1504 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1505 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3722 | 1506 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1507 |
lua_pushnumber(L, gear^.Timer) |
3722 | 1508 |
else |
1509 |
lua_pushnil(L); |
|
10287 | 1510 |
end |
1511 |
else |
|
1512 |
lua_pushnil(L); // return value on stack (nil) |
|
3722 | 1513 |
lc_gettimer:= 1 |
1514 |
end; |
|
1515 |
||
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1516 |
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
|
1517 |
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
|
1518 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1519 |
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
|
1520 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1521 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1522 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1523 |
lua_pushnumber(L, gear^.FlightTime) |
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1524 |
else |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1525 |
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
|
1526 |
end |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1527 |
else |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1528 |
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
|
1529 |
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
|
1530 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1531 |
|
3722 | 1532 |
function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
1533 |
var gear : PGear; |
|
1534 |
begin |
|
10297 | 1535 |
if CheckLuaParamCount(L, 1, 'GetHealth', 'gearUid') then |
3722 | 1536 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1537 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3722 | 1538 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1539 |
lua_pushnumber(L, gear^.Health) |
3722 | 1540 |
else |
1541 |
lua_pushnil(L); |
|
10287 | 1542 |
end |
1543 |
else |
|
1544 |
lua_pushnil(L); // return value on stack (nil) |
|
3722 | 1545 |
lc_gethealth:= 1 |
1546 |
end; |
|
1547 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1548 |
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
|
1549 |
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
|
1550 |
begin |
10297 | 1551 |
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
|
1552 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1553 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
1554 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1555 |
lua_pushnumber(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
|
1556 |
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
|
1557 |
lua_pushnil(L); |
10287 | 1558 |
end |
1559 |
else |
|
1560 |
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
|
1561 |
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
|
1562 |
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
|
1563 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1564 |
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
|
1565 |
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
|
1566 |
begin |
10297 | 1567 |
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
|
1568 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1569 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
1570 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1571 |
lua_pushnumber(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
|
1572 |
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
|
1573 |
lua_pushnil(L); |
10287 | 1574 |
end |
1575 |
else |
|
1576 |
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
|
1577 |
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
|
1578 |
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
|
1579 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1580 |
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
|
1581 |
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
|
1582 |
begin |
10297 | 1583 |
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
|
1584 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1585 |
gears:= GearByUID(Trunc(lua_tonumber(L, 1))); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1586 |
geard:= GearByUID(Trunc(lua_tonumber(L, 2))); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1587 |
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
|
1588 |
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
|
1589 |
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
|
1590 |
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
|
1591 |
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
|
1592 |
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
|
1593 |
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
|
1594 |
end; |
10287 | 1595 |
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
|
1596 |
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
|
1597 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1598 |
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
|
1599 |
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
|
1600 |
begin |
10297 | 1601 |
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
|
1602 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1603 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
1604 |
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
|
1605 |
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
|
1606 |
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
|
1607 |
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
|
1608 |
|
3761 | 1609 |
function lc_hogsay(L : Plua_State) : LongInt; Cdecl; |
1610 |
var gear : PGear; |
|
1611 |
vgear : PVisualGear; |
|
4533 | 1612 |
s : LongWord; |
10287 | 1613 |
n : LongInt; |
3761 | 1614 |
begin |
10297 | 1615 |
if CheckAndFetchParamCount(L, 3, 4, 'HogSay', 'gearUid, text, manner [, vgState]', n) then |
3761 | 1616 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1617 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3761 | 1618 |
if gear <> nil then |
1619 |
begin |
|
10287 | 1620 |
// state defaults to 0 if state param is given |
1621 |
if n = 4 then |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1622 |
s:= Trunc(lua_tonumber(L, 4)) |
10287 | 1623 |
else |
1624 |
s:= 0; |
|
4533 | 1625 |
vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
3761 | 1626 |
if vgear <> nil then |
1627 |
begin |
|
10518
dbbe2f6c0a96
make gear ability to speak somewhat less ironic
sheepluva
parents:
10516
diff
changeset
|
1628 |
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
|
1629 |
if Gear^.Kind = gtHedgehog then |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1630 |
begin |
11022 | 1631 |
AddChatString(#9+'[' + gear^.Hedgehog^.Name + '] '+vgear^.text); |
10210
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1632 |
vgear^.Hedgehog:= gear^.Hedgehog |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1633 |
end |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1634 |
else vgear^.Frame:= gear^.uid; |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1635 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1636 |
vgear^.FrameTicks:= Trunc(lua_tonumber(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
|
1637 |
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
|
1638 |
vgear^.FrameTicks:= 1; |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1639 |
lua_pushnumber(L, vgear^.Uid); |
5529 | 1640 |
end |
3761 | 1641 |
end |
10289 | 1642 |
else |
1643 |
lua_pushnil(L) |
|
4533 | 1644 |
end |
10287 | 1645 |
else |
1646 |
lua_pushnil(L); |
|
5529 | 1647 |
lc_hogsay:= 1 |
3761 | 1648 |
end; |
1649 |
||
4851 | 1650 |
function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1651 |
var gear, prevgear : PGear; |
|
1652 |
begin |
|
10297 | 1653 |
if CheckLuaParamCount(L, 1, 'SwitchHog', 'gearUid') then |
4851 | 1654 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1655 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4851 | 1656 |
// should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1657 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
|
1658 |
begin |
|
1659 |
prevgear := CurrentHedgehog^.Gear; |
|
7573 | 1660 |
if prevgear <> nil then |
1661 |
begin |
|
1662 |
prevgear^.Active := false; |
|
1663 |
prevgear^.State:= prevgear^.State and (not gstHHDriven); |
|
1664 |
prevgear^.Z := cHHZ; |
|
1665 |
prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
|
1666 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1667 |
|
7270
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1668 |
SwitchCurrentHedgehog(gear^.Hedgehog); |
12376
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12365
diff
changeset
|
1669 |
AmmoMenuInvalidated:= true; |
7270
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1670 |
CurrentTeam:= CurrentHedgehog^.Team; |
4851 | 1671 |
|
12376
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12365
diff
changeset
|
1672 |
repeat |
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12365
diff
changeset
|
1673 |
CurrentTeam^.CurrHedgehog := (CurrentTeam^.CurrHedgehog + 1) mod CurrentTeam^.HedgehogsNumber |
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12365
diff
changeset
|
1674 |
until |
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12365
diff
changeset
|
1675 |
CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = CurrentHedgehog^.Gear; |
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12365
diff
changeset
|
1676 |
|
4851 | 1677 |
gear^.State:= gear^.State or gstHHDriven; |
1678 |
gear^.Active := true; |
|
1679 |
gear^.Z := cCurrHHZ; |
|
7401 | 1680 |
gear^.Message:= gear^.Message or gmRemoveFromList or gmAddToList; |
4851 | 1681 |
end |
1682 |
end; |
|
1683 |
lc_switchhog:= 0 |
|
1684 |
end; |
|
1685 |
||
13383
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1686 |
function lc_enableswitchhog(L : Plua_State) : LongInt; Cdecl; |
13385
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1687 |
var gear, iterator: PGear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1688 |
alreadySwitching: boolean; |
13383
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1689 |
begin |
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1690 |
if CheckLuaParamCount(L, 0, 'EnableSwitchHog', '') then |
13385
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1691 |
if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1692 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1693 |
alreadySwitching:= false; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1694 |
iterator:= GearsList; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1695 |
// Check if there's already a switcher gear |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1696 |
while (iterator <> nil) do |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1697 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1698 |
if (iterator^.Kind = gtSwitcher) then |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1699 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1700 |
alreadySwitching:= true; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1701 |
lua_pushnumber(L, iterator^.Uid); |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1702 |
break; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1703 |
end; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1704 |
iterator:= iterator^.NextGear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1705 |
end; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1706 |
if (not alreadySwitching) then |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1707 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1708 |
// Enable switching and return gear UID |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1709 |
gear:= AddGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), gtSwitcher, 0, _0, _0, 0); |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1710 |
CurAmmoGear:= gear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1711 |
lastGearByUID:= gear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1712 |
bShowFinger:= false; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1713 |
lua_pushnumber(L, gear^.Uid); |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1714 |
end; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1715 |
end |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1716 |
// Return nil on failure |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1717 |
else |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1718 |
lua_pushnil(L) |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1719 |
else |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1720 |
lua_pushnil(L); |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13383
diff
changeset
|
1721 |
lc_enableswitchhog:= 1; |
13383
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1722 |
end; |
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1723 |
|
4481 | 1724 |
function lc_addammo(L : Plua_State) : LongInt; Cdecl; |
1725 |
var gear : PGear; |
|
12952
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1726 |
at, n, c: LongInt; |
10281 | 1727 |
const |
1728 |
call = 'AddAmmo'; |
|
1729 |
params = 'gearUid, ammoType [, ammoCount]'; |
|
4481 | 1730 |
begin |
10297 | 1731 |
if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
4481 | 1732 |
begin |
10281 | 1733 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
12952
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1734 |
if (at >= 0) and (TAmmoType(at) <> amNothing) then |
10281 | 1735 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1736 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10281 | 1737 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
10287 | 1738 |
if n = 2 then |
10281 | 1739 |
AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1740 |
else |
|
12952
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1741 |
begin |
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1742 |
c:= Trunc(lua_tonumber(L, 3)); |
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1743 |
if (c = 0) and (CurrentHedgehog = gear^.Hedgehog) and (gear^.Hedgehog^.CurAmmoType = TAmmoType(at)) then |
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1744 |
ParseCommand('setweap ' + char(0), true, true); |
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1745 |
SetAmmo(gear^.Hedgehog^, TAmmoType(at), c); |
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12944
diff
changeset
|
1746 |
end; |
10281 | 1747 |
end; |
10287 | 1748 |
end; |
4481 | 1749 |
lc_addammo:= 0 |
1750 |
end; |
|
1751 |
||
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
|
1752 |
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
|
1753 |
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
|
1754 |
ammo : PAmmo; |
10281 | 1755 |
at : LongInt; |
1756 |
const |
|
1757 |
call = 'GetAmmoCount'; |
|
1758 |
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
|
1759 |
begin |
10297 | 1760 |
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
|
1761 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1762 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1763 |
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
|
1764 |
begin |
10281 | 1765 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1766 |
if at >= 0 then |
|
1767 |
begin |
|
1768 |
ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
|
1769 |
if ammo^.AmmoType = amNothing then |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1770 |
lua_pushnumber(L, 0) |
10281 | 1771 |
else |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1772 |
lua_pushnumber(L, ammo^.Count); |
10281 | 1773 |
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
|
1774 |
end |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1775 |
else lua_pushnumber(L, 0); |
10287 | 1776 |
end |
1777 |
else |
|
1778 |
lua_pushnil(L); |
|
6046 | 1779 |
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
|
1780 |
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
|
1781 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1782 |
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
|
1783 |
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
|
1784 |
begin |
10297 | 1785 |
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
|
1786 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1787 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3723 | 1788 |
if gear <> nil then |
1789 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1790 |
gear^.Health:= Trunc(lua_tonumber(L, 2)); |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1791 |
|
9914 | 1792 |
if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1793 |
begin |
|
13602
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13600
diff
changeset
|
1794 |
if gear^.Health > cMaxHogHealth then |
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13600
diff
changeset
|
1795 |
gear^.Health:= cMaxHogHealth; |
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13600
diff
changeset
|
1796 |
if gear^.Health < 0 then |
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13600
diff
changeset
|
1797 |
gear^.Health:= 0; |
9914 | 1798 |
RenderHealth(gear^.Hedgehog^); |
1799 |
RecountTeamHealth(gear^.Hedgehog^.Team) |
|
1800 |
end; |
|
1801 |
// Why did this do a "setalltoactive" ? |
|
10015 | 1802 |
//SetAllToActive; |
9914 | 1803 |
Gear^.Active:= true; |
1804 |
AllInactive:= false |
|
3723 | 1805 |
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
|
1806 |
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
|
1807 |
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
|
1808 |
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
|
1809 |
|
12944
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1810 |
function lc_healhog(L : Plua_State) : LongInt; Cdecl; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1811 |
var gear : PGear; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1812 |
healthBoost, n: LongInt; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1813 |
begin |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1814 |
if CheckAndFetchParamCountRange(L, 2, 4, 'HealHog', 'gearUid, healthBoost [, showMessage [, tint]]', n) then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1815 |
begin |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1816 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1817 |
healthBoost:= Trunc(lua_tonumber(L, 2)); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1818 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (healthBoost >= 1) then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1819 |
begin |
13622
a6abc2c1fc1a
Show correct health increase when hog health cap is reached
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset
|
1820 |
healthBoost:= IncHogHealth(gear^.Hedgehog, healthBoost); |
12944
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1821 |
RenderHealth(gear^.Hedgehog^); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1822 |
RecountTeamHealth(gear^.Hedgehog^.Team); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1823 |
if n = 4 then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1824 |
HHHeal(gear^.Hedgehog, healthBoost, lua_toboolean(L, 3), Trunc(lua_tonumber(L, 4))) |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1825 |
else if n = 3 then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1826 |
HHHeal(gear^.Hedgehog, healthBoost, lua_toboolean(L, 3)) |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1827 |
else if n = 2 then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1828 |
HHHeal(gear^.Hedgehog, healthBoost, true); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1829 |
Gear^.Active:= true; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1830 |
AllInactive:= false |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1831 |
end |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1832 |
end; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1833 |
lc_healhog:= 0 |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1834 |
end; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
1835 |
|
3722 | 1836 |
function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1837 |
var gear : PGear; |
|
1838 |
begin |
|
10297 | 1839 |
if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then |
3722 | 1840 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1841 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1842 |
if gear <> nil then gear^.Timer:= Trunc(lua_tonumber(L, 2)) |
3722 | 1843 |
end; |
1844 |
lc_settimer:= 0 |
|
1845 |
end; |
|
1846 |
||
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1847 |
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
|
1848 |
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
|
1849 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1850 |
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
|
1851 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1852 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1853 |
if gear <> nil then gear^.FlightTime:= Trunc(lua_tonumber(L, 2)) |
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1854 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1855 |
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
|
1856 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1857 |
|
3756 | 1858 |
function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1859 |
var gear: PGear; |
|
10281 | 1860 |
t : LongInt; |
1861 |
const |
|
1862 |
call = 'SetEffect'; |
|
1863 |
params = 'gearUid, effect, effectState'; |
|
3756 | 1864 |
begin |
10297 | 1865 |
if CheckLuaParamCount(L, 3, call, params) then |
10281 | 1866 |
begin |
1867 |
t:= LuaToHogEffectOrd(L, 2, call, params); |
|
1868 |
if t >= 0 then |
|
1869 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1870 |
gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
10281 | 1871 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1872 |
gear^.Hedgehog^.Effects[THogEffect(t)]:= Trunc(lua_tonumber(L, 3)); |
10281 | 1873 |
end; |
1874 |
end; |
|
3756 | 1875 |
lc_seteffect := 0; |
1876 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1877 |
|
5489 | 1878 |
function lc_geteffect(L : Plua_State) : LongInt; Cdecl; |
1879 |
var gear : PGear; |
|
10281 | 1880 |
t : LongInt; |
1881 |
const |
|
1882 |
call = 'GetEffect'; |
|
1883 |
params = 'gearUid, effect'; |
|
5489 | 1884 |
begin |
10297 | 1885 |
if CheckLuaParamCount(L, 2, call, params) then |
5489 | 1886 |
begin |
10281 | 1887 |
t:= LuaToHogEffectOrd(L, 2, call, params); |
1888 |
if t >= 0 then |
|
1889 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1890 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10281 | 1891 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1892 |
lua_pushnumber(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
10281 | 1893 |
else |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1894 |
lua_pushnumber(L, 0) |
10281 | 1895 |
end; |
10287 | 1896 |
end |
1897 |
else |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1898 |
lua_pushnumber(L, 0); |
5489 | 1899 |
lc_geteffect:= 1 |
1900 |
end; |
|
3756 | 1901 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1902 |
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
|
1903 |
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
|
1904 |
begin |
10297 | 1905 |
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
|
1906 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1907 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3723 | 1908 |
if gear <> nil then |
1909 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1910 |
gear^.State:= Trunc(lua_tonumber(L, 2)); |
3723 | 1911 |
SetAllToActive; |
1912 |
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
|
1913 |
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
|
1914 |
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
|
1915 |
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
|
1916 |
|
3acdb4dac6eb
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_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
|
1918 |
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
|
1919 |
begin |
10297 | 1920 |
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
|
1921 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1922 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
1923 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1924 |
lua_pushnumber(L, gear^.State) |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1925 |
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
|
1926 |
lua_pushnil(L) |
10287 | 1927 |
end |
1928 |
else |
|
1929 |
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
|
1930 |
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
|
1931 |
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
|
1932 |
|
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1933 |
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
|
1934 |
var gear : PGear; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1935 |
begin |
10297 | 1936 |
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
|
1937 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1938 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1939 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1940 |
lua_pushnumber(L, gear^.Tag) |
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1941 |
else |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1942 |
lua_pushnil(L); |
10287 | 1943 |
end |
1944 |
else |
|
1945 |
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
|
1946 |
lc_gettag:= 1 |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1947 |
end; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
1948 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1949 |
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
|
1950 |
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
|
1951 |
begin |
10297 | 1952 |
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
|
1953 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1954 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3723 | 1955 |
if gear <> nil then |
1956 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
1957 |
gear^.Tag:= Trunc(lua_tonumber(L, 2)); |
3723 | 1958 |
SetAllToActive; |
1959 |
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
|
1960 |
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
|
1961 |
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
|
1962 |
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
|
1963 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1964 |
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
|
1965 |
begin |
3407 | 1966 |
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
|
1967 |
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
|
1968 |
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
|
1969 |
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
|
1970 |
|
12291
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1971 |
function lc_endturn(L : Plua_State) : LongInt; Cdecl; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1972 |
var n: LongInt; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1973 |
const |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1974 |
call = 'EndTurn'; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1975 |
params = '[noTaunts]'; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1976 |
begin |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1977 |
if CheckAndFetchParamCount(L, 0, 1, call, params, n) then |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1978 |
if n >= 1 then |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1979 |
LuaNoEndTurnTaunts:= lua_toboolean(L, 1); |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1980 |
LuaEndTurnRequested:= true; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1981 |
lc_endturn:= 0 |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1982 |
end; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
1983 |
|
13345
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1984 |
function lc_retreat(L : Plua_State) : LongInt; Cdecl; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1985 |
var n, time: LongInt; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1986 |
respectFactor: Boolean; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1987 |
const |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1988 |
call = 'Retreat'; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1989 |
params = 'time [, respectGetAwayTimeFactor]'; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1990 |
begin |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1991 |
if CheckAndFetchParamCount(L, 1, 2, call, params, n) then |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1992 |
begin |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1993 |
IsGetAwayTime:= true; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1994 |
AttackBar:= 0; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1995 |
time:= Trunc(lua_tonumber(L, 1)); |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1996 |
if n = 2 then |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1997 |
respectFactor:= lua_toboolean(L, 2) |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1998 |
else |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
1999 |
respectFactor:= True; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2000 |
if respectFactor then |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2001 |
TurnTimeLeft:= (time * cGetAwayTime) div 100 |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2002 |
else |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2003 |
TurnTimeLeft:= time; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2004 |
if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2005 |
begin |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2006 |
CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstAttacked; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2007 |
CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and (not gstAttacking); |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2008 |
end; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2009 |
end; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2010 |
lc_retreat:= 0 |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2011 |
end; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
2012 |
|
13175
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
2013 |
function lc_skipturn(L : Plua_State): LongInt; Cdecl; |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
2014 |
begin |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
2015 |
L:= L; // avoid compiler hint |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
2016 |
ParseCommand('skip', true, true); |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
2017 |
lc_skipturn:= 0; |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
2018 |
end; |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
2019 |
|
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2020 |
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
|
2021 |
var statInfo : TStatInfoType; |
10287 | 2022 |
i, n : LongInt; |
2023 |
color, tn: shortstring; |
|
2024 |
needsTn : boolean; |
|
10281 | 2025 |
const |
2026 |
call = 'SendStat'; |
|
2027 |
params = 'statInfoType, color [, teamname]'; |
|
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2028 |
begin |
10297 | 2029 |
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
|
2030 |
begin |
10281 | 2031 |
i:= LuaToStatInfoTypeOrd(L, 1, call, params); |
2032 |
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
|
2033 |
begin |
10287 | 2034 |
statInfo:= TStatInfoType(i); |
2035 |
needsTn:= ((statInfo = siPlayerKills) or (statInfo = siClanHealth)); |
|
2036 |
// check if param count is correct for the used statInfo |
|
2037 |
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
|
2038 |
begin |
10287 | 2039 |
if n = 3 then |
2040 |
LuaCallError(EnumToStr(statInfo) + ' does not support the teamname parameter', call, params) |
|
2041 |
else |
|
2042 |
LuaCallError(EnumToStr(statInfo) + ' requires the teamname parameter', call, params); |
|
10281 | 2043 |
end |
10287 | 2044 |
else // count is correct! |
10281 | 2045 |
begin |
10542 | 2046 |
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
|
2047 |
begin |
10281 | 2048 |
// 3: team name |
2049 |
for i:= 0 to Pred(TeamsCount) do |
|
2050 |
begin |
|
10282 | 2051 |
color:= _S'0'; |
10281 | 2052 |
tn:= lua_tostring(L, 3); |
2053 |
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
|
2054 |
begin |
10281 | 2055 |
if TeamName = tn then |
2056 |
begin |
|
2057 |
color := uUtils.IntToStr(Clan^.Color); |
|
2058 |
Break; |
|
2059 |
end |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2060 |
end |
10281 | 2061 |
end; |
2062 |
if (statInfo = siPlayerKills) then |
|
2063 |
begin |
|
2064 |
SendStat(siPlayerKills, color + ' ' + |
|
2065 |
lua_tostring(L, 2) + ' ' + tn); |
|
2066 |
end |
|
2067 |
else if (statInfo = siClanHealth) then |
|
2068 |
begin |
|
2069 |
SendStat(siClanHealth, color + ' ' + |
|
2070 |
lua_tostring(L, 2)); |
|
2071 |
end |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2072 |
end |
10281 | 2073 |
else |
2074 |
begin |
|
2075 |
SendStat(statInfo,lua_tostring(L, 2)); |
|
2076 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2077 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2078 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2079 |
end; |
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2080 |
lc_sendstat:= 0 |
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2081 |
end; |
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2082 |
|
12337
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2083 |
function lc_sendgameresultoff(L : Plua_State) : LongInt; Cdecl; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2084 |
begin |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2085 |
L:= L; // avoid compiler hint |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2086 |
uStats.SendGameResultOn := false; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2087 |
lc_sendgameresultoff:= 0 |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2088 |
end; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2089 |
|
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2090 |
function lc_sendrankingstatsoff(L : Plua_State) : LongInt; Cdecl; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2091 |
begin |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2092 |
L:= L; // avoid compiler hint |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2093 |
uStats.SendRankingStatsOn := false; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2094 |
lc_sendrankingstatsoff:= 0 |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2095 |
end; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2096 |
|
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2097 |
function lc_sendachievementsstatsoff(L : Plua_State) : LongInt; Cdecl; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2098 |
begin |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2099 |
L:= L; // avoid compiler hint |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2100 |
uStats.SendAchievementsStatsOn := false; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2101 |
lc_sendachievementsstatsoff:= 0 |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2102 |
end; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
2103 |
|
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
2104 |
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
|
2105 |
begin |
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
2106 |
L:= L; // avoid compiler hint |
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
2107 |
uStats.SendHealthStatsOn := false; |
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
2108 |
lc_sendhealthstatsoff:= 0 |
9174
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
2109 |
end; |
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
2110 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2111 |
function 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
|
2112 |
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
|
2113 |
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
|
2114 |
tryhard: boolean; |
10287 | 2115 |
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
|
2116 |
begin |
10297 | 2117 |
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
|
2118 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2119 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
2120 |
fall:= lua_toboolean(L, 2); |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2121 |
left:= Trunc(lua_tonumber(L, 3)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2122 |
right:= Trunc(lua_tonumber(L, 4)); |
10287 | 2123 |
if n = 5 then |
10496 | 2124 |
tryhard:= lua_toboolean(L, 5) |
2125 |
else |
|
2126 |
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
|
2127 |
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
|
2128 |
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
|
2129 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2130 |
lua_pushnumber(L, gear^.uid) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2131 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2132 |
lua_pushnil(L); |
10287 | 2133 |
end |
2134 |
else |
|
2135 |
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
|
2136 |
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
|
2137 |
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
|
2138 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2139 |
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
|
2140 |
var gear: PGear; |
10281 | 2141 |
n, s: LongInt; |
13127
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2142 |
instaVoice: boolean; |
10281 | 2143 |
const |
2144 |
call = 'PlaySound'; |
|
13127
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2145 |
params = 'soundId [, hhGearUid [, instaVoice]]'; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2146 |
begin |
13127
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2147 |
if CheckAndFetchParamCountRange(L, 1, 3, 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
|
2148 |
begin |
10281 | 2149 |
s:= LuaToSoundOrd(L, 1, call, params); |
2150 |
if s >= 0 then |
|
2151 |
begin |
|
2152 |
// no gear specified |
|
2153 |
if n = 1 then |
|
13126
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2154 |
PlaySound(TSound(s), false, true) |
10287 | 2155 |
else |
10281 | 2156 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2157 |
gear:= GearByUID(Trunc(lua_tonumber(L, 2))); |
10281 | 2158 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
13127
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2159 |
begin |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2160 |
instaVoice:= false; |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2161 |
if n = 3 then |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2162 |
instaVoice:= lua_toboolean(L, 3); |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2163 |
if instaVoice then |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2164 |
PlaySoundV(TSound(s), gear^.Hedgehog^.Team^.Voicepack, false, true) |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2165 |
else |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2166 |
AddVoice(TSound(s), gear^.Hedgehog^.Team^.Voicepack, true); |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13126
diff
changeset
|
2167 |
end; |
10281 | 2168 |
end; |
2169 |
end; |
|
2170 |
end; |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2171 |
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
|
2172 |
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
|
2173 |
|
13126
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2174 |
function lc_setsoundmask(L : Plua_State) : LongInt; Cdecl; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2175 |
var s: LongInt; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2176 |
soundState: boolean; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2177 |
const |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2178 |
call = 'SetSoundMasked'; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2179 |
params = 'soundId, isMasked]'; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2180 |
begin |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2181 |
if CheckLuaParamCount(L, 2, call, params) then |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2182 |
begin |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2183 |
s:= LuaToSoundOrd(L, 1, call, params); |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2184 |
if s <> Ord(sndNone) then |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2185 |
begin |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2186 |
soundState:= lua_toboolean(L, 2); |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2187 |
MaskedSounds[TSound(s)]:= soundState; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2188 |
end; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2189 |
end; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2190 |
lc_setsoundmask:= 0; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2191 |
end; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
2192 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2193 |
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
|
2194 |
var np: LongInt; |
13587
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2195 |
colorArg: Int64; |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2196 |
colorStr: 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
|
2197 |
begin |
10297 | 2198 |
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
|
2199 |
begin |
13587
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2200 |
colorArg:= Trunc(lua_tonumber(L, 2)); |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2201 |
if (colorArg < 0) and (abs(colorArg) <= cClanColors) then |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2202 |
// Pick clan color from settings (recommended) |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2203 |
colorStr:= IntToStr(ClanColorArray[Pred(abs(colorArg))]) |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2204 |
else if (colorArg >= 0) and (colorArg <= $ffffffff) then |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2205 |
// Specify color directly |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2206 |
colorStr:= IntToStr(colorArg) |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2207 |
else |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2208 |
begin |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2209 |
OutError('Lua error: AddTeam: Invalid ''color'' argument, must be between '+IntToStr(-cClanColors)+' and 0xffffffff!', true); |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2210 |
lc_addteam:= 0; |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2211 |
exit; |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2212 |
end; |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
2213 |
ParseCommand('addteam x ' + colorStr + ' ' + lua_tostring(L, 1), true, true); |
7805 | 2214 |
ParseCommand('grave ' + lua_tostring(L, 3), true, true); |
2215 |
ParseCommand('fort ' + lua_tostring(L, 4), true, true); |
|
2216 |
ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); |
|
2217 |
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
|
2218 |
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
|
2219 |
// fails on x64 |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2220 |
//lua_pushnumber(L, LongInt(CurrentTeam)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2221 |
end; |
10287 | 2222 |
//else |
2223 |
//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
|
2224 |
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
|
2225 |
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
|
2226 |
|
13023
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2227 |
function lc_setteamlabel(L : Plua_State) : LongInt; Cdecl; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2228 |
var teamValue: ansistring; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2229 |
i, n: LongInt; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2230 |
success: boolean; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2231 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2232 |
if CheckAndFetchParamCount(L, 1, 2, 'SetTeamLabel', 'teamname[, label]', n) then |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2233 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2234 |
success:= false; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2235 |
// fetch team |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2236 |
if TeamsCount > 0 then |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2237 |
for i:= 0 to Pred(TeamsCount) do |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2238 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2239 |
// skip teams that don't have matching name |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2240 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2241 |
continue; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2242 |
|
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2243 |
// value of type nil? Then let's clear the team value |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2244 |
if (n < 2) or lua_isnil(L, 2) then |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2245 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2246 |
FreeAndNilTexture(TeamsArray[i]^.LuaTeamValueTex); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2247 |
TeamsArray[i]^.hasLuaTeamValue:= false; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2248 |
success:= true; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2249 |
end |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2250 |
// value of type string? Then let's set the team value |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2251 |
else if (lua_isstring(L, 2)) then |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2252 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2253 |
teamValue:= lua_tostring(L, 2); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2254 |
TeamsArray[i]^.LuaTeamValue:= teamValue; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2255 |
FreeAndNilTexture(TeamsArray[i]^.LuaTeamValueTex); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2256 |
TeamsArray[i]^.LuaTeamValueTex := RenderStringTex(teamValue, TeamsArray[i]^.Clan^.Color, fnt16); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2257 |
TeamsArray[i]^.hasLuaTeamValue:= true; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2258 |
success:= true; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2259 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2260 |
// don't change more than one team |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2261 |
break; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2262 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2263 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2264 |
// return true if operation was successful, false otherwise |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2265 |
lua_pushboolean(L, success); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2266 |
lc_setteamlabel:= 1; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2267 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
2268 |
|
12936 | 2269 |
function lc_getteamname(L : Plua_State) : LongInt; Cdecl; |
2270 |
var t: LongInt; |
|
2271 |
begin |
|
2272 |
if CheckLuaParamCount(L, 1, 'GetTeamName', 'teamIdx') then |
|
2273 |
begin |
|
2274 |
t:= Trunc(lua_tonumber(L, 1)); |
|
2275 |
if (t < 0) or (t >= TeamsCount) then |
|
2276 |
lua_pushnil(L) |
|
2277 |
else |
|
2278 |
lua_pushstring(L, str2pchar(TeamsArray[t]^.TeamName)); |
|
2279 |
end |
|
2280 |
else |
|
2281 |
lua_pushnil(L); |
|
2282 |
lc_getteamname:= 1; |
|
2283 |
end; |
|
2284 |
||
13025
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2285 |
function lc_getteamindex(L : Plua_state) : LongInt; Cdecl; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2286 |
var i: LongInt; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2287 |
found: boolean; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2288 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2289 |
found:= false; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2290 |
if CheckLuaParamCount(L, 1, 'GetTeamIndex', 'teamname') then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2291 |
if TeamsCount > 0 then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2292 |
for i:= 0 to Pred(TeamsCount) do |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2293 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2294 |
// skip teams that don't have matching name |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2295 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2296 |
continue; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2297 |
lua_pushnumber(L, i); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2298 |
found:= true; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2299 |
break; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2300 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2301 |
if (not found) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2302 |
lua_pushnil(L); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2303 |
lc_getteamindex:= 1; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2304 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2305 |
|
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2306 |
function lc_getteamclan(L : Plua_state) : LongInt; Cdecl; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2307 |
var i: LongInt; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2308 |
found: boolean; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2309 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2310 |
found:= false; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2311 |
if CheckLuaParamCount(L, 1, 'GetTeamClan', 'teamname') then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2312 |
if TeamsCount > 0 then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2313 |
for i:= 0 to Pred(TeamsCount) do |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2314 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2315 |
// skip teams that don't have matching name |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2316 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2317 |
continue; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2318 |
lua_pushnumber(L, TeamsArray[i]^.Clan^.ClanIndex); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2319 |
found:= true; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2320 |
break; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2321 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2322 |
if (not found) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2323 |
lua_pushnil(L); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2324 |
lc_getteamclan:= 1; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2325 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
2326 |
|
10290 | 2327 |
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
|
2328 |
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
|
2329 |
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
|
2330 |
hidden: boolean; |
10290 | 2331 |
begin |
10297 | 2332 |
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
|
2333 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2334 |
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
|
2335 |
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
|
2336 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2337 |
// 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
|
2338 |
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
|
2339 |
continue; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2340 |
|
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2341 |
// 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
|
2342 |
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
|
2343 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2344 |
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
|
2345 |
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
|
2346 |
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
|
2347 |
// 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
|
2348 |
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
|
2349 |
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
|
2350 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2351 |
// 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
|
2352 |
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
|
2353 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2354 |
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
|
2355 |
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
|
2356 |
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
|
2357 |
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
|
2358 |
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
|
2359 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2360 |
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
|
2361 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2362 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2363 |
// 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
|
2364 |
break; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2365 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2366 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2367 |
lc_dismissteam:= 0; |
10290 | 2368 |
end; |
2369 |
||
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2370 |
function lc_getteamstats(L : Plua_State) : LongInt; Cdecl; |
12626 | 2371 |
var i: LongInt; |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2372 |
begin |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2373 |
if CheckLuaParamCount(L, 1, 'GetTeamStats', 'teamname') then |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2374 |
begin |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2375 |
if TeamsCount > 0 then |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2376 |
for i:= 0 to Pred(TeamsCount) do |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2377 |
begin |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2378 |
// skip teams that don't have matching name |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2379 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2380 |
continue; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2381 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2382 |
lua_newtable(L); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2383 |
|
12605 | 2384 |
lua_pushstring(L, str2pchar('Kills')); |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2385 |
lua_pushnumber(L, TeamsArray[i]^.stats.Kills); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2386 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2387 |
|
12605 | 2388 |
lua_pushstring(L, str2pchar('Suicides')); |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2389 |
lua_pushnumber(L, TeamsArray[i]^.stats.Suicides); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2390 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2391 |
|
12605 | 2392 |
lua_pushstring(L, str2pchar('AIKills')); |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2393 |
lua_pushnumber(L, TeamsArray[i]^.stats.AIKills); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2394 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2395 |
|
12605 | 2396 |
lua_pushstring(L, str2pchar('TeamKills')); |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2397 |
lua_pushnumber(L, TeamsArray[i]^.stats.TeamKills); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2398 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2399 |
|
12605 | 2400 |
lua_pushstring(L, str2pchar('TurnSkips')); |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2401 |
lua_pushnumber(L, TeamsArray[i]^.stats.TurnSkips); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2402 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2403 |
|
12605 | 2404 |
lua_pushstring(L, str2pchar('TeamDamage')); |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2405 |
lua_pushnumber(L, TeamsArray[i]^.stats.TeamDamage); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2406 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2407 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2408 |
end; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2409 |
end |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2410 |
else |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2411 |
lua_pushnil(L); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2412 |
lc_getteamstats:= 1; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2413 |
end; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2414 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2415 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
2416 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2417 |
function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
3271 | 2418 |
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
|
2419 |
begin |
10297 | 2420 |
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
|
2421 |
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
|
2422 |
temp:= lua_tostring(L, 4); |
7805 | 2423 |
ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
2424 |
ParseCommand('hat ' + temp, true, true); |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2425 |
lua_pushnumber(L, CurrentHedgehog^.Gear^.uid); |
10287 | 2426 |
end |
2427 |
else |
|
2428 |
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
|
2429 |
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
|
2430 |
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
|
2431 |
|
3761 | 2432 |
function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
2433 |
var gear: PGear; |
|
2434 |
begin |
|
10297 | 2435 |
if CheckLuaParamCount(L, 2, 'HogTurnLeft', 'gearUid, boolean') then |
3761 | 2436 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2437 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3761 | 2438 |
if gear <> nil then |
2439 |
gear^.dX.isNegative:= lua_toboolean(L, 2); |
|
2440 |
end; |
|
2441 |
lc_hogturnleft:= 0; |
|
2442 |
end; |
|
2443 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2444 |
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
|
2445 |
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
|
2446 |
begin |
10297 | 2447 |
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
|
2448 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2449 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
2450 |
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
|
2451 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2452 |
lua_pushnumber(L, hwRound(gear^.X)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2453 |
lua_pushnumber(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
|
2454 |
end |
5964 | 2455 |
else |
2456 |
begin |
|
2457 |
lua_pushnil(L); |
|
2458 |
lua_pushnil(L) |
|
2459 |
end; |
|
10287 | 2460 |
end |
2461 |
else |
|
2462 |
begin |
|
2463 |
lua_pushnil(L); |
|
2464 |
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
|
2465 |
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
|
2466 |
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
|
2467 |
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
|
2468 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2469 |
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
|
2470 |
var gear: PGear; |
4832 | 2471 |
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
|
2472 |
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
|
2473 |
begin |
10297 | 2474 |
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
|
2475 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2476 |
gear:= GearByUID(Trunc(lua_tonumber(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
|
2477 |
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
|
2478 |
begin |
4832 | 2479 |
col:= gear^.CollisionIndex >= 0; |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2480 |
x:= Trunc(lua_tonumber(L, 2)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2481 |
y:= Trunc(lua_tonumber(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
|
2482 |
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
|
2483 |
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
|
2484 |
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
|
2485 |
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
|
2486 |
if col then |
9291
15f7bb217b66
Make add/delete consistent (this has bugged me for so long)
nemo
parents:
9285
diff
changeset
|
2487 |
AddCI(gear); |
4832 | 2488 |
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
|
2489 |
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
|
2490 |
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
|
2491 |
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
|
2492 |
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
|
2493 |
|
5517 | 2494 |
function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl; |
2495 |
var gear: PGear; |
|
2496 |
begin |
|
10297 | 2497 |
if CheckLuaParamCount(L, 1, 'GetGearTarget', 'gearUid') then |
5517 | 2498 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2499 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
5517 | 2500 |
if gear <> nil then |
2501 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2502 |
lua_pushnumber(L, gear^.Target.X); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2503 |
lua_pushnumber(L, gear^.Target.Y) |
5612
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2504 |
end |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2505 |
else |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2506 |
begin |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2507 |
lua_pushnil(L); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2508 |
lua_pushnil(L) |
5517 | 2509 |
end |
10287 | 2510 |
end |
2511 |
else |
|
2512 |
begin |
|
2513 |
lua_pushnil(L); |
|
2514 |
lua_pushnil(L) |
|
5517 | 2515 |
end; |
2516 |
lc_getgeartarget:= 2; |
|
2517 |
end; |
|
2518 |
||
2519 |
function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl; |
|
2520 |
var gear: PGear; |
|
2521 |
begin |
|
10297 | 2522 |
if CheckLuaParamCount(L, 3, 'SetGearTarget', 'gearUid, x, y') then |
5517 | 2523 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2524 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
5517 | 2525 |
if gear <> nil then |
2526 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2527 |
gear^.Target.X:= Trunc(lua_tonumber(L, 2)); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2528 |
gear^.Target.Y:= Trunc(lua_tonumber(L, 3)) |
5517 | 2529 |
end |
2530 |
end; |
|
2531 |
lc_setgeartarget:= 0 |
|
2532 |
end; |
|
2533 |
||
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
|
2534 |
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
|
2535 |
var gear: PGear; |
6780 | 2536 |
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
|
2537 |
begin |
10297 | 2538 |
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
|
2539 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2540 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
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
|
2541 |
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
|
2542 |
begin |
6780 | 2543 |
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
|
2544 |
// gear dX determines hog orientation |
6780 | 2545 |
if (gear^.dX.isNegative) and (t = 0) then t:= -1; |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2546 |
lua_pushnumber(L, t); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2547 |
lua_pushnumber(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
|
2548 |
end |
10287 | 2549 |
end |
2550 |
else |
|
2551 |
begin |
|
2552 |
lua_pushnil(L); |
|
2553 |
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
|
2554 |
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
|
2555 |
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
|
2556 |
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
|
2557 |
|
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
|
2558 |
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
|
2559 |
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
|
2560 |
begin |
10297 | 2561 |
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
|
2562 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2563 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
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
|
2564 |
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
|
2565 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2566 |
gear^.dX:= int2hwFloat(Trunc(lua_tonumber(L, 2))) / 1000000; |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2567 |
gear^.dY:= int2hwFloat(Trunc(lua_tonumber(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
|
2568 |
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
|
2569 |
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
|
2570 |
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
|
2571 |
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
|
2572 |
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
|
2573 |
|
3736 | 2574 |
function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
2575 |
begin |
|
10297 | 2576 |
if CheckLuaParamCount(L, 1, 'SetZoom', 'zoomLevel') then |
3736 | 2577 |
begin |
2578 |
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
|
2579 |
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
|
2580 |
ZoomValue:= cMaxZoomLevel; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2581 |
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
|
2582 |
ZoomValue:= cMinZoomLevel; |
3736 | 2583 |
end; |
2584 |
lc_setzoom:= 0 |
|
2585 |
end; |
|
2586 |
||
2587 |
function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
|
2588 |
begin |
|
10297 | 2589 |
if CheckLuaParamCount(L, 0, 'GetZoom', '') then |
10287 | 2590 |
lua_pushnumber(L, ZoomValue) |
3736 | 2591 |
else |
10287 | 2592 |
lua_pushnil(L); |
3736 | 2593 |
lc_getzoom:= 1 |
2594 |
end; |
|
2595 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2596 |
function lc_setammo(L : Plua_State) : LongInt; Cdecl; |
10281 | 2597 |
var np, at: LongInt; |
2598 |
const |
|
2599 |
call = 'SetAmmo'; |
|
2600 |
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
|
2601 |
begin |
10297 | 2602 |
if CheckAndFetchParamCount(L, 4, 5, call, params, np) then |
10281 | 2603 |
begin |
2604 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
2605 |
if at >= 0 then |
|
2606 |
begin |
|
2607 |
if np = 4 then |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2608 |
ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), 1) |
10281 | 2609 |
else |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2610 |
ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5))); |
10281 | 2611 |
end; |
2612 |
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
|
2613 |
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
|
2614 |
end; |
4243 | 2615 |
|
13459
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2616 |
|
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2617 |
function lc_getammo(L : Plua_State) : LongInt; Cdecl; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2618 |
var i, at, rawProb, probLevel: LongInt; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2619 |
const |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2620 |
call = 'GetAmmo'; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2621 |
params = 'ammoType'; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2622 |
begin |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2623 |
if CheckLuaParamCount(L, 1, call, params) then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2624 |
begin |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2625 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2626 |
if at >= 0 then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2627 |
begin |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2628 |
// Ammo count |
13460
38814954a248
Fix GetAmmo getting wrong ammo count
Wuzzy <Wuzzy2@mail.ru>
parents:
13459
diff
changeset
|
2629 |
i:= InitialAmmoCounts[TAmmoType(at)]; |
13459
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2630 |
if i = AMMO_INFINITE then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2631 |
i:= 9; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2632 |
lua_pushnumber(L, i); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2633 |
// Probability |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2634 |
rawProb:= Ammoz[TAmmoType(at)].Probability; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2635 |
probLevel:= -1; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2636 |
for i := 0 to High(probabilityLevels) do |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2637 |
if rawProb = probabilityLevels[i] then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2638 |
probLevel:= i; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2639 |
lua_pushnumber(L, probLevel); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2640 |
// Delay in turns |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2641 |
lua_pushnumber(L, Ammoz[TAmmoType(at)].SkipTurns); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2642 |
// Number in case |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2643 |
lua_pushnumber(L, Ammoz[TAmmoType(at)].NumberInCase); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2644 |
lc_getammo:= 4 |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2645 |
end |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2646 |
else |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2647 |
lc_getammo:= 0 |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2648 |
end; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2649 |
end; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2650 |
|
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
2651 |
|
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
|
2652 |
function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; |
10287 | 2653 |
var at: LongInt; |
10281 | 2654 |
const |
2655 |
call = 'SetAmmoDelay'; |
|
2656 |
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
|
2657 |
begin |
10297 | 2658 |
if CheckLuaParamCount(L, 2, call, params) then |
10281 | 2659 |
begin |
10287 | 2660 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2661 |
if at >= 0 then |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2662 |
ScriptSetAmmoDelay(TAmmoType(at), Trunc(lua_tonumber(L, 2))); |
10281 | 2663 |
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
|
2664 |
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
|
2665 |
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
|
2666 |
|
4243 | 2667 |
function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
2668 |
var m : LongInt; |
|
2669 |
begin |
|
10297 | 2670 |
if CheckLuaParamCount(L, 1, 'GetRandom', 'number') then |
4243 | 2671 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2672 |
m:= Trunc(lua_tonumber(L, 1)); |
4243 | 2673 |
if (m > 0) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2674 |
lua_pushnumber(L, GetRandom(m)) |
4243 | 2675 |
else |
2676 |
begin |
|
2677 |
LuaError('Lua: Tried to pass 0 to GetRandom!'); |
|
2678 |
lua_pushnil(L); |
|
2679 |
end |
|
10287 | 2680 |
end |
2681 |
else |
|
2682 |
lua_pushnil(L); // return value on stack (nil) |
|
4243 | 2683 |
lc_getrandom:= 1 |
2684 |
end; |
|
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2685 |
|
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2686 |
function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
13067
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13043
diff
changeset
|
2687 |
var vg: PVisualGear; |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2688 |
begin |
10297 | 2689 |
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
|
2690 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2691 |
cWindSpeed:= int2hwfloat(Trunc(lua_tonumber(L, 1))) / 100 * cMaxWindSpeed; |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2692 |
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
|
2693 |
if cWindSpeed.isNegative then |
13067
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13043
diff
changeset
|
2694 |
cWindSpeedf := -cWindSpeedf; |
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13043
diff
changeset
|
2695 |
vg:= AddVisualGear(0, 0, vgtSmoothWindBar); |
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13043
diff
changeset
|
2696 |
if vg <> nil then vg^.dAngle:= hwFloat2Float(cWindSpeed); |
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13043
diff
changeset
|
2697 |
AddFileLog('Wind = '+FloatToStr(cWindSpeed)); |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2698 |
end; |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2699 |
lc_setwind:= 0 |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2700 |
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
|
2701 |
|
12935
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2702 |
function lc_getwind(L : Plua_State) : LongInt; Cdecl; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2703 |
var wind: extended; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2704 |
begin |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2705 |
if CheckLuaParamCount(L, 0, 'GetWind', '') then |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2706 |
begin |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2707 |
wind:= hwFloat2float((cWindSpeed / cMaxWindSpeed) * 100); |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2708 |
if wind < -100 then |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2709 |
wind:= -100 |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2710 |
else if wind > 100 then |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2711 |
wind:= 100; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2712 |
lua_pushnumber(L, wind); |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2713 |
end |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2714 |
else |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2715 |
lua_pushnil(L); |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2716 |
lc_getwind:= 1 |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2717 |
end; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
2718 |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2719 |
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
|
2720 |
begin |
10297 | 2721 |
if CheckLuaParamCount(L, 0, 'MapHasBorder', '') then |
10287 | 2722 |
lua_pushboolean(L, hasBorder) |
2723 |
else |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2724 |
lua_pushnil(L); |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2725 |
lc_maphasborder:= 1 |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2726 |
end; |
4869 | 2727 |
|
2728 |
function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
|
2729 |
var gear : PGear; |
|
2730 |
begin |
|
10297 | 2731 |
if CheckLuaParamCount(L, 1, 'GetGearRadius', 'gearUid') then |
4869 | 2732 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2733 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4869 | 2734 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2735 |
lua_pushnumber(L, gear^.Radius) |
4869 | 2736 |
else |
2737 |
lua_pushnil(L); |
|
10287 | 2738 |
end |
2739 |
else |
|
2740 |
lua_pushnil(L); // return value on stack (nil) |
|
4869 | 2741 |
lc_getgearradius:= 1 |
2742 |
end; |
|
4875 | 2743 |
|
2744 |
function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
|
2745 |
var gear : PGear; |
|
2746 |
begin |
|
10297 | 2747 |
if CheckLuaParamCount(L, 1, 'GetHogHat', 'gearUid') then |
10287 | 2748 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2749 |
gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
2750 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4875 | 2751 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
2752 |
else |
|
2753 |
lua_pushnil(L); |
|
10287 | 2754 |
end |
2755 |
else |
|
2756 |
lua_pushnil(L); |
|
4875 | 2757 |
lc_gethoghat := 1; |
2758 |
end; |
|
2759 |
||
2760 |
function lc_sethoghat(L : Plua_State) : LongInt; Cdecl; |
|
2761 |
var gear : PGear; |
|
2762 |
hat: ShortString; |
|
2763 |
begin |
|
10297 | 2764 |
if CheckLuaParamCount(L, 2, 'SetHogHat', 'gearUid, hat') then |
4875 | 2765 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2766 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4875 | 2767 |
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
|
2768 |
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
|
2769 |
hat:= lua_tostring(L, 2); |
4875 | 2770 |
gear^.Hedgehog^.Hat:= hat; |
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
2771 |
AddFileLog('Changed hat to: '+hat); |
7887 | 2772 |
if (Length(hat) > 39) and (Copy(hat,1,8) = 'Reserved') and (Copy(hat,9,32) = gear^.Hedgehog^.Team^.PlayerHash) then |
2773 |
LoadHedgehogHat(gear^.Hedgehog^, 'Reserved/' + Copy(hat,9,Length(hat)-8)) |
|
2774 |
else |
|
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
2775 |
LoadHedgehogHat(gear^.Hedgehog^, hat) |
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
2776 |
end |
4875 | 2777 |
end; |
2778 |
lc_sethoghat:= 0; |
|
2779 |
end; |
|
4985 | 2780 |
|
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
|
2781 |
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
|
2782 |
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
|
2783 |
lf : Word; |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2784 |
tint : LongWord; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2785 |
i, n : LongInt; |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2786 |
placed, behind, flipHoriz, flipVert : boolean; |
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
|
2787 |
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
|
2788 |
call = 'PlaceSprite'; |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2789 |
params = 'x, y, sprite, frameIdx, tint, behind, flipHoriz, flipVert, [, 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
|
2790 |
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
|
2791 |
placed:= false; |
10297 | 2792 |
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
|
2793 |
begin |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2794 |
if not lua_isnoneornil(L, 5) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2795 |
tint := Trunc(lua_tonumber(L, 5)) |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2796 |
else tint := $FFFFFFFF; |
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2797 |
if not lua_isnoneornil(L, 6) then |
11682 | 2798 |
behind := lua_toboolean(L, 6) |
10901 | 2799 |
else behind := false; |
2800 |
if not lua_isnoneornil(L, 7) then |
|
11682 | 2801 |
flipHoriz := lua_toboolean(L, 7) |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2802 |
else flipHoriz := false; |
10901 | 2803 |
if not lua_isnoneornil(L, 8) then |
11682 | 2804 |
flipVert := lua_toboolean(L, 8) |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
2805 |
else flipVert := false; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2806 |
lf:= 0; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
2807 |
|
11061 | 2808 |
// accept any amount of landflags, loop is never executed if n<9 |
10901 | 2809 |
for i:= 9 to n do |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2810 |
lf:= lf or Trunc(lua_tonumber(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
|
2811 |
|
10281 | 2812 |
n:= LuaToSpriteOrd(L, 3, call, params); |
2813 |
if n >= 0 then |
|
2814 |
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
|
2815 |
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
|
2816 |
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
|
2817 |
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
|
2818 |
else |
10368
7ebb71a36e95
Forced sprites placing mode, exposed to scripts (not tested at all)
unc0rr
parents:
10347
diff
changeset
|
2819 |
placed:= ForcePlaceOnLand( |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2820 |
Trunc(lua_tonumber(L, 1)) - SpritesData[spr].Width div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2821 |
Trunc(lua_tonumber(L, 2)) - SpritesData[spr].Height div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2822 |
spr, Trunc(lua_tonumber(L, 4)), lf, tint, behind, flipHoriz, flipVert); |
10281 | 2823 |
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
|
2824 |
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
|
2825 |
|
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
|
2826 |
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
|
2827 |
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
|
2828 |
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
|
2829 |
|
10901 | 2830 |
function lc_erasesprite(L : Plua_State) : LongInt; Cdecl; |
2831 |
var spr : TSprite; |
|
2832 |
lf : Word; |
|
2833 |
i, n : LongInt; |
|
10903 | 2834 |
eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert : boolean; |
10901 | 2835 |
const |
2836 |
call = 'EraseSprite'; |
|
11060 | 2837 |
params = 'x, y, sprite, frameIdx, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert, [, landFlag, ... ]'; |
10901 | 2838 |
begin |
2839 |
if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
|
2840 |
begin |
|
2841 |
if not lua_isnoneornil(L, 5) then |
|
11682 | 2842 |
eraseOnLFMatch := lua_toboolean(L, 5) |
10901 | 2843 |
else eraseOnLFMatch := false; |
2844 |
if not lua_isnoneornil(L, 6) then |
|
11682 | 2845 |
onlyEraseLF := lua_toboolean(L, 6) |
10903 | 2846 |
else onlyEraseLF := false; |
2847 |
if not lua_isnoneornil(L, 7) then |
|
11682 | 2848 |
flipHoriz := lua_toboolean(L, 7) |
10901 | 2849 |
else flipHoriz := false; |
10903 | 2850 |
if not lua_isnoneornil(L, 8) then |
11682 | 2851 |
flipVert := lua_toboolean(L, 8) |
10901 | 2852 |
else flipVert := false; |
2853 |
lf:= 0; |
|
2854 |
||
11060 | 2855 |
// accept any amount of landflags, loop is never executed if n<9 |
10903 | 2856 |
for i:= 9 to n do |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2857 |
lf:= lf or Trunc(lua_tonumber(L, i)); |
10901 | 2858 |
|
2859 |
n:= LuaToSpriteOrd(L, 3, call, params); |
|
2860 |
if n >= 0 then |
|
2861 |
begin |
|
2862 |
spr:= TSprite(n); |
|
2863 |
if SpritesData[spr].Surface = nil then |
|
2864 |
LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
|
2865 |
else |
|
2866 |
EraseLand( |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2867 |
Trunc(lua_tonumber(L, 1)) - SpritesData[spr].Width div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2868 |
Trunc(lua_tonumber(L, 2)) - SpritesData[spr].Height div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2869 |
spr, Trunc(lua_tonumber(L, 4)), lf, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert); |
10901 | 2870 |
end; |
2871 |
end; |
|
2872 |
lc_erasesprite:= 0 |
|
2873 |
end; |
|
2874 |
||
4985 | 2875 |
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
|
2876 |
var placed: boolean; |
4985 | 2877 |
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
|
2878 |
placed:= false; |
10297 | 2879 |
if CheckLuaParamCount(L, 3, 'PlaceGirder', 'x, y, frameIdx') then |
10295 | 2880 |
placed:= TryPlaceOnLandSimple( |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2881 |
Trunc(lua_tonumber(L, 1)) - SpritesData[sprAmGirder].Width div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2882 |
Trunc(lua_tonumber(L, 2)) - SpritesData[sprAmGirder].Height div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2883 |
sprAmGirder, Trunc(lua_tonumber(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
|
2884 |
|
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
|
2885 |
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
|
2886 |
lc_placegirder:= 1 |
4985 | 2887 |
end; |
5013 | 2888 |
|
12095 | 2889 |
function lc_placerubber(L : Plua_State) : LongInt; Cdecl; |
2890 |
var placed: boolean; |
|
2891 |
begin |
|
2892 |
placed:= false; |
|
2893 |
if CheckLuaParamCount(L, 3, 'PlaceRubber', 'x, y, frameIdx') then |
|
2894 |
placed:= TryPlaceOnLand( |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2895 |
Trunc(lua_tonumber(L, 1)) - SpritesData[sprAmRubber].Width div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2896 |
Trunc(lua_tonumber(L, 2)) - SpritesData[sprAmRubber].Height div 2, |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2897 |
sprAmRubber, Trunc(lua_tonumber(L, 3)), true, lfBouncy); |
12095 | 2898 |
|
2899 |
lua_pushboolean(L, placed); |
|
2900 |
lc_placerubber:= 1 |
|
2901 |
end; |
|
2902 |
||
5013 | 2903 |
function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
2904 |
begin |
|
10297 | 2905 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, 'GetCurAmmoType', '')) then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2906 |
lua_pushnumber(L, ord(CurrentHedgehog^.CurAmmoType)) |
10291 | 2907 |
else |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2908 |
lua_pushnumber(L, ord(amNothing)); |
5013 | 2909 |
lc_getcurammotype := 1; |
2910 |
end; |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2911 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2912 |
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
|
2913 |
begin |
10297 | 2914 |
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
|
2915 |
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
|
2916 |
lc_savecampaignvar := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2917 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2918 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2919 |
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
|
2920 |
begin |
10297 | 2921 |
if CheckLuaParamCount(L, 1, 'GetCampaignVar', 'varname') then |
9718
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9670
diff
changeset
|
2922 |
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
|
2923 |
lua_pushstring(L, str2pchar(CampaignVariable)); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2924 |
lc_getcampaignvar := 1; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2925 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2926 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2927 |
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
|
2928 |
var gear: PGear; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2929 |
begin |
10297 | 2930 |
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
|
2931 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2932 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
12365
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2933 |
if (gear <> nil) and (gear^.hedgehog <> nil) then |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2934 |
begin |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2935 |
HideHog(gear^.hedgehog); |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2936 |
lua_pushboolean(L, true); |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2937 |
end |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2938 |
else |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2939 |
lua_pushboolean(L, false); |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2940 |
end; |
12365
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12337
diff
changeset
|
2941 |
lc_hidehog := 1; |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2942 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2943 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2944 |
function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
8370 | 2945 |
var i, h: LongInt; |
8012 | 2946 |
uid: LongWord; |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2947 |
begin |
10297 | 2948 |
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
|
2949 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
2950 |
uid:= LongWord(Trunc(lua_tonumber(L, 1))); |
8012 | 2951 |
if TeamsCount > 0 then |
2952 |
for i:= 0 to Pred(TeamsCount) do |
|
2953 |
for h:= 0 to cMaxHHIndex do |
|
2954 |
if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
|
2955 |
begin |
|
2956 |
RestoreHog(@TeamsArray[i]^.Hedgehogs[h]); |
|
2957 |
exit(0) |
|
2958 |
end |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2959 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2960 |
lc_restorehog := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2961 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
2962 |
|
13582 | 2963 |
function lc_ishoghidden(L: Plua_State): LongInt; Cdecl; |
2964 |
var i, h: LongInt; |
|
2965 |
uid: LongWord; |
|
2966 |
gear: PGear; |
|
2967 |
begin |
|
2968 |
if CheckLuaParamCount(L, 1, 'IsHogHidden', 'gearUid') then |
|
2969 |
begin |
|
2970 |
uid:= LongWord(Trunc(lua_tonumber(L, 1))); |
|
2971 |
gear:= GearByUID(uid); |
|
2972 |
if (gear <> nil) and (gear^.hedgehog <> nil) then |
|
2973 |
begin |
|
2974 |
lua_pushboolean(L, false); |
|
2975 |
lc_ishoghidden:= 1; |
|
2976 |
exit; |
|
2977 |
end |
|
2978 |
else |
|
2979 |
if TeamsCount > 0 then |
|
2980 |
for i:= 0 to Pred(TeamsCount) do |
|
2981 |
for h:= 0 to cMaxHHIndex do |
|
2982 |
if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
|
2983 |
begin |
|
2984 |
lua_pushboolean(L, true); |
|
2985 |
lc_ishoghidden:= 1; |
|
2986 |
exit; |
|
2987 |
end |
|
2988 |
end; |
|
2989 |
lua_pushnil(L); |
|
2990 |
lc_ishoghidden:= 1; |
|
2991 |
end; |
|
2992 |
||
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2993 |
// boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2994 |
function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2995 |
var rtn: Boolean; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
2996 |
begin |
10297 | 2997 |
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
|
2998 |
begin |
10818
f642a28cab0c
Add placement of airmines in engine outside of hog proximity. Has a bug, only protecting 1st team. Also fix a spelling error and rename gstHHChooseTarget to gstChooseTarget
nemo
parents:
10809
diff
changeset
|
2999 |
rtn:= TestRectangleForObstacle( |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3000 |
Trunc(lua_tonumber(L, 1)), |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3001 |
Trunc(lua_tonumber(L, 2)), |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3002 |
Trunc(lua_tonumber(L, 3)), |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3003 |
Trunc(lua_tonumber(L, 4)), |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3004 |
lua_toboolean(L, 5) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3005 |
); |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3006 |
lua_pushboolean(L, rtn); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3007 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3008 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3009 |
lua_pushnil(L); // return value on stack (nil) |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3010 |
lc_testrectforobstacle:= 1 |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3011 |
end; |
7996 | 3012 |
|
3013 |
||
9815 | 3014 |
function lc_getgravity(L : Plua_State) : LongInt; Cdecl; |
3015 |
begin |
|
10297 | 3016 |
if CheckLuaParamCount(L, 0, 'GetGravity', '') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3017 |
lua_pushnumber(L, hwRound(SignAs(_0_5, cGravity) + (cGravity * 50 / cMaxWindSpeed))); |
9815 | 3018 |
lc_getgravity:= 1 |
3019 |
end; |
|
3020 |
||
3021 |
function lc_setgravity(L : Plua_State) : LongInt; Cdecl; |
|
3022 |
begin |
|
10297 | 3023 |
if CheckLuaParamCount(L, 1, 'SetGravity', 'percent') then |
9815 | 3024 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3025 |
cGravity:= _0_02 * Trunc(lua_tonumber(L, 1)) * cMaxWindSpeed; |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3026 |
cGravityf:= 0.00025 * Trunc(lua_tonumber(L, 1)) * 0.02 |
9815 | 3027 |
end; |
3028 |
lc_setgravity:= 0 |
|
3029 |
end; |
|
3030 |
||
9914 | 3031 |
function lc_setwaterline(L : Plua_State) : LongInt; Cdecl; |
3032 |
var iterator: PGear; |
|
3033 |
begin |
|
10297 | 3034 |
if CheckLuaParamCount(L, 1, 'SetWaterLine', 'waterline') then |
9914 | 3035 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3036 |
cWaterLine:= Trunc(lua_tonumber(L,1)); |
9914 | 3037 |
AllInactive:= false; |
3038 |
iterator:= GearsList; |
|
3039 |
while iterator <> nil do |
|
3040 |
begin |
|
9917 | 3041 |
if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then |
9914 | 3042 |
begin |
3043 |
iterator^.Active:= true; |
|
3044 |
if iterator^.dY.QWordValue = 0 then iterator^.dY.isNegative:= false; |
|
3045 |
iterator^.State:= iterator^.State or gstMoving; |
|
3046 |
DeleteCI(iterator) |
|
3047 |
end; |
|
3048 |
iterator:= iterator^.NextGear |
|
3049 |
end |
|
3050 |
end; |
|
3051 |
lc_setwaterline:= 0 |
|
3052 |
end; |
|
9815 | 3053 |
|
11066 | 3054 |
function lc_setgearaihints(L : Plua_State) : LongInt; Cdecl; |
7996 | 3055 |
var gear: PGear; |
3056 |
begin |
|
13041
434bcdd9562c
Fix inconsistent name of SetGearAIHints
Wuzzy <Wuzzy2@mail.ru>
parents:
13025
diff
changeset
|
3057 |
if CheckLuaParamCount(L, 2, 'SetGearAIHints', 'gearUid, aiHints') then |
7996 | 3058 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3059 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
7996 | 3060 |
if gear <> nil then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3061 |
gear^.aihints:= Trunc(lua_tonumber(L, 2)); |
7996 | 3062 |
end; |
11066 | 3063 |
lc_setgearaihints:= 0 |
7996 | 3064 |
end; |
3065 |
||
8043 | 3066 |
|
3067 |
function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
|
3068 |
begin |
|
10297 | 3069 |
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
|
3070 |
ScriptLoad(lua_tostring(L, 1)) |
8043 | 3071 |
else |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3072 |
lua_pushnil(L); |
8043 | 3073 |
lc_hedgewarsscriptload:= 0; |
3074 |
end; |
|
9397 | 3075 |
|
3076 |
||
3077 |
function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
|
3078 |
begin |
|
10297 | 3079 |
if CheckLuaParamCount(L, 4, 'DeclareAchievement', 'achievementId, teamname, location, value') then |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3080 |
declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), Trunc(lua_tonumber(L, 4))); |
9397 | 3081 |
lc_declareachievement:= 0 |
3082 |
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
|
3083 |
|
11851 | 3084 |
function lc_getammoname(L : Plua_state) : LongInt; Cdecl; |
11950
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3085 |
var np, at: LongInt; |
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3086 |
ignoreOverwrite: Boolean; |
11851 | 3087 |
const call = 'GetAmmoName'; |
11950
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3088 |
params = 'ammoType [, ignoreOverwrite ]'; |
11851 | 3089 |
begin |
11950
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3090 |
if CheckAndFetchParamCountRange(L, 1, 2, call, params, np) then |
11851 | 3091 |
begin |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3092 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
11950
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3093 |
ignoreOverwrite := false; |
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3094 |
if np > 1 then |
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3095 |
ignoreOverwrite := lua_toboolean(L, 2); |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3096 |
if at >= 0 then |
11950
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11949
diff
changeset
|
3097 |
if (not ignoreOverwrite) and (length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0) then |
11949
87edf67f2107
GetAmmoName now returns ammo name overwritten by SetAmmoTexts
Wuzzy <almikes@aol.com>
parents:
11946
diff
changeset
|
3098 |
lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId])) |
87edf67f2107
GetAmmoName now returns ammo name overwritten by SetAmmoTexts
Wuzzy <almikes@aol.com>
parents:
11946
diff
changeset
|
3099 |
else |
87edf67f2107
GetAmmoName now returns ammo name overwritten by SetAmmoTexts
Wuzzy <almikes@aol.com>
parents:
11946
diff
changeset
|
3100 |
lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId])); |
11851 | 3101 |
end |
3102 |
else |
|
3103 |
lua_pushnil(L); |
|
3104 |
lc_getammoname:= 1; |
|
3105 |
end; |
|
3106 |
||
13376
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3107 |
function lc_getammotimer(L : Plua_state) : LongInt; Cdecl; |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3108 |
var at: LongInt; |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3109 |
weapon: PAmmo; |
13378
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3110 |
gear: PGear; |
13376
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3111 |
const call = 'GetAmmoTimer'; |
13378
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3112 |
params = 'gearUid, ammoType'; |
13376
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3113 |
begin |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3114 |
if CheckLuaParamCount(L, 2, call, params) then |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3115 |
begin |
13378
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3116 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3117 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3118 |
begin |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3119 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3120 |
weapon:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3121 |
if (Ammoz[TAmmoType(at)].Ammo.Propz and ammoprop_Timerable) <> 0 then |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3122 |
lua_pushnumber(L, weapon^.Timer) |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3123 |
else |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3124 |
lua_pushnil(L); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13376
diff
changeset
|
3125 |
end |
13376
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3126 |
else |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3127 |
lua_pushnil(L); |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3128 |
end |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3129 |
else |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3130 |
lua_pushnil(L); |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3131 |
lc_getammotimer:= 1; |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3132 |
end; |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
3133 |
|
12934
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3134 |
function lc_setvampiric(L : Plua_state) : LongInt; Cdecl; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3135 |
begin |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3136 |
if CheckLuaParamCount(L, 1, 'SetVampiric', 'bool') then |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3137 |
cVampiric := lua_toboolean(L, 1); |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3138 |
lc_setvampiric := 0; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3139 |
end; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3140 |
|
13581
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3141 |
function lc_getvampiric(L : Plua_state) : LongInt; Cdecl; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3142 |
begin |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3143 |
lua_pushboolean(L, cVampiric); |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3144 |
lc_getvampiric := 1; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3145 |
end; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3146 |
|
12934
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3147 |
function lc_setlasersight(L : Plua_state) : LongInt; Cdecl; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3148 |
begin |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3149 |
if CheckLuaParamCount(L, 1, 'SetLaserSight', 'bool') then |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3150 |
cLaserSighting:= lua_toboolean(L, 1); |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3151 |
lc_setlasersight:= 0; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3152 |
end; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
3153 |
|
13581
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3154 |
function lc_getlasersight(L : Plua_state) : LongInt; Cdecl; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3155 |
begin |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3156 |
lua_pushboolean(L, cLaserSighting); |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3157 |
lc_getlasersight:= 1; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3158 |
end; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
3159 |
|
13275 | 3160 |
function lc_explode(L : Plua_state) : LongInt; Cdecl; |
3161 |
var mask: LongWord; |
|
3162 |
n: LongInt; |
|
3163 |
begin |
|
3164 |
if CheckAndFetchParamCount(L, 3, 4, 'Explode', 'x, y, radius[, options]', n) then |
|
3165 |
if CurrentHedgehog <> nil then |
|
3166 |
begin |
|
3167 |
mask:= EXPLAutoSound; |
|
3168 |
if (n = 4) then |
|
3169 |
mask:= Trunc(lua_tonumber(L, 4)); |
|
3170 |
doMakeExplosion(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), CurrentHedgehog, mask); |
|
3171 |
lua_pushboolean(L, true); |
|
3172 |
end |
|
3173 |
else |
|
3174 |
lua_pushboolean(L, false) |
|
3175 |
else |
|
3176 |
lua_pushboolean(L, false); |
|
3177 |
lc_explode:= 1; |
|
3178 |
end; |
|
3179 |
||
11574 | 3180 |
function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl; |
3181 |
begin |
|
3182 |
if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3183 |
startGhostPoints(Trunc(lua_tonumber(L, 1))); |
11574 | 3184 |
lc_startghostpoints:= 0 |
3185 |
end; |
|
3186 |
||
3187 |
function lc_dumppoint(L : Plua_State) : LongInt; Cdecl; |
|
3188 |
begin |
|
3189 |
if CheckLuaParamCount(L, 2, 'DumpPoint', 'x, y') then |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3190 |
dumpPoint(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2))); |
11574 | 3191 |
lc_dumppoint:= 0 |
3192 |
end; |
|
3193 |
||
10611 | 3194 |
|
3195 |
procedure ScriptFlushPoints(); |
|
3196 |
begin |
|
3197 |
ParseCommand('draw ' + PointsBuffer, true, true); |
|
3198 |
PointsBuffer:= ''; |
|
3199 |
end; |
|
3200 |
||
3201 |
||
3202 |
function lc_addPoint(L : Plua_State) : LongInt; Cdecl; |
|
10660
79fa79c77c38
fix size of PtrInt. enable tests for pas2c (all passing now)
sheepluva
parents:
10634
diff
changeset
|
3203 |
var np, param: LongInt; |
10611 | 3204 |
begin |
10613 | 3205 |
if CheckAndFetchParamCountRange(L, 2, 4, 'AddPoint', 'x, y [, width [, erase] ]', np) then |
10611 | 3206 |
begin |
3207 |
// x |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3208 |
param:= LongInt(Trunc(lua_tonumber(L,1))); |
10660
79fa79c77c38
fix size of PtrInt. enable tests for pas2c (all passing now)
sheepluva
parents:
10634
diff
changeset
|
3209 |
PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
10611 | 3210 |
PointsBuffer:= PointsBuffer + char((param and $FF)); |
3211 |
// y |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3212 |
param:= LongInt(Trunc(lua_tonumber(L,2))); |
10660
79fa79c77c38
fix size of PtrInt. enable tests for pas2c (all passing now)
sheepluva
parents:
10634
diff
changeset
|
3213 |
PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
10611 | 3214 |
PointsBuffer:= PointsBuffer + char((param and $FF)); |
3215 |
// width |
|
3216 |
if np > 2 then |
|
3217 |
begin |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3218 |
param:= Trunc(lua_tonumber(L,3)); |
10611 | 3219 |
param:= (param or $80); |
3220 |
// erase |
|
3221 |
if (np > 3) and lua_toboolean(L, 4) then |
|
3222 |
param:= (param or $40); |
|
3223 |
PointsBuffer:= PointsBuffer + char(param); |
|
3224 |
end |
|
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
3225 |
// no width defined |
10611 | 3226 |
else |
3227 |
PointsBuffer:= PointsBuffer + char(0); |
|
3228 |
||
3229 |
// flush before shortstring limit length is reached |
|
3230 |
if length(PointsBuffer) > 245 then |
|
3231 |
ScriptFlushPoints(); |
|
3232 |
end; |
|
3233 |
lc_addPoint:= 0 |
|
3234 |
end; |
|
3235 |
||
3236 |
||
3237 |
function lc_flushPoints(L : Plua_State) : LongInt; Cdecl; |
|
3238 |
begin |
|
3239 |
if CheckLuaParamCount(L, 0, 'FlushPoints', '') then |
|
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
3240 |
if length(PointsBuffer) > 0 then |
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
3241 |
ScriptFlushPoints(); |
10611 | 3242 |
lc_flushPoints:= 0 |
3243 |
end; |
|
3244 |
||
10618 | 3245 |
// 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
|
3246 |
function lc_endluatest(L : Plua_State) : LongInt; Cdecl; |
10618 | 3247 |
var rstring: shortstring; |
3248 |
const |
|
3249 |
call = 'EndLuaTest'; |
|
3250 |
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
|
3251 |
begin |
10618 | 3252 |
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
|
3253 |
begin |
10618 | 3254 |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3255 |
case Trunc(lua_tonumber(L, 1)) of |
10618 | 3256 |
HaltTestSuccess : rstring:= 'Success'; |
11622 | 3257 |
HaltTestFailed: rstring:= 'FAILED'; |
10618 | 3258 |
else |
3259 |
begin |
|
3260 |
LuaCallError('Parameter must be either ' + params, call, params); |
|
3261 |
exit(0); |
|
3262 |
end; |
|
3263 |
end; |
|
3264 |
||
3265 |
if cTestLua then |
|
3266 |
begin |
|
3267 |
WriteLnToConsole('Lua test finished, result: ' + rstring); |
|
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3268 |
halt(Trunc(lua_tonumber(L, 1))); |
10618 | 3269 |
end |
3270 |
else LuaError('Not in lua test mode, engine will keep running. Reported test result: ' + rstring); |
|
3271 |
||
3272 |
end; |
|
3273 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3274 |
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
|
3275 |
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
|
3276 |
/////////////////// |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3277 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3278 |
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
|
3279 |
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
|
3280 |
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
|
3281 |
n:= lua_gettop(luaState); |
3539 | 3282 |
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
|
3283 |
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
|
3284 |
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
|
3285 |
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
|
3286 |
else if lua_toboolean(luaState, i) then |
3539 | 3287 |
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
|
3288 |
else |
3539 | 3289 |
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
|
3290 |
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
|
3291 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3292 |
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
|
3293 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3294 |
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
|
3295 |
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
|
3296 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3297 |
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
|
3298 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3299 |
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
|
3300 |
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
|
3301 |
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
|
3302 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3303 |
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
|
3304 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3305 |
lua_pushnumber(luaState, value); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3306 |
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
|
3307 |
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
|
3308 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3309 |
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
|
3310 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3311 |
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
|
3312 |
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
|
3313 |
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
|
3314 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3315 |
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
|
3316 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3317 |
lua_getglobal(luaState, Str2PChar(name)); |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3318 |
ScriptGetInteger:= Trunc(lua_tonumber(luaState, -1)); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3319 |
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
|
3320 |
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
|
3321 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3322 |
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
|
3323 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3324 |
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
|
3325 |
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
|
3326 |
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
|
3327 |
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
|
3328 |
|
12754
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3329 |
function ScriptGetAnsiString(name : shortstring) : ansistring; |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3330 |
begin |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3331 |
lua_getglobal(luaState, Str2PChar(name)); |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3332 |
ScriptGetAnsiString:= lua_tostringa(luaState, -1); |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3333 |
lua_pop(luaState, 1); |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3334 |
end; |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3335 |
|
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3336 |
procedure ScriptOnPreviewInit; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3337 |
begin |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3338 |
// 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
|
3339 |
if not ScriptLoaded then |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3340 |
exit; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3341 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3342 |
ScriptSetString('Seed', cSeed); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3343 |
ScriptSetInteger('TemplateFilter', cTemplateFilter); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3344 |
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
|
3345 |
ScriptSetInteger('MapGen', ord(cMapGen)); |
11062 | 3346 |
ScriptSetInteger('MapFeatureSize', cFeatureSize); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3347 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3348 |
ScriptCall('onPreviewInit'); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3349 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3350 |
// pop game variables |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3351 |
ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3352 |
cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3353 |
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
|
3354 |
cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
11062 | 3355 |
cFeatureSize := ScriptGetInteger('MapFeatureSize'); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3356 |
end; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3357 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3358 |
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
|
3359 |
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
|
3360 |
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
|
3361 |
// 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
|
3362 |
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
|
3363 |
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
|
3364 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3365 |
// push game variables so they may be modified by the script |
13221
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3366 |
ScriptSetInteger('CursorX', NoPointX); |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3367 |
ScriptSetInteger('CursorY', NoPointX); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3368 |
ScriptSetInteger('GameFlags', GameFlags); |
11884
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11854
diff
changeset
|
3369 |
ScriptSetInteger('WorldEdge', ord(WorldEdge)); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3370 |
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
|
3371 |
ScriptSetInteger('TemplateFilter', cTemplateFilter); |
7567 | 3372 |
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
|
3373 |
ScriptSetInteger('MapGen', ord(cMapGen)); |
11061 | 3374 |
ScriptSetInteger('MapFeatureSize', cFeatureSize); |
5583
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
3375 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
3376 |
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
|
3377 |
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
|
3378 |
ScriptSetInteger('CaseFreq', cCaseFactor); |
13632
605767bbd022
Move max. number of crate spawns into variable
Wuzzy <Wuzzy2@mail.ru>
parents:
13623
diff
changeset
|
3379 |
ScriptSetInteger('MaxCaseDrops', cMaxCaseDrops); |
4162 | 3380 |
ScriptSetInteger('HealthCaseProb', cHealthCaseProb); |
3381 |
ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount); |
|
4221 | 3382 |
ScriptSetInteger('DamagePercent', cDamagePercent); |
6557 | 3383 |
ScriptSetInteger('RopePercent', cRopePercent); |
4003
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
3999
diff
changeset
|
3384 |
ScriptSetInteger('MinesNum', cLandMines); |
4221 | 3385 |
ScriptSetInteger('MinesTime', cMinesTime); |
3386 |
ScriptSetInteger('MineDudPercent', cMineDudPercent); |
|
11968
0c1420aaa59e
Expose number of air mines in Lua variable AirMinesNum
Wuzzy <almikes@aol.com>
parents:
11950
diff
changeset
|
3387 |
ScriptSetInteger('AirMinesNum', cAirMines); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3388 |
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
|
3389 |
ScriptSetInteger('Delay', cInactDelay); |
3774 | 3390 |
ScriptSetInteger('Ready', cReadyDelay); |
3197 | 3391 |
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
4162 | 3392 |
ScriptSetInteger('WaterRise', cWaterRise); |
3393 |
ScriptSetInteger('HealthDecrease', cHealthDecrease); |
|
9836 | 3394 |
ScriptSetInteger('GetAwayTime', cGetAwayTime); |
12306
46e1e25fec5e
Lua variable: AmmoTypeMax (maximum ammo type ID for iterating)
Wuzzy <almikes@aol.com>
parents:
12299
diff
changeset
|
3395 |
ScriptSetInteger('AmmoTypeMax', Ord(High(TAmmoType))); |
6828
6a5d33bff0b0
At mikade's request. give scripting access to the map name prior to override.
nemo
parents:
6790
diff
changeset
|
3396 |
ScriptSetString('Map', cMapName); |
11742
571d06a86bb6
fix for issue 71: Lua API: “Theme” variable is set to empty string initially
Wuzzy <almikes@aol.com>
parents:
11741
diff
changeset
|
3397 |
ScriptSetString('Theme', Theme); |
4883
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
3398 |
ScriptSetString('Goals', ''); |
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
3399 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3400 |
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
|
3401 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3402 |
// pop game variables |
7805 | 3403 |
ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3404 |
cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
7567 | 3405 |
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
|
3406 |
cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
11061 | 3407 |
cFeatureSize := ScriptGetInteger('MapFeatureSize'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3408 |
GameFlags := ScriptGetInteger('GameFlags'); |
11884
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11854
diff
changeset
|
3409 |
WorldEdge := TWorldEdge(ScriptGetInteger('WorldEdge')); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3410 |
cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3411 |
cCaseFactor := ScriptGetInteger('CaseFreq'); |
13632
605767bbd022
Move max. number of crate spawns into variable
Wuzzy <Wuzzy2@mail.ru>
parents:
13623
diff
changeset
|
3412 |
cMaxCaseDrops := ScriptGetInteger('MaxCaseDrops'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3413 |
cHealthCaseProb := ScriptGetInteger('HealthCaseProb'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3414 |
cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3415 |
cDamagePercent := ScriptGetInteger('DamagePercent'); |
6523 | 3416 |
cRopePercent := ScriptGetInteger('RopePercent'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3417 |
cLandMines := ScriptGetInteger('MinesNum'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3418 |
cMinesTime := ScriptGetInteger('MinesTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3419 |
cMineDudPercent := ScriptGetInteger('MineDudPercent'); |
11968
0c1420aaa59e
Expose number of air mines in Lua variable AirMinesNum
Wuzzy <almikes@aol.com>
parents:
11950
diff
changeset
|
3420 |
cAirMines := ScriptGetInteger('AirMinesNum'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3421 |
cExplosives := ScriptGetInteger('Explosives'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3422 |
cInactDelay := ScriptGetInteger('Delay'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3423 |
cReadyDelay := ScriptGetInteger('Ready'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3424 |
cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3425 |
cWaterRise := ScriptGetInteger('WaterRise'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3426 |
cHealthDecrease := ScriptGetInteger('HealthDecrease'); |
9836 | 3427 |
cGetAwayTime := ScriptGetInteger('GetAwayTime'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3428 |
|
7771 | 3429 |
if cMapName <> ScriptGetString('Map') then |
7805 | 3430 |
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
|
3431 |
if ScriptGetString('Theme') <> '' then |
7805 | 3432 |
ParseCommand('theme ' + ScriptGetString('Theme'), true, true); |
12754
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12688
diff
changeset
|
3433 |
LuaGoals:= ScriptGetAnsiString('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
|
3434 |
|
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3435 |
// 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
|
3436 |
k:= 0; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3437 |
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
|
3438 |
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
|
3439 |
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
|
3440 |
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
|
3441 |
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
|
3442 |
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
|
3443 |
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
|
3444 |
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
|
3445 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3446 |
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
|
3447 |
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
|
3448 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3449 |
end |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
3450 |
else |
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3451 |
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
|
3452 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3453 |
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
|
3454 |
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
|
3455 |
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
|
3456 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3457 |
end; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3458 |
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
|
3459 |
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
|
3460 |
// 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
|
3461 |
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
|
3462 |
uAmmos.initModule; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3463 |
if ScriptExists('onAmmoStoreInit') then |
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3464 |
begin |
6752 | 3465 |
ScriptPrepareAmmoStore; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3466 |
ScriptCall('onAmmoStoreInit'); |
6746 | 3467 |
SetAmmoLoadout(ScriptAmmoLoadout); |
3468 |
SetAmmoProbability(ScriptAmmoProbability); |
|
3469 |
SetAmmoDelay(ScriptAmmoDelay); |
|
3470 |
SetAmmoReinforcement(ScriptAmmoReinforcement) |
|
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3471 |
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
|
3472 |
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
|
3473 |
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
|
3474 |
|
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
3475 |
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
|
3476 |
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
|
3477 |
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
|
3478 |
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
|
3479 |
|
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3480 |
|
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3481 |
// 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
|
3482 |
procedure ScriptOnScreenResize(); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3483 |
begin |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3484 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3485 |
ScriptSetInteger('ScreenWidth', cScreenWidth); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3486 |
ScriptCall('onScreenResize'); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3487 |
end; |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3488 |
|
8031 | 3489 |
// custom script loader via physfs, passed to lua_load |
8034 | 3490 |
const BUFSIZE = 1024; |
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3491 |
|
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3492 |
var inComment: boolean; |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3493 |
var inQuote: boolean; |
12464
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12463
diff
changeset
|
3494 |
var locSum: LongWord; |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3495 |
var braceCount: LongWord; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3496 |
var wordCount: LongWord; |
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3497 |
var lastChar: char; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3498 |
// ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3499 |
function ScriptReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3500 |
var mybuf: PChar; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3501 |
i: LongInt; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3502 |
begin |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3503 |
mybuf := physfsReader(L, f, sz); |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3504 |
if (mybuf <> nil) and ((sz^) > 0) then |
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3505 |
begin |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3506 |
for i:= 0 to sz^-1 do |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3507 |
begin |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3508 |
if (lastChar = '-') and (mybuf[i] = '-') then |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3509 |
inComment := true |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3510 |
// gonna add any non-magic whitespace and skip - just to make comment avoidance easier |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3511 |
else if not inComment and (byte(mybuf[i]) > $20) and (byte(mybuf[i]) < $7F) and (mybuf[i]<>'-') then |
12499
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12498
diff
changeset
|
3512 |
begin |
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12498
diff
changeset
|
3513 |
AddRandomness(byte(mybuf[i])); // wish I had the seed... |
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12498
diff
changeset
|
3514 |
CheckSum := CheckSum xor GetRandom($FFFFFFFF); |
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12498
diff
changeset
|
3515 |
end; |
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3516 |
lastChar := mybuf[i]; |
12460 | 3517 |
if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3518 |
inComment := false |
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3519 |
end; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3520 |
end; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3521 |
ScriptReader:= mybuf |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3522 |
end; |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3523 |
function ScriptLocaleReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3524 |
var mybuf: PChar; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3525 |
i: LongInt; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3526 |
begin |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3527 |
mybuf := physfsReader(L, f, sz); |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3528 |
if (mybuf <> nil) and ((sz^) > 0) then |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3529 |
begin |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3530 |
for i:= 0 to sz^-1 do |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3531 |
begin |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3532 |
if not inComment and (mybuf[i] = '"') and (lastChar <> '\') then |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3533 |
inQuote := not inQuote; |
12499
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12498
diff
changeset
|
3534 |
if not inQuote and (lastChar = '-') and (mybuf[i] = '-') then |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3535 |
inComment := true; |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3536 |
if not inComment and (not inQuote) then |
12464
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12463
diff
changeset
|
3537 |
locSum := locSum xor (byte(mybuf[i]) shl (i mod 4)); |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3538 |
if not inComment and (not inQuote) and |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3539 |
((mybuf[i] = '(') or |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3540 |
(mybuf[i] = ')') or |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3541 |
(mybuf[i] = '+') or |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3542 |
(mybuf[i] = '#') or |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3543 |
(braceCount > 2) or |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3544 |
(wordCount > 6)) then |
12464
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12463
diff
changeset
|
3545 |
CheckSum := locSum; |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3546 |
if not inComment and (not inQuote) and ((mybuf[i] = '{') or (mybuf[i] = '}')) then |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3547 |
inc(braceCount); |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3548 |
if not inComment and (not inQuote) and |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3549 |
(((byte(mybuf[i]) > $40) and (byte(mybuf[i]) < $5B)) or |
12464
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12463
diff
changeset
|
3550 |
((byte(mybuf[i]) > $60) and (byte(mybuf[i]) < $7B)) or |
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12463
diff
changeset
|
3551 |
((byte(mybuf[i]) >= $30) and (byte(mybuf[i]) < $3A))) then |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3552 |
inc(wordCount); |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3553 |
lastChar := mybuf[i]; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3554 |
if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
12601
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12581
diff
changeset
|
3555 |
inComment := false |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3556 |
end; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3557 |
end; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3558 |
ScriptLocaleReader:= mybuf |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3559 |
end; |
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3560 |
// ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3561 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3562 |
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
|
3563 |
var ret : LongInt; |
5243 | 3564 |
s : shortstring; |
8031 | 3565 |
f : PFSFile; |
8034 | 3566 |
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
|
3567 |
begin |
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3568 |
inComment:= false; |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3569 |
inQuote:= false; |
12459
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12376
diff
changeset
|
3570 |
lastChar:= 'X'; |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3571 |
braceCount:= 0; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3572 |
wordCount:= 0; |
12464
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12463
diff
changeset
|
3573 |
locSum:= 0; |
8031 | 3574 |
s:= cPathz[ptData] + name; |
3575 |
if not pfsExists(s) then |
|
9531
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
3576 |
begin |
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
3577 |
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
|
3578 |
exit; |
9531
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
3579 |
end; |
6088 | 3580 |
|
8031 | 3581 |
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
|
3582 |
if f = nil then |
8031 | 3583 |
exit; |
3584 |
||
13398 | 3585 |
hedgewarsMountPackage(Str2PChar(copy(s, 3, length(s)-6)+'.hwp')); |
12321
d09eba2e1dd8
Move sidecar lua load to prior to script load. This should let the script use it for dependencies.
nemo
parents:
12306
diff
changeset
|
3586 |
|
8073 | 3587 |
physfsReaderSetBuffer(@buf); |
12463 | 3588 |
if Pos('Locale/',s) <> 0 then |
12462
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12460
diff
changeset
|
3589 |
ret:= lua_load(luaState, @ScriptLocaleReader, f, Str2PChar(s)) |
13354
40742f3f7dd9
Seed reset seems fine when moved out of the loader. Also bump protocol
nemo
parents:
13353
diff
changeset
|
3590 |
else |
40742f3f7dd9
Seed reset seems fine when moved out of the loader. Also bump protocol
nemo
parents:
13353
diff
changeset
|
3591 |
begin |
40742f3f7dd9
Seed reset seems fine when moved out of the loader. Also bump protocol
nemo
parents:
13353
diff
changeset
|
3592 |
SetRandomSeed(cSeed,true); |
40742f3f7dd9
Seed reset seems fine when moved out of the loader. Also bump protocol
nemo
parents:
13353
diff
changeset
|
3593 |
ret:= lua_load(luaState, @ScriptReader, f, Str2PChar(s)) |
40742f3f7dd9
Seed reset seems fine when moved out of the loader. Also bump protocol
nemo
parents:
13353
diff
changeset
|
3594 |
end; |
8031 | 3595 |
pfsClose(f); |
3596 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3597 |
if ret <> 0 then |
3774 | 3598 |
begin |
10312 | 3599 |
LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
3600 |
LuaError(lua_tostring(luaState, -1)); |
|
3774 | 3601 |
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
|
3602 |
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
|
3603 |
begin |
3539 | 3604 |
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
|
3605 |
// 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
|
3606 |
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
|
3607 |
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
|
3608 |
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
|
3609 |
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
|
3610 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3611 |
procedure SetGlobals; |
13221
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3612 |
var x, y: 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
|
3613 |
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
|
3614 |
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
12581
1fb961480b3c
Lua API: Add ReadyTimeLeft variable
Wuzzy <almikes@aol.com>
parents:
12541
diff
changeset
|
3615 |
ScriptSetInteger('ReadyTimeLeft', ReadyTimeLeft); |
3761 | 3616 |
ScriptSetInteger('GameTime', GameTicks); |
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
3617 |
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
|
3618 |
ScriptSetInteger('WaterLine', cWaterLine); |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3619 |
if isCursorVisible and (not bShowAmmoMenu) then |
10989 | 3620 |
begin |
13221
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3621 |
x:= CursorPoint.X - WorldDx; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3622 |
y:= cScreenHeight - CursorPoint.Y - WorldDy; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3623 |
if (PrevCursorX <> x) or |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3624 |
(PrevCursorY <> y) then |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3625 |
begin |
13221
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3626 |
ScriptSetInteger('CursorX', x); |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3627 |
ScriptSetInteger('CursorY', y); |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3628 |
PrevCursorX:= x; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3629 |
PrevCursorY:= y; |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3630 |
end |
10989 | 3631 |
end |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3632 |
else |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3633 |
begin |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3634 |
ScriptSetInteger('CursorX', NoPointX); |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3635 |
ScriptSetInteger('CursorY', NoPointX); |
13221
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3636 |
PrevCursorX:= NoPointX; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
3637 |
PrevCursorY:= NoPointX |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3638 |
end; |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3639 |
|
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
|
3640 |
if not mapDims then |
7650 | 3641 |
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
|
3642 |
mapDims:= true; |
7650 | 3643 |
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
3644 |
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
|
3645 |
ScriptSetInteger('LeftX', leftX); |
|
3646 |
ScriptSetInteger('RightX', rightX); |
|
3647 |
ScriptSetInteger('TopY', topY) |
|
3648 |
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
|
3649 |
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
|
3650 |
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
|
3651 |
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
|
3652 |
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
|
3653 |
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
|
3654 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3655 |
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
|
3656 |
begin |
11183 | 3657 |
// TODO |
3658 |
// Use setters instead, because globals should be read-only! |
|
3659 |
// Otherwise globals might be changed by Lua, but then unexpectatly overwritten by engine when a ScriptCall is triggered by whatever Lua is doing! |
|
3660 |
// Sure, one could work around that in engine (e.g. by setting writable globals in SetGlobals only when their engine-side value has actually changed since SetGlobals was called the last time...), but things just get messier and messier then. |
|
3661 |
// It is inconsistent anyway to have some globals be read-only and others not with no indication whatsoever. |
|
3662 |
// -- sheepluva |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3663 |
TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); |
12581
1fb961480b3c
Lua API: Add ReadyTimeLeft variable
Wuzzy <almikes@aol.com>
parents:
12541
diff
changeset
|
3664 |
ReadyTimeLeft:= ScriptGetInteger('ReadyTimeLeft'); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3665 |
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
|
3666 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3667 |
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
|
3668 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8012
diff
changeset
|
3669 |
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
|
3670 |
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
|
3671 |
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
|
3672 |
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
|
3673 |
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
|
3674 |
begin |
10312 | 3675 |
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
|
3676 |
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
|
3677 |
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
|
3678 |
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
|
3679 |
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
|
3680 |
|
7805 | 3681 |
(* |
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
|
3682 |
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
|
3683 |
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
|
3684 |
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
|
3685 |
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
|
3686 |
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
|
3687 |
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
|
3688 |
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
|
3689 |
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
|
3690 |
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
|
3691 |
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
|
3692 |
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
|
3693 |
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
|
3694 |
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
|
3695 |
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
|
3696 |
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
|
3697 |
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
|
3698 |
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
|
3699 |
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
|
3700 |
end; |
7805 | 3701 |
*) |
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
|
3702 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3703 |
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
|
3704 |
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
|
3705 |
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
|
3706 |
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
|
3707 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3708 |
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
|
3709 |
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
|
3710 |
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
|
3711 |
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
|
3712 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3713 |
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
|
3714 |
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
|
3715 |
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
|
3716 |
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
|
3717 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3718 |
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
|
3719 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8012
diff
changeset
|
3720 |
if (not ScriptLoaded) or (not ScriptExists(fname)) then |
10560 | 3721 |
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
|
3722 |
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
|
3723 |
lua_getglobal(luaState, Str2PChar(fname)); |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3724 |
lua_pushnumber(luaState, par1); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3725 |
lua_pushnumber(luaState, par2); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3726 |
lua_pushnumber(luaState, par3); |
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3727 |
lua_pushnumber(luaState, par4); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3728 |
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
|
3729 |
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
|
3730 |
begin |
10312 | 3731 |
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
|
3732 |
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
|
3733 |
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
|
3734 |
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
|
3735 |
begin |
12299
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12291
diff
changeset
|
3736 |
ScriptCall:= Trunc(lua_tonumber(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
|
3737 |
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
|
3738 |
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
|
3739 |
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
|
3740 |
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
|
3741 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3742 |
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
|
3743 |
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
|
3744 |
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
|
3745 |
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
|
3746 |
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
|
3747 |
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
|
3748 |
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
|
3749 |
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
|
3750 |
ScriptExists:= not lua_isnoneornil(luaState, -1); |
12112
0695302f3f5f
Fix ScriptExists() destroying lua stack (fixes Bug #146)
sheepluva
parents:
12095
diff
changeset
|
3751 |
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
|
3752 |
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
|
3753 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3754 |
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
|
3755 |
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
|
3756 |
begin |
3346 | 3757 |
ScriptAmmoLoadout:= ''; |
3758 |
ScriptAmmoDelay:= ''; |
|
3759 |
ScriptAmmoProbability:= ''; |
|
3760 |
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
|
3761 |
for i:=1 to ord(High(TAmmoType)) do |
3346 | 3762 |
begin |
3763 |
ScriptAmmoLoadout:= ScriptAmmoLoadout + '0'; |
|
3764 |
ScriptAmmoProbability:= ScriptAmmoProbability + '0'; |
|
3765 |
ScriptAmmoDelay:= ScriptAmmoDelay + '0'; |
|
3766 |
ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0'; |
|
3767 |
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
|
3768 |
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
|
3769 |
|
9750 | 3770 |
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
|
3771 |
begin |
9750 | 3772 |
//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 |
3773 |
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
|
3774 |
exit; |
3346 | 3775 |
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1]; |
9750 | 3776 |
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
|
3777 |
ScriptSetAmmoDelay(ammo, delay); |
3346 | 3778 |
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
|
3779 |
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
|
3780 |
|
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
|
3781 |
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
|
3782 |
begin |
11682 | 3783 |
// change loadout string if ammo store has not been initialized yet |
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
|
3784 |
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
|
3785 |
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
|
3786 |
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
|
3787 |
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
|
3788 |
end |
11682 | 3789 |
// change 'live' delay values |
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
|
3790 |
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
|
3791 |
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
|
3792 |
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
|
3793 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3794 |
procedure ScriptApplyAmmoStore; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
3795 |
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
|
3796 |
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
|
3797 |
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
|
3798 |
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
|
3799 |
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
|
3800 |
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
|
3801 |
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
|
3802 |
ScriptPrepareAmmoStore; |
6746 | 3803 |
ScriptCall('onNewAmmoStore',i,-1); |
3804 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
3805 |
SetAmmoProbability(ScriptAmmoProbability); |
|
3806 |
SetAmmoDelay(ScriptAmmoDelay); |
|
3807 |
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
|
3808 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
3809 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
3810 |
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
|
3811 |
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
|
3812 |
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
|
3813 |
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
|
3814 |
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
|
3815 |
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
|
3816 |
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
|
3817 |
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
|
3818 |
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
|
3819 |
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
|
3820 |
ScriptPrepareAmmoStore; |
6746 | 3821 |
ScriptCall('onNewAmmoStore',i,j); |
3822 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
3823 |
SetAmmoProbability(ScriptAmmoProbability); |
|
3824 |
SetAmmoDelay(ScriptAmmoDelay); |
|
3825 |
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
|
3826 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
3827 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
3828 |
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
|
3829 |
end |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
3830 |
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
|
3831 |
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
|
3832 |
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
|
3833 |
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
|
3834 |
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
|
3835 |
ScriptPrepareAmmoStore; |
6746 | 3836 |
ScriptCall('onNewAmmoStore',i,-1); |
3837 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
3838 |
SetAmmoProbability(ScriptAmmoProbability); |
|
3839 |
SetAmmoDelay(ScriptAmmoDelay); |
|
3840 |
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
|
3841 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
3842 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
3843 |
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
|
3844 |
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
|
3845 |
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
|
3846 |
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
|
3847 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3848 |
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
|
3849 |
var at : TGearType; |
4453 | 3850 |
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
|
3851 |
am : TAmmoType; |
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
3852 |
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
|
3853 |
st : TSound; |
5118 | 3854 |
he : THogEffect; |
3855 |
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
|
3856 |
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
|
3857 |
mg : TMapGen; |
11884
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11854
diff
changeset
|
3858 |
we : TWorldEdge; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3859 |
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
|
3860 |
// initialize lua |
10239 | 3861 |
luaState:= lua_open; |
11537 | 3862 |
if checkFails(luaState <> nil, 'lua_open failed', true) then exit; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3863 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3864 |
// open internal libraries |
10239 | 3865 |
luaopen_base(luaState); |
3866 |
luaopen_string(luaState); |
|
3867 |
luaopen_math(luaState); |
|
3868 |
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
|
3869 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3870 |
// import some variables |
13093
2b5314cc356c
Lua: Rename global variable “L” to “LOCALE”
Wuzzy <Wuzzy2@mail.ru>
parents:
13067
diff
changeset
|
3871 |
ScriptSetString(_S'LOCALE', 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
|
3872 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3873 |
// import game flags |
13277
5984e8c6cbeb
Add new game flag gfSwitchHog, enable hog switching at turn start
Wuzzy <Wuzzy2@mail.ru>
parents:
13275
diff
changeset
|
3874 |
ScriptSetInteger('gfSwitchHog', gfSwitchHog); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3875 |
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
|
3876 |
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
|
3877 |
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
|
3878 |
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
|
3879 |
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
|
3880 |
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
|
3881 |
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
|
3882 |
ScriptSetInteger('gfInvulnerable', gfInvulnerable); |
10671 | 3883 |
ScriptSetInteger('gfResetHealth', gfResetHealth); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3884 |
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
|
3885 |
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
|
3886 |
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
|
3887 |
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
|
3888 |
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
|
3889 |
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
|
3890 |
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
|
3891 |
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
|
3892 |
ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
4162 | 3893 |
ScriptSetInteger('gfDisableLandObjects', gfDisableLandObjects); |
3894 |
ScriptSetInteger('gfAISurvival', gfAISurvival); |
|
3895 |
ScriptSetInteger('gfInfAttack', gfInfAttack); |
|
3896 |
ScriptSetInteger('gfResetWeps', gfResetWeps); |
|
3897 |
ScriptSetInteger('gfPerHogAmmo', gfPerHogAmmo); |
|
4219 | 3898 |
ScriptSetInteger('gfDisableWind', gfDisableWind); |
4319 | 3899 |
ScriptSetInteger('gfMoreWind', gfMoreWind); |
5016
9347d82a26cc
added game mode Tag Team, mostly untested, please test :)
Henek
parents:
5013
diff
changeset
|
3900 |
ScriptSetInteger('gfTagTeam', gfTagTeam); |
9387 | 3901 |
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
|
3902 |
|
3894 | 3903 |
ScriptSetInteger('gmLeft', gmLeft); |
3904 |
ScriptSetInteger('gmRight', gmRight); |
|
3905 |
ScriptSetInteger('gmUp', gmUp); |
|
3906 |
ScriptSetInteger('gmDown', gmDown); |
|
3907 |
ScriptSetInteger('gmSwitch', gmSwitch); |
|
3908 |
ScriptSetInteger('gmAttack', gmAttack); |
|
3909 |
ScriptSetInteger('gmLJump', gmLJump); |
|
3910 |
ScriptSetInteger('gmHJump', gmHJump); |
|
3911 |
ScriptSetInteger('gmDestroy', gmDestroy); |
|
3912 |
ScriptSetInteger('gmSlot', gmSlot); |
|
3913 |
ScriptSetInteger('gmWeapon', gmWeapon); |
|
3914 |
ScriptSetInteger('gmTimer', gmTimer); |
|
3915 |
ScriptSetInteger('gmAnimate', gmAnimate); |
|
3916 |
ScriptSetInteger('gmPrecise', gmPrecise); |
|
3892 | 3917 |
ScriptSetInteger('gmAllStoppable', gmAllStoppable); |
3918 |
||
3761 | 3919 |
// speech bubbles |
3920 |
ScriptSetInteger('SAY_SAY', 1); |
|
3921 |
ScriptSetInteger('SAY_THINK', 2); |
|
3922 |
ScriptSetInteger('SAY_SHOUT', 3); |
|
3923 |
||
13598
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13587
diff
changeset
|
3924 |
// other |
13600
0adc82afb784
Add Lua globals: AMMO_INFINITE and NoPointX
Wuzzy <Wuzzy2@mail.ru>
parents:
13598
diff
changeset
|
3925 |
ScriptSetInteger('AMMO_INFINITE', AMMO_INFINITE); |
13598
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13587
diff
changeset
|
3926 |
ScriptSetInteger('JETPACK_FUEL_INFINITE', JETPACK_FUEL_INFINITE); |
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13587
diff
changeset
|
3927 |
ScriptSetInteger('BIRDY_ENERGY_INFINITE', BIRDY_ENERGY_INFINITE); |
13600
0adc82afb784
Add Lua globals: AMMO_INFINITE and NoPointX
Wuzzy <Wuzzy2@mail.ru>
parents:
13598
diff
changeset
|
3928 |
ScriptSetInteger('NoPointX', NoPointX); |
13602
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13600
diff
changeset
|
3929 |
ScriptSetInteger('cMaxHogHealth', cMaxHogHealth); |
13598
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13587
diff
changeset
|
3930 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3931 |
// 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
|
3932 |
for at:= Low(TGearType) to High(TGearType) do |
3337 | 3933 |
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
|
3934 |
|
4453 | 3935 |
for vgt:= Low(TVisualGearType) to High(TVisualGearType) do |
3936 |
ScriptSetInteger(EnumToStr(vgt), ord(vgt)); |
|
3937 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3938 |
// 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
|
3939 |
for st:= Low(TSound) to High(TSound) do |
3337 | 3940 |
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
|
3941 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3942 |
// 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
|
3943 |
for am:= Low(TAmmoType) to High(TAmmoType) do |
3337 | 3944 |
ScriptSetInteger(EnumToStr(am), ord(am)); |
3697 | 3945 |
|
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
3946 |
for si:= Low(TStatInfoType) to High(TStatInfoType) do |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
3947 |
ScriptSetInteger(EnumToStr(si), ord(si)); |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
3948 |
|
3756 | 3949 |
for he:= Low(THogEffect) to High(THogEffect) do |
3950 |
ScriptSetInteger(EnumToStr(he), ord(he)); |
|
3951 |
||
5118 | 3952 |
for cg:= Low(TCapGroup) to High(TCapGroup) do |
3953 |
ScriptSetInteger(EnumToStr(cg), ord(cg)); |
|
3954 |
||
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
|
3955 |
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
|
3956 |
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
|
3957 |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
3958 |
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
|
3959 |
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
|
3960 |
|
11884
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11854
diff
changeset
|
3961 |
for we:= Low(TWorldEdge) to High(TWorldEdge) do |
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11854
diff
changeset
|
3962 |
ScriptSetInteger(EnumToStr(we), ord(we)); |
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11854
diff
changeset
|
3963 |
|
13647
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13632
diff
changeset
|
3964 |
ScriptSetInteger('capcolDefault' , capcolDefault); |
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13632
diff
changeset
|
3965 |
ScriptSetInteger('capcolSetting' , capcolSetting); |
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13632
diff
changeset
|
3966 |
|
10289 | 3967 |
ScriptSetInteger('gstDrowning' , gstDrowning); |
3968 |
ScriptSetInteger('gstHHDriven' , gstHHDriven); |
|
3969 |
ScriptSetInteger('gstMoving' , gstMoving); |
|
3970 |
ScriptSetInteger('gstAttacked' , gstAttacked); |
|
3971 |
ScriptSetInteger('gstAttacking' , gstAttacking); |
|
3972 |
ScriptSetInteger('gstCollision' , gstCollision); |
|
11052 | 3973 |
ScriptSetInteger('gstChooseTarget' , gstChooseTarget); |
10289 | 3974 |
ScriptSetInteger('gstHHJumping' , gstHHJumping); |
3975 |
ScriptSetInteger('gsttmpFlag' , gsttmpFlag); |
|
3976 |
ScriptSetInteger('gstHHThinking' , gstHHThinking); |
|
3977 |
ScriptSetInteger('gstNoDamage' , gstNoDamage); |
|
3978 |
ScriptSetInteger('gstHHHJump' , gstHHHJump); |
|
3979 |
ScriptSetInteger('gstAnimation' , gstAnimation); |
|
3980 |
ScriptSetInteger('gstHHDeath' , gstHHDeath); |
|
3981 |
ScriptSetInteger('gstWinner' , gstWinner); |
|
3982 |
ScriptSetInteger('gstWait' , gstWait); |
|
3983 |
ScriptSetInteger('gstNotKickable' , gstNotKickable); |
|
3984 |
ScriptSetInteger('gstLoser' , gstLoser); |
|
3985 |
ScriptSetInteger('gstHHGone' , gstHHGone); |
|
3986 |
ScriptSetInteger('gstInvisible' , gstInvisible); |
|
11052 | 3987 |
ScriptSetInteger('gstSubmersible' , gstSubmersible); |
3988 |
ScriptSetInteger('gstFrozen' , gstFrozen); |
|
3989 |
ScriptSetInteger('gstNoGravity' , gstNoGravity); |
|
5527 | 3990 |
|
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8077
diff
changeset
|
3991 |
// ai hints |
10289 | 3992 |
ScriptSetInteger('aihUsualProcessing', aihUsualProcessing); |
3993 |
ScriptSetInteger('aihDoesntMatter' , aihDoesntMatter); |
|
7996 | 3994 |
|
13042
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13041
diff
changeset
|
3995 |
// land flags (partial) |
10283 | 3996 |
ScriptSetInteger('lfIndestructible', lfIndestructible); |
10421 | 3997 |
ScriptSetInteger('lfIce' , lfIce); |
3998 |
ScriptSetInteger('lfBouncy' , lfBouncy); |
|
3999 |
||
13042
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13041
diff
changeset
|
4000 |
ScriptSetInteger('lfLandMask' , lfLandMask); |
13468
f1d349a52bc7
Refactor: lfCurrentHog→lfCurHogCrate, lfNotCurrentMask→lfNotCurHogCrate
Wuzzy <Wuzzy2@mail.ru>
parents:
13466
diff
changeset
|
4001 |
ScriptSetInteger('lfCurHogCrate' , lfCurHogCrate); |
13042
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13041
diff
changeset
|
4002 |
ScriptSetInteger('lfHHMask' , lfHHMask); |
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13041
diff
changeset
|
4003 |
ScriptSetInteger('lfNotHHObjMask' , lfNotHHObjMask); |
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13041
diff
changeset
|
4004 |
ScriptSetInteger('lfAllObjMask' , lfAllObjMask); |
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13041
diff
changeset
|
4005 |
|
13275 | 4006 |
// explosion constants |
4007 |
ScriptSetInteger('EXPLAutoSound' , EXPLAutoSound); |
|
4008 |
ScriptSetInteger('EXPLNoDamage' , EXPLNoDamage); |
|
4009 |
ScriptSetInteger('EXPLDoNotTouchHH' , EXPLDoNotTouchHH); |
|
4010 |
ScriptSetInteger('EXPLDontDraw' , EXPLDontDraw); |
|
4011 |
ScriptSetInteger('EXPLNoGfx' , EXPLNoGfx); |
|
4012 |
ScriptSetInteger('EXPLPoisoned' , EXPLPoisoned); |
|
4013 |
ScriptSetInteger('EXPLDoNotTouchAny', EXPLDoNotTouchAny); |
|
13609
73b096e1d895
Fix hammer/pickhammer not digging land with gfSolidLand on
Wuzzy <Wuzzy2@mail.ru>
parents:
13602
diff
changeset
|
4014 |
ScriptSetInteger('EXPLForceDraw' , EXPLForceDraw); |
13275 | 4015 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4016 |
// register functions |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
4017 |
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
|
4018 |
lua_register(luaState, _P'RestoreHog', @lc_restorehog); |
13582 | 4019 |
lua_register(luaState, _P'IsHogHidden', @lc_ishoghidden); |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
4020 |
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
|
4021 |
lua_register(luaState, _P'GetCampaignVar', @lc_getcampaignvar); |
7072 | 4022 |
lua_register(luaState, _P'band', @lc_band); |
4023 |
lua_register(luaState, _P'bor', @lc_bor); |
|
4024 |
lua_register(luaState, _P'bnot', @lc_bnot); |
|
4025 |
lua_register(luaState, _P'div', @lc_div); |
|
4026 |
lua_register(luaState, _P'GetInputMask', @lc_getinputmask); |
|
4027 |
lua_register(luaState, _P'SetInputMask', @lc_setinputmask); |
|
4028 |
lua_register(luaState, _P'AddGear', @lc_addgear); |
|
10290 | 4029 |
lua_register(luaState, _P'DismissTeam', @lc_dismissteam); |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
4030 |
lua_register(luaState, _P'EnableGameFlags', @lc_enablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
4031 |
lua_register(luaState, _P'DisableGameFlags', @lc_disablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
4032 |
lua_register(luaState, _P'ClearGameFlags', @lc_cleargameflags); |
10035 | 4033 |
lua_register(luaState, _P'GetGameFlag', @lc_getgameflag); |
7072 | 4034 |
lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
4035 |
lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
|
4036 |
lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
|
11885
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11884
diff
changeset
|
4037 |
lua_register(luaState, _P'GetVisualGearType', @lc_getvisualgeartype); |
7072 | 4038 |
lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
4039 |
lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); |
|
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
4040 |
lua_register(luaState, _P'GetGearValues', @lc_getgearvalues); |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
4041 |
lua_register(luaState, _P'SetGearValues', @lc_setgearvalues); |
7072 | 4042 |
lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
4043 |
lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
|
4044 |
lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
|
12937 | 4045 |
lua_register(luaState, _P'SpawnSupplyCrate', @lc_spawnsupplycrate); |
7072 | 4046 |
lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
4047 |
lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
|
4048 |
lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); |
|
4049 |
lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
|
12915 | 4050 |
lua_register(luaState, _P'WriteLnToChat', @lc_writelntochat); |
7072 | 4051 |
lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
4052 |
lua_register(luaState, _P'EndGame', @lc_endgame); |
|
12291
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12167
diff
changeset
|
4053 |
lua_register(luaState, _P'EndTurn', @lc_endturn); |
13345
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13277
diff
changeset
|
4054 |
lua_register(luaState, _P'Retreat', @lc_retreat); |
13175
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13127
diff
changeset
|
4055 |
lua_register(luaState, _P'SkipTurn', @lc_skipturn); |
12541
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12499
diff
changeset
|
4056 |
lua_register(luaState, _P'GetTeamStats', @lc_getteamstats); |
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
4057 |
lua_register(luaState, _P'SendStat', @lc_sendstat); |
12337
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
4058 |
lua_register(luaState, _P'SendGameResultOff', @lc_sendgameresultoff); |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
4059 |
lua_register(luaState, _P'SendRankingStatsOff', @lc_sendrankingstatsoff); |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12321
diff
changeset
|
4060 |
lua_register(luaState, _P'SendAchievementsStatsOff', @lc_sendachievementsstatsoff); |
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
4061 |
lua_register(luaState, _P'SendHealthStatsOff', @lc_sendhealthstatsoff); |
7072 | 4062 |
lua_register(luaState, _P'FindPlace', @lc_findplace); |
4063 |
lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
|
4064 |
lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
|
4065 |
lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
|
4066 |
lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget); |
|
4067 |
lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity); |
|
4068 |
lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity); |
|
4069 |
lua_register(luaState, _P'ParseCommand', @lc_parsecommand); |
|
4070 |
lua_register(luaState, _P'ShowMission', @lc_showmission); |
|
4071 |
lua_register(luaState, _P'HideMission', @lc_hidemission); |
|
11944
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11885
diff
changeset
|
4072 |
lua_register(luaState, _P'SetAmmoTexts', @lc_setammotexts); |
11946
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
4073 |
lua_register(luaState, _P'SetAmmoDescriptionAppendix', @lc_setammodescriptionappendix); |
7072 | 4074 |
lua_register(luaState, _P'AddCaption', @lc_addcaption); |
4075 |
lua_register(luaState, _P'SetAmmo', @lc_setammo); |
|
13459
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13439
diff
changeset
|
4076 |
lua_register(luaState, _P'GetAmmo', @lc_getammo); |
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
|
4077 |
lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay); |
7072 | 4078 |
lua_register(luaState, _P'PlaySound', @lc_playsound); |
13126
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13093
diff
changeset
|
4079 |
lua_register(luaState, _P'SetSoundMask', @lc_setsoundmask); |
12936 | 4080 |
lua_register(luaState, _P'GetTeamName', @lc_getteamname); |
13025
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
4081 |
lua_register(luaState, _P'GetTeamIndex', @lc_getteamindex); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
4082 |
lua_register(luaState, _P'GetTeamClan', @lc_getteamclan); |
7072 | 4083 |
lua_register(luaState, _P'AddTeam', @lc_addteam); |
13023
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12952
diff
changeset
|
4084 |
lua_register(luaState, _P'SetTeamLabel', @lc_setteamlabel); |
7072 | 4085 |
lua_register(luaState, _P'AddHog', @lc_addhog); |
4086 |
lua_register(luaState, _P'AddAmmo', @lc_addammo); |
|
4087 |
lua_register(luaState, _P'GetAmmoCount', @lc_getammocount); |
|
12944
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12937
diff
changeset
|
4088 |
lua_register(luaState, _P'HealHog', @lc_healhog); |
7072 | 4089 |
lua_register(luaState, _P'SetHealth', @lc_sethealth); |
4090 |
lua_register(luaState, _P'GetHealth', @lc_gethealth); |
|
4091 |
lua_register(luaState, _P'SetEffect', @lc_seteffect); |
|
4092 |
lua_register(luaState, _P'GetEffect', @lc_geteffect); |
|
4093 |
lua_register(luaState, _P'GetHogClan', @lc_gethogclan); |
|
4094 |
lua_register(luaState, _P'GetClanColor', @lc_getclancolor); |
|
4095 |
lua_register(luaState, _P'SetClanColor', @lc_setclancolor); |
|
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
4096 |
lua_register(luaState, _P'GetHogVoicepack', @lc_gethogvoicepack); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
4097 |
lua_register(luaState, _P'GetHogFlag', @lc_gethogflag); |
12051 | 4098 |
lua_register(luaState, _P'GetHogFort', @lc_gethogfort); |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
4099 |
lua_register(luaState, _P'GetHogGrave', @lc_gethoggrave); |
11852 | 4100 |
lua_register(luaState, _P'IsHogLocal', @lc_ishoglocal); |
7072 | 4101 |
lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname); |
9788 | 4102 |
lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname); |
7072 | 4103 |
lua_register(luaState, _P'GetHogName', @lc_gethogname); |
4104 |
lua_register(luaState, _P'SetHogName', @lc_sethogname); |
|
4105 |
lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel); |
|
4106 |
lua_register(luaState, _P'SetHogLevel', @lc_sethoglevel); |
|
4107 |
lua_register(luaState, _P'GetX', @lc_getx); |
|
4108 |
lua_register(luaState, _P'GetY', @lc_gety); |
|
4109 |
lua_register(luaState, _P'CopyPV', @lc_copypv); |
|
4110 |
lua_register(luaState, _P'FollowGear', @lc_followgear); |
|
4111 |
lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear); |
|
4112 |
lua_register(luaState, _P'SetState', @lc_setstate); |
|
4113 |
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
|
4114 |
lua_register(luaState, _P'GetTag', @lc_gettag); |
7072 | 4115 |
lua_register(luaState, _P'SetTag', @lc_settag); |
4116 |
lua_register(luaState, _P'SetTimer', @lc_settimer); |
|
4117 |
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
|
4118 |
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
|
4119 |
lua_register(luaState, _P'GetFlightTime', @lc_getflighttime); |
7072 | 4120 |
lua_register(luaState, _P'SetZoom', @lc_setzoom); |
4121 |
lua_register(luaState, _P'GetZoom', @lc_getzoom); |
|
4122 |
lua_register(luaState, _P'HogSay', @lc_hogsay); |
|
4123 |
lua_register(luaState, _P'SwitchHog', @lc_switchhog); |
|
13383
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
4124 |
lua_register(luaState, _P'EnableSwitchHog', @lc_enableswitchhog); |
7072 | 4125 |
lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
4126 |
lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); |
|
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
4127 |
lua_register(luaState, _P'SetGearElasticity', @lc_setgearelasticity); |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
4128 |
lua_register(luaState, _P'GetGearFriction', @lc_getgearfriction); |
10808
1e39630d7c2e
Add a couple of more variable bindings, make all the set visual gear values optional, to allow skipping trailing params or specifying ones in the middle as nil to not set. Should make using it more convenient in simple cases.
nemo
parents:
10671
diff
changeset
|
4129 |
lua_register(luaState, _P'SetGearFriction', @lc_setgearfriction); |
7072 | 4130 |
lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
4131 |
lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
|
4132 |
lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
|
4133 |
lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |
|
4134 |
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
|
4135 |
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
|
4136 |
lua_register(luaState, _P'SetGearCollisionMask', @lc_setgearcollisionmask); |
7072 | 4137 |
lua_register(luaState, _P'GetRandom', @lc_getrandom); |
4138 |
lua_register(luaState, _P'SetWind', @lc_setwind); |
|
12935
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12934
diff
changeset
|
4139 |
lua_register(luaState, _P'GetWind', @lc_getwind); |
7072 | 4140 |
lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
4141 |
lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
|
4142 |
lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
|
10901 | 4143 |
lua_register(luaState, _P'EraseSprite', @lc_erasesprite); |
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
|
4144 |
lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
7072 | 4145 |
lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
12095 | 4146 |
lua_register(luaState, _P'PlaceRubber', @lc_placerubber); |
7072 | 4147 |
lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
4148 |
lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
|
9815 | 4149 |
lua_register(luaState, _P'GetGravity', @lc_getgravity); |
4150 |
lua_register(luaState, _P'SetGravity', @lc_setgravity); |
|
9914 | 4151 |
lua_register(luaState, _P'SetWaterLine', @lc_setwaterline); |
10291 | 4152 |
lua_register(luaState, _P'SetNextWeapon', @lc_setnextweapon); |
10289 | 4153 |
lua_register(luaState, _P'SetWeapon', @lc_setweapon); |
11525 | 4154 |
lua_register(luaState, _P'SetCinematicMode', @lc_setcinematicmode); |
11058
b91667fd6f20
Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default
sheepluva
parents:
11052
diff
changeset
|
4155 |
lua_register(luaState, _P'SetMaxBuildDistance', @lc_setmaxbuilddistance); |
11851 | 4156 |
lua_register(luaState, _P'GetAmmoName', @lc_getammoname); |
13376
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13375
diff
changeset
|
4157 |
lua_register(luaState, _P'GetAmmoTimer', @lc_getammotimer); |
12934
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
4158 |
lua_register(luaState, _P'SetVampiric', @lc_setvampiric); |
13581
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
4159 |
lua_register(luaState, _P'GetVampiric', @lc_getvampiric); |
12934
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12915
diff
changeset
|
4160 |
lua_register(luaState, _P'SetLaserSight', @lc_setlasersight); |
13581
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13468
diff
changeset
|
4161 |
lua_register(luaState, _P'GetLaserSight', @lc_getlasersight); |
13275 | 4162 |
lua_register(luaState, _P'Explode', @lc_explode); |
10611 | 4163 |
// drawn map functions |
4164 |
lua_register(luaState, _P'AddPoint', @lc_addPoint); |
|
4165 |
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
|
4166 |
|
11066 | 4167 |
lua_register(luaState, _P'SetGearAIHints', @lc_setgearaihints); |
8043 | 4168 |
lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload); |
9397 | 4169 |
lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement); |
11574 | 4170 |
lua_register(luaState, _P'StartGhostPoints', @lc_startghostpoints); |
4171 |
lua_register(luaState, _P'DumpPoint', @lc_dumppoint); |
|
7996 | 4172 |
|
10618 | 4173 |
ScriptSetInteger('TEST_SUCCESSFUL' , HaltTestSuccess); |
4174 |
ScriptSetInteger('TEST_FAILED' , HaltTestFailed); |
|
4175 |
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
|
4176 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4177 |
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
|
4178 |
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
|
4179 |
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
|
4180 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4181 |
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
|
4182 |
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
|
4183 |
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
|
4184 |
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
|
4185 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4186 |
{$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
|
4187 |
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
|
4188 |
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
|
4189 |
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
|
4190 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4191 |
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
|
4192 |
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
|
4193 |
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
|
4194 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4195 |
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
|
4196 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4197 |
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
|
4198 |
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
|
4199 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4200 |
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
|
4201 |
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
|
4202 |
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
|
4203 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4204 |
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
|
4205 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4206 |
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
|
4207 |
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
|
4208 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4209 |
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
|
4210 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4211 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4212 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4213 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4214 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4215 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4216 |
par4:= par4; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4217 |
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
|
4218 |
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
|
4219 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4220 |
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
|
4221 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4222 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4223 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4224 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4225 |
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
|
4226 |
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
|
4227 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4228 |
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
|
4229 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4230 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4231 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4232 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4233 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4234 |
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
|
4235 |
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
|
4236 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4237 |
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
|
4238 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4239 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4240 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4241 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4242 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4243 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4244 |
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
|
4245 |
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
|
4246 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4247 |
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
|
4248 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4249 |
fname:= fname; // avoid hint |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4250 |
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
|
4251 |
end; |
7805 | 4252 |
(* |
5410 | 4253 |
function ParseCommandOverride(key, value : shortstring) : shortstring; |
4254 |
begin |
|
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4255 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4256 |
key:= key; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4257 |
value:= value; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4258 |
ParseCommandOverride:= '' |
5410 | 4259 |
end; |
7805 | 4260 |
*) |
5410 | 4261 |
|
6430 | 4262 |
procedure ScriptOnScreenResize; |
4263 |
begin |
|
4264 |
end; |
|
4265 |
||
11683
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4266 |
procedure ScriptOnPreviewInit; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4267 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4268 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4269 |
|
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4270 |
procedure ScriptSetInteger(name : shortstring; value : LongInt); |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4271 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4272 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4273 |
|
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4274 |
procedure ScriptSetString(name : shortstring; value : shortstring); |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4275 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4276 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4277 |
|
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4278 |
procedure LuaParseString(s : ShortString); |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4279 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4280 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11682
diff
changeset
|
4281 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4282 |
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
|
4283 |
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
|
4284 |
mapDims:= false; |
10611 | 4285 |
PointsBuffer:= ''; |
13221
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
4286 |
PrevCursorX:= NoPointX; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13175
diff
changeset
|
4287 |
PrevCursorY:= NoPointX; |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4288 |
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
|
4289 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4290 |
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
|
4291 |
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
|
4292 |
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
|
4293 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4294 |
{$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
|
4295 |
end. |