author | Wuzzy <Wuzzy2@mail.ru> |
Fri, 19 Apr 2019 15:58:42 +0200 | |
changeset 14833 | 16d5951d4044 |
parent 14775 | b39da9cf7616 |
child 14948 | 9d6a25239d00 |
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 |
* |
|
12107
0695302f3f5f
Fix ScriptExists() destroying lua stack (fixes Bug #146)
sheepluva
parents:
12090
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 |
|
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
37 |
function ScriptLoad(name : shortstring; mustExist : boolean): boolean; |
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); |
13754
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
43 |
procedure ScriptSetMapGlobals; |
3043
3acdb4dac6eb
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 |
|
3acdb4dac6eb
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 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
|
10312 | 52 |
procedure LuaParseString(s: shortString); |
5410 | 53 |
|
7805 | 54 |
//function ParseCommandOverride(key, value : shortstring) : shortstring; This did not work out well |
5577 | 55 |
|
3043
3acdb4dac6eb
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 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
|
57 |
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
|
58 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
59 |
implementation |
9205
abce6011f86c
aaaaand let's not forget about lua, which has also a slightly revised build process
koda
parents:
9180
diff
changeset
|
60 |
|
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6430
diff
changeset
|
61 |
uses LuaPas, |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
62 |
uConsole, |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
63 |
uConsts, |
6543 | 64 |
uGears, |
6468 | 65 |
uGearsList, |
6543 | 66 |
uGearsUtils, |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
67 |
uFloat, |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
68 |
uWorld, |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
69 |
uAmmos, |
6763 | 70 |
uTeams, |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
71 |
uSound, |
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
72 |
uChat, |
4243 | 73 |
uStats, |
4875 | 74 |
uStore, |
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
4319
diff
changeset
|
75 |
uRandom, |
4359 | 76 |
uTypes, |
4373 | 77 |
uVariables, |
4374 | 78 |
uCommands, |
4403 | 79 |
uCaptions, |
4832 | 80 |
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
|
81 |
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
|
82 |
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
|
83 |
uTextures, |
4985 | 84 |
uLandGraphics, |
11821 | 85 |
uUtils, |
8031 | 86 |
uIO, |
9283
76e68c136a11
Refactoring: VGSHandlers.inc -> uVisualGearsHandlers.pas
unc0rr
parents:
9245
diff
changeset
|
87 |
uVisualGearsList, |
9285 | 88 |
uGearsHandlersMess, |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
89 |
uPhysFSLayer, |
13674
3f6fae745f84
Make engine chat syntax translatable
Wuzzy <Wuzzy2@mail.ru>
parents:
13663
diff
changeset
|
90 |
uLocale, |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
91 |
SDLh |
10129
cd2a64a1f4aa
- Pas2C: make use of 'external' function decorator
unc0rr
parents:
10127
diff
changeset
|
92 |
{$IFNDEF PAS2C} |
9952
32f5982604f4
Fix build (no idea what's going on in this branch btw)
unc0rr
parents:
9950
diff
changeset
|
93 |
, 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
|
94 |
{$ENDIF} |
8031 | 95 |
; |
3697 | 96 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
97 |
var luaState : Plua_State; |
3346 | 98 |
ScriptAmmoLoadout : shortstring; |
99 |
ScriptAmmoProbability : shortstring; |
|
100 |
ScriptAmmoDelay : shortstring; |
|
101 |
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
|
102 |
ScriptLoaded : boolean; |
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
103 |
PointsBuffer: shortstring; |
13216
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
104 |
PrevCursorX, PrevCursorY: LongInt; |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
105 |
PendingTurnTimeLeft, PendingReadyTimeLeft: LongWord; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
106 |
isPendingTurnTimeLeft, isPendingReadyTimeLeft: boolean; |
3697 | 107 |
|
11678
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
108 |
{$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
|
109 |
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
|
110 |
procedure ScriptApplyAmmoStore; forward; |
9750 | 111 |
procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward; |
14640
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
112 |
procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: LongWord); 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
|
113 |
|
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
114 |
var LuaDebugInfo: lua_Debug; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
115 |
|
10617 | 116 |
procedure SetGlobals; forward; |
13747
be265ab8a4fb
Call GetGlobals after entering Lua command with /lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13745
diff
changeset
|
117 |
procedure GetGlobals; forward; |
10312 | 118 |
procedure LuaParseString(s: shortString); |
119 |
begin |
|
10617 | 120 |
SetGlobals; |
10312 | 121 |
AddFileLog('[Lua] input string: ' + s); |
122 |
AddChatString(#3 + '[Lua] > ' + s); |
|
123 |
if luaL_dostring(luaState, Str2PChar(s)) <> 0 then |
|
124 |
begin |
|
125 |
AddFileLog('[Lua] input string parsing error!'); |
|
126 |
AddChatString(#5 + '[Lua] Error while parsing!'); |
|
13747
be265ab8a4fb
Call GetGlobals after entering Lua command with /lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13745
diff
changeset
|
127 |
end |
be265ab8a4fb
Call GetGlobals after entering Lua command with /lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13745
diff
changeset
|
128 |
else |
be265ab8a4fb
Call GetGlobals after entering Lua command with /lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13745
diff
changeset
|
129 |
GetGlobals(); |
10312 | 130 |
end; |
131 |
||
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
132 |
function LuaUpdateDebugInfo(): Boolean; |
3539 | 133 |
begin |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
134 |
FillChar(LuaDebugInfo, sizeof(LuaDebugInfo), 0); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
135 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
136 |
if lua_getstack(luaState, 1, @LuaDebugInfo) = 0 then |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
137 |
exit(false); // stack not deep enough |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
138 |
|
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
139 |
// get source name and line count |
10297 | 140 |
lua_getinfo(luaState, PChar('Sl'), @LuaDebugInfo); |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
141 |
exit(true); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
142 |
end; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
143 |
|
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
144 |
procedure LuaErrorOrWarning(s: shortstring; isWarning: boolean); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
145 |
var src, intro: shortstring; |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
146 |
const |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
147 |
maxsrclen = 20; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
148 |
begin |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
149 |
if isWarning then |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
150 |
intro:= 'LUA WARNING' |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
151 |
else |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
152 |
intro:= 'LUA ERROR'; |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
153 |
if LuaUpdateDebugInfo() then |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
154 |
begin |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
155 |
src:= StrPas(LuaDebugInfo.source); |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
156 |
s:= intro + ': [ ... ' |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
157 |
+ copy(src, Length(src) - maxsrclen, maxsrclen - 3) + ':' |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
158 |
+ inttostr(LuaDebugInfo.currentLine) + ']: ' + s; |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
159 |
end |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
160 |
else |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
161 |
s:= intro + ': ' + s; |
3539 | 162 |
WriteLnToConsole(s); |
13744
cb2857f55130
Change chat text color for Lua warnings to yellow
Wuzzy <Wuzzy2@mail.ru>
parents:
13743
diff
changeset
|
163 |
if isWarning then |
cb2857f55130
Change chat text color for Lua warnings to yellow
Wuzzy <Wuzzy2@mail.ru>
parents:
13743
diff
changeset
|
164 |
AddChatString(#0 + s) |
cb2857f55130
Change chat text color for Lua warnings to yellow
Wuzzy <Wuzzy2@mail.ru>
parents:
13743
diff
changeset
|
165 |
else |
cb2857f55130
Change chat text color for Lua warnings to yellow
Wuzzy <Wuzzy2@mail.ru>
parents:
13743
diff
changeset
|
166 |
AddChatString(#5 + s); |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
167 |
if cTestLua and (not isWarning) then |
10306 | 168 |
halt(HaltTestLuaError); |
3539 | 169 |
end; |
170 |
||
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
171 |
procedure LuaError(s: shortstring); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
172 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
173 |
LuaErrorOrWarning(s, false); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
174 |
end; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
175 |
|
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
176 |
procedure LuaWarning(s: shortstring); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
177 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
178 |
LuaErrorOrWarning(s, true); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
179 |
end; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
180 |
|
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
181 |
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
|
182 |
begin |
10293
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
183 |
LuaError(call + ': ' + error); |
201ea4989985
state file name and line number in lua error messages
sheepluva
parents:
10291
diff
changeset
|
184 |
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
|
185 |
end; |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
186 |
|
10285 | 187 |
procedure LuaParameterCountError(expected, call, paramsyntax: shortstring; wrongcount: LongInt); inline; |
188 |
begin |
|
189 |
// TODO: i18n? |
|
190 |
LuaCallError('Wrong number of parameters! (is: ' + inttostr(wrongcount) + ', should be: '+ expected + ')', call, paramsyntax); |
|
191 |
end; |
|
192 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
193 |
// compare with allowed count |
10297 | 194 |
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
|
195 |
var c: LongInt; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
196 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
197 |
c:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
198 |
if c <> count then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
199 |
begin |
10285 | 200 |
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
|
201 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
202 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
203 |
|
10297 | 204 |
CheckLuaParamCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
205 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
206 |
|
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
207 |
// check if is either count1 or count2 |
10297 | 208 |
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
|
209 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
210 |
actual:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
211 |
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
|
212 |
begin |
10285 | 213 |
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
|
214 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
215 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
216 |
|
10297 | 217 |
CheckAndFetchParamCount:= true; |
10284
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 |
|
10611 | 220 |
// check if is in range of count1 and count2 |
221 |
function CheckAndFetchParamCountRange(L : Plua_State; count1, count2: LongInt; call, paramsyntax: shortstring; out actual: LongInt): boolean; inline; |
|
222 |
begin |
|
223 |
actual:= lua_gettop(L); |
|
224 |
if (actual < count1) or (actual > count2) then |
|
225 |
begin |
|
226 |
LuaParameterCountError('at least ' + inttostr(count1) + ', but at most ' + inttostr(count2), call, paramsyntax, actual); |
|
227 |
exit(false); |
|
228 |
end; |
|
229 |
||
230 |
CheckAndFetchParamCountRange:= true; |
|
231 |
end; |
|
232 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
233 |
// check if is same or higher as minCount |
10297 | 234 |
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
|
235 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
236 |
actual:= lua_gettop(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
237 |
if (actual < minCount) then |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
238 |
begin |
10285 | 239 |
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
|
240 |
exit(false); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
241 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
242 |
|
10297 | 243 |
CheckAndFetchLuaParamMinCount:= true; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
244 |
end; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
245 |
|
10281 | 246 |
function LuaToGearTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
247 |
begin |
|
248 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
249 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 250 |
if (i < ord(Low(TGearType))) or (i > ord(High(TGearType))) then |
251 |
begin |
|
252 |
LuaCallError('Invalid gearType!', call, paramsyntax); |
|
253 |
LuaToGearTypeOrd:= -1; |
|
254 |
end |
|
255 |
else |
|
256 |
LuaToGearTypeOrd:= i; |
|
257 |
end; |
|
258 |
||
259 |
function LuaToVisualGearTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
260 |
begin |
|
261 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
262 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 263 |
if (i < ord(Low(TVisualGearType))) or (i > ord(High(TVisualGearType))) then |
264 |
begin |
|
265 |
LuaCallError('Invalid visualGearType!', call, paramsyntax); |
|
266 |
LuaToVisualGearTypeOrd:= -1; |
|
267 |
end |
|
268 |
else |
|
269 |
LuaToVisualGearTypeOrd:= i; |
|
270 |
end; |
|
271 |
||
272 |
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
|
273 |
begin |
10281 | 274 |
if lua_isnoneornil(L, i) then i:= -1 |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
275 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 276 |
if (i < ord(Low(TAmmoType))) or (i > ord(High(TAmmoType))) then |
277 |
begin |
|
278 |
LuaCallError('Invalid ammoType!', call, paramsyntax); |
|
279 |
LuaToAmmoTypeOrd:= -1; |
|
280 |
end |
|
281 |
else |
|
282 |
LuaToAmmoTypeOrd:= i; |
|
283 |
end; |
|
284 |
||
285 |
function LuaToStatInfoTypeOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
286 |
begin |
|
287 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
288 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 289 |
if (i < ord(Low(TStatInfoType))) or (i > ord(High(TStatInfoType))) then |
290 |
begin |
|
291 |
LuaCallError('Invalid statInfoType!', call, paramsyntax); |
|
292 |
LuaToStatInfoTypeOrd:= -1; |
|
293 |
end |
|
294 |
else |
|
295 |
LuaToStatInfoTypeOrd:= i; |
|
296 |
end; |
|
297 |
||
298 |
function LuaToSoundOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
299 |
begin |
|
300 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
301 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 302 |
if (i < ord(Low(TSound))) or (i > ord(High(TSound))) then |
303 |
begin |
|
304 |
LuaCallError('Invalid soundId!', call, paramsyntax); |
|
305 |
LuaToSoundOrd:= -1; |
|
306 |
end |
|
307 |
else |
|
308 |
LuaToSoundOrd:= i; |
|
309 |
end; |
|
310 |
||
311 |
function LuaToHogEffectOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
312 |
begin |
|
313 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
314 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 315 |
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
|
316 |
begin |
11844
a784866c91ad
Lua API: fix incorrect error message. thanks to TheAnachron and rhino for pointing this out
sheepluva
parents:
11823
diff
changeset
|
317 |
LuaCallError('Invalid effect type!', call, paramsyntax); |
10281 | 318 |
LuaToHogEffectOrd:= -1; |
319 |
end |
|
320 |
else |
|
321 |
LuaToHogEffectOrd:= i; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
322 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
323 |
|
10281 | 324 |
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
|
325 |
begin |
10281 | 326 |
if lua_isnoneornil(L, i) then i:= -1 |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
327 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 328 |
if (i < ord(Low(TCapGroup))) or (i > ord(High(TCapGroup))) then |
329 |
begin |
|
330 |
LuaCallError('Invalid capgroup type!', call, paramsyntax); |
|
331 |
LuaToCapGroupOrd:= -1; |
|
332 |
end |
|
333 |
else |
|
334 |
LuaToCapGroupOrd:= i; |
|
335 |
end; |
|
336 |
||
337 |
function LuaToSpriteOrd(L : Plua_State; i: LongInt; call, paramsyntax: shortstring): LongInt; inline; |
|
338 |
begin |
|
339 |
if lua_isnoneornil(L, i) then i:= -1 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
340 |
else i:= Trunc(lua_tonumber(L, i)); |
10281 | 341 |
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
|
342 |
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
|
343 |
LuaCallError('Invalid sprite id!', call, paramsyntax); |
10281 | 344 |
LuaToSpriteOrd:= -1; |
345 |
end |
|
346 |
else |
|
347 |
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
|
348 |
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
|
349 |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
350 |
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
|
351 |
begin |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
352 |
if lua_isnoneornil(L, i) then i:= -1 |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
353 |
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
|
354 |
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
|
355 |
begin |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
356 |
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
|
357 |
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
|
358 |
end |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
359 |
else |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
360 |
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
|
361 |
end; |
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
362 |
|
11677 | 363 |
// 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
|
364 |
|
3539 | 365 |
// 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
|
366 |
// 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
|
367 |
// where L contains the state, returns the number of return values on the stack |
10297 | 368 |
// call CheckLuaParamCount or CheckAndFetchParamCount |
10287 | 369 |
// to validate/get the number of passed arguments (see their call definitions) |
370 |
// |
|
371 |
// 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
|
372 |
|
4483 | 373 |
function lc_band(L: PLua_State): LongInt; Cdecl; |
374 |
begin |
|
10297 | 375 |
if CheckLuaParamCount(L, 2, 'band', 'value1, value2') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
376 |
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
|
377 |
else |
4483 | 378 |
lua_pushnil(L); |
379 |
lc_band := 1; |
|
380 |
end; |
|
381 |
||
382 |
function lc_bor(L: PLua_State): LongInt; Cdecl; |
|
383 |
begin |
|
10297 | 384 |
if CheckLuaParamCount(L, 2, 'bor', 'value1, value2') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
385 |
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
|
386 |
else |
4483 | 387 |
lua_pushnil(L); |
388 |
lc_bor := 1; |
|
389 |
end; |
|
390 |
||
391 |
function lc_bnot(L: PLua_State): LongInt; Cdecl; |
|
392 |
begin |
|
10297 | 393 |
if CheckLuaParamCount(L, 1, 'bnot', 'value') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
394 |
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
|
395 |
else |
4483 | 396 |
lua_pushnil(L); |
397 |
lc_bnot := 1; |
|
398 |
end; |
|
399 |
||
6764 | 400 |
function lc_div(L: PLua_State): LongInt; Cdecl; |
401 |
begin |
|
10297 | 402 |
if CheckLuaParamCount(L, 2, 'div', 'dividend, divisor') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
403 |
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
|
404 |
else |
6764 | 405 |
lua_pushnil(L); |
406 |
lc_div := 1; |
|
407 |
end; |
|
408 |
||
4523 | 409 |
function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; |
410 |
begin |
|
10297 | 411 |
if CheckLuaParamCount(L, 0, 'GetInputMask', '') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
412 |
lua_pushnumber(L, InputMask); |
4523 | 413 |
lc_getinputmask:= 1 |
414 |
end; |
|
415 |
||
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
|
416 |
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
|
417 |
begin |
10297 | 418 |
if CheckLuaParamCount(L, 1, 'SetInputMask', 'mask') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
419 |
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
|
420 |
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
|
421 |
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
|
422 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
423 |
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
|
424 |
begin |
10297 | 425 |
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
|
426 |
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
|
427 |
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
|
428 |
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
|
429 |
|
12910 | 430 |
function lc_writelntochat(L : Plua_State) : LongInt; Cdecl; |
431 |
begin |
|
432 |
if CheckLuaParamCount(L, 1, 'WriteLnToChat', 'string') then |
|
433 |
AddChatString(#2 + lua_tostring(L, 1)); |
|
434 |
lc_writelntochat:= 0; |
|
435 |
end; |
|
436 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
437 |
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
|
438 |
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
|
439 |
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
|
440 |
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
|
441 |
begin |
10297 | 442 |
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
|
443 |
begin |
10131
4b4a043111f4
- pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10129
diff
changeset
|
444 |
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
|
445 |
|
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
|
446 |
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
|
447 |
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
|
448 |
|
7805 | 449 |
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
|
450 |
|
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
|
10291 | 455 |
// sets weapon to the desired ammo type |
10289 | 456 |
function lc_setweapon(L : Plua_State) : LongInt; Cdecl; |
457 |
var at: LongInt; |
|
458 |
const |
|
459 |
call = 'SetWeapon'; |
|
460 |
params = 'ammoType'; |
|
461 |
begin |
|
10291 | 462 |
// no point to run this without any CurrentHedgehog |
10297 | 463 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 1, call, params)) then |
10289 | 464 |
begin |
465 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
466 |
if at >= 0 then |
|
467 |
ParseCommand('setweap ' + char(at), true, true); |
|
468 |
end; |
|
469 |
lc_setweapon:= 0; |
|
470 |
end; |
|
471 |
||
11520 | 472 |
// enable/disable cinematic effects |
473 |
function lc_setcinematicmode(L : Plua_State) : LongInt; Cdecl; |
|
474 |
const |
|
475 |
call = 'SetCinematicMode'; |
|
476 |
params = 'enable'; |
|
477 |
begin |
|
478 |
if (CheckLuaParamCount(L, 1, call, params)) then |
|
479 |
begin |
|
480 |
CinematicScript:= lua_toboolean(L, 1); |
|
481 |
end; |
|
482 |
lc_setcinematicmode:= 0; |
|
483 |
end; |
|
484 |
||
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
|
485 |
// 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
|
486 |
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
|
487 |
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
|
488 |
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
|
489 |
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
|
490 |
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
|
491 |
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
|
492 |
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
|
493 |
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
|
494 |
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
|
495 |
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
|
496 |
// 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
|
497 |
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
|
498 |
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
|
499 |
else |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
500 |
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
|
501 |
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
|
502 |
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
|
503 |
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
|
504 |
|
10291 | 505 |
// sets weapon to whatever weapons is next (wraps around, amSkip is skipped) |
506 |
function lc_setnextweapon(L : Plua_State) : LongInt; Cdecl; |
|
507 |
var at : LongInt; |
|
508 |
nextAmmo : TAmmo; |
|
509 |
s, a, cs, fa: LongInt; |
|
510 |
const |
|
511 |
call = 'SetNextWeapon'; |
|
512 |
params = ''; |
|
513 |
begin |
|
10297 | 514 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, call, params)) then |
10291 | 515 |
begin |
516 |
at:= -1; |
|
517 |
with CurrentHedgehog^ do |
|
518 |
begin |
|
519 |
cs:= 0; // current slot |
|
520 |
fa:= 0; // first ammo item to check |
|
521 |
||
11677 | 522 |
// if something is selected, find it is successor |
10291 | 523 |
if curAmmoType <> amNothing then |
524 |
begin |
|
525 |
// get current slot index |
|
526 |
cs:= Ammoz[CurAmmoType].Slot; |
|
527 |
// find current ammo index |
|
528 |
while (fa < cMaxSlotAmmoIndex) |
|
529 |
and (Ammo^[cs, fa].AmmoType <> CurAmmoType) do |
|
530 |
inc(fa); |
|
11677 | 531 |
// increase once more because we will not successor |
10291 | 532 |
inc(fa); |
533 |
end; |
|
534 |
||
535 |
// find first available ammo |
|
536 |
// revisit current slot too (current item might not be first) |
|
537 |
for s:= cs to cs + cMaxSlotIndex + 1 do |
|
538 |
begin |
|
539 |
for a:= fa to cMaxSlotAmmoIndex do |
|
540 |
begin |
|
541 |
// check if we went full circle |
|
542 |
if (a = fa) and (s = cs + cMaxSlotIndex + 1) then |
|
543 |
exit(0); |
|
544 |
||
545 |
// get ammo |
|
546 |
nextAmmo:= Ammo^[s mod (cMaxSlotIndex + 1), a]; |
|
547 |
// only switch to ammos the hog actually has |
|
548 |
if (nextAmmo.AmmoType <> amNothing) |
|
549 |
and (nextAmmo.AmmoType <> amSkip) and (nextAmmo.Count > 0) then |
|
550 |
begin |
|
551 |
at:= ord(nextAmmo.AmmoType); |
|
552 |
break; |
|
553 |
end; |
|
554 |
end; |
|
555 |
// stop slot loop if something was found |
|
556 |
if at >= 0 then |
|
557 |
break; |
|
558 |
// check following slots starting with first item |
|
559 |
fa:= 0; |
|
560 |
end; |
|
561 |
end; |
|
562 |
||
563 |
if at >= 0 then |
|
564 |
ParseCommand('setweap ' + char(at), true, true); |
|
565 |
end; |
|
566 |
lc_setnextweapon:= 0; |
|
567 |
end; |
|
568 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
569 |
function lc_showmission(L : Plua_State) : LongInt; Cdecl; |
13467
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13457
diff
changeset
|
570 |
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
|
571 |
begin |
13467
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13457
diff
changeset
|
572 |
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:
13457
diff
changeset
|
573 |
if n = 5 then |
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13457
diff
changeset
|
574 |
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:
13457
diff
changeset
|
575 |
else |
854caa3c9212
Lua API: Add parameter forceDisplay to ShowMission to prevent manual hiding
Wuzzy <Wuzzy2@mail.ru>
parents:
13457
diff
changeset
|
576 |
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
|
577 |
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
|
578 |
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
|
579 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
580 |
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
|
581 |
begin |
3407 | 582 |
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
|
583 |
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
|
584 |
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
|
585 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
586 |
|
11939
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
587 |
function lc_setammotexts(L : Plua_State) : LongInt; Cdecl; |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
588 |
const |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
589 |
call = 'SetAmmoTexts'; |
13370
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
590 |
params = 'ammoType, name, caption, description [, showExtra]'; |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
591 |
var n: integer; |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
592 |
showExtra: boolean; |
11939
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
593 |
begin |
13370
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
594 |
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:
13349
diff
changeset
|
595 |
begin |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
596 |
if n = 5 then |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
597 |
showExtra:= lua_toboolean(L, 5) |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
598 |
else |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
599 |
showExtra:= true; |
e202d58236b1
Lua API: Add 5th parameter showExtra to SetAmmoTexts to hide extra text
Wuzzy <Wuzzy2@mail.ru>
parents:
13349
diff
changeset
|
600 |
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:
13349
diff
changeset
|
601 |
end; |
11939
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
602 |
lc_setammotexts:= 0; |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
603 |
end; |
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
604 |
|
11941
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
605 |
function lc_setammodescriptionappendix(L : Plua_State) : LongInt; Cdecl; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
606 |
const |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
607 |
call = 'SetAmmoDescriptionAppendix'; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
608 |
params = 'ammoType, descAppend'; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
609 |
var |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
610 |
ammoType: TAmmoType; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
611 |
descAppend: ansistring; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
612 |
begin |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
613 |
if CheckLuaParamCount(L, 2, call, params) then |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
614 |
begin |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
615 |
ammoType := TAmmoType(LuaToAmmoTypeOrd(L, 1, call, params)); |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
616 |
descAppend := lua_tostringA(L, 2); |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
617 |
trluaammoa[Ammoz[ammoType].NameId] := descAppend; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
618 |
end; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
619 |
lc_setammodescriptionappendix := 0; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
620 |
end; |
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
621 |
|
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
622 |
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
|
623 |
var i, n : integer; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
624 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
625 |
// can have 1 or more arguments |
10297 | 626 |
if CheckAndFetchLuaParamMinCount(L, 1, 'EnableGameFlags', 'gameFlag, ... ', n) then |
10035 | 627 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
628 |
for i:= 1 to n do |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
629 |
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
|
630 |
ScriptSetInteger('GameFlags', GameFlags); |
10035 | 631 |
end; |
8370 | 632 |
lc_enablegameflags:= 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 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
635 |
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
|
636 |
var i , n: integer; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
637 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
638 |
// can have 1 or more arguments |
10297 | 639 |
if CheckAndFetchLuaParamMinCount(L, 1, 'DisableGameFlags', 'gameFlag, ... ', n) then |
10035 | 640 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
641 |
for i:= 1 to n do |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
642 |
GameFlags := GameFlags and (not LongWord(Trunc(lua_tonumber(L, i)))); |
10035 | 643 |
ScriptSetInteger('GameFlags', GameFlags); |
644 |
end; |
|
8370 | 645 |
lc_disablegameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
646 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
647 |
|
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
648 |
function lc_cleargameflags(L : Plua_State) : LongInt; Cdecl; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
649 |
begin |
10297 | 650 |
if CheckLuaParamCount(L, 0, 'ClearGameFlags', '') then |
10035 | 651 |
begin |
652 |
GameFlags:= 0; |
|
653 |
ScriptSetInteger('GameFlags', GameFlags); |
|
654 |
end; |
|
8370 | 655 |
lc_cleargameflags:= 0; |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
656 |
end; |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
657 |
|
10035 | 658 |
function lc_getgameflag(L : Plua_State) : LongInt; Cdecl; |
659 |
begin |
|
10297 | 660 |
if CheckLuaParamCount(L, 1, 'GetGameFlag', 'gameflag') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
661 |
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
|
662 |
else |
10035 | 663 |
lua_pushnil(L); |
664 |
lc_getgameflag:= 1; |
|
665 |
end; |
|
666 |
||
4243 | 667 |
function lc_addcaption(L : Plua_State) : LongInt; Cdecl; |
10281 | 668 |
var cg: LongInt; |
669 |
const |
|
670 |
call = 'AddCaption'; |
|
671 |
params = 'text [, color, captiongroup]'; |
|
4243 | 672 |
begin |
10297 | 673 |
if CheckAndFetchParamCount(L, 1, 3, call, params, cg) then |
4243 | 674 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
675 |
if cg = 1 then |
13642
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13627
diff
changeset
|
676 |
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
|
677 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
678 |
begin |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
679 |
cg:= LuaToCapGroupOrd(L, 3, call, params); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
680 |
if cg >= 0 then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
681 |
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
|
682 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
683 |
end; |
4243 | 684 |
lc_addcaption:= 0; |
685 |
end; |
|
686 |
||
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
|
687 |
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
|
688 |
var gear: PGear; |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
689 |
explode, poison: boolean; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
690 |
n: LongInt; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
691 |
begin |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
692 |
if CheckAndFetchParamCountRange(L, 2, 4, 'SpawnFakeHealthCrate', 'x, y [, explode [, poison]]', 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
|
693 |
begin |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
694 |
explode:= false; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
695 |
poison:= false; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
696 |
if (n >= 3) and (not lua_isnil(L, 3)) then |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
697 |
explode:= lua_toboolean(L, 3); |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
698 |
if (n = 4) and (not lua_isnil(L, 4)) then |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
699 |
poison:= lua_toboolean(L, 4); |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
700 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
701 |
gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
702 |
HealthCrate, explode, poison); |
11196
f4cf2cdea8e5
Add nil check in fake crate spawn for if crate fails to spawn
nemo
parents:
11179
diff
changeset
|
703 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
704 |
lua_pushnumber(L, gear^.uid) |
11196
f4cf2cdea8e5
Add nil check in fake crate spawn for if crate fails to spawn
nemo
parents:
11179
diff
changeset
|
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); |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
709 |
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
|
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 |
|
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
|
712 |
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
|
713 |
var gear: PGear; |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
714 |
explode, poison: boolean; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
715 |
n: LongInt; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
716 |
begin |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
717 |
if CheckAndFetchParamCountRange(L, 2, 4, 'SpawnFakeAmmoCrate', 'x, y [, explode [, poison]]', 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
|
718 |
begin |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
719 |
explode:= false; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
720 |
poison:= false; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
721 |
if (n >= 3) and (not lua_isnil(L, 3)) then |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
722 |
explode:= lua_toboolean(L, 3); |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
723 |
if (n = 4) and (not lua_isnil(L, 4)) then |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
724 |
poison:= lua_toboolean(L, 4); |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
725 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
726 |
gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
727 |
AmmoCrate, explode, poison); |
11251 | 728 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
729 |
lua_pushnumber(L, gear^.uid) |
11251 | 730 |
else lua_pushnil(L) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
731 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
732 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
733 |
lua_pushnil(L); |
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
|
734 |
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
|
735 |
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
|
736 |
|
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
|
737 |
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
|
738 |
var gear: PGear; |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
739 |
explode, poison: boolean; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
740 |
n: LongInt; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
741 |
begin |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
742 |
if CheckAndFetchParamCountRange(L, 2, 4, 'SpawnFakeUtilityCrate', 'x, y [, explode [, poison]]', n) then |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
743 |
begin |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
744 |
explode:= false; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
745 |
poison:= false; |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
746 |
if (n >= 3) and (not lua_isnil(L, 3)) then |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
747 |
explode:= lua_toboolean(L, 3); |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
748 |
if (n = 4) and (not lua_isnil(L, 4)) then |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
749 |
poison:= lua_toboolean(L, 4); |
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
750 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
751 |
gear := SpawnFakeCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), |
14414
c2cd3f64b9f7
Lua API: Make the last 2 params optional in the SpawnFake*Crate functions
Wuzzy <Wuzzy2@mail.ru>
parents:
14387
diff
changeset
|
752 |
UtilityCrate, explode, poison); |
11251 | 753 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
754 |
lua_pushnumber(L, gear^.uid) |
11251 | 755 |
else lua_pushnil(L) |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
756 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
757 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
758 |
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
|
759 |
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
|
760 |
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
|
761 |
|
3730 | 762 |
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
|
763 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
764 |
var health, n: LongInt; |
3730 | 765 |
begin |
10297 | 766 |
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
|
767 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
768 |
if n = 3 then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
769 |
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
|
770 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
771 |
health:= cHealthCaseAmount; |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
772 |
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
|
773 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
774 |
lua_pushnumber(L, gear^.uid) |
11251 | 775 |
else lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
776 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
777 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
778 |
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
|
779 |
lc_spawnhealthcrate := 1; |
3734 | 780 |
end; |
781 |
||
782 |
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
|
783 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
784 |
n : LongInt; |
3734 | 785 |
begin |
10297 | 786 |
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
|
787 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
788 |
if n = 3 then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
789 |
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:
12286
diff
changeset
|
790 |
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
|
791 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
792 |
lua_pushnumber(L, gear^.uid) |
11251 | 793 |
else lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
794 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
795 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
796 |
lua_pushnil(L); |
3734 | 797 |
lc_spawnammocrate := 1; |
798 |
end; |
|
799 |
||
800 |
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
|
801 |
var gear: PGear; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
802 |
n : LongInt; |
3734 | 803 |
begin |
10297 | 804 |
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
|
805 |
begin |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
806 |
if n = 3 then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
807 |
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:
12286
diff
changeset
|
808 |
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
|
809 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
810 |
lua_pushnumber(L, gear^.uid) |
11251 | 811 |
else lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
812 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
813 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
814 |
lua_pushnil(L); |
3734 | 815 |
lc_spawnutilitycrate := 1; |
3730 | 816 |
end; |
817 |
||
12932 | 818 |
function lc_spawnsupplycrate(L: PLua_State): LongInt; Cdecl; |
819 |
var gear: PGear; |
|
820 |
n, at:LongInt; |
|
821 |
t: TCrateType; |
|
822 |
begin |
|
823 |
if CheckAndFetchParamCount(L, 3, 4, 'SpawnSupplyCrate', 'x, y, content [, amount]', n) then |
|
824 |
begin |
|
825 |
// Get crate type (ammo or utility) |
|
826 |
at:= Trunc(lua_tonumber(L, 3)); |
|
827 |
if (Ammoz[TAmmoType(at)].Ammo.Propz and ammoprop_Utility) <> 0 then |
|
828 |
t:= UtilityCrate |
|
829 |
else |
|
830 |
t:= AmmoCrate; |
|
831 |
if n = 3 then |
|
832 |
gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), t, at, 0) |
|
833 |
else gear := SpawnCustomCrateAt(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), t, at, Trunc(lua_tonumber(L, 4))); |
|
834 |
if gear <> nil then |
|
835 |
lua_pushnumber(L, gear^.uid) |
|
836 |
else lua_pushnil(L); |
|
837 |
end |
|
838 |
else |
|
839 |
lua_pushnil(L); |
|
840 |
lc_spawnsupplycrate := 1; |
|
841 |
end; |
|
842 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
843 |
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
|
844 |
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
|
845 |
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
|
846 |
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
|
847 |
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
|
848 |
const |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
849 |
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
|
850 |
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
|
851 |
begin |
10297 | 852 |
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
|
853 |
begin |
10281 | 854 |
t:= LuaToGearTypeOrd(L, 3, call, params); |
855 |
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
|
856 |
begin |
10281 | 857 |
gt:= TGearType(t); |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
858 |
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:
12286
diff
changeset
|
859 |
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:
12286
diff
changeset
|
860 |
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:
12286
diff
changeset
|
861 |
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:
12286
diff
changeset
|
862 |
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:
12286
diff
changeset
|
863 |
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
|
864 |
|
10279
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
865 |
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
|
866 |
lastGearByUID:= gear; |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
867 |
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
|
868 |
end |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
869 |
else |
b75e7ebfbe11
fix possible engine crash that a lua script could cause by passing an invalid geartype to addgear
sheepluva
parents:
10278
diff
changeset
|
870 |
lua_pushnil(L); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
871 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
872 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
873 |
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
|
874 |
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
|
875 |
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
|
876 |
|
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
|
877 |
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
|
878 |
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
|
879 |
begin |
10297 | 880 |
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
|
881 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
882 |
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
|
883 |
if gear <> nil then |
7517 | 884 |
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
|
885 |
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
|
886 |
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
|
887 |
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
|
888 |
|
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 |
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
|
890 |
var vg : PVisualGear; |
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
891 |
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
|
892 |
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
|
893 |
vgt: TVisualGearType; |
10281 | 894 |
uid: Longword; |
895 |
const |
|
896 |
call = 'AddVisualGear'; |
|
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
897 |
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
|
898 |
begin |
10281 | 899 |
uid:= 0; |
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
900 |
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
|
901 |
begin |
10281 | 902 |
s:= LuaToVisualGearTypeOrd(L, 3, call, params); |
903 |
if s >= 0 then |
|
904 |
begin |
|
905 |
vgt:= TVisualGearType(s); |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
906 |
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:
12286
diff
changeset
|
907 |
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:
12286
diff
changeset
|
908 |
s:= Trunc(lua_tonumber(L, 4)); |
10281 | 909 |
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
|
910 |
|
10346
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
911 |
if n = 6 then |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
912 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
913 |
layer:= Trunc(lua_tonumber(L, 6)); |
10347 | 914 |
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
|
915 |
end |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
916 |
else |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
917 |
vg:= AddVisualGear(x, y, vgt, s, c); |
dd22bcf08e4f
lua api: allow to specify layer when adding visual gear
sheepluva
parents:
10312
diff
changeset
|
918 |
|
10281 | 919 |
if vg <> nil then |
920 |
begin |
|
921 |
lastVisualGearByUID:= vg; |
|
922 |
uid:= vg^.uid; |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
923 |
lua_pushnumber(L, uid); |
10281 | 924 |
end; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
925 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
926 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
927 |
lua_pushnil(L); |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
928 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
929 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
930 |
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
|
931 |
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
|
932 |
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
|
933 |
|
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 |
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
|
935 |
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
|
936 |
begin |
10281 | 937 |
vg:= nil; |
10297 | 938 |
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
|
939 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
940 |
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
|
941 |
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
|
942 |
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
|
943 |
end; |
10281 | 944 |
// allow caller to know whether there was something to delete |
945 |
lua_pushboolean(L, vg <> nil); |
|
946 |
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
|
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 |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
949 |
function lc_getvisualgeartype(L : Plua_State) : LongInt; Cdecl; |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
950 |
var vg : PVisualGear; |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
951 |
begin |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
952 |
if CheckLuaParamCount(L, 1, 'GetVisualGearType', 'vgUid') then |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
953 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
954 |
vg := VisualGearByUID(Trunc(lua_tonumber(L, 1))); |
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
955 |
if vg <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
956 |
lua_pushnumber(L, ord(vg^.Kind)) |
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
957 |
else |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
958 |
lua_pushnil(L); |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
959 |
end |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
960 |
else |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
961 |
lua_pushnil(L); // return value on stack (nil) |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
962 |
lc_getvisualgeartype:= 1 |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
963 |
end; |
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
964 |
|
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
965 |
|
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
|
966 |
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
|
967 |
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
|
968 |
begin |
10297 | 969 |
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
|
970 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
971 |
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
|
972 |
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
|
973 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
974 |
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:
12286
diff
changeset
|
975 |
lua_pushnumber(L, round(vg^.Y)); |
5075
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
976 |
lua_pushnumber(L, vg^.dX); |
59b13b38a827
not useful for visual gears, and apparently not helpful for consistency
nemo
parents:
5074
diff
changeset
|
977 |
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
|
978 |
lua_pushnumber(L, vg^.Angle); |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
979 |
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:
12286
diff
changeset
|
980 |
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:
12286
diff
changeset
|
981 |
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:
12286
diff
changeset
|
982 |
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:
12286
diff
changeset
|
983 |
lua_pushnumber(L, vg^.Tint); |
14188 | 984 |
lua_pushnumber(L, vg^.Scale); |
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
|
985 |
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
|
986 |
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
|
987 |
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
|
988 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
14188 | 989 |
lua_pushnil(L); 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
|
990 |
end |
10287 | 991 |
end |
992 |
else |
|
993 |
begin |
|
994 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
|
14188 | 995 |
lua_pushnil(L); 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
|
996 |
end; |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
997 |
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
|
998 |
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
|
999 |
|
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
|
1000 |
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
|
1001 |
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
|
1002 |
begin |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1003 |
// Param count can be 1-11 at present |
14188 | 1004 |
// if CheckLuaParamCount(L, 11, 'SetVisualGearValues', 'vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint, Scale') then |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1005 |
// begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1006 |
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
|
1007 |
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
|
1008 |
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
|
1009 |
if not lua_isnoneornil(L, 2) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1010 |
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
|
1011 |
if not lua_isnoneornil(L, 3) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1012 |
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
|
1013 |
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
|
1014 |
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
|
1015 |
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
|
1016 |
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
|
1017 |
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
|
1018 |
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
|
1019 |
if not lua_isnoneornil(L, 7) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1020 |
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
|
1021 |
if not lua_isnoneornil(L, 8) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1022 |
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
|
1023 |
if not lua_isnoneornil(L, 9) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1024 |
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
|
1025 |
if not lua_isnoneornil(L, 10) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1026 |
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
|
1027 |
if not lua_isnoneornil(L, 11) then |
13434
745e9174038e
somehow scale was omitted from this catch-all VG init. late addition to the struct perhaps.
nemo
parents:
13394
diff
changeset
|
1028 |
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:
13394
diff
changeset
|
1029 |
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:
13394
diff
changeset
|
1030 |
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
|
1031 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1032 |
// end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1033 |
// else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1034 |
// 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
|
1035 |
lc_setvisualgearvalues:= 0 |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1036 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1037 |
|
11677 | 1038 |
// 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
|
1039 |
// 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
|
1040 |
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
|
1041 |
var gear: PGear; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1042 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1043 |
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
|
1044 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1045 |
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
|
1046 |
if gear <> nil then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1047 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1048 |
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:
12286
diff
changeset
|
1049 |
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:
12286
diff
changeset
|
1050 |
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:
12286
diff
changeset
|
1051 |
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:
12286
diff
changeset
|
1052 |
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:
12286
diff
changeset
|
1053 |
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
|
1054 |
lua_pushnumber(L, gear^.DirAngle); |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1055 |
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:
12286
diff
changeset
|
1056 |
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:
12286
diff
changeset
|
1057 |
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:
12286
diff
changeset
|
1058 |
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:
12286
diff
changeset
|
1059 |
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:
12286
diff
changeset
|
1060 |
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
|
1061 |
end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1062 |
else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1063 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1064 |
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
|
1065 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
11468
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
|
1066 |
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
|
1067 |
end |
10287 | 1068 |
end |
1069 |
else |
|
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1070 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1071 |
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
|
1072 |
lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); |
11468
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
|
1073 |
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
|
1074 |
end; |
11468
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
|
1075 |
lc_getgearvalues:= 13 |
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1076 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1077 |
|
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1078 |
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
|
1079 |
var gear : PGear; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1080 |
begin |
11468
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
|
1081 |
// 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
|
1082 |
// 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
|
1083 |
// begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1084 |
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
|
1085 |
if gear <> nil then |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1086 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1087 |
if not lua_isnoneornil(L, 2) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1088 |
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
|
1089 |
if not lua_isnoneornil(L, 3) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1090 |
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
|
1091 |
if not lua_isnoneornil(L, 4) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1092 |
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
|
1093 |
if not lua_isnoneornil(L, 5) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1094 |
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
|
1095 |
if not lua_isnoneornil(L, 6) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1096 |
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
|
1097 |
if not lua_isnoneornil(L, 7) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1098 |
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
|
1099 |
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
|
1100 |
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
|
1101 |
if not lua_isnoneornil(L, 9) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1102 |
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
|
1103 |
if not lua_isnoneornil(L, 10) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1104 |
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
|
1105 |
if not lua_isnoneornil(L, 11) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1106 |
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
|
1107 |
if not lua_isnoneornil(L, 12) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1108 |
gear^.Tint := Trunc(lua_tonumber(L, 12)); |
11172 | 1109 |
if not lua_isnoneornil(L, 13) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1110 |
gear^.Damage := Trunc(lua_tonumber(L, 13)); |
11468
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
|
1111 |
if not lua_isnoneornil(L, 14) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1112 |
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
|
1113 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1114 |
// end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1115 |
// else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1116 |
// 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
|
1117 |
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
|
1118 |
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
|
1119 |
|
3058 | 1120 |
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl; |
1121 |
begin |
|
10297 | 1122 |
if CheckLuaParamCount(L, 0, 'GetFollowGear', '') then |
3058 | 1123 |
begin |
1124 |
if FollowGear = nil then |
|
1125 |
lua_pushnil(L) |
|
1126 |
else |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1127 |
lua_pushnumber(L, FollowGear^.uid); |
10287 | 1128 |
end |
1129 |
else |
|
1130 |
lua_pushnil(L); |
|
3058 | 1131 |
lc_getfollowgear:= 1; // 1 return value |
1132 |
end; |
|
1133 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1134 |
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
|
1135 |
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
|
1136 |
begin |
10297 | 1137 |
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
|
1138 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1139 |
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
|
1140 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1141 |
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
|
1142 |
else |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1143 |
lua_pushnil(L); |
10287 | 1144 |
end |
1145 |
else |
|
1146 |
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
|
1147 |
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
|
1148 |
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
|
1149 |
|
3892 | 1150 |
function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl; |
1151 |
var gear : PGear; |
|
1152 |
begin |
|
10297 | 1153 |
if CheckLuaParamCount(L, 1, 'GetGearMessage', 'gearUid') then |
3892 | 1154 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1155 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3892 | 1156 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1157 |
lua_pushnumber(L, gear^.message) |
3892 | 1158 |
else |
1159 |
lua_pushnil(L); |
|
10287 | 1160 |
end |
1161 |
else |
|
1162 |
lua_pushnil(L); // return value on stack (nil) |
|
3892 | 1163 |
lc_getgearmessage:= 1 |
1164 |
end; |
|
1165 |
||
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
|
1166 |
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
|
1167 |
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
|
1168 |
begin |
10297 | 1169 |
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
|
1170 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1171 |
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
|
1172 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1173 |
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
|
1174 |
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
|
1175 |
lua_pushnil(L); |
10287 | 1176 |
end |
1177 |
else |
|
1178 |
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
|
1179 |
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
|
1180 |
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
|
1181 |
|
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
|
1182 |
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
|
1183 |
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
|
1184 |
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
|
1185 |
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
|
1186 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1187 |
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
|
1188 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1189 |
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
|
1190 |
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
|
1191 |
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
|
1192 |
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
|
1193 |
|
10809
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1194 |
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
|
1195 |
var gear : PGear; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1196 |
begin |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1197 |
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
|
1198 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1199 |
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
|
1200 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1201 |
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
|
1202 |
else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1203 |
lua_pushnil(L); |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1204 |
end |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1205 |
else |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1206 |
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
|
1207 |
lc_getgearfriction:= 1 |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1208 |
end; |
bb2e4e9944f7
Add generic getter/setter for a bunch of more obscure gear structure values
nemo
parents:
10808
diff
changeset
|
1209 |
|
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
|
1210 |
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
|
1211 |
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
|
1212 |
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
|
1213 |
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
|
1214 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1215 |
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
|
1216 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1217 |
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
|
1218 |
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
|
1219 |
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
|
1220 |
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
|
1221 |
|
3896 | 1222 |
function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl; |
1223 |
var gear : PGear; |
|
1224 |
begin |
|
10297 | 1225 |
if CheckLuaParamCount(L, 2, 'SetGearMessage', 'gearUid, message') then |
3896 | 1226 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1227 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3896 | 1228 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1229 |
gear^.message:= Trunc(lua_tonumber(L, 2)); |
3896 | 1230 |
end; |
1231 |
lc_setgearmessage:= 0 |
|
1232 |
end; |
|
1233 |
||
6523 | 1234 |
function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; |
1235 |
var gear : PGear; |
|
1236 |
begin |
|
10297 | 1237 |
if CheckLuaParamCount(L, 1, 'GetGearPos', 'gearUid') then |
6523 | 1238 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1239 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
6523 | 1240 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1241 |
lua_pushnumber(L, gear^.Pos) |
6523 | 1242 |
else |
1243 |
lua_pushnil(L); |
|
10287 | 1244 |
end |
1245 |
else |
|
1246 |
lua_pushnil(L); // return value on stack (nil) |
|
6523 | 1247 |
lc_getgearpos:= 1 |
1248 |
end; |
|
1249 |
||
1250 |
function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; |
|
1251 |
var gear : PGear; |
|
1252 |
begin |
|
10297 | 1253 |
if CheckLuaParamCount(L, 2, 'SetGearPos', 'gearUid, value') then |
6523 | 1254 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1255 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
6523 | 1256 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1257 |
gear^.Pos:= Trunc(lua_tonumber(L, 2)); |
6523 | 1258 |
end; |
1259 |
lc_setgearpos:= 0 |
|
1260 |
end; |
|
1261 |
||
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
|
1262 |
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
|
1263 |
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
|
1264 |
begin |
10297 | 1265 |
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
|
1266 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1267 |
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
|
1268 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1269 |
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
|
1270 |
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
|
1271 |
lua_pushnil(L); |
10287 | 1272 |
end |
1273 |
else |
|
1274 |
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
|
1275 |
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
|
1276 |
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
|
1277 |
|
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
|
1278 |
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
|
1279 |
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
|
1280 |
begin |
10297 | 1281 |
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
|
1282 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1283 |
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
|
1284 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1285 |
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
|
1286 |
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
|
1287 |
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
|
1288 |
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
|
1289 |
|
3755 | 1290 |
function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; |
1291 |
var gear : PGear; |
|
1292 |
begin |
|
10297 | 1293 |
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
|
1294 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1295 |
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
|
1296 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1297 |
lua_pushnumber(L, gear^.Hedgehog^.BotLevel) |
3755 | 1298 |
else |
1299 |
lua_pushnil(L); |
|
1300 |
end; |
|
1301 |
lc_gethoglevel := 1; |
|
1302 |
end; |
|
1303 |
||
4496 | 1304 |
function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl; |
1305 |
var gear : PGear; |
|
1306 |
begin |
|
10297 | 1307 |
if CheckLuaParamCount(L, 2, 'SetHogLevel', 'gearUid, level') then |
4496 | 1308 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1309 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4496 | 1310 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1311 |
gear^.Hedgehog^.BotLevel:= Trunc(lua_tonumber(L, 2)); |
4496 | 1312 |
end; |
1313 |
lc_sethoglevel:= 0 |
|
1314 |
end; |
|
1315 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1316 |
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
|
1317 |
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
|
1318 |
begin |
10297 | 1319 |
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
|
1320 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1321 |
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
|
1322 |
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
|
1323 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1324 |
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
|
1325 |
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
|
1326 |
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
|
1327 |
lua_pushnil(L); |
10287 | 1328 |
end |
1329 |
else |
|
1330 |
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
|
1331 |
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
|
1332 |
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
|
1333 |
|
4498 | 1334 |
function lc_getclancolor(L : Plua_State) : LongInt; Cdecl; |
11736
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1335 |
var idx: integer; |
4498 | 1336 |
begin |
11736
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1337 |
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:
11678
diff
changeset
|
1338 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1339 |
idx:= Trunc(lua_tonumber(L, 1)); |
11736
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1340 |
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:
11678
diff
changeset
|
1341 |
begin |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1342 |
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:
11678
diff
changeset
|
1343 |
lua_pushnil(L); |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1344 |
end |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1345 |
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:
11678
diff
changeset
|
1346 |
begin |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1347 |
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:
11678
diff
changeset
|
1348 |
lua_pushnil(L); |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1349 |
end |
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1350 |
else |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1351 |
lua_pushnumber(L, ClansArray[idx]^.Color shl 8 or $FF); |
11736
e9481c5a130b
Lua-API - GetClanColor: Verify argument and display error message on fail (instead of engine crash)
sheepluva
parents:
11678
diff
changeset
|
1352 |
end |
10287 | 1353 |
else |
4498 | 1354 |
lua_pushnil(L); // return value on stack (nil) |
1355 |
lc_getclancolor:= 1 |
|
1356 |
end; |
|
1357 |
||
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1358 |
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
|
1359 |
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
|
1360 |
team : PTeam; |
14666 | 1361 |
hh : THedgehog; |
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
|
1362 |
i, j : LongInt; |
14663
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1363 |
colorArg: Int64; |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1364 |
color: LongWord; |
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1365 |
begin |
10297 | 1366 |
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
|
1367 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1368 |
i:= Trunc(lua_tonumber(L,1)); |
11677 | 1369 |
if i >= ClansCount then exit(0); |
10581 | 1370 |
clan := ClansArray[i]; |
14663
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1371 |
colorArg:= Trunc(lua_tonumber(L, 2)); |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1372 |
if (colorArg < 0) and (abs(colorArg) <= cClanColors) then |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1373 |
// Pick clan color from settings (recommended) |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1374 |
color:= ClanColorArray[Pred(abs(colorArg))] |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1375 |
else if (colorArg >= 0) and (colorArg <= $ffffffff) then |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1376 |
// Specify color directly |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1377 |
color:= colorArg shr 8 |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1378 |
else |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1379 |
begin |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1380 |
OutError('Lua error: SetClanColor: Invalid ''color'' argument, must be between '+IntToStr(-cClanColors)+' and 0xffffffff!', true); |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1381 |
lc_setclancolor:= 0; |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1382 |
exit; |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1383 |
end; |
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1384 |
|
bc4296649bbf
SetClanColor: Accept negative color argument to select user color
Wuzzy <Wuzzy2@mail.ru>
parents:
14662
diff
changeset
|
1385 |
clan^.Color:= color; |
9656 | 1386 |
|
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
|
1387 |
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
|
1388 |
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
|
1389 |
team:= clan^.Teams[i]; |
13618
edffc9b7ad58
Add comments for most hwengine constants
Wuzzy <Wuzzy2@mail.ru>
parents:
13617
diff
changeset
|
1390 |
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
|
1391 |
begin |
14666 | 1392 |
hh:= team^.Hedgehogs[j]; |
1393 |
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
|
1394 |
begin |
14666 | 1395 |
FreeAndNilTexture(hh.NameTagTex); |
1396 |
hh.NameTagTex:= RenderStringTex(ansistring(hh.Name), clan^.Color, fnt16); |
|
1397 |
RenderHealth(hh); |
|
1398 |
team^.Hedgehogs[j]:= hh; |
|
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
|
1399 |
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
|
1400 |
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
|
1401 |
FreeAndNilTexture(team^.NameTagTex); |
10127 | 1402 |
team^.NameTagTex:= RenderStringTex(ansistring(clan^.Teams[i]^.TeamName), clan^.Color, fnt16); |
9656 | 1403 |
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
|
1404 |
|
11677 | 1405 |
FreeAndNilTexture(clan^.HealthTex); |
9656 | 1406 |
clan^.HealthTex:= makeHealthBarTexture(cTeamHealthWidth + 5, clan^.Teams[0]^.NameTagTex^.h, clan^.Color); |
1407 |
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
|
1408 |
|
4882
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1409 |
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
|
1410 |
end; |
b4c84db92d8f
expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents:
4875
diff
changeset
|
1411 |
|
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1412 |
function lc_gethogvoicepack(L : Plua_State) : LongInt; Cdecl; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1413 |
var gear : PGear; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1414 |
begin |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1415 |
if CheckLuaParamCount(L, 1, 'GetHogVoicepack', 'gearUid') then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1416 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1417 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1418 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1419 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Voicepack^.name)) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1420 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1421 |
lua_pushnil(L); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1422 |
end |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1423 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1424 |
lua_pushnil(L); // return value on stack (nil) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1425 |
lc_gethogvoicepack:= 1 |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1426 |
end; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1427 |
|
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1428 |
function lc_gethoggrave(L : Plua_State) : LongInt; Cdecl; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1429 |
var gear : PGear; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1430 |
begin |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1431 |
if CheckLuaParamCount(L, 1, 'GetHogGrave', 'gearUid') then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1432 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1433 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1434 |
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
|
1435 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.GraveName)) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1436 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1437 |
lua_pushnil(L); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1438 |
end |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1439 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1440 |
lua_pushnil(L); // return value on stack (nil) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1441 |
lc_gethoggrave:= 1 |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1442 |
end; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1443 |
|
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1444 |
function lc_gethogflag(L : Plua_State) : LongInt; Cdecl; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1445 |
var gear : PGear; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1446 |
begin |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1447 |
if CheckLuaParamCount(L, 1, 'GetHogFlag', 'gearUid') then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1448 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1449 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11847 | 1450 |
// TODO error messages |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1451 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1452 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.Flag)) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1453 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1454 |
lua_pushnil(L); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1455 |
end |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1456 |
else |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1457 |
lua_pushnil(L); // return value on stack (nil) |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1458 |
lc_gethogflag:= 1 |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1459 |
end; |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
1460 |
|
12046 | 1461 |
function lc_gethogfort(L : Plua_State) : LongInt; Cdecl; |
1462 |
var gear : PGear; |
|
1463 |
begin |
|
1464 |
if CheckLuaParamCount(L, 1, 'GetHogFort', 'gearUid') then |
|
1465 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1466 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
12046 | 1467 |
// TODO error messages |
1468 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1469 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.FortName)) |
|
1470 |
else |
|
1471 |
lua_pushnil(L); |
|
1472 |
end |
|
1473 |
else |
|
1474 |
lua_pushnil(L); // return value on stack (nil) |
|
1475 |
lc_gethogfort:= 1 |
|
1476 |
end; |
|
1477 |
||
11847 | 1478 |
function lc_ishoglocal(L : Plua_State) : LongInt; Cdecl; |
1479 |
var gear : PGear; |
|
1480 |
begin |
|
1481 |
if CheckLuaParamCount(L, 1, 'IsHogLocal', 'gearUid') then |
|
1482 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1483 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11847 | 1484 |
// TODO error messages |
1485 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
|
1486 |
lua_pushboolean(L, IsHogLocal(gear^.Hedgehog)) |
|
1487 |
else |
|
1488 |
lua_pushnil(L); |
|
1489 |
end |
|
1490 |
else |
|
1491 |
lua_pushnil(L); // return value on stack (nil) |
|
1492 |
lc_ishoglocal:= 1 |
|
1493 |
end; |
|
1494 |
||
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1495 |
function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1496 |
var gear : PGear; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1497 |
begin |
10297 | 1498 |
if CheckLuaParamCount(L, 1, 'GetHogTeamName', 'gearUid') then |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1499 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1500 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
11847 | 1501 |
// TODO error messages |
8228
8cc5dc7f7ef9
kinda treat graves like hedgehogs for the purpose of looking up hog info
nemo
parents:
8145
diff
changeset
|
1502 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4372 | 1503 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) |
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1504 |
else |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1505 |
lua_pushnil(L); |
10287 | 1506 |
end |
1507 |
else |
|
1508 |
lua_pushnil(L); // return value on stack (nil) |
|
4236
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1509 |
lc_gethogteamname:= 1 |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1510 |
end; |
fa2680cfff86
added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents:
4235
diff
changeset
|
1511 |
|
9788 | 1512 |
function lc_sethogteamname(L : Plua_State) : LongInt; Cdecl; |
1513 |
var gear : PGear; |
|
1514 |
begin |
|
10297 | 1515 |
if CheckLuaParamCount(L, 2, 'SetHogTeamName', 'gearUid, name') then |
9788 | 1516 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1517 |
gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
9788 | 1518 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
1519 |
begin |
|
1520 |
gear^.Hedgehog^.Team^.TeamName := lua_tostring(L, 2); |
|
1521 |
||
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
|
1522 |
FreeAndNilTexture(gear^.Hedgehog^.Team^.NameTagTex); |
10127 | 1523 |
gear^.Hedgehog^.Team^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Team^.TeamName), gear^.Hedgehog^.Team^.Clan^.Color, fnt16); |
9788 | 1524 |
end |
1525 |
else |
|
1526 |
lua_pushnil(L); |
|
10287 | 1527 |
end |
1528 |
else |
|
1529 |
lua_pushnil(L); // return value on stack (nil) |
|
9788 | 1530 |
lc_sethogteamname:= 1 |
1531 |
end; |
|
1532 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1533 |
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
|
1534 |
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
|
1535 |
begin |
10297 | 1536 |
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
|
1537 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1538 |
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
|
1539 |
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
|
1540 |
begin |
4372 | 1541 |
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
|
1542 |
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
|
1543 |
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
|
1544 |
lua_pushnil(L); |
10287 | 1545 |
end |
1546 |
else |
|
1547 |
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
|
1548 |
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
|
1549 |
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
|
1550 |
|
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1551 |
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
|
1552 |
var gear : PGear; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1553 |
begin |
10297 | 1554 |
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
|
1555 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1556 |
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
|
1557 |
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
|
1558 |
begin |
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
1559 |
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
|
1560 |
|
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
|
1561 |
FreeAndNilTexture(gear^.Hedgehog^.NameTagTex); |
10127 | 1562 |
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
|
1563 |
end |
5245
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1564 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1565 |
lc_sethogname:= 0; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1566 |
end; |
ce407084728f
Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
5243
diff
changeset
|
1567 |
|
3722 | 1568 |
function lc_gettimer(L : Plua_State) : LongInt; Cdecl; |
1569 |
var gear : PGear; |
|
1570 |
begin |
|
10297 | 1571 |
if CheckLuaParamCount(L, 1, 'GetTimer', 'gearUid') then |
3722 | 1572 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1573 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3722 | 1574 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1575 |
lua_pushnumber(L, gear^.Timer) |
3722 | 1576 |
else |
1577 |
lua_pushnil(L); |
|
10287 | 1578 |
end |
1579 |
else |
|
1580 |
lua_pushnil(L); // return value on stack (nil) |
|
3722 | 1581 |
lc_gettimer:= 1 |
1582 |
end; |
|
1583 |
||
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1584 |
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
|
1585 |
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
|
1586 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1587 |
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
|
1588 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1589 |
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
|
1590 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1591 |
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
|
1592 |
else |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1593 |
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
|
1594 |
end |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1595 |
else |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1596 |
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
|
1597 |
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
|
1598 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1599 |
|
3722 | 1600 |
function lc_gethealth(L : Plua_State) : LongInt; Cdecl; |
1601 |
var gear : PGear; |
|
1602 |
begin |
|
10297 | 1603 |
if CheckLuaParamCount(L, 1, 'GetHealth', 'gearUid') then |
3722 | 1604 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1605 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3722 | 1606 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1607 |
lua_pushnumber(L, gear^.Health) |
3722 | 1608 |
else |
1609 |
lua_pushnil(L); |
|
10287 | 1610 |
end |
1611 |
else |
|
1612 |
lua_pushnil(L); // return value on stack (nil) |
|
3722 | 1613 |
lc_gethealth:= 1 |
1614 |
end; |
|
1615 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1616 |
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
|
1617 |
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
|
1618 |
begin |
10297 | 1619 |
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
|
1620 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1621 |
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
|
1622 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1623 |
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
|
1624 |
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
|
1625 |
lua_pushnil(L); |
10287 | 1626 |
end |
1627 |
else |
|
1628 |
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
|
1629 |
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
|
1630 |
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
|
1631 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1632 |
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
|
1633 |
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
|
1634 |
begin |
10297 | 1635 |
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
|
1636 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1637 |
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
|
1638 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1639 |
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
|
1640 |
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
|
1641 |
lua_pushnil(L); |
10287 | 1642 |
end |
1643 |
else |
|
1644 |
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
|
1645 |
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
|
1646 |
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
|
1647 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1648 |
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
|
1649 |
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
|
1650 |
begin |
10297 | 1651 |
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
|
1652 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1653 |
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:
12286
diff
changeset
|
1654 |
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
|
1655 |
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
|
1656 |
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
|
1657 |
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
|
1658 |
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
|
1659 |
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
|
1660 |
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
|
1661 |
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
|
1662 |
end; |
10287 | 1663 |
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
|
1664 |
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
|
1665 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1666 |
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
|
1667 |
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
|
1668 |
begin |
10297 | 1669 |
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
|
1670 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1671 |
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
|
1672 |
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
|
1673 |
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
|
1674 |
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
|
1675 |
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
|
1676 |
|
3761 | 1677 |
function lc_hogsay(L : Plua_State) : LongInt; Cdecl; |
1678 |
var gear : PGear; |
|
1679 |
vgear : PVisualGear; |
|
4533 | 1680 |
s : LongWord; |
10287 | 1681 |
n : LongInt; |
3761 | 1682 |
begin |
10297 | 1683 |
if CheckAndFetchParamCount(L, 3, 4, 'HogSay', 'gearUid, text, manner [, vgState]', n) then |
3761 | 1684 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1685 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3761 | 1686 |
if gear <> nil then |
1687 |
begin |
|
10287 | 1688 |
// state defaults to 0 if state param is given |
1689 |
if n = 4 then |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1690 |
s:= Trunc(lua_tonumber(L, 4)) |
10287 | 1691 |
else |
1692 |
s:= 0; |
|
4533 | 1693 |
vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true); |
3761 | 1694 |
if vgear <> nil then |
1695 |
begin |
|
10518
dbbe2f6c0a96
make gear ability to speak somewhat less ironic
sheepluva
parents:
10516
diff
changeset
|
1696 |
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
|
1697 |
if Gear^.Kind = gtHedgehog then |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1698 |
begin |
13897
aa321e51da14
make explicit for pas2c some string casts that fpc was probably doing automatically
nemo
parents:
13891
diff
changeset
|
1699 |
AddChatString(#9+Format(shortstring(trmsg[sidChatHog]), 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
|
1700 |
vgear^.Hedgehog:= gear^.Hedgehog |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1701 |
end |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1702 |
else vgear^.Frame:= gear^.uid; |
1a6b9a98147c
hm. I think I forgot to commit this when adding speech bubble change
nemo
parents:
10150
diff
changeset
|
1703 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1704 |
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
|
1705 |
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
|
1706 |
vgear^.FrameTicks:= 1; |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1707 |
lua_pushnumber(L, vgear^.Uid); |
5529 | 1708 |
end |
3761 | 1709 |
end |
10289 | 1710 |
else |
1711 |
lua_pushnil(L) |
|
4533 | 1712 |
end |
10287 | 1713 |
else |
1714 |
lua_pushnil(L); |
|
5529 | 1715 |
lc_hogsay:= 1 |
3761 | 1716 |
end; |
1717 |
||
4851 | 1718 |
function lc_switchhog(L : Plua_State) : LongInt; Cdecl; |
1719 |
var gear, prevgear : PGear; |
|
1720 |
begin |
|
10297 | 1721 |
if CheckLuaParamCount(L, 1, 'SwitchHog', 'gearUid') then |
4851 | 1722 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1723 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4851 | 1724 |
// should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence. |
1725 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then |
|
1726 |
begin |
|
1727 |
prevgear := CurrentHedgehog^.Gear; |
|
7573 | 1728 |
if prevgear <> nil then |
1729 |
begin |
|
1730 |
prevgear^.Active := false; |
|
1731 |
prevgear^.State:= prevgear^.State and (not gstHHDriven); |
|
1732 |
prevgear^.Z := cHHZ; |
|
1733 |
prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; |
|
1734 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1735 |
|
7270
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1736 |
SwitchCurrentHedgehog(gear^.Hedgehog); |
12371
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12360
diff
changeset
|
1737 |
AmmoMenuInvalidated:= true; |
7270
93e92e82d5c8
Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents:
7156
diff
changeset
|
1738 |
CurrentTeam:= CurrentHedgehog^.Team; |
4851 | 1739 |
|
12371
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12360
diff
changeset
|
1740 |
repeat |
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12360
diff
changeset
|
1741 |
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:
12360
diff
changeset
|
1742 |
until |
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12360
diff
changeset
|
1743 |
CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = CurrentHedgehog^.Gear; |
2b1dd699b371
Lua: Fix SwitchHog breaking the ammo menu of the new hog
Wuzzy <almikes@aol.com>
parents:
12360
diff
changeset
|
1744 |
|
4851 | 1745 |
gear^.State:= gear^.State or gstHHDriven; |
1746 |
gear^.Active := true; |
|
1747 |
gear^.Z := cCurrHHZ; |
|
7401 | 1748 |
gear^.Message:= gear^.Message or gmRemoveFromList or gmAddToList; |
4851 | 1749 |
end |
1750 |
end; |
|
1751 |
lc_switchhog:= 0 |
|
1752 |
end; |
|
1753 |
||
13378
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13373
diff
changeset
|
1754 |
function lc_enableswitchhog(L : Plua_State) : LongInt; Cdecl; |
13380
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1755 |
var gear, iterator: PGear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1756 |
alreadySwitching: boolean; |
13378
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13373
diff
changeset
|
1757 |
begin |
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13373
diff
changeset
|
1758 |
if CheckLuaParamCount(L, 0, 'EnableSwitchHog', '') then |
13380
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1759 |
if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1760 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1761 |
alreadySwitching:= false; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1762 |
iterator:= GearsList; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1763 |
// Check if there's already a switcher gear |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1764 |
while (iterator <> nil) do |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1765 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1766 |
if (iterator^.Kind = gtSwitcher) then |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1767 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1768 |
alreadySwitching:= true; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1769 |
lua_pushnumber(L, iterator^.Uid); |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1770 |
break; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1771 |
end; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1772 |
iterator:= iterator^.NextGear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1773 |
end; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1774 |
if (not alreadySwitching) then |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1775 |
begin |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1776 |
// Enable switching and return gear UID |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1777 |
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:
13378
diff
changeset
|
1778 |
CurAmmoGear:= gear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1779 |
lastGearByUID:= gear; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1780 |
bShowFinger:= false; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1781 |
lua_pushnumber(L, gear^.Uid); |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1782 |
end; |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1783 |
end |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1784 |
// Return nil on failure |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1785 |
else |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1786 |
lua_pushnil(L) |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1787 |
else |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1788 |
lua_pushnil(L); |
cd55c7f25e04
Make EnableSwitchHog() more robust against failure, return gear UID
Wuzzy <Wuzzy2@mail.ru>
parents:
13378
diff
changeset
|
1789 |
lc_enableswitchhog:= 1; |
13378
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13373
diff
changeset
|
1790 |
end; |
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13373
diff
changeset
|
1791 |
|
4481 | 1792 |
function lc_addammo(L : Plua_State) : LongInt; Cdecl; |
1793 |
var gear : PGear; |
|
12947
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12939
diff
changeset
|
1794 |
at, n, c: LongInt; |
10281 | 1795 |
const |
1796 |
call = 'AddAmmo'; |
|
1797 |
params = 'gearUid, ammoType [, ammoCount]'; |
|
4481 | 1798 |
begin |
10297 | 1799 |
if CheckAndFetchParamCount(L, 2, 3, call, params, n) then |
4481 | 1800 |
begin |
10281 | 1801 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
12947
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12939
diff
changeset
|
1802 |
if (at >= 0) and (TAmmoType(at) <> amNothing) then |
10281 | 1803 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1804 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10281 | 1805 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
10287 | 1806 |
if n = 2 then |
10281 | 1807 |
AddAmmo(gear^.Hedgehog^, TAmmoType(at)) |
1808 |
else |
|
12947
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12939
diff
changeset
|
1809 |
begin |
c8b7bc04eb4c
Lua API: AddAmmo unselects weapons before it would remove current ammo from current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
12939
diff
changeset
|
1810 |
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:
12939
diff
changeset
|
1811 |
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:
12939
diff
changeset
|
1812 |
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:
12939
diff
changeset
|
1813 |
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:
12939
diff
changeset
|
1814 |
end; |
10281 | 1815 |
end; |
10287 | 1816 |
end; |
4481 | 1817 |
lc_addammo:= 0 |
1818 |
end; |
|
1819 |
||
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
|
1820 |
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
|
1821 |
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
|
1822 |
ammo : PAmmo; |
10281 | 1823 |
at : LongInt; |
1824 |
const |
|
1825 |
call = 'GetAmmoCount'; |
|
1826 |
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
|
1827 |
begin |
10297 | 1828 |
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
|
1829 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1830 |
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
|
1831 |
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
|
1832 |
begin |
10281 | 1833 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
1834 |
if at >= 0 then |
|
1835 |
begin |
|
1836 |
ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
|
1837 |
if ammo^.AmmoType = amNothing then |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1838 |
lua_pushnumber(L, 0) |
10281 | 1839 |
else |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1840 |
lua_pushnumber(L, ammo^.Count); |
10281 | 1841 |
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
|
1842 |
end |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1843 |
else lua_pushnumber(L, 0); |
10287 | 1844 |
end |
1845 |
else |
|
1846 |
lua_pushnil(L); |
|
6046 | 1847 |
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
|
1848 |
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
|
1849 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1850 |
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
|
1851 |
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
|
1852 |
begin |
10297 | 1853 |
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
|
1854 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1855 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3723 | 1856 |
if gear <> nil then |
1857 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1858 |
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
|
1859 |
|
9914 | 1860 |
if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
1861 |
begin |
|
13597
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13595
diff
changeset
|
1862 |
if gear^.Health > cMaxHogHealth then |
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13595
diff
changeset
|
1863 |
gear^.Health:= cMaxHogHealth; |
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13595
diff
changeset
|
1864 |
if gear^.Health < 0 then |
f7cbf7d8298d
Cap hedgehog health to prevent overflow bugs
Wuzzy <Wuzzy2@mail.ru>
parents:
13595
diff
changeset
|
1865 |
gear^.Health:= 0; |
9914 | 1866 |
RenderHealth(gear^.Hedgehog^); |
1867 |
RecountTeamHealth(gear^.Hedgehog^.Team) |
|
14775
b39da9cf7616
Renew crate health display when health changed
Wuzzy <Wuzzy2@mail.ru>
parents:
14771
diff
changeset
|
1868 |
end |
b39da9cf7616
Renew crate health display when health changed
Wuzzy <Wuzzy2@mail.ru>
parents:
14771
diff
changeset
|
1869 |
else if (gear^.RenderHealth) and (gear^.Tex <> nil) then |
b39da9cf7616
Renew crate health display when health changed
Wuzzy <Wuzzy2@mail.ru>
parents:
14771
diff
changeset
|
1870 |
FreeAndNilTexture(gear^.Tex); |
9914 | 1871 |
Gear^.Active:= true; |
1872 |
AllInactive:= false |
|
3723 | 1873 |
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
|
1874 |
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
|
1875 |
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
|
1876 |
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
|
1877 |
|
12939
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1878 |
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:
12932
diff
changeset
|
1879 |
var gear : PGear; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1880 |
healthBoost, n: LongInt; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1881 |
begin |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1882 |
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:
12932
diff
changeset
|
1883 |
begin |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1884 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1885 |
healthBoost:= Trunc(lua_tonumber(L, 2)); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1886 |
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:
12932
diff
changeset
|
1887 |
begin |
13617
a6abc2c1fc1a
Show correct health increase when hog health cap is reached
Wuzzy <Wuzzy2@mail.ru>
parents:
13604
diff
changeset
|
1888 |
healthBoost:= IncHogHealth(gear^.Hedgehog, healthBoost); |
12939
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1889 |
RenderHealth(gear^.Hedgehog^); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1890 |
RecountTeamHealth(gear^.Hedgehog^.Team); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1891 |
if n = 4 then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1892 |
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:
12932
diff
changeset
|
1893 |
else if n = 3 then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1894 |
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:
12932
diff
changeset
|
1895 |
else if n = 2 then |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1896 |
HHHeal(gear^.Hedgehog, healthBoost, true); |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1897 |
Gear^.Active:= true; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1898 |
AllInactive:= false |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1899 |
end |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1900 |
end; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1901 |
lc_healhog:= 0 |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1902 |
end; |
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
1903 |
|
3722 | 1904 |
function lc_settimer(L : Plua_State) : LongInt; Cdecl; |
1905 |
var gear : PGear; |
|
1906 |
begin |
|
10297 | 1907 |
if CheckLuaParamCount(L, 2, 'SetTimer', 'gearUid, timer') then |
3722 | 1908 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1909 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
14771
ab7bf5036314
Render mine timer if gear info is active
Wuzzy <Wuzzy2@mail.ru>
parents:
14666
diff
changeset
|
1910 |
if gear <> nil then |
ab7bf5036314
Render mine timer if gear info is active
Wuzzy <Wuzzy2@mail.ru>
parents:
14666
diff
changeset
|
1911 |
begin |
ab7bf5036314
Render mine timer if gear info is active
Wuzzy <Wuzzy2@mail.ru>
parents:
14666
diff
changeset
|
1912 |
gear^.Timer:= Trunc(lua_tonumber(L, 2)); |
ab7bf5036314
Render mine timer if gear info is active
Wuzzy <Wuzzy2@mail.ru>
parents:
14666
diff
changeset
|
1913 |
if gear^.RenderTimer and (gear^.Tex <> nil) then |
ab7bf5036314
Render mine timer if gear info is active
Wuzzy <Wuzzy2@mail.ru>
parents:
14666
diff
changeset
|
1914 |
FreeAndNilTexture(gear^.Tex); |
ab7bf5036314
Render mine timer if gear info is active
Wuzzy <Wuzzy2@mail.ru>
parents:
14666
diff
changeset
|
1915 |
end; |
3722 | 1916 |
end; |
1917 |
lc_settimer:= 0 |
|
1918 |
end; |
|
1919 |
||
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1920 |
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
|
1921 |
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
|
1922 |
begin |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1923 |
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
|
1924 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1925 |
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:
12286
diff
changeset
|
1926 |
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
|
1927 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1928 |
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
|
1929 |
end; |
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10581
diff
changeset
|
1930 |
|
3756 | 1931 |
function lc_seteffect(L : Plua_State) : LongInt; Cdecl; |
1932 |
var gear: PGear; |
|
10281 | 1933 |
t : LongInt; |
1934 |
const |
|
1935 |
call = 'SetEffect'; |
|
1936 |
params = 'gearUid, effect, effectState'; |
|
3756 | 1937 |
begin |
10297 | 1938 |
if CheckLuaParamCount(L, 3, call, params) then |
10281 | 1939 |
begin |
1940 |
t:= LuaToHogEffectOrd(L, 2, call, params); |
|
1941 |
if t >= 0 then |
|
1942 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1943 |
gear := GearByUID(Trunc(lua_tonumber(L, 1))); |
10281 | 1944 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1945 |
gear^.Hedgehog^.Effects[THogEffect(t)]:= Trunc(lua_tonumber(L, 3)); |
10281 | 1946 |
end; |
1947 |
end; |
|
3756 | 1948 |
lc_seteffect := 0; |
1949 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
1950 |
|
5489 | 1951 |
function lc_geteffect(L : Plua_State) : LongInt; Cdecl; |
1952 |
var gear : PGear; |
|
10281 | 1953 |
t : LongInt; |
1954 |
const |
|
1955 |
call = 'GetEffect'; |
|
1956 |
params = 'gearUid, effect'; |
|
5489 | 1957 |
begin |
10297 | 1958 |
if CheckLuaParamCount(L, 2, call, params) then |
5489 | 1959 |
begin |
10281 | 1960 |
t:= LuaToHogEffectOrd(L, 2, call, params); |
1961 |
if t >= 0 then |
|
1962 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1963 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
10281 | 1964 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1965 |
lua_pushnumber(L, gear^.Hedgehog^.Effects[THogEffect(t)]) |
10281 | 1966 |
else |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1967 |
lua_pushnumber(L, 0) |
10281 | 1968 |
end; |
10287 | 1969 |
end |
1970 |
else |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1971 |
lua_pushnumber(L, 0); |
5489 | 1972 |
lc_geteffect:= 1 |
1973 |
end; |
|
3756 | 1974 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1975 |
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
|
1976 |
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
|
1977 |
begin |
10297 | 1978 |
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
|
1979 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1980 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3723 | 1981 |
if gear <> nil then |
1982 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1983 |
gear^.State:= Trunc(lua_tonumber(L, 2)); |
3723 | 1984 |
SetAllToActive; |
1985 |
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
|
1986 |
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
|
1987 |
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
|
1988 |
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
|
1989 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
1990 |
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
|
1991 |
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
|
1992 |
begin |
10297 | 1993 |
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
|
1994 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1995 |
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
|
1996 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
1997 |
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
|
1998 |
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
|
1999 |
lua_pushnil(L) |
10287 | 2000 |
end |
2001 |
else |
|
2002 |
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
|
2003 |
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
|
2004 |
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
|
2005 |
|
7156
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
2006 |
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
|
2007 |
var gear : PGear; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
2008 |
begin |
10297 | 2009 |
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
|
2010 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2011 |
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
|
2012 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2013 |
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
|
2014 |
else |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
2015 |
lua_pushnil(L); |
10287 | 2016 |
end |
2017 |
else |
|
2018 |
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
|
2019 |
lc_gettag:= 1 |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
2020 |
end; |
09262f82e99d
Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents:
7135
diff
changeset
|
2021 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2022 |
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
|
2023 |
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
|
2024 |
begin |
10297 | 2025 |
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
|
2026 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2027 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3723 | 2028 |
if gear <> nil then |
2029 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2030 |
gear^.Tag:= Trunc(lua_tonumber(L, 2)); |
3723 | 2031 |
SetAllToActive; |
2032 |
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
|
2033 |
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
|
2034 |
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
|
2035 |
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
|
2036 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2037 |
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
|
2038 |
begin |
3407 | 2039 |
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
|
2040 |
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
|
2041 |
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
|
2042 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2043 |
|
12286
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2044 |
function lc_endturn(L : Plua_State) : LongInt; Cdecl; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2045 |
var n: LongInt; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2046 |
const |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2047 |
call = 'EndTurn'; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2048 |
params = '[noTaunts]'; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2049 |
begin |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2050 |
if CheckAndFetchParamCount(L, 0, 1, call, params, n) then |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2051 |
if n >= 1 then |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2052 |
LuaNoEndTurnTaunts:= lua_toboolean(L, 1); |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2053 |
LuaEndTurnRequested:= true; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2054 |
lc_endturn:= 0 |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2055 |
end; |
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
2056 |
|
13340
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2057 |
function lc_retreat(L : Plua_State) : LongInt; Cdecl; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2058 |
var n, time: LongInt; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2059 |
respectFactor: Boolean; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2060 |
const |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2061 |
call = 'Retreat'; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2062 |
params = 'time [, respectGetAwayTimeFactor]'; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2063 |
begin |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2064 |
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:
13272
diff
changeset
|
2065 |
begin |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2066 |
IsGetAwayTime:= true; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2067 |
AttackBar:= 0; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2068 |
time:= Trunc(lua_tonumber(L, 1)); |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2069 |
if n = 2 then |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2070 |
respectFactor:= lua_toboolean(L, 2) |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2071 |
else |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2072 |
respectFactor:= True; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2073 |
if respectFactor then |
13745
d7b72ea8d136
Fix buggy behaviour when setting TurnTimeLeft through Retreat
Wuzzy <Wuzzy2@mail.ru>
parents:
13744
diff
changeset
|
2074 |
PendingTurnTimeLeft:= (time * cGetAwayTime) div 100 |
13340
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2075 |
else |
13745
d7b72ea8d136
Fix buggy behaviour when setting TurnTimeLeft through Retreat
Wuzzy <Wuzzy2@mail.ru>
parents:
13744
diff
changeset
|
2076 |
PendingTurnTimeLeft:= time; |
d7b72ea8d136
Fix buggy behaviour when setting TurnTimeLeft through Retreat
Wuzzy <Wuzzy2@mail.ru>
parents:
13744
diff
changeset
|
2077 |
isPendingTurnTimeLeft:= true; |
13340
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2078 |
if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2079 |
begin |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2080 |
CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstAttacked; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2081 |
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:
13272
diff
changeset
|
2082 |
end; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2083 |
end; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2084 |
lc_retreat:= 0 |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2085 |
end; |
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
2086 |
|
13170
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
2087 |
function lc_skipturn(L : Plua_State): LongInt; Cdecl; |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
2088 |
begin |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
2089 |
L:= L; // avoid compiler hint |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
2090 |
ParseCommand('skip', true, true); |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
2091 |
lc_skipturn:= 0; |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
2092 |
end; |
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
2093 |
|
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2094 |
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
|
2095 |
var statInfo : TStatInfoType; |
10287 | 2096 |
i, n : LongInt; |
2097 |
color, tn: shortstring; |
|
2098 |
needsTn : boolean; |
|
10281 | 2099 |
const |
2100 |
call = 'SendStat'; |
|
2101 |
params = 'statInfoType, color [, teamname]'; |
|
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2102 |
begin |
10297 | 2103 |
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
|
2104 |
begin |
10281 | 2105 |
i:= LuaToStatInfoTypeOrd(L, 1, call, params); |
2106 |
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
|
2107 |
begin |
10287 | 2108 |
statInfo:= TStatInfoType(i); |
2109 |
needsTn:= ((statInfo = siPlayerKills) or (statInfo = siClanHealth)); |
|
2110 |
// check if param count is correct for the used statInfo |
|
2111 |
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
|
2112 |
begin |
10287 | 2113 |
if n = 3 then |
2114 |
LuaCallError(EnumToStr(statInfo) + ' does not support the teamname parameter', call, params) |
|
2115 |
else |
|
2116 |
LuaCallError(EnumToStr(statInfo) + ' requires the teamname parameter', call, params); |
|
10281 | 2117 |
end |
10287 | 2118 |
else // count is correct! |
10281 | 2119 |
begin |
10542 | 2120 |
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
|
2121 |
begin |
10281 | 2122 |
// 3: team name |
2123 |
for i:= 0 to Pred(TeamsCount) do |
|
2124 |
begin |
|
10282 | 2125 |
color:= _S'0'; |
10281 | 2126 |
tn:= lua_tostring(L, 3); |
2127 |
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
|
2128 |
begin |
10281 | 2129 |
if TeamName = tn then |
2130 |
begin |
|
2131 |
color := uUtils.IntToStr(Clan^.Color); |
|
2132 |
Break; |
|
2133 |
end |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2134 |
end |
10281 | 2135 |
end; |
2136 |
if (statInfo = siPlayerKills) then |
|
2137 |
begin |
|
2138 |
SendStat(siPlayerKills, color + ' ' + |
|
2139 |
lua_tostring(L, 2) + ' ' + tn); |
|
2140 |
end |
|
2141 |
else if (statInfo = siClanHealth) then |
|
2142 |
begin |
|
2143 |
SendStat(siClanHealth, color + ' ' + |
|
2144 |
lua_tostring(L, 2)); |
|
2145 |
end |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2146 |
end |
10281 | 2147 |
else |
2148 |
begin |
|
2149 |
SendStat(statInfo,lua_tostring(L, 2)); |
|
2150 |
end; |
|
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2151 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2152 |
end; |
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
2153 |
end; |
9171
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2154 |
lc_sendstat:= 0 |
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2155 |
end; |
e72f4f37a444
added sendstat and sendstats support for lua scripts
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
2156 |
|
12332
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2157 |
function lc_sendgameresultoff(L : Plua_State) : LongInt; Cdecl; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2158 |
begin |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2159 |
L:= L; // avoid compiler hint |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2160 |
uStats.SendGameResultOn := false; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2161 |
lc_sendgameresultoff:= 0 |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2162 |
end; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2163 |
|
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2164 |
function lc_sendrankingstatsoff(L : Plua_State) : LongInt; Cdecl; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2165 |
begin |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2166 |
L:= L; // avoid compiler hint |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2167 |
uStats.SendRankingStatsOn := false; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2168 |
lc_sendrankingstatsoff:= 0 |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2169 |
end; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2170 |
|
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2171 |
function lc_sendachievementsstatsoff(L : Plua_State) : LongInt; Cdecl; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2172 |
begin |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2173 |
L:= L; // avoid compiler hint |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2174 |
uStats.SendAchievementsStatsOn := false; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2175 |
lc_sendachievementsstatsoff:= 0 |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2176 |
end; |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
2177 |
|
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
2178 |
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
|
2179 |
begin |
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
2180 |
L:= L; // avoid compiler hint |
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
2181 |
uStats.SendHealthStatsOn := false; |
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
2182 |
lc_sendhealthstatsoff:= 0 |
9174
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
2183 |
end; |
d328fe17b195
made lua scripts able to turn off automatic game stats
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9173
diff
changeset
|
2184 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2185 |
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
|
2186 |
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
|
2187 |
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
|
2188 |
tryhard: boolean; |
10287 | 2189 |
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
|
2190 |
begin |
10297 | 2191 |
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
|
2192 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2193 |
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
|
2194 |
fall:= lua_toboolean(L, 2); |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2195 |
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:
12286
diff
changeset
|
2196 |
right:= Trunc(lua_tonumber(L, 4)); |
10287 | 2197 |
if n = 5 then |
10496 | 2198 |
tryhard:= lua_toboolean(L, 5) |
2199 |
else |
|
2200 |
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
|
2201 |
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
|
2202 |
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
|
2203 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2204 |
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
|
2205 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2206 |
lua_pushnil(L); |
10287 | 2207 |
end |
2208 |
else |
|
2209 |
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
|
2210 |
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
|
2211 |
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
|
2212 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2213 |
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
|
2214 |
var gear: PGear; |
10281 | 2215 |
n, s: LongInt; |
13122
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2216 |
instaVoice: boolean; |
10281 | 2217 |
const |
2218 |
call = 'PlaySound'; |
|
13122
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2219 |
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
|
2220 |
begin |
13122
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2221 |
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
|
2222 |
begin |
10281 | 2223 |
s:= LuaToSoundOrd(L, 1, call, params); |
2224 |
if s >= 0 then |
|
2225 |
begin |
|
2226 |
// no gear specified |
|
2227 |
if n = 1 then |
|
13121
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2228 |
PlaySound(TSound(s), false, true) |
10287 | 2229 |
else |
10281 | 2230 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2231 |
gear:= GearByUID(Trunc(lua_tonumber(L, 2))); |
10281 | 2232 |
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then |
13122
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2233 |
begin |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2234 |
instaVoice:= false; |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2235 |
if n = 3 then |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2236 |
instaVoice:= lua_toboolean(L, 3); |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2237 |
if instaVoice then |
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2238 |
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:
13121
diff
changeset
|
2239 |
else |
14058
bf8b7c166b3c
Play another voice as fallback if sndRevenge could not be found
Wuzzy <Wuzzy2@mail.ru>
parents:
13997
diff
changeset
|
2240 |
AddVoice(TSound(s), gear^.Hedgehog^.Team^.Voicepack, true, false); |
13122
d52d79f35558
Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice
Wuzzy <Wuzzy2@mail.ru>
parents:
13121
diff
changeset
|
2241 |
end; |
10281 | 2242 |
end; |
2243 |
end; |
|
2244 |
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
|
2245 |
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
|
2246 |
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
|
2247 |
|
13997
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2248 |
function lc_playmusicsound(L : Plua_State) : LongInt; Cdecl; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2249 |
var s: LongInt; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2250 |
const |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2251 |
call = 'PlayMusicSound'; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2252 |
params = 'soundId'; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2253 |
begin |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2254 |
if CheckLuaParamCount(L, 1, call, params) then |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2255 |
begin |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2256 |
s:= LuaToSoundOrd(L, 1, call, params); |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2257 |
if s >= 0 then |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2258 |
PlayMusicSound(TSound(s)) |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2259 |
end; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2260 |
lc_playmusicsound:= 0; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2261 |
end; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2262 |
|
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2263 |
function lc_stopmusicsound(L : Plua_State) : LongInt; Cdecl; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2264 |
var s: LongInt; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2265 |
const |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2266 |
call = 'StopMusicSound'; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2267 |
params = 'soundId'; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2268 |
begin |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2269 |
if CheckLuaParamCount(L, 1, call, params) then |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2270 |
begin |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2271 |
s:= LuaToSoundOrd(L, 1, call, params); |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2272 |
if s >= 0 then |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2273 |
StopMusicSound(TSound(s)) |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2274 |
end; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2275 |
lc_stopmusicsound:= 0; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2276 |
end; |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2277 |
|
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
2278 |
|
13121
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2279 |
function lc_setsoundmask(L : Plua_State) : LongInt; Cdecl; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2280 |
var s: LongInt; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2281 |
soundState: boolean; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2282 |
const |
13812
e2d902745fd5
Fix some syntax errors in internal Lua syntax documentation
Wuzzy <Wuzzy2@mail.ru>
parents:
13766
diff
changeset
|
2283 |
call = 'SetSoundMask'; |
e2d902745fd5
Fix some syntax errors in internal Lua syntax documentation
Wuzzy <Wuzzy2@mail.ru>
parents:
13766
diff
changeset
|
2284 |
params = 'soundId, isMasked'; |
13121
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2285 |
begin |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2286 |
if CheckLuaParamCount(L, 2, call, params) then |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2287 |
begin |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2288 |
s:= LuaToSoundOrd(L, 1, call, params); |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2289 |
if s <> Ord(sndNone) then |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2290 |
begin |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2291 |
soundState:= lua_toboolean(L, 2); |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2292 |
MaskedSounds[TSound(s)]:= soundState; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2293 |
end; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2294 |
end; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2295 |
lc_setsoundmask:= 0; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2296 |
end; |
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
2297 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2298 |
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
|
2299 |
var np: LongInt; |
13582
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2300 |
colorArg: Int64; |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2301 |
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
|
2302 |
begin |
10297 | 2303 |
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
|
2304 |
begin |
13582
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2305 |
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:
13577
diff
changeset
|
2306 |
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:
13577
diff
changeset
|
2307 |
// 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:
13577
diff
changeset
|
2308 |
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:
13577
diff
changeset
|
2309 |
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:
13577
diff
changeset
|
2310 |
// Specify color directly |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2311 |
colorStr:= IntToStr(colorArg) |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2312 |
else |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2313 |
begin |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2314 |
OutError('Lua error: AddTeam: Invalid ''color'' argument, must be between '+IntToStr(-cClanColors)+' and 0xffffffff!', true); |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2315 |
lua_pushnil(L); |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2316 |
lua_pushnil(L); |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2317 |
lc_addteam:= 2; |
13582
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2318 |
exit; |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2319 |
end; |
517b26009073
Lua: Allow to use negative value for AddTeam to select a default clan color
Wuzzy <Wuzzy2@mail.ru>
parents:
13577
diff
changeset
|
2320 |
ParseCommand('addteam x ' + colorStr + ' ' + lua_tostring(L, 1), true, true); |
7805 | 2321 |
ParseCommand('grave ' + lua_tostring(L, 3), true, true); |
2322 |
ParseCommand('fort ' + lua_tostring(L, 4), true, true); |
|
2323 |
ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); |
|
2324 |
if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true); |
|
14558
ce40351e0690
Use player team's control scheme for all teams if there's a mission team
Wuzzy <Wuzzy2@mail.ru>
parents:
14557
diff
changeset
|
2325 |
// If there's a mission team, copy it's control scheme. |
ce40351e0690
Use player team's control scheme for all teams if there's a mission team
Wuzzy <Wuzzy2@mail.ru>
parents:
14557
diff
changeset
|
2326 |
// So in singleplayer missions, all teams use the player team's controls. |
ce40351e0690
Use player team's control scheme for all teams if there's a mission team
Wuzzy <Wuzzy2@mail.ru>
parents:
14557
diff
changeset
|
2327 |
if MissionTeam <> nil then |
ce40351e0690
Use player team's control scheme for all teams if there's a mission team
Wuzzy <Wuzzy2@mail.ru>
parents:
14557
diff
changeset
|
2328 |
CurrentTeam^.Binds:= MissionTeam^.Binds |
ce40351e0690
Use player team's control scheme for all teams if there's a mission team
Wuzzy <Wuzzy2@mail.ru>
parents:
14557
diff
changeset
|
2329 |
// Default keys otherwise |
ce40351e0690
Use player team's control scheme for all teams if there's a mission team
Wuzzy <Wuzzy2@mail.ru>
parents:
14557
diff
changeset
|
2330 |
else |
ce40351e0690
Use player team's control scheme for all teams if there's a mission team
Wuzzy <Wuzzy2@mail.ru>
parents:
14557
diff
changeset
|
2331 |
CurrentTeam^.Binds:= DefaultBinds; |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2332 |
// push team name and index |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2333 |
lua_pushstring(L, str2pchar(CurrentTeam^.TeamName)); |
14500
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2334 |
lua_pushnumber(L, TeamsCount - 1); |
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2335 |
end |
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2336 |
else |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2337 |
begin |
14500
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2338 |
lua_pushnil(L); |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2339 |
lua_pushnil(L); |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2340 |
end; |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2341 |
lc_addteam:= 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
|
2342 |
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
|
2343 |
|
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2344 |
function lc_addmissionteam(L : Plua_State) : LongInt; Cdecl; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2345 |
var colorArg: Int64; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2346 |
colorStr: shortstring; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2347 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2348 |
if CheckLuaParamCount(L, 1, 'AddMissionTeam', 'color') then |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2349 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2350 |
if(MissionTeam = nil) then |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2351 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2352 |
OutError('Lua error: AddMissionTeam: Could not add team. Note: This function only works in singleplayer missions!', true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2353 |
lc_addmissionteam:= 0; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2354 |
exit; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2355 |
end; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2356 |
|
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2357 |
colorArg:= Trunc(lua_tonumber(L, 1)); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2358 |
if (colorArg < 0) and (abs(colorArg) <= cClanColors) then |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2359 |
// Pick clan color from settings (recommended) |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2360 |
colorStr:= IntToStr(ClanColorArray[Pred(abs(colorArg))]) |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2361 |
else if (colorArg >= 0) and (colorArg <= $ffffffff) then |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2362 |
// Specify color directly |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2363 |
colorStr:= IntToStr(colorArg) |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2364 |
else |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2365 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2366 |
OutError('Lua error: AddMissionTeam: Invalid ''color'' argument, must be between '+IntToStr(-cClanColors)+' and 0xffffffff!', true); |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2367 |
lua_pushnil(L); |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2368 |
lua_pushnil(L); |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2369 |
lc_addmissionteam:= 2; |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2370 |
exit; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2371 |
end; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2372 |
|
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2373 |
ParseCommand('addteam x ' + colorStr + ' ' + MissionTeam^.TeamName, true, true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2374 |
ParseCommand('grave ' + MissionTeam^.GraveName, true, true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2375 |
ParseCommand('fort ' + MissionTeam^.FortName, true, true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2376 |
ParseCommand('voicepack ' + MissionTeam^.Voicepack^.name, true, true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2377 |
ParseCommand('flag ' + MissionTeam^.Flag, true, true); |
14557
181509fe1ae8
Fix player team ignoring custom team control scheme in campaign/missions
Wuzzy <Wuzzy2@mail.ru>
parents:
14543
diff
changeset
|
2378 |
CurrentTeam^.Binds:= MissionTeam^.Binds; |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2379 |
// push real team name and team index |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2380 |
lua_pushstring(L, str2pchar(CurrentTeam^.TeamName)); |
14500
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2381 |
lua_pushnumber(L, TeamsCount - 1); |
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2382 |
end |
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2383 |
else |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2384 |
begin |
14500
4e5280a9e782
Lua: AddTeam / AddMissionTeam now return team index
Wuzzy <Wuzzy2@mail.ru>
parents:
14498
diff
changeset
|
2385 |
lua_pushnil(L); |
14505
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2386 |
lua_pushnil(L); |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2387 |
end; |
764ba6182389
Change AddTeam/AddMissionTeam to return real team name and index (in that order)
Wuzzy <Wuzzy2@mail.ru>
parents:
14500
diff
changeset
|
2388 |
lc_addmissionteam:= 2; |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2389 |
end; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2390 |
|
13018
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2391 |
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:
12947
diff
changeset
|
2392 |
var teamValue: ansistring; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2393 |
i, n: LongInt; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2394 |
success: boolean; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2395 |
begin |
14304 | 2396 |
success:= false; |
13018
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2397 |
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:
12947
diff
changeset
|
2398 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2399 |
success:= false; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2400 |
// fetch team |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2401 |
if TeamsCount > 0 then |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2402 |
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:
12947
diff
changeset
|
2403 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2404 |
// 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:
12947
diff
changeset
|
2405 |
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:
12947
diff
changeset
|
2406 |
continue; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2407 |
|
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2408 |
// 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:
12947
diff
changeset
|
2409 |
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:
12947
diff
changeset
|
2410 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2411 |
FreeAndNilTexture(TeamsArray[i]^.LuaTeamValueTex); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2412 |
TeamsArray[i]^.hasLuaTeamValue:= false; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2413 |
success:= true; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2414 |
end |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2415 |
// 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:
12947
diff
changeset
|
2416 |
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:
12947
diff
changeset
|
2417 |
begin |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2418 |
teamValue:= lua_tostring(L, 2); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2419 |
TeamsArray[i]^.LuaTeamValue:= teamValue; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2420 |
FreeAndNilTexture(TeamsArray[i]^.LuaTeamValueTex); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2421 |
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:
12947
diff
changeset
|
2422 |
TeamsArray[i]^.hasLuaTeamValue:= true; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2423 |
success:= true; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2424 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2425 |
// 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:
12947
diff
changeset
|
2426 |
break; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2427 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2428 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2429 |
// 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:
12947
diff
changeset
|
2430 |
lua_pushboolean(L, success); |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2431 |
lc_setteamlabel:= 1; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2432 |
end; |
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
2433 |
|
14632
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2434 |
function lc_setteampassive(L : Plua_State) : LongInt; Cdecl; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2435 |
var i, j: LongInt; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2436 |
success, passive, passiveClan: boolean; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2437 |
begin |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2438 |
success:= false; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2439 |
if CheckLuaParamCount(L, 2, 'SetTeamPassive', 'teamname, isPassive') then |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2440 |
begin |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2441 |
success:= false; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2442 |
// fetch team |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2443 |
if TeamsCount > 0 then |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2444 |
for i:= 0 to Pred(TeamsCount) do |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2445 |
if TeamsArray[i]^.TeamName = lua_tostring(L, 1) then |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2446 |
begin |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2447 |
passive:= lua_toboolean(L, 2); |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2448 |
TeamsArray[i]^.Passive:= passive; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2449 |
// also update clan state |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2450 |
if passive then |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2451 |
begin |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2452 |
passiveClan:= true; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2453 |
for j:= 0 to Pred(TeamsCount) do |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2454 |
if (not TeamsArray[j]^.Passive) then |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2455 |
begin |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2456 |
passiveClan:= false; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2457 |
break; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2458 |
end; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2459 |
end |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2460 |
else |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2461 |
passiveClan:= false; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2462 |
TeamsArray[i]^.Clan^.Passive:= passiveClan; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2463 |
|
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2464 |
success:= true; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2465 |
// don't change more than one team |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2466 |
break; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2467 |
end; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2468 |
end; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2469 |
// return true if operation was successful, false otherwise |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2470 |
lua_pushboolean(L, success); |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2471 |
lc_setteampassive:= 1; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2472 |
end; |
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
2473 |
|
12931 | 2474 |
function lc_getteamname(L : Plua_State) : LongInt; Cdecl; |
2475 |
var t: LongInt; |
|
2476 |
begin |
|
2477 |
if CheckLuaParamCount(L, 1, 'GetTeamName', 'teamIdx') then |
|
2478 |
begin |
|
2479 |
t:= Trunc(lua_tonumber(L, 1)); |
|
2480 |
if (t < 0) or (t >= TeamsCount) then |
|
2481 |
lua_pushnil(L) |
|
2482 |
else |
|
2483 |
lua_pushstring(L, str2pchar(TeamsArray[t]^.TeamName)); |
|
2484 |
end |
|
2485 |
else |
|
2486 |
lua_pushnil(L); |
|
2487 |
lc_getteamname:= 1; |
|
2488 |
end; |
|
2489 |
||
13020
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2490 |
function lc_getteamindex(L : Plua_state) : LongInt; Cdecl; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2491 |
var i: LongInt; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2492 |
found: boolean; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2493 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2494 |
found:= false; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2495 |
if CheckLuaParamCount(L, 1, 'GetTeamIndex', 'teamname') then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2496 |
if TeamsCount > 0 then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2497 |
for i:= 0 to Pred(TeamsCount) do |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2498 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2499 |
// skip teams that don't have matching name |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2500 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2501 |
continue; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2502 |
lua_pushnumber(L, i); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2503 |
found:= true; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2504 |
break; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2505 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2506 |
if (not found) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2507 |
lua_pushnil(L); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2508 |
lc_getteamindex:= 1; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2509 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2510 |
|
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2511 |
function lc_getteamclan(L : Plua_state) : LongInt; Cdecl; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2512 |
var i: LongInt; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2513 |
found: boolean; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2514 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2515 |
found:= false; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2516 |
if CheckLuaParamCount(L, 1, 'GetTeamClan', 'teamname') then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2517 |
if TeamsCount > 0 then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2518 |
for i:= 0 to Pred(TeamsCount) do |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2519 |
begin |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2520 |
// skip teams that don't have matching name |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2521 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2522 |
continue; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2523 |
lua_pushnumber(L, TeamsArray[i]^.Clan^.ClanIndex); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2524 |
found:= true; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2525 |
break; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2526 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2527 |
if (not found) then |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2528 |
lua_pushnil(L); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2529 |
lc_getteamclan:= 1; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2530 |
end; |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
2531 |
|
10290 | 2532 |
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
|
2533 |
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
|
2534 |
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
|
2535 |
hidden: boolean; |
10290 | 2536 |
begin |
10297 | 2537 |
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
|
2538 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2539 |
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
|
2540 |
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
|
2541 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2542 |
// 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
|
2543 |
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
|
2544 |
continue; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2545 |
|
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2546 |
// 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
|
2547 |
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
|
2548 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2549 |
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
|
2550 |
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
|
2551 |
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
|
2552 |
// 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
|
2553 |
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
|
2554 |
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
|
2555 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2556 |
// 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
|
2557 |
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
|
2558 |
begin |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2559 |
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
|
2560 |
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
|
2561 |
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
|
2562 |
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
|
2563 |
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
|
2564 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2565 |
HHGear^.Message:= HHGear^.Message or gmDestroy; |
14639
7c5a9c1b9d4e
Fix DismissTeam not clearing the team properly
Wuzzy <Wuzzy2@mail.ru>
parents:
14632
diff
changeset
|
2566 |
HHGear^.Active:= true; |
7c5a9c1b9d4e
Fix DismissTeam not clearing the team properly
Wuzzy <Wuzzy2@mail.ru>
parents:
14632
diff
changeset
|
2567 |
AllInactive:= false; |
10553
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2568 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2569 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2570 |
// 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
|
2571 |
break; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2572 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2573 |
end; |
67c6de2a0213
new implementation for Lua API DismissTeam. all hedgehogs of the team are now removed without using teamgone
sheepluva
parents:
10542
diff
changeset
|
2574 |
lc_dismissteam:= 0; |
10290 | 2575 |
end; |
2576 |
||
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2577 |
function lc_getteamstats(L : Plua_State) : LongInt; Cdecl; |
12621 | 2578 |
var i: LongInt; |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2579 |
begin |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2580 |
if CheckLuaParamCount(L, 1, 'GetTeamStats', 'teamname') then |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2581 |
begin |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2582 |
if TeamsCount > 0 then |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2583 |
for i:= 0 to Pred(TeamsCount) do |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2584 |
begin |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2585 |
// skip teams that don't have matching name |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2586 |
if TeamsArray[i]^.TeamName <> lua_tostring(L, 1) then |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2587 |
continue; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2588 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2589 |
lua_newtable(L); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2590 |
|
12600 | 2591 |
lua_pushstring(L, str2pchar('Kills')); |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2592 |
lua_pushnumber(L, TeamsArray[i]^.stats.Kills); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2593 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2594 |
|
12600 | 2595 |
lua_pushstring(L, str2pchar('Suicides')); |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2596 |
lua_pushnumber(L, TeamsArray[i]^.stats.Suicides); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2597 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2598 |
|
12600 | 2599 |
lua_pushstring(L, str2pchar('AIKills')); |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2600 |
lua_pushnumber(L, TeamsArray[i]^.stats.AIKills); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2601 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2602 |
|
12600 | 2603 |
lua_pushstring(L, str2pchar('TeamKills')); |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2604 |
lua_pushnumber(L, TeamsArray[i]^.stats.TeamKills); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2605 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2606 |
|
12600 | 2607 |
lua_pushstring(L, str2pchar('TurnSkips')); |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2608 |
lua_pushnumber(L, TeamsArray[i]^.stats.TurnSkips); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2609 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2610 |
|
12600 | 2611 |
lua_pushstring(L, str2pchar('TeamDamage')); |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2612 |
lua_pushnumber(L, TeamsArray[i]^.stats.TeamDamage); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2613 |
lua_settable(L, -3); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2614 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2615 |
end; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2616 |
end |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2617 |
else |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2618 |
lua_pushnil(L); |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2619 |
lc_getteamstats:= 1; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2620 |
end; |
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2621 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2622 |
|
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
2623 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2624 |
function lc_addhog(L : Plua_State) : LongInt; Cdecl; |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2625 |
var hatName: 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
|
2626 |
begin |
10297 | 2627 |
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
|
2628 |
begin |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2629 |
hatName:= lua_tostring(L, 4); |
7805 | 2630 |
ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2631 |
ParseCommand('hat ' + hatName, true, true); |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2632 |
lua_pushnumber(L, CurrentHedgehog^.Gear^.uid); |
10287 | 2633 |
end |
2634 |
else |
|
2635 |
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
|
2636 |
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
|
2637 |
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
|
2638 |
|
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2639 |
function lc_addmissionhog(L : Plua_State) : LongInt; Cdecl; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2640 |
var hatName: ShortString; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2641 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2642 |
if CheckLuaParamCount(L, 1, 'AddMissionHog', 'health') then |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2643 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2644 |
if(MissionTeam = nil) then |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2645 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2646 |
OutError('Lua error: AddMissionHog: Could not add hog. Mission team is not set!', true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2647 |
lua_pushnil(L); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2648 |
lc_addmissionhog:= 1; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2649 |
exit; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2650 |
end; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2651 |
with MissionTeam^.Hedgehogs[CurrentTeam^.HedgehogsNumber] do |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2652 |
begin |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2653 |
hatName:= Hat; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2654 |
ParseCommand('addhh ' + IntToStr(BotLevel) + ' ' + lua_tostring(L, 1) + ' ' + Name, true, true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2655 |
ParseCommand('hat ' + hatName, true, true); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2656 |
end; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2657 |
lua_pushnumber(L, CurrentHedgehog^.Gear^.uid); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2658 |
end |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2659 |
else |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2660 |
lua_pushnil(L); |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2661 |
lc_addmissionhog:= 1; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2662 |
end; |
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
2663 |
|
3761 | 2664 |
function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl; |
2665 |
var gear: PGear; |
|
2666 |
begin |
|
10297 | 2667 |
if CheckLuaParamCount(L, 2, 'HogTurnLeft', 'gearUid, boolean') then |
3761 | 2668 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2669 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
3761 | 2670 |
if gear <> nil then |
2671 |
gear^.dX.isNegative:= lua_toboolean(L, 2); |
|
2672 |
end; |
|
2673 |
lc_hogturnleft:= 0; |
|
2674 |
end; |
|
2675 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2676 |
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
|
2677 |
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
|
2678 |
begin |
10297 | 2679 |
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
|
2680 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2681 |
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
|
2682 |
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
|
2683 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2684 |
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:
12286
diff
changeset
|
2685 |
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
|
2686 |
end |
5964 | 2687 |
else |
2688 |
begin |
|
2689 |
lua_pushnil(L); |
|
2690 |
lua_pushnil(L) |
|
2691 |
end; |
|
10287 | 2692 |
end |
2693 |
else |
|
2694 |
begin |
|
2695 |
lua_pushnil(L); |
|
2696 |
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
|
2697 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2698 |
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
|
2699 |
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
|
2700 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2701 |
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
|
2702 |
var gear: PGear; |
4832 | 2703 |
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
|
2704 |
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
|
2705 |
begin |
10297 | 2706 |
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
|
2707 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2708 |
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
|
2709 |
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
|
2710 |
begin |
4832 | 2711 |
col:= gear^.CollisionIndex >= 0; |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2712 |
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:
12286
diff
changeset
|
2713 |
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
|
2714 |
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
|
2715 |
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
|
2716 |
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
|
2717 |
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
|
2718 |
if col then |
9291
15f7bb217b66
Make add/delete consistent (this has bugged me for so long)
nemo
parents:
9285
diff
changeset
|
2719 |
AddCI(gear); |
4832 | 2720 |
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
|
2721 |
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
|
2722 |
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
|
2723 |
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
|
2724 |
end; |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2725 |
|
5517 | 2726 |
function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl; |
2727 |
var gear: PGear; |
|
2728 |
begin |
|
10297 | 2729 |
if CheckLuaParamCount(L, 1, 'GetGearTarget', 'gearUid') then |
5517 | 2730 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2731 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
5517 | 2732 |
if gear <> nil then |
2733 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2734 |
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:
12286
diff
changeset
|
2735 |
lua_pushnumber(L, gear^.Target.Y) |
5612
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2736 |
end |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2737 |
else |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2738 |
begin |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2739 |
lua_pushnil(L); |
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5583
diff
changeset
|
2740 |
lua_pushnil(L) |
5517 | 2741 |
end |
10287 | 2742 |
end |
2743 |
else |
|
2744 |
begin |
|
2745 |
lua_pushnil(L); |
|
2746 |
lua_pushnil(L) |
|
5517 | 2747 |
end; |
2748 |
lc_getgeartarget:= 2; |
|
2749 |
end; |
|
2750 |
||
2751 |
function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl; |
|
2752 |
var gear: PGear; |
|
2753 |
begin |
|
10297 | 2754 |
if CheckLuaParamCount(L, 3, 'SetGearTarget', 'gearUid, x, y') then |
5517 | 2755 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2756 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
5517 | 2757 |
if gear <> nil then |
2758 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2759 |
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:
12286
diff
changeset
|
2760 |
gear^.Target.Y:= Trunc(lua_tonumber(L, 3)) |
5517 | 2761 |
end |
2762 |
end; |
|
2763 |
lc_setgeartarget:= 0 |
|
2764 |
end; |
|
2765 |
||
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
|
2766 |
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
|
2767 |
var gear: PGear; |
6780 | 2768 |
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
|
2769 |
begin |
10297 | 2770 |
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
|
2771 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2772 |
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
|
2773 |
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
|
2774 |
begin |
6780 | 2775 |
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
|
2776 |
// gear dX determines hog orientation |
6780 | 2777 |
if (gear^.dX.isNegative) and (t = 0) then t:= -1; |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2778 |
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:
12286
diff
changeset
|
2779 |
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
|
2780 |
end |
10287 | 2781 |
end |
2782 |
else |
|
2783 |
begin |
|
2784 |
lua_pushnil(L); |
|
2785 |
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
|
2786 |
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
|
2787 |
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
|
2788 |
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
|
2789 |
|
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
|
2790 |
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
|
2791 |
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
|
2792 |
begin |
10297 | 2793 |
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
|
2794 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2795 |
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
|
2796 |
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
|
2797 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2798 |
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:
12286
diff
changeset
|
2799 |
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
|
2800 |
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
|
2801 |
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
|
2802 |
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
|
2803 |
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
|
2804 |
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
|
2805 |
|
3736 | 2806 |
function lc_setzoom(L : Plua_State) : LongInt; Cdecl; |
2807 |
begin |
|
10297 | 2808 |
if CheckLuaParamCount(L, 1, 'SetZoom', 'zoomLevel') then |
3736 | 2809 |
begin |
2810 |
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
|
2811 |
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
|
2812 |
ZoomValue:= cMaxZoomLevel; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
2813 |
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
|
2814 |
ZoomValue:= cMinZoomLevel; |
3736 | 2815 |
end; |
2816 |
lc_setzoom:= 0 |
|
2817 |
end; |
|
2818 |
||
2819 |
function lc_getzoom(L : Plua_State) : LongInt; Cdecl; |
|
2820 |
begin |
|
10297 | 2821 |
if CheckLuaParamCount(L, 0, 'GetZoom', '') then |
10287 | 2822 |
lua_pushnumber(L, ZoomValue) |
3736 | 2823 |
else |
10287 | 2824 |
lua_pushnil(L); |
3736 | 2825 |
lc_getzoom:= 1 |
2826 |
end; |
|
2827 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
2828 |
function lc_setammo(L : Plua_State) : LongInt; Cdecl; |
10281 | 2829 |
var np, at: LongInt; |
2830 |
const |
|
2831 |
call = 'SetAmmo'; |
|
2832 |
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
|
2833 |
begin |
10297 | 2834 |
if CheckAndFetchParamCount(L, 4, 5, call, params, np) then |
10281 | 2835 |
begin |
2836 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
|
2837 |
if at >= 0 then |
|
2838 |
begin |
|
2839 |
if np = 4 then |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2840 |
ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), 1) |
10281 | 2841 |
else |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2842 |
ScriptSetAmmo(TAmmoType(at), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), Trunc(lua_tonumber(L, 4)), Trunc(lua_tonumber(L, 5))); |
10281 | 2843 |
end; |
2844 |
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
|
2845 |
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
|
2846 |
end; |
4243 | 2847 |
|
13456
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2848 |
|
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2849 |
function lc_getammo(L : Plua_State) : LongInt; Cdecl; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2850 |
var i, at, rawProb, probLevel: LongInt; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2851 |
const |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2852 |
call = 'GetAmmo'; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2853 |
params = 'ammoType'; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2854 |
begin |
14309 | 2855 |
lc_getammo:= 0; |
13456
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2856 |
if CheckLuaParamCount(L, 1, call, params) then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2857 |
begin |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2858 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2859 |
if at >= 0 then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2860 |
begin |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2861 |
// Ammo count |
13457
38814954a248
Fix GetAmmo getting wrong ammo count
Wuzzy <Wuzzy2@mail.ru>
parents:
13456
diff
changeset
|
2862 |
i:= InitialAmmoCounts[TAmmoType(at)]; |
13456
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2863 |
if i = AMMO_INFINITE then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2864 |
i:= 9; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2865 |
lua_pushnumber(L, i); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2866 |
// Probability |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2867 |
rawProb:= Ammoz[TAmmoType(at)].Probability; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2868 |
probLevel:= -1; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2869 |
for i := 0 to High(probabilityLevels) do |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2870 |
if rawProb = probabilityLevels[i] then |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2871 |
probLevel:= i; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2872 |
lua_pushnumber(L, probLevel); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2873 |
// Delay in turns |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2874 |
lua_pushnumber(L, Ammoz[TAmmoType(at)].SkipTurns); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2875 |
// Number in case |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2876 |
lua_pushnumber(L, Ammoz[TAmmoType(at)].NumberInCase); |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2877 |
lc_getammo:= 4 |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2878 |
end |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2879 |
end; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2880 |
end; |
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2881 |
|
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
2882 |
|
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
|
2883 |
function lc_setammodelay(L : Plua_State) : LongInt; Cdecl; |
14661
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2884 |
var at, delay: LongInt; |
10281 | 2885 |
const |
2886 |
call = 'SetAmmoDelay'; |
|
2887 |
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
|
2888 |
begin |
10297 | 2889 |
if CheckLuaParamCount(L, 2, call, params) then |
10281 | 2890 |
begin |
10287 | 2891 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
14661
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2892 |
delay:= Trunc(lua_tonumber(L, 2)); |
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2893 |
if (at >= 0) and (TAmmoType(at) <> amNothing) then |
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2894 |
begin |
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2895 |
ScriptSetAmmoDelay(TAmmoType(at), delay); |
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2896 |
// Unselect weapon if neccessary |
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2897 |
if (delay > 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.CurAmmoType = TAmmoType(at)) then |
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2898 |
ParseCommand('setweap ' + char(0), true, true); |
e6363b84b3fe
SetAmmoDelay: Unselect weapon if neccessary
Wuzzy <Wuzzy2@mail.ru>
parents:
14640
diff
changeset
|
2899 |
end; |
10281 | 2900 |
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
|
2901 |
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
|
2902 |
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
|
2903 |
|
4243 | 2904 |
function lc_getrandom(L : Plua_State) : LongInt; Cdecl; |
2905 |
var m : LongInt; |
|
2906 |
begin |
|
10297 | 2907 |
if CheckLuaParamCount(L, 1, 'GetRandom', 'number') then |
4243 | 2908 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2909 |
m:= Trunc(lua_tonumber(L, 1)); |
4243 | 2910 |
if (m > 0) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2911 |
lua_pushnumber(L, GetRandom(m)) |
4243 | 2912 |
else |
2913 |
begin |
|
2914 |
LuaError('Lua: Tried to pass 0 to GetRandom!'); |
|
2915 |
lua_pushnil(L); |
|
2916 |
end |
|
10287 | 2917 |
end |
2918 |
else |
|
2919 |
lua_pushnil(L); // return value on stack (nil) |
|
4243 | 2920 |
lc_getrandom:= 1 |
2921 |
end; |
|
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2922 |
|
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2923 |
function lc_setwind(L : Plua_State) : LongInt; Cdecl; |
13062
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13038
diff
changeset
|
2924 |
var vg: PVisualGear; |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2925 |
begin |
10297 | 2926 |
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
|
2927 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2928 |
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
|
2929 |
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
|
2930 |
if cWindSpeed.isNegative then |
13062
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13038
diff
changeset
|
2931 |
cWindSpeedf := -cWindSpeedf; |
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13038
diff
changeset
|
2932 |
vg:= AddVisualGear(0, 0, vgtSmoothWindBar); |
bcb87269867e
Lua API: Fix SetWind not updating flake direction
Wuzzy <Wuzzy2@mail.ru>
parents:
13038
diff
changeset
|
2933 |
if vg <> nil then vg^.dAngle:= hwFloat2Float(cWindSpeed); |
14240 | 2934 |
AddFileLog('Script set wind = '+FloatToStr(cWindSpeed)); |
4399
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2935 |
end; |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2936 |
lc_setwind:= 0 |
87bc4a9e6ef0
fix key binds for lua created teams and added wind control
Henek
parents:
4393
diff
changeset
|
2937 |
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
|
2938 |
|
12930
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2939 |
function lc_getwind(L : Plua_State) : LongInt; Cdecl; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2940 |
var wind: extended; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2941 |
begin |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2942 |
if CheckLuaParamCount(L, 0, 'GetWind', '') then |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2943 |
begin |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2944 |
wind:= hwFloat2float((cWindSpeed / cMaxWindSpeed) * 100); |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2945 |
if wind < -100 then |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2946 |
wind:= -100 |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2947 |
else if wind > 100 then |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2948 |
wind:= 100; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2949 |
lua_pushnumber(L, wind); |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2950 |
end |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2951 |
else |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2952 |
lua_pushnil(L); |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2953 |
lc_getwind:= 1 |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2954 |
end; |
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
2955 |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2956 |
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
|
2957 |
begin |
10297 | 2958 |
if CheckLuaParamCount(L, 0, 'MapHasBorder', '') then |
10287 | 2959 |
lua_pushboolean(L, hasBorder) |
2960 |
else |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2961 |
lua_pushnil(L); |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2962 |
lc_maphasborder:= 1 |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4546
diff
changeset
|
2963 |
end; |
4869 | 2964 |
|
2965 |
function lc_getgearradius(L : Plua_State) : LongInt; Cdecl; |
|
2966 |
var gear : PGear; |
|
2967 |
begin |
|
10297 | 2968 |
if CheckLuaParamCount(L, 1, 'GetGearRadius', 'gearUid') then |
4869 | 2969 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2970 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4869 | 2971 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2972 |
lua_pushnumber(L, gear^.Radius) |
4869 | 2973 |
else |
2974 |
lua_pushnil(L); |
|
10287 | 2975 |
end |
2976 |
else |
|
2977 |
lua_pushnil(L); // return value on stack (nil) |
|
4869 | 2978 |
lc_getgearradius:= 1 |
2979 |
end; |
|
4875 | 2980 |
|
2981 |
function lc_gethoghat(L : Plua_State): LongInt; Cdecl; |
|
2982 |
var gear : PGear; |
|
2983 |
begin |
|
10297 | 2984 |
if CheckLuaParamCount(L, 1, 'GetHogHat', 'gearUid') then |
10287 | 2985 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
2986 |
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
|
2987 |
if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then |
4875 | 2988 |
lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) |
2989 |
else |
|
2990 |
lua_pushnil(L); |
|
10287 | 2991 |
end |
2992 |
else |
|
2993 |
lua_pushnil(L); |
|
4875 | 2994 |
lc_gethoghat := 1; |
2995 |
end; |
|
2996 |
||
2997 |
function lc_sethoghat(L : Plua_State) : LongInt; Cdecl; |
|
2998 |
var gear : PGear; |
|
2999 |
hat: ShortString; |
|
3000 |
begin |
|
10297 | 3001 |
if CheckLuaParamCount(L, 2, 'SetHogHat', 'gearUid, hat') then |
4875 | 3002 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3003 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
4875 | 3004 |
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
|
3005 |
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
|
3006 |
hat:= lua_tostring(L, 2); |
4875 | 3007 |
gear^.Hedgehog^.Hat:= hat; |
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
3008 |
AddFileLog('Changed hat to: '+hat); |
7887 | 3009 |
if (Length(hat) > 39) and (Copy(hat,1,8) = 'Reserved') and (Copy(hat,9,32) = gear^.Hedgehog^.Team^.PlayerHash) then |
3010 |
LoadHedgehogHat(gear^.Hedgehog^, 'Reserved/' + Copy(hat,9,Length(hat)-8)) |
|
3011 |
else |
|
9748
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
3012 |
LoadHedgehogHat(gear^.Hedgehog^, hat) |
b0286b0c91ce
sethogname/hat need to wrap entire operation around test of hog/gear
nemo
parents:
9718
diff
changeset
|
3013 |
end |
4875 | 3014 |
end; |
3015 |
lc_sethoghat:= 0; |
|
3016 |
end; |
|
4985 | 3017 |
|
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
|
3018 |
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
|
3019 |
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
|
3020 |
lf : Word; |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
3021 |
tint : LongWord; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3022 |
i, n : LongInt; |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
3023 |
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
|
3024 |
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
|
3025 |
call = 'PlaceSprite'; |
13812
e2d902745fd5
Fix some syntax errors in internal Lua syntax documentation
Wuzzy <Wuzzy2@mail.ru>
parents:
13766
diff
changeset
|
3026 |
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
|
3027 |
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
|
3028 |
placed:= false; |
10297 | 3029 |
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
|
3030 |
begin |
10897
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
3031 |
if not lua_isnoneornil(L, 5) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3032 |
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
|
3033 |
else tint := $FFFFFFFF; |
8ea636ce120a
Add options to set colouring, behind existing land, and horizontal/vertical flipping to PlaceSprite
nemo
parents:
10818
diff
changeset
|
3034 |
if not lua_isnoneornil(L, 6) then |
11677 | 3035 |
behind := lua_toboolean(L, 6) |
10901 | 3036 |
else behind := false; |
3037 |
if not lua_isnoneornil(L, 7) then |
|
11677 | 3038 |
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
|
3039 |
else flipHoriz := false; |
10901 | 3040 |
if not lua_isnoneornil(L, 8) then |
11677 | 3041 |
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
|
3042 |
else flipVert := false; |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3043 |
lf:= 0; |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3044 |
|
11061 | 3045 |
// accept any amount of landflags, loop is never executed if n<9 |
10901 | 3046 |
for i:= 9 to n do |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3047 |
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
|
3048 |
|
10281 | 3049 |
n:= LuaToSpriteOrd(L, 3, call, params); |
3050 |
if n >= 0 then |
|
3051 |
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
|
3052 |
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
|
3053 |
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
|
3054 |
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
|
3055 |
else |
10368
7ebb71a36e95
Forced sprites placing mode, exposed to scripts (not tested at all)
unc0rr
parents:
10347
diff
changeset
|
3056 |
placed:= ForcePlaceOnLand( |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3057 |
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:
12286
diff
changeset
|
3058 |
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:
12286
diff
changeset
|
3059 |
spr, Trunc(lua_tonumber(L, 4)), lf, tint, behind, flipHoriz, flipVert); |
10281 | 3060 |
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
|
3061 |
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
|
3062 |
|
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
|
3063 |
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
|
3064 |
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
|
3065 |
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
|
3066 |
|
10901 | 3067 |
function lc_erasesprite(L : Plua_State) : LongInt; Cdecl; |
3068 |
var spr : TSprite; |
|
3069 |
lf : Word; |
|
3070 |
i, n : LongInt; |
|
10903 | 3071 |
eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert : boolean; |
10901 | 3072 |
const |
3073 |
call = 'EraseSprite'; |
|
13812
e2d902745fd5
Fix some syntax errors in internal Lua syntax documentation
Wuzzy <Wuzzy2@mail.ru>
parents:
13766
diff
changeset
|
3074 |
params = 'x, y, sprite, frameIdx, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert [, landFlag, ... ]'; |
10901 | 3075 |
begin |
3076 |
if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
|
3077 |
begin |
|
3078 |
if not lua_isnoneornil(L, 5) then |
|
11677 | 3079 |
eraseOnLFMatch := lua_toboolean(L, 5) |
10901 | 3080 |
else eraseOnLFMatch := false; |
3081 |
if not lua_isnoneornil(L, 6) then |
|
11677 | 3082 |
onlyEraseLF := lua_toboolean(L, 6) |
10903 | 3083 |
else onlyEraseLF := false; |
3084 |
if not lua_isnoneornil(L, 7) then |
|
11677 | 3085 |
flipHoriz := lua_toboolean(L, 7) |
10901 | 3086 |
else flipHoriz := false; |
10903 | 3087 |
if not lua_isnoneornil(L, 8) then |
11677 | 3088 |
flipVert := lua_toboolean(L, 8) |
10901 | 3089 |
else flipVert := false; |
3090 |
lf:= 0; |
|
3091 |
||
11060 | 3092 |
// accept any amount of landflags, loop is never executed if n<9 |
10903 | 3093 |
for i:= 9 to n do |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3094 |
lf:= lf or Trunc(lua_tonumber(L, i)); |
10901 | 3095 |
|
3096 |
n:= LuaToSpriteOrd(L, 3, call, params); |
|
3097 |
if n >= 0 then |
|
3098 |
begin |
|
3099 |
spr:= TSprite(n); |
|
3100 |
if SpritesData[spr].Surface = nil then |
|
3101 |
LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
|
3102 |
else |
|
3103 |
EraseLand( |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3104 |
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:
12286
diff
changeset
|
3105 |
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:
12286
diff
changeset
|
3106 |
spr, Trunc(lua_tonumber(L, 4)), lf, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert); |
10901 | 3107 |
end; |
3108 |
end; |
|
3109 |
lc_erasesprite:= 0 |
|
3110 |
end; |
|
3111 |
||
4985 | 3112 |
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
|
3113 |
var placed: boolean; |
4985 | 3114 |
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
|
3115 |
placed:= false; |
10297 | 3116 |
if CheckLuaParamCount(L, 3, 'PlaceGirder', 'x, y, frameIdx') then |
10295 | 3117 |
placed:= TryPlaceOnLandSimple( |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3118 |
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:
12286
diff
changeset
|
3119 |
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:
12286
diff
changeset
|
3120 |
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
|
3121 |
|
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
|
3122 |
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
|
3123 |
lc_placegirder:= 1 |
4985 | 3124 |
end; |
5013 | 3125 |
|
12090 | 3126 |
function lc_placerubber(L : Plua_State) : LongInt; Cdecl; |
3127 |
var placed: boolean; |
|
3128 |
begin |
|
3129 |
placed:= false; |
|
3130 |
if CheckLuaParamCount(L, 3, 'PlaceRubber', 'x, y, frameIdx') then |
|
3131 |
placed:= TryPlaceOnLand( |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3132 |
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:
12286
diff
changeset
|
3133 |
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:
12286
diff
changeset
|
3134 |
sprAmRubber, Trunc(lua_tonumber(L, 3)), true, lfBouncy); |
12090 | 3135 |
|
3136 |
lua_pushboolean(L, placed); |
|
3137 |
lc_placerubber:= 1 |
|
3138 |
end; |
|
3139 |
||
5013 | 3140 |
function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
3141 |
begin |
|
10297 | 3142 |
if (CurrentHedgehog <> nil) and (CheckLuaParamCount(L, 0, 'GetCurAmmoType', '')) then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3143 |
lua_pushnumber(L, ord(CurrentHedgehog^.CurAmmoType)) |
10291 | 3144 |
else |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3145 |
lua_pushnumber(L, ord(amNothing)); |
5013 | 3146 |
lc_getcurammotype := 1; |
3147 |
end; |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3148 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3149 |
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
|
3150 |
begin |
10297 | 3151 |
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
|
3152 |
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
|
3153 |
lc_savecampaignvar := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3154 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3155 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3156 |
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
|
3157 |
begin |
10297 | 3158 |
if CheckLuaParamCount(L, 1, 'GetCampaignVar', 'varname') then |
9718
563a34cd8398
unbreak various parts of campaign variable loading/saving
sheepluva
parents:
9670
diff
changeset
|
3159 |
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
|
3160 |
lua_pushstring(L, str2pchar(CampaignVariable)); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3161 |
lc_getcampaignvar := 1; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3162 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3163 |
|
14484
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3164 |
function lc_savemissionvar(L : Plua_State): LongInt; Cdecl; |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3165 |
begin |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3166 |
if CheckLuaParamCount(L, 2, 'SaveMissionVar', 'varname, value') then |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3167 |
SendIPC('v!' + lua_tostring(L, 1) + ' ' + lua_tostring(L, 2) + #0); |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3168 |
lc_savemissionvar := 0; |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3169 |
end; |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3170 |
|
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3171 |
function lc_getmissionvar(L : Plua_State): LongInt; Cdecl; |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3172 |
begin |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3173 |
if CheckLuaParamCount(L, 1, 'GetMissionVar', 'varname') then |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3174 |
SendIPCAndWaitReply('v?' + lua_tostring(L, 1) + #0); |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3175 |
lua_pushstring(L, str2pchar(MissionVariable)); |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3176 |
lc_getmissionvar := 1; |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3177 |
end; |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
3178 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3179 |
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
|
3180 |
var gear: PGear; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3181 |
begin |
10297 | 3182 |
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
|
3183 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3184 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
12360
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12332
diff
changeset
|
3185 |
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:
12332
diff
changeset
|
3186 |
begin |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12332
diff
changeset
|
3187 |
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:
12332
diff
changeset
|
3188 |
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:
12332
diff
changeset
|
3189 |
end |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12332
diff
changeset
|
3190 |
else |
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12332
diff
changeset
|
3191 |
lua_pushboolean(L, false); |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3192 |
end; |
12360
a775a61e02ab
Lua: Fix HideHog causing engine crash when provided with invalid gear ID or hog was hidden
Wuzzy <almikes@aol.com>
parents:
12332
diff
changeset
|
3193 |
lc_hidehog := 1; |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3194 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3195 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3196 |
function lc_restorehog(L: Plua_State): LongInt; Cdecl; |
8370 | 3197 |
var i, h: LongInt; |
8012 | 3198 |
uid: LongWord; |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3199 |
begin |
10297 | 3200 |
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
|
3201 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3202 |
uid:= LongWord(Trunc(lua_tonumber(L, 1))); |
8012 | 3203 |
if TeamsCount > 0 then |
3204 |
for i:= 0 to Pred(TeamsCount) do |
|
3205 |
for h:= 0 to cMaxHHIndex do |
|
3206 |
if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
|
3207 |
begin |
|
3208 |
RestoreHog(@TeamsArray[i]^.Hedgehogs[h]); |
|
3209 |
exit(0) |
|
3210 |
end |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3211 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3212 |
lc_restorehog := 0; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3213 |
end; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
3214 |
|
13577 | 3215 |
function lc_ishoghidden(L: Plua_State): LongInt; Cdecl; |
3216 |
var i, h: LongInt; |
|
3217 |
uid: LongWord; |
|
3218 |
gear: PGear; |
|
3219 |
begin |
|
3220 |
if CheckLuaParamCount(L, 1, 'IsHogHidden', 'gearUid') then |
|
3221 |
begin |
|
3222 |
uid:= LongWord(Trunc(lua_tonumber(L, 1))); |
|
3223 |
gear:= GearByUID(uid); |
|
3224 |
if (gear <> nil) and (gear^.hedgehog <> nil) then |
|
3225 |
begin |
|
3226 |
lua_pushboolean(L, false); |
|
3227 |
lc_ishoghidden:= 1; |
|
3228 |
exit; |
|
3229 |
end |
|
3230 |
else |
|
3231 |
if TeamsCount > 0 then |
|
3232 |
for i:= 0 to Pred(TeamsCount) do |
|
3233 |
for h:= 0 to cMaxHHIndex do |
|
3234 |
if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then |
|
3235 |
begin |
|
3236 |
lua_pushboolean(L, true); |
|
3237 |
lc_ishoghidden:= 1; |
|
3238 |
exit; |
|
3239 |
end |
|
3240 |
end; |
|
3241 |
lua_pushnil(L); |
|
3242 |
lc_ishoghidden:= 1; |
|
3243 |
end; |
|
3244 |
||
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3245 |
// boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3246 |
function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3247 |
var rtn: Boolean; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3248 |
begin |
10297 | 3249 |
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
|
3250 |
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
|
3251 |
rtn:= TestRectangleForObstacle( |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3252 |
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:
12286
diff
changeset
|
3253 |
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:
12286
diff
changeset
|
3254 |
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:
12286
diff
changeset
|
3255 |
Trunc(lua_tonumber(L, 4)), |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3256 |
lua_toboolean(L, 5) |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3257 |
); |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3258 |
lua_pushboolean(L, rtn); |
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3259 |
end |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3260 |
else |
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3261 |
lua_pushnil(L); // return value on stack (nil) |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3262 |
lc_testrectforobstacle:= 1 |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5825
diff
changeset
|
3263 |
end; |
7996 | 3264 |
|
3265 |
||
9815 | 3266 |
function lc_getgravity(L : Plua_State) : LongInt; Cdecl; |
3267 |
begin |
|
10297 | 3268 |
if CheckLuaParamCount(L, 0, 'GetGravity', '') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3269 |
lua_pushnumber(L, hwRound(SignAs(_0_5, cGravity) + (cGravity * 50 / cMaxWindSpeed))); |
9815 | 3270 |
lc_getgravity:= 1 |
3271 |
end; |
|
3272 |
||
3273 |
function lc_setgravity(L : Plua_State) : LongInt; Cdecl; |
|
3274 |
begin |
|
10297 | 3275 |
if CheckLuaParamCount(L, 1, 'SetGravity', 'percent') then |
9815 | 3276 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3277 |
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:
12286
diff
changeset
|
3278 |
cGravityf:= 0.00025 * Trunc(lua_tonumber(L, 1)) * 0.02 |
9815 | 3279 |
end; |
3280 |
lc_setgravity:= 0 |
|
3281 |
end; |
|
3282 |
||
9914 | 3283 |
function lc_setwaterline(L : Plua_State) : LongInt; Cdecl; |
3284 |
var iterator: PGear; |
|
3285 |
begin |
|
10297 | 3286 |
if CheckLuaParamCount(L, 1, 'SetWaterLine', 'waterline') then |
9914 | 3287 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3288 |
cWaterLine:= Trunc(lua_tonumber(L,1)); |
9914 | 3289 |
AllInactive:= false; |
3290 |
iterator:= GearsList; |
|
3291 |
while iterator <> nil do |
|
3292 |
begin |
|
9917 | 3293 |
if not (iterator^.Kind in [gtPortal, gtAirAttack]) and (iterator^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) then |
9914 | 3294 |
begin |
3295 |
iterator^.Active:= true; |
|
3296 |
if iterator^.dY.QWordValue = 0 then iterator^.dY.isNegative:= false; |
|
3297 |
iterator^.State:= iterator^.State or gstMoving; |
|
3298 |
DeleteCI(iterator) |
|
3299 |
end; |
|
3300 |
iterator:= iterator^.NextGear |
|
3301 |
end |
|
3302 |
end; |
|
3303 |
lc_setwaterline:= 0 |
|
3304 |
end; |
|
9815 | 3305 |
|
11066 | 3306 |
function lc_setgearaihints(L : Plua_State) : LongInt; Cdecl; |
7996 | 3307 |
var gear: PGear; |
3308 |
begin |
|
13036
434bcdd9562c
Fix inconsistent name of SetGearAIHints
Wuzzy <Wuzzy2@mail.ru>
parents:
13020
diff
changeset
|
3309 |
if CheckLuaParamCount(L, 2, 'SetGearAIHints', 'gearUid, aiHints') then |
7996 | 3310 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3311 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
7996 | 3312 |
if gear <> nil then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3313 |
gear^.aihints:= Trunc(lua_tonumber(L, 2)); |
7996 | 3314 |
end; |
11066 | 3315 |
lc_setgearaihints:= 0 |
7996 | 3316 |
end; |
3317 |
||
8043 | 3318 |
|
3319 |
function lc_hedgewarsscriptload(L : Plua_State) : LongInt; Cdecl; |
|
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3320 |
var success : boolean; |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3321 |
n : LongInt; |
8043 | 3322 |
begin |
14304 | 3323 |
success:= false; |
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3324 |
if CheckAndFetchParamCount(L, 1, 2, 'HedgewarsScriptLoad', 'scriptPath [, mustExist]', n) then |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3325 |
begin |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3326 |
if n = 1 then |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3327 |
success:= ScriptLoad(lua_tostring(L, 1), true) |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3328 |
else |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3329 |
success:= ScriptLoad(lua_tostring(L, 1), lua_toboolean(L, 2)); |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3330 |
end |
8043 | 3331 |
else |
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3332 |
success:= false; |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3333 |
lua_pushboolean(L, success); |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3334 |
lc_hedgewarsscriptload:= 1; |
8043 | 3335 |
end; |
9397 | 3336 |
|
3337 |
||
3338 |
function lc_declareachievement(L : Plua_State) : LongInt; Cdecl; |
|
3339 |
begin |
|
10297 | 3340 |
if CheckLuaParamCount(L, 4, 'DeclareAchievement', 'achievementId, teamname, location, value') then |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3341 |
declareAchievement(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), Trunc(lua_tonumber(L, 4))); |
9397 | 3342 |
lc_declareachievement:= 0 |
3343 |
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
|
3344 |
|
11846 | 3345 |
function lc_getammoname(L : Plua_state) : LongInt; Cdecl; |
11945
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3346 |
var np, at: LongInt; |
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3347 |
ignoreOverwrite: Boolean; |
11846 | 3348 |
const call = 'GetAmmoName'; |
11945
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3349 |
params = 'ammoType [, ignoreOverwrite ]'; |
11846 | 3350 |
begin |
11945
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3351 |
if CheckAndFetchParamCountRange(L, 1, 2, call, params, np) then |
11846 | 3352 |
begin |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3353 |
at:= LuaToAmmoTypeOrd(L, 1, call, params); |
11945
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3354 |
ignoreOverwrite := false; |
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3355 |
if np > 1 then |
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3356 |
ignoreOverwrite := lua_toboolean(L, 2); |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3357 |
if at >= 0 then |
11945
1e58845fa3c1
Allow to ignore overwritten ammo name in GetAmmoName
Wuzzy <almikes@aol.com>
parents:
11944
diff
changeset
|
3358 |
if (not ignoreOverwrite) and (length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0) then |
11944
87edf67f2107
GetAmmoName now returns ammo name overwritten by SetAmmoTexts
Wuzzy <almikes@aol.com>
parents:
11941
diff
changeset
|
3359 |
lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId])) |
87edf67f2107
GetAmmoName now returns ammo name overwritten by SetAmmoTexts
Wuzzy <almikes@aol.com>
parents:
11941
diff
changeset
|
3360 |
else |
87edf67f2107
GetAmmoName now returns ammo name overwritten by SetAmmoTexts
Wuzzy <almikes@aol.com>
parents:
11941
diff
changeset
|
3361 |
lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId])); |
11846 | 3362 |
end |
3363 |
else |
|
3364 |
lua_pushnil(L); |
|
3365 |
lc_getammoname:= 1; |
|
3366 |
end; |
|
3367 |
||
13371
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3368 |
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:
13370
diff
changeset
|
3369 |
var at: LongInt; |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3370 |
weapon: PAmmo; |
13373
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3371 |
gear: PGear; |
13371
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3372 |
const call = 'GetAmmoTimer'; |
13373
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3373 |
params = 'gearUid, ammoType'; |
13371
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3374 |
begin |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3375 |
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:
13370
diff
changeset
|
3376 |
begin |
13373
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3377 |
gear:= GearByUID(Trunc(lua_tonumber(L, 1))); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3378 |
if (gear <> nil) and (gear^.Hedgehog <> nil) then |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3379 |
begin |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3380 |
at:= LuaToAmmoTypeOrd(L, 2, call, params); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3381 |
weapon:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(at)); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3382 |
if (Ammoz[TAmmoType(at)].Ammo.Propz and ammoprop_Timerable) <> 0 then |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3383 |
lua_pushnumber(L, weapon^.Timer) |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3384 |
else |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3385 |
lua_pushnil(L); |
0a93948e8ec7
Fix GetAmmoTimer implementation, swap arguments
Wuzzy <Wuzzy2@mail.ru>
parents:
13371
diff
changeset
|
3386 |
end |
13371
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3387 |
else |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3388 |
lua_pushnil(L); |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3389 |
end |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3390 |
else |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3391 |
lua_pushnil(L); |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3392 |
lc_getammotimer:= 1; |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3393 |
end; |
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
3394 |
|
12929
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3395 |
function lc_setvampiric(L : Plua_state) : LongInt; Cdecl; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3396 |
begin |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3397 |
if CheckLuaParamCount(L, 1, 'SetVampiric', 'bool') then |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3398 |
cVampiric := lua_toboolean(L, 1); |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3399 |
lc_setvampiric := 0; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3400 |
end; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3401 |
|
13576
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3402 |
function lc_getvampiric(L : Plua_state) : LongInt; Cdecl; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3403 |
begin |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3404 |
lua_pushboolean(L, cVampiric); |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3405 |
lc_getvampiric := 1; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3406 |
end; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3407 |
|
12929
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3408 |
function lc_setlasersight(L : Plua_state) : LongInt; Cdecl; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3409 |
begin |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3410 |
if CheckLuaParamCount(L, 1, 'SetLaserSight', 'bool') then |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3411 |
cLaserSighting:= lua_toboolean(L, 1); |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3412 |
lc_setlasersight:= 0; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3413 |
end; |
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
3414 |
|
13576
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3415 |
function lc_getlasersight(L : Plua_state) : LongInt; Cdecl; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3416 |
begin |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3417 |
lua_pushboolean(L, cLaserSighting); |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3418 |
lc_getlasersight:= 1; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3419 |
end; |
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
3420 |
|
13270 | 3421 |
function lc_explode(L : Plua_state) : LongInt; Cdecl; |
3422 |
var mask: LongWord; |
|
3423 |
n: LongInt; |
|
3424 |
begin |
|
3425 |
if CheckAndFetchParamCount(L, 3, 4, 'Explode', 'x, y, radius[, options]', n) then |
|
3426 |
if CurrentHedgehog <> nil then |
|
3427 |
begin |
|
3428 |
mask:= EXPLAutoSound; |
|
3429 |
if (n = 4) then |
|
3430 |
mask:= Trunc(lua_tonumber(L, 4)); |
|
3431 |
doMakeExplosion(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2)), Trunc(lua_tonumber(L, 3)), CurrentHedgehog, mask); |
|
3432 |
lua_pushboolean(L, true); |
|
3433 |
end |
|
3434 |
else |
|
3435 |
lua_pushboolean(L, false) |
|
3436 |
else |
|
3437 |
lua_pushboolean(L, false); |
|
3438 |
lc_explode:= 1; |
|
3439 |
end; |
|
3440 |
||
13741
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3441 |
function lc_setturntimeleft(L : Plua_State) : LongInt; Cdecl; |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3442 |
var number: Int64; |
13741
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3443 |
begin |
13812
e2d902745fd5
Fix some syntax errors in internal Lua syntax documentation
Wuzzy <Wuzzy2@mail.ru>
parents:
13766
diff
changeset
|
3444 |
if CheckLuaParamCount(L, 1, 'SetTurnTimeLeft', 'newTurnTimeLeft') then |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3445 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3446 |
number:= Trunc(lua_tonumber(L, 1)); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3447 |
if number < 0 then |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3448 |
number:= 0; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3449 |
if number > cMaxTurnTime then |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3450 |
number:= cMaxTurnTime; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3451 |
// The real TurnTimeLeft will be set in SetGlobals |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3452 |
PendingTurnTimeLeft:= number; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3453 |
isPendingTurnTimeLeft:= true; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3454 |
end; |
13741
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3455 |
lc_setturntimeleft:= 0; |
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3456 |
end; |
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3457 |
|
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3458 |
function lc_setreadytimeleft(L : Plua_State) : LongInt; Cdecl; |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3459 |
var number: Int64; |
13741
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3460 |
begin |
13812
e2d902745fd5
Fix some syntax errors in internal Lua syntax documentation
Wuzzy <Wuzzy2@mail.ru>
parents:
13766
diff
changeset
|
3461 |
if CheckLuaParamCount(L, 1, 'SetReadyTimeLeft', 'newReadyTimeLeft') then |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3462 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3463 |
number:= Trunc(lua_tonumber(L, 1)); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3464 |
if number < 0 then |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3465 |
number:= 0; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3466 |
if number > cMaxTurnTime then |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3467 |
number:= cMaxTurnTime; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3468 |
// The real ReadyTimeLeft will be set in SetGlobals |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3469 |
PendingReadyTimeLeft:= number; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3470 |
isPendingReadyTimeLeft:= true; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3471 |
end; |
13741
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3472 |
lc_setreadytimeleft:= 0; |
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3473 |
end; |
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3474 |
|
14415
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3475 |
function lc_setturntimepaused(L : Plua_State) : LongInt; Cdecl; |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3476 |
begin |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3477 |
if CheckLuaParamCount(L, 1, 'SetTurnTimePaused', 'isPaused') then |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3478 |
LuaClockPaused:= lua_toboolean(L, 1); |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3479 |
lc_setturntimepaused:= 0; |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3480 |
end; |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3481 |
|
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3482 |
function lc_getturntimepaused(L : Plua_State) : LongInt; Cdecl; |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3483 |
begin |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3484 |
if CheckLuaParamCount(L, 0, 'GetTurnTimePaused', '') then |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3485 |
lua_pushboolean(L, LuaClockPaused) |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3486 |
else |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3487 |
lua_pushnil(L); |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3488 |
lc_getturntimepaused:= 1; |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3489 |
end; |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
3490 |
|
11569 | 3491 |
function lc_startghostpoints(L : Plua_State) : LongInt; Cdecl; |
3492 |
begin |
|
3493 |
if CheckLuaParamCount(L, 1, 'StartGhostPoints', 'count') then |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3494 |
startGhostPoints(Trunc(lua_tonumber(L, 1))); |
11569 | 3495 |
lc_startghostpoints:= 0 |
3496 |
end; |
|
3497 |
||
3498 |
function lc_dumppoint(L : Plua_State) : LongInt; Cdecl; |
|
3499 |
begin |
|
3500 |
if CheckLuaParamCount(L, 2, 'DumpPoint', 'x, y') then |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3501 |
dumpPoint(Trunc(lua_tonumber(L, 1)), Trunc(lua_tonumber(L, 2))); |
11569 | 3502 |
lc_dumppoint:= 0 |
3503 |
end; |
|
3504 |
||
10611 | 3505 |
|
3506 |
procedure ScriptFlushPoints(); |
|
3507 |
begin |
|
3508 |
ParseCommand('draw ' + PointsBuffer, true, true); |
|
3509 |
PointsBuffer:= ''; |
|
3510 |
end; |
|
3511 |
||
3512 |
||
3513 |
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
|
3514 |
var np, param: LongInt; |
10611 | 3515 |
begin |
10613 | 3516 |
if CheckAndFetchParamCountRange(L, 2, 4, 'AddPoint', 'x, y [, width [, erase] ]', np) then |
10611 | 3517 |
begin |
3518 |
// x |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3519 |
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
|
3520 |
PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
10611 | 3521 |
PointsBuffer:= PointsBuffer + char((param and $FF)); |
3522 |
// y |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3523 |
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
|
3524 |
PointsBuffer:= PointsBuffer + char((param shr 8) and $FF); |
10611 | 3525 |
PointsBuffer:= PointsBuffer + char((param and $FF)); |
3526 |
// width |
|
3527 |
if np > 2 then |
|
3528 |
begin |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3529 |
param:= Trunc(lua_tonumber(L,3)); |
10611 | 3530 |
param:= (param or $80); |
3531 |
// erase |
|
3532 |
if (np > 3) and lua_toboolean(L, 4) then |
|
3533 |
param:= (param or $40); |
|
3534 |
PointsBuffer:= PointsBuffer + char(param); |
|
3535 |
end |
|
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
3536 |
// no width defined |
10611 | 3537 |
else |
3538 |
PointsBuffer:= PointsBuffer + char(0); |
|
3539 |
||
3540 |
// flush before shortstring limit length is reached |
|
3541 |
if length(PointsBuffer) > 245 then |
|
3542 |
ScriptFlushPoints(); |
|
3543 |
end; |
|
3544 |
lc_addPoint:= 0 |
|
3545 |
end; |
|
3546 |
||
3547 |
||
3548 |
function lc_flushPoints(L : Plua_State) : LongInt; Cdecl; |
|
3549 |
begin |
|
3550 |
if CheckLuaParamCount(L, 0, 'FlushPoints', '') then |
|
10615
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
3551 |
if length(PointsBuffer) > 0 then |
e3dcb235a354
fix some things I messed up with the drawing functions
sheepluva
parents:
10613
diff
changeset
|
3552 |
ScriptFlushPoints(); |
10611 | 3553 |
lc_flushPoints:= 0 |
3554 |
end; |
|
3555 |
||
10618 | 3556 |
// 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
|
3557 |
function lc_endluatest(L : Plua_State) : LongInt; Cdecl; |
10618 | 3558 |
var rstring: shortstring; |
3559 |
const |
|
3560 |
call = 'EndLuaTest'; |
|
3561 |
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
|
3562 |
begin |
10618 | 3563 |
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
|
3564 |
begin |
10618 | 3565 |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3566 |
case Trunc(lua_tonumber(L, 1)) of |
10618 | 3567 |
HaltTestSuccess : rstring:= 'Success'; |
11617 | 3568 |
HaltTestFailed: rstring:= 'FAILED'; |
10618 | 3569 |
else |
3570 |
begin |
|
3571 |
LuaCallError('Parameter must be either ' + params, call, params); |
|
3572 |
exit(0); |
|
3573 |
end; |
|
3574 |
end; |
|
3575 |
||
3576 |
if cTestLua then |
|
3577 |
begin |
|
3578 |
WriteLnToConsole('Lua test finished, result: ' + rstring); |
|
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3579 |
halt(Trunc(lua_tonumber(L, 1))); |
10618 | 3580 |
end |
3581 |
else LuaError('Not in lua test mode, engine will keep running. Reported test result: ' + rstring); |
|
3582 |
||
3583 |
end; |
|
3584 |
||
10284
e9c85a0acdd2
placeSprite accepts any amount of landflags now; further WIP wrt cleanup/fixing
sheepluva
parents:
10283
diff
changeset
|
3585 |
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
|
3586 |
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
|
3587 |
/////////////////// |
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3588 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3589 |
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
|
3590 |
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
|
3591 |
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
|
3592 |
n:= lua_gettop(luaState); |
3539 | 3593 |
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
|
3594 |
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
|
3595 |
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
|
3596 |
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
|
3597 |
else if lua_toboolean(luaState, i) then |
3539 | 3598 |
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
|
3599 |
else |
3539 | 3600 |
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
|
3601 |
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
|
3602 |
|
3acdb4dac6eb
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 |
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
|
3604 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3605 |
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
|
3606 |
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
|
3607 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3608 |
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
|
3609 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3610 |
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
|
3611 |
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
|
3612 |
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
|
3613 |
|
3acdb4dac6eb
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 |
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
|
3615 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3616 |
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
|
3617 |
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
|
3618 |
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
|
3619 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3620 |
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
|
3621 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3622 |
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
|
3623 |
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
|
3624 |
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
|
3625 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3626 |
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
|
3627 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3628 |
lua_getglobal(luaState, Str2PChar(name)); |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
3629 |
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
|
3630 |
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
|
3631 |
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
|
3632 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3633 |
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
|
3634 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3635 |
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
|
3636 |
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
|
3637 |
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
|
3638 |
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
|
3639 |
|
12749
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3640 |
function ScriptGetAnsiString(name : shortstring) : ansistring; |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3641 |
begin |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3642 |
lua_getglobal(luaState, Str2PChar(name)); |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3643 |
ScriptGetAnsiString:= lua_tostringa(luaState, -1); |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3644 |
lua_pop(luaState, 1); |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3645 |
end; |
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3646 |
|
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3647 |
procedure ScriptOnPreviewInit; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3648 |
begin |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3649 |
// 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
|
3650 |
if not ScriptLoaded then |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3651 |
exit; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3652 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3653 |
ScriptSetString('Seed', cSeed); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3654 |
ScriptSetInteger('TemplateFilter', cTemplateFilter); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3655 |
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
|
3656 |
ScriptSetInteger('MapGen', ord(cMapGen)); |
11062 | 3657 |
ScriptSetInteger('MapFeatureSize', cFeatureSize); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3658 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3659 |
ScriptCall('onPreviewInit'); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3660 |
|
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3661 |
// pop game variables |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3662 |
ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3663 |
cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3664 |
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
|
3665 |
cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
11062 | 3666 |
cFeatureSize := ScriptGetInteger('MapFeatureSize'); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3667 |
end; |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10143
diff
changeset
|
3668 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3669 |
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
|
3670 |
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
|
3671 |
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
|
3672 |
// 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
|
3673 |
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
|
3674 |
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
|
3675 |
|
3acdb4dac6eb
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 |
// push game variables so they may be modified by the script |
13216
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3677 |
ScriptSetInteger('CursorX', NoPointX); |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3678 |
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
|
3679 |
ScriptSetInteger('GameFlags', GameFlags); |
11879
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11849
diff
changeset
|
3680 |
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
|
3681 |
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
|
3682 |
ScriptSetInteger('TemplateFilter', cTemplateFilter); |
7567 | 3683 |
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
|
3684 |
ScriptSetInteger('MapGen', ord(cMapGen)); |
11061 | 3685 |
ScriptSetInteger('MapFeatureSize', cFeatureSize); |
5583
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
3686 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
63b274a4fb01
At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents:
5554
diff
changeset
|
3687 |
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
|
3688 |
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
|
3689 |
ScriptSetInteger('CaseFreq', cCaseFactor); |
13627
605767bbd022
Move max. number of crate spawns into variable
Wuzzy <Wuzzy2@mail.ru>
parents:
13618
diff
changeset
|
3690 |
ScriptSetInteger('MaxCaseDrops', cMaxCaseDrops); |
4162 | 3691 |
ScriptSetInteger('HealthCaseProb', cHealthCaseProb); |
3692 |
ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount); |
|
14543
d0441c7e9000
Lua: Add InitHealth, read-only variable containing the initial hog health setting
Wuzzy <Wuzzy2@mail.ru>
parents:
14505
diff
changeset
|
3693 |
ScriptSetInteger('InitHealth', cInitHealth); |
4221 | 3694 |
ScriptSetInteger('DamagePercent', cDamagePercent); |
6557 | 3695 |
ScriptSetInteger('RopePercent', cRopePercent); |
4003
ca0600ab38bf
disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents:
3999
diff
changeset
|
3696 |
ScriptSetInteger('MinesNum', cLandMines); |
4221 | 3697 |
ScriptSetInteger('MinesTime', cMinesTime); |
3698 |
ScriptSetInteger('MineDudPercent', cMineDudPercent); |
|
11963
0c1420aaa59e
Expose number of air mines in Lua variable AirMinesNum
Wuzzy <almikes@aol.com>
parents:
11945
diff
changeset
|
3699 |
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
|
3700 |
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
|
3701 |
ScriptSetInteger('Delay', cInactDelay); |
3774 | 3702 |
ScriptSetInteger('Ready', cReadyDelay); |
3197 | 3703 |
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); |
4162 | 3704 |
ScriptSetInteger('WaterRise', cWaterRise); |
3705 |
ScriptSetInteger('HealthDecrease', cHealthDecrease); |
|
9836 | 3706 |
ScriptSetInteger('GetAwayTime', cGetAwayTime); |
12301
46e1e25fec5e
Lua variable: AmmoTypeMax (maximum ammo type ID for iterating)
Wuzzy <almikes@aol.com>
parents:
12294
diff
changeset
|
3707 |
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
|
3708 |
ScriptSetString('Map', cMapName); |
11737
571d06a86bb6
fix for issue 71: Lua API: “Theme” variable is set to empty string initially
Wuzzy <almikes@aol.com>
parents:
11736
diff
changeset
|
3709 |
ScriptSetString('Theme', Theme); |
4883
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
3710 |
ScriptSetString('Goals', ''); |
7cddc9201a1d
added dummy for tardis and ugly icons for tardis and structure
Henek
parents:
4882
diff
changeset
|
3711 |
|
3043
3acdb4dac6eb
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 |
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
|
3713 |
|
3acdb4dac6eb
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 |
// pop game variables |
7805 | 3715 |
ParseCommand('seed ' + ScriptGetString('Seed'), true, true); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3716 |
cTemplateFilter := ScriptGetInteger('TemplateFilter'); |
7567 | 3717 |
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
|
3718 |
cMapGen := TMapGen(ScriptGetInteger('MapGen')); |
11061 | 3719 |
cFeatureSize := ScriptGetInteger('MapFeatureSize'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3720 |
GameFlags := ScriptGetInteger('GameFlags'); |
11879
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11849
diff
changeset
|
3721 |
WorldEdge := TWorldEdge(ScriptGetInteger('WorldEdge')); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3722 |
cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3723 |
cCaseFactor := ScriptGetInteger('CaseFreq'); |
13627
605767bbd022
Move max. number of crate spawns into variable
Wuzzy <Wuzzy2@mail.ru>
parents:
13618
diff
changeset
|
3724 |
cMaxCaseDrops := ScriptGetInteger('MaxCaseDrops'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3725 |
cHealthCaseProb := ScriptGetInteger('HealthCaseProb'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3726 |
cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount'); |
14543
d0441c7e9000
Lua: Add InitHealth, read-only variable containing the initial hog health setting
Wuzzy <Wuzzy2@mail.ru>
parents:
14505
diff
changeset
|
3727 |
cInitHealth := ScriptGetInteger('InitHealth'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3728 |
cDamagePercent := ScriptGetInteger('DamagePercent'); |
6523 | 3729 |
cRopePercent := ScriptGetInteger('RopePercent'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3730 |
cLandMines := ScriptGetInteger('MinesNum'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3731 |
cMinesTime := ScriptGetInteger('MinesTime'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3732 |
cMineDudPercent := ScriptGetInteger('MineDudPercent'); |
11963
0c1420aaa59e
Expose number of air mines in Lua variable AirMinesNum
Wuzzy <almikes@aol.com>
parents:
11945
diff
changeset
|
3733 |
cAirMines := ScriptGetInteger('AirMinesNum'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3734 |
cExplosives := ScriptGetInteger('Explosives'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3735 |
cInactDelay := ScriptGetInteger('Delay'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3736 |
cReadyDelay := ScriptGetInteger('Ready'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3737 |
cSuddenDTurns := ScriptGetInteger('SuddenDeathTurns'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3738 |
cWaterRise := ScriptGetInteger('WaterRise'); |
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3739 |
cHealthDecrease := ScriptGetInteger('HealthDecrease'); |
9836 | 3740 |
cGetAwayTime := ScriptGetInteger('GetAwayTime'); |
6312
658055a3f160
fix map/template override, remove some pointless command calls
nemo
parents:
6131
diff
changeset
|
3741 |
|
7771 | 3742 |
if cMapName <> ScriptGetString('Map') then |
7805 | 3743 |
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
|
3744 |
if ScriptGetString('Theme') <> '' then |
7805 | 3745 |
ParseCommand('theme ' + ScriptGetString('Theme'), true, true); |
12749
1df909b46c05
Lua API: Fix Goals text being cut off at ca. 255 characters
Wuzzy <Wuzzy2@mail.ru>
parents:
12683
diff
changeset
|
3746 |
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
|
3747 |
|
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3748 |
// 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
|
3749 |
k:= 0; |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3750 |
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
|
3751 |
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
|
3752 |
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
|
3753 |
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
|
3754 |
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
|
3755 |
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
|
3756 |
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
|
3757 |
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
|
3758 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3759 |
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
|
3760 |
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
|
3761 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3762 |
end |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
3763 |
else |
6578
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3764 |
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
|
3765 |
begin |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3766 |
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
|
3767 |
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
|
3768 |
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
|
3769 |
inc(k) |
d4ad42283125
Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents:
6563
diff
changeset
|
3770 |
end; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3771 |
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
|
3772 |
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
|
3773 |
// 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
|
3774 |
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
|
3775 |
uAmmos.initModule; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3776 |
if ScriptExists('onAmmoStoreInit') then |
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3777 |
begin |
6752 | 3778 |
ScriptPrepareAmmoStore; |
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3779 |
ScriptCall('onAmmoStoreInit'); |
6746 | 3780 |
SetAmmoLoadout(ScriptAmmoLoadout); |
3781 |
SetAmmoProbability(ScriptAmmoProbability); |
|
3782 |
SetAmmoDelay(ScriptAmmoDelay); |
|
3783 |
SetAmmoReinforcement(ScriptAmmoReinforcement) |
|
6743
864bf0f52a8c
make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents:
6742
diff
changeset
|
3784 |
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
|
3785 |
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
|
3786 |
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
|
3787 |
|
4235
6b1dfbd60a45
added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents:
4221
diff
changeset
|
3788 |
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
|
3789 |
ScriptSetInteger('TeamsCount', TeamsCount); |
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3790 |
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
|
3791 |
|
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3792 |
|
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3793 |
// 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
|
3794 |
procedure ScriptOnScreenResize(); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3795 |
begin |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3796 |
ScriptSetInteger('ScreenHeight', cScreenHeight); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3797 |
ScriptSetInteger('ScreenWidth', cScreenWidth); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3798 |
ScriptCall('onScreenResize'); |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3799 |
end; |
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3800 |
|
8031 | 3801 |
// custom script loader via physfs, passed to lua_load |
8034 | 3802 |
const BUFSIZE = 1024; |
5825
a6eab1b7c00d
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents:
5703
diff
changeset
|
3803 |
|
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3804 |
var inComment: boolean; |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3805 |
var inQuote: boolean; |
12459
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12458
diff
changeset
|
3806 |
var locSum: LongWord; |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3807 |
var braceCount: LongWord; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3808 |
var wordCount: LongWord; |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3809 |
var lastChar: char; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3810 |
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:
12371
diff
changeset
|
3811 |
var mybuf: PChar; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3812 |
i: LongInt; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3813 |
begin |
13863
35ba3a550cad
Backed out changeset 5f6208031658 (fixes 652)
Wuzzy <Wuzzy2@mail.ru>
parents:
13857
diff
changeset
|
3814 |
SetRandomSeed(cSeed,true); |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3815 |
mybuf := physfsReader(L, f, sz); |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3816 |
if (mybuf <> nil) and ((sz^) > 0) then |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3817 |
begin |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3818 |
for i:= 0 to sz^-1 do |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3819 |
begin |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3820 |
if (lastChar = '-') and (mybuf[i] = '-') then |
14237
3d4a5a10d2cd
lua comment handling is seriously WTF, but let's at least allow some partial single line
nemo
parents:
14188
diff
changeset
|
3821 |
inComment := true |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3822 |
else if not inComment and (byte(mybuf[i]) > $20) and (byte(mybuf[i]) < $7F) and (mybuf[i]<>'-') then |
12494
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12493
diff
changeset
|
3823 |
begin |
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12493
diff
changeset
|
3824 |
AddRandomness(byte(mybuf[i])); // wish I had the seed... |
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12493
diff
changeset
|
3825 |
CheckSum := CheckSum xor GetRandom($FFFFFFFF); |
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12493
diff
changeset
|
3826 |
end; |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3827 |
lastChar := mybuf[i]; |
14237
3d4a5a10d2cd
lua comment handling is seriously WTF, but let's at least allow some partial single line
nemo
parents:
14188
diff
changeset
|
3828 |
// lua apparently allows -- [===============[ as a valid block comment start. |
3d4a5a10d2cd
lua comment handling is seriously WTF, but let's at least allow some partial single line
nemo
parents:
14188
diff
changeset
|
3829 |
// I can't be bothered to check for that nonsense. Will allow limited single line without [ |
14238 | 3830 |
if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) or (mybuf[i] = '[') then |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3831 |
inComment := false |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3832 |
end; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3833 |
end; |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3834 |
ScriptReader:= mybuf |
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3835 |
end; |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3836 |
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:
12455
diff
changeset
|
3837 |
var mybuf: PChar; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3838 |
i: LongInt; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3839 |
begin |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3840 |
mybuf := physfsReader(L, f, sz); |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3841 |
if (mybuf <> nil) and ((sz^) > 0) then |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3842 |
begin |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3843 |
for i:= 0 to sz^-1 do |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3844 |
begin |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3845 |
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:
12455
diff
changeset
|
3846 |
inQuote := not inQuote; |
12494
1b483882b60f
mix it up some more. also had screwed up -- inside quotes
nemo
parents:
12493
diff
changeset
|
3847 |
if not inQuote and (lastChar = '-') and (mybuf[i] = '-') then |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3848 |
inComment := true; |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3849 |
if not inComment and (not inQuote) then |
12459
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12458
diff
changeset
|
3850 |
locSum := locSum xor (byte(mybuf[i]) shl (i mod 4)); |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3851 |
if not inComment and (not inQuote) and |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3852 |
((mybuf[i] = '(') or |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3853 |
(mybuf[i] = ')') or |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3854 |
(mybuf[i] = '+') or |
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3855 |
(mybuf[i] = '#') or |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3856 |
(braceCount > 2) or |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3857 |
(wordCount > 6)) then |
12459
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12458
diff
changeset
|
3858 |
CheckSum := locSum; |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3859 |
if not inComment and (not inQuote) and ((mybuf[i] = '{') or (mybuf[i] = '}')) then |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3860 |
inc(braceCount); |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3861 |
if not inComment and (not inQuote) and |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3862 |
(((byte(mybuf[i]) > $40) and (byte(mybuf[i]) < $5B)) or |
12459
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12458
diff
changeset
|
3863 |
((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:
12458
diff
changeset
|
3864 |
((byte(mybuf[i]) >= $30) and (byte(mybuf[i]) < $3A))) then |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3865 |
inc(wordCount); |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3866 |
lastChar := mybuf[i]; |
14237
3d4a5a10d2cd
lua comment handling is seriously WTF, but let's at least allow some partial single line
nemo
parents:
14188
diff
changeset
|
3867 |
// this allows at least supporting the commented strings at end of line with lua script names |
14238 | 3868 |
if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) or (mybuf[i] = '[') then |
12596
c9711561f947
fix some things that annoy pas2c and whitespaces
sheepluva
parents:
12576
diff
changeset
|
3869 |
inComment := false |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3870 |
end; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3871 |
end; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3872 |
ScriptLocaleReader:= mybuf |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3873 |
end; |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3874 |
|
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3875 |
function ScriptLoad(name : shortstring; mustExist : boolean): 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
|
3876 |
var ret : LongInt; |
5243 | 3877 |
s : shortstring; |
8031 | 3878 |
f : PFSFile; |
8034 | 3879 |
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
|
3880 |
begin |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3881 |
inComment:= false; |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3882 |
inQuote:= false; |
12454
a675a94b5cc1
Totally untested. Trying to ensure scripts loaded more or less match.
nemo
parents:
12371
diff
changeset
|
3883 |
lastChar:= 'X'; |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3884 |
braceCount:= 0; |
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3885 |
wordCount:= 0; |
12459
06bf46238a89
ranges for alnum were silly. also lets not fail to same value
nemo
parents:
12458
diff
changeset
|
3886 |
locSum:= 0; |
8031 | 3887 |
s:= cPathz[ptData] + name; |
3888 |
if not pfsExists(s) then |
|
9531
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
3889 |
begin |
13723
61095cb5f58a
Critical error if loading a script has failed
Wuzzy <Wuzzy2@mail.ru>
parents:
13674
diff
changeset
|
3890 |
if mustExist then |
61095cb5f58a
Critical error if loading a script has failed
Wuzzy <Wuzzy2@mail.ru>
parents:
13674
diff
changeset
|
3891 |
OutError('Script not found: ' + name, true) |
61095cb5f58a
Critical error if loading a script has failed
Wuzzy <Wuzzy2@mail.ru>
parents:
13674
diff
changeset
|
3892 |
else |
61095cb5f58a
Critical error if loading a script has failed
Wuzzy <Wuzzy2@mail.ru>
parents:
13674
diff
changeset
|
3893 |
AddFileLog('[LUA] Script not found: ' + name); |
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3894 |
ScriptLoad:= false; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6578
diff
changeset
|
3895 |
exit; |
9531
7fcdedc45589
Unbreak access to Data dir in profile broken in r8b48c27201af
unc0rr
parents:
9409
diff
changeset
|
3896 |
end; |
6088 | 3897 |
|
8031 | 3898 |
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
|
3899 |
if f = nil then |
13723
61095cb5f58a
Critical error if loading a script has failed
Wuzzy <Wuzzy2@mail.ru>
parents:
13674
diff
changeset
|
3900 |
OutError('Error reading script: ' + name, true); |
8031 | 3901 |
|
13393 | 3902 |
hedgewarsMountPackage(Str2PChar(copy(s, 3, length(s)-6)+'.hwp')); |
12316
d09eba2e1dd8
Move sidecar lua load to prior to script load. This should let the script use it for dependencies.
nemo
parents:
12301
diff
changeset
|
3903 |
|
8073 | 3904 |
physfsReaderSetBuffer(@buf); |
13824 | 3905 |
if (Pos('Locale/',s) <> 0) or (s = 'Scripts/OfficialChallengeHashes.lua') then |
12457
19e7838bedad
Try to prevent the script safety checking from totally screwing up localisation. Also untested.
nemo
parents:
12455
diff
changeset
|
3906 |
ret:= lua_load(luaState, @ScriptLocaleReader, f, Str2PChar(s)) |
13349
40742f3f7dd9
Seed reset seems fine when moved out of the loader. Also bump protocol
nemo
parents:
13348
diff
changeset
|
3907 |
else |
14237
3d4a5a10d2cd
lua comment handling is seriously WTF, but let's at least allow some partial single line
nemo
parents:
14188
diff
changeset
|
3908 |
begin |
13349
40742f3f7dd9
Seed reset seems fine when moved out of the loader. Also bump protocol
nemo
parents:
13348
diff
changeset
|
3909 |
SetRandomSeed(cSeed,true); |
14237
3d4a5a10d2cd
lua comment handling is seriously WTF, but let's at least allow some partial single line
nemo
parents:
14188
diff
changeset
|
3910 |
ret:= lua_load(luaState, @ScriptReader, f, Str2PChar(s)) |
3d4a5a10d2cd
lua comment handling is seriously WTF, but let's at least allow some partial single line
nemo
parents:
14188
diff
changeset
|
3911 |
end; |
8031 | 3912 |
pfsClose(f); |
3913 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3914 |
if ret <> 0 then |
3774 | 3915 |
begin |
10312 | 3916 |
LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
3917 |
LuaError(lua_tostring(luaState, -1)); |
|
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3918 |
ScriptLoad:= false; |
3774 | 3919 |
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
|
3920 |
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
|
3921 |
begin |
3539 | 3922 |
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
|
3923 |
// 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
|
3924 |
lua_pcall(luaState, 0, 0, 0); |
13728
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3925 |
ScriptLoaded:= true; |
247d1bcf3c5e
Add 2nd optional parameter to HedgewarsScriptLoad. If false, its OK if file does not exist. Also, return true/false on success
Wuzzy <Wuzzy2@mail.ru>
parents:
13727
diff
changeset
|
3926 |
ScriptLoad:= 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
|
3927 |
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
|
3928 |
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
|
3929 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3930 |
procedure SetGlobals; |
13216
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3931 |
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
|
3932 |
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
|
3933 |
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
12576
1fb961480b3c
Lua API: Add ReadyTimeLeft variable
Wuzzy <almikes@aol.com>
parents:
12536
diff
changeset
|
3934 |
ScriptSetInteger('ReadyTimeLeft', ReadyTimeLeft); |
3761 | 3935 |
ScriptSetInteger('GameTime', GameTicks); |
13651
56a925256039
Add separate TotalRounds var for Lua to count the *actual* number of rounds that have been played
Wuzzy <Wuzzy2@mail.ru>
parents:
13642
diff
changeset
|
3936 |
ScriptSetInteger('TotalRounds', TotalRoundsReal); |
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
|
3937 |
ScriptSetInteger('WaterLine', cWaterLine); |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3938 |
if isCursorVisible and (not bShowAmmoMenu) then |
10989 | 3939 |
begin |
13216
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3940 |
x:= CursorPoint.X - WorldDx; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3941 |
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:
13170
diff
changeset
|
3942 |
if (PrevCursorX <> x) or |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3943 |
(PrevCursorY <> y) then |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3944 |
begin |
13216
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3945 |
ScriptSetInteger('CursorX', x); |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3946 |
ScriptSetInteger('CursorY', y); |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3947 |
PrevCursorX:= x; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3948 |
PrevCursorY:= y; |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3949 |
end |
10989 | 3950 |
end |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3951 |
else |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3952 |
begin |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3953 |
ScriptSetInteger('CursorX', NoPointX); |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3954 |
ScriptSetInteger('CursorY', NoPointX); |
13216
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3955 |
PrevCursorX:= NoPointX; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
3956 |
PrevCursorY:= NoPointX |
10978
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3957 |
end; |
54a49174dbec
cursor x/y when targeting for mikade's visual effects. this is not synced
nemo
parents:
10903
diff
changeset
|
3958 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3959 |
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
|
3960 |
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
|
3961 |
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
|
3962 |
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
|
3963 |
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
|
3964 |
|
13754
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3965 |
procedure ScriptSetMapGlobals; |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3966 |
begin |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3967 |
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3968 |
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3969 |
ScriptSetInteger('LeftX', leftX); |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3970 |
ScriptSetInteger('RightX', rightX); |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3971 |
ScriptSetInteger('TopY', topY); |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3972 |
end; |
f1c66a34f2fe
Lua: Fix LeftX, RightX, TopY, LAND_WIDTH, LAND_HEIGHT being broken if onVisualGearAdd is set
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
3973 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
3974 |
procedure GetGlobals; |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3975 |
var currentTTL, currentRTL, newTTL, newRTL: 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
|
3976 |
begin |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3977 |
// Setting TurnTimeLeft and ReadyTimeLeft should now be done in the setter functions. |
13741
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3978 |
// SetTurnTimeLeft and SetReadTimeLeft. |
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
3979 |
// GetGloals should be removed in a future release. |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3980 |
|
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3981 |
// DEPRECATED: Read TurnTimeLeft and ReadyTimeLeft from script directly. |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3982 |
// TODO: Remove this behaviour in a future version. |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3983 |
currentTTL:= TurnTimeLeft; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3984 |
currentRTL:= ReadyTimeLeft; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3985 |
newTTL:= ScriptGetInteger('TurnTimeLeft'); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3986 |
newRTL:= ScriptGetInteger('ReadyTimeLeft'); |
13766
c46998ecd8fa
Don't write TurnTimeLeft deprecation warning if setter function was used
Wuzzy <Wuzzy2@mail.ru>
parents:
13754
diff
changeset
|
3987 |
if (currentTTL <> newTTL) and (not isPendingTurnTimeLeft) then |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3988 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3989 |
TurnTimeLeft:= newTTL; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3990 |
LuaWarning('Writing to TurnTimeLeft directly is deprecated! Use SetTurnTimeLeft instead!'); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3991 |
end; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3992 |
|
13766
c46998ecd8fa
Don't write TurnTimeLeft deprecation warning if setter function was used
Wuzzy <Wuzzy2@mail.ru>
parents:
13754
diff
changeset
|
3993 |
if (currentRTL <> newRTL) and (not isPendingReadyTimeLeft) then |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3994 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3995 |
ReadyTimeLeft:= newRTL; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3996 |
LuaWarning('Writing to ReadyTimeLeft directly is deprecated! Use SetReadyTimeLeft instead!'); |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3997 |
end; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3998 |
|
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
3999 |
// Set TurnTimeLeft and ReadyTimeLeft if activated by SetTurnTimeLeft and SetReadyTimeLeft before |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4000 |
if isPendingTurnTimeLeft then |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4001 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4002 |
TurnTimeLeft:= PendingTurnTimeLeft; |
13835
0beff00d223a
Set script globals TurnTimeLeft and ReadyTimeLeft immediately after they were changed by Lua call
Wuzzy <Wuzzy2@mail.ru>
parents:
13824
diff
changeset
|
4003 |
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4004 |
isPendingTurnTimeLeft:= false; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4005 |
end; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4006 |
if isPendingReadyTimeLeft then |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4007 |
begin |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4008 |
ReadyTimeLeft:= PendingReadyTimeLeft; |
13835
0beff00d223a
Set script globals TurnTimeLeft and ReadyTimeLeft immediately after they were changed by Lua call
Wuzzy <Wuzzy2@mail.ru>
parents:
13824
diff
changeset
|
4009 |
ScriptSetInteger('ReadyTimeLeft', ReadyTimeLeft); |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4010 |
isPendingReadyTimeLeft:= false; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4011 |
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
|
4012 |
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
|
4013 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4014 |
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
|
4015 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8012
diff
changeset
|
4016 |
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
|
4017 |
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
|
4018 |
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
|
4019 |
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
|
4020 |
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
|
4021 |
begin |
10312 | 4022 |
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
|
4023 |
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
|
4024 |
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
|
4025 |
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
|
4026 |
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
|
4027 |
|
7805 | 4028 |
(* |
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
|
4029 |
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
|
4030 |
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
|
4031 |
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
|
4032 |
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
|
4033 |
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
|
4034 |
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
|
4035 |
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
|
4036 |
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
|
4037 |
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
|
4038 |
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
|
4039 |
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
|
4040 |
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
|
4041 |
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
|
4042 |
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
|
4043 |
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
|
4044 |
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
|
4045 |
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
|
4046 |
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
|
4047 |
end; |
7805 | 4048 |
*) |
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
|
4049 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4050 |
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
|
4051 |
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
|
4052 |
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
|
4053 |
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
|
4054 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4055 |
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
|
4056 |
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
|
4057 |
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
|
4058 |
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
|
4059 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4060 |
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
|
4061 |
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
|
4062 |
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
|
4063 |
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
|
4064 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4065 |
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
|
4066 |
begin |
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8012
diff
changeset
|
4067 |
if (not ScriptLoaded) or (not ScriptExists(fname)) then |
10560 | 4068 |
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
|
4069 |
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
|
4070 |
lua_getglobal(luaState, Str2PChar(fname)); |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
4071 |
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:
12286
diff
changeset
|
4072 |
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:
12286
diff
changeset
|
4073 |
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:
12286
diff
changeset
|
4074 |
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
|
4075 |
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
|
4076 |
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
|
4077 |
begin |
10312 | 4078 |
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
|
4079 |
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
|
4080 |
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
|
4081 |
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
|
4082 |
begin |
12294
0deabf747b8f
For testing purposes, drop tointeger and pushint since Lua uses ptrdiff causing inconsistent behaviour if we try to get a longword value from tointeger on 64 bit vs 32bit. This should improve script reliability a bit
nemo
parents:
12286
diff
changeset
|
4083 |
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
|
4084 |
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
|
4085 |
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
|
4086 |
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
|
4087 |
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
|
4088 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4089 |
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
|
4090 |
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
|
4091 |
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
|
4092 |
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
|
4093 |
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
|
4094 |
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
|
4095 |
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
|
4096 |
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
|
4097 |
ScriptExists:= not lua_isnoneornil(luaState, -1); |
12107
0695302f3f5f
Fix ScriptExists() destroying lua stack (fixes Bug #146)
sheepluva
parents:
12090
diff
changeset
|
4098 |
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
|
4099 |
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
|
4100 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4101 |
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
|
4102 |
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
|
4103 |
begin |
3346 | 4104 |
ScriptAmmoLoadout:= ''; |
4105 |
ScriptAmmoDelay:= ''; |
|
4106 |
ScriptAmmoProbability:= ''; |
|
4107 |
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
|
4108 |
for i:=1 to ord(High(TAmmoType)) do |
3346 | 4109 |
begin |
4110 |
ScriptAmmoLoadout:= ScriptAmmoLoadout + '0'; |
|
4111 |
ScriptAmmoProbability:= ScriptAmmoProbability + '0'; |
|
4112 |
ScriptAmmoDelay:= ScriptAmmoDelay + '0'; |
|
4113 |
ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0'; |
|
4114 |
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
|
4115 |
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
|
4116 |
|
9750 | 4117 |
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
|
4118 |
begin |
9750 | 4119 |
//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 |
4120 |
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
|
4121 |
exit; |
3346 | 4122 |
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1]; |
9750 | 4123 |
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
|
4124 |
ScriptSetAmmoDelay(ammo, delay); |
3346 | 4125 |
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
|
4126 |
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
|
4127 |
|
14640
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4128 |
procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: LongWord); |
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
|
4129 |
begin |
11677 | 4130 |
// 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
|
4131 |
if (StoreCnt = 0) then |
14640
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4132 |
begin |
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
|
4133 |
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
|
4134 |
ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1]; |
14640
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4135 |
end |
11677 | 4136 |
// 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
|
4137 |
else if (CurrentTeam <> nil) then |
14640
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4138 |
begin |
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4139 |
ammoz[ammo].SkipTurns:= CurrentTeam^.Clan^.TurnNumber + delay; |
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4140 |
if ammoz[ammo].SkipTurns > 0 then |
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4141 |
dec(ammoz[ammo].SkipTurns); |
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4142 |
AmmoMenuInvalidated:= true; |
03033213e800
Lua: Fix SetAmmoDelay not working properly when called after initialization
Wuzzy <Wuzzy2@mail.ru>
parents:
14639
diff
changeset
|
4143 |
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
|
4144 |
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
|
4145 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4146 |
procedure ScriptApplyAmmoStore; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
4147 |
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
|
4148 |
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
|
4149 |
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
|
4150 |
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
|
4151 |
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
|
4152 |
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
|
4153 |
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
|
4154 |
ScriptPrepareAmmoStore; |
6746 | 4155 |
ScriptCall('onNewAmmoStore',i,-1); |
4156 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
4157 |
SetAmmoProbability(ScriptAmmoProbability); |
|
4158 |
SetAmmoDelay(ScriptAmmoDelay); |
|
4159 |
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
|
4160 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
4161 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
4162 |
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
|
4163 |
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
|
4164 |
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
|
4165 |
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
|
4166 |
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
|
4167 |
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
|
4168 |
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
|
4169 |
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
|
4170 |
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
|
4171 |
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
|
4172 |
ScriptPrepareAmmoStore; |
6746 | 4173 |
ScriptCall('onNewAmmoStore',i,j); |
4174 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
4175 |
SetAmmoProbability(ScriptAmmoProbability); |
|
4176 |
SetAmmoDelay(ScriptAmmoDelay); |
|
4177 |
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
|
4178 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
4179 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
4180 |
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
|
4181 |
end |
9752
656c511ab0f3
here have some lua love: make parameter count error messages more helpful to lua devs
sheepluva
parents:
9751
diff
changeset
|
4182 |
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
|
4183 |
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
|
4184 |
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
|
4185 |
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
|
4186 |
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
|
4187 |
ScriptPrepareAmmoStore; |
6746 | 4188 |
ScriptCall('onNewAmmoStore',i,-1); |
4189 |
SetAmmoLoadout(ScriptAmmoLoadout); |
|
4190 |
SetAmmoProbability(ScriptAmmoProbability); |
|
4191 |
SetAmmoDelay(ScriptAmmoDelay); |
|
4192 |
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
|
4193 |
end; |
6563
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
4194 |
AddAmmoStore; |
30e042398411
Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents:
6557
diff
changeset
|
4195 |
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
|
4196 |
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
|
4197 |
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
|
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 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
|
4201 |
var at : TGearType; |
4453 | 4202 |
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
|
4203 |
am : TAmmoType; |
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
4204 |
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
|
4205 |
st : TSound; |
5118 | 4206 |
he : THogEffect; |
4207 |
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
|
4208 |
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
|
4209 |
mg : TMapGen; |
11879
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11849
diff
changeset
|
4210 |
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
|
4211 |
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
|
4212 |
// initialize lua |
10239 | 4213 |
luaState:= lua_open; |
11532 | 4214 |
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
|
4215 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4216 |
// open internal libraries |
10239 | 4217 |
luaopen_base(luaState); |
4218 |
luaopen_string(luaState); |
|
4219 |
luaopen_math(luaState); |
|
4220 |
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
|
4221 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4222 |
// import some variables |
14619
62dea281e4d5
Refactor hwengine: Rename cLocale to cLanguage
Wuzzy <Wuzzy2@mail.ru>
parents:
14558
diff
changeset
|
4223 |
ScriptSetString(_S'LOCALE', cLanguage); |
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
|
4224 |
|
14318
a6c5ce147530
Lua API: Change PLATFORM to INTERFACE
Wuzzy <Wuzzy2@mail.ru>
parents:
14309
diff
changeset
|
4225 |
{$IFDEF USE_TOUCH_INTERFACE} |
a6c5ce147530
Lua API: Change PLATFORM to INTERFACE
Wuzzy <Wuzzy2@mail.ru>
parents:
14309
diff
changeset
|
4226 |
ScriptSetString(_S'INTERFACE', 'touch'); |
13954
429945a9b8db
Lua: Add PLATFORM global var to distinguish between desktop and mobile builds
Wuzzy <Wuzzy2@mail.ru>
parents:
13897
diff
changeset
|
4227 |
{$ELSE} |
14318
a6c5ce147530
Lua API: Change PLATFORM to INTERFACE
Wuzzy <Wuzzy2@mail.ru>
parents:
14309
diff
changeset
|
4228 |
ScriptSetString(_S'INTERFACE', 'desktop'); |
13954
429945a9b8db
Lua: Add PLATFORM global var to distinguish between desktop and mobile builds
Wuzzy <Wuzzy2@mail.ru>
parents:
13897
diff
changeset
|
4229 |
{$ENDIF} |
429945a9b8db
Lua: Add PLATFORM global var to distinguish between desktop and mobile builds
Wuzzy <Wuzzy2@mail.ru>
parents:
13897
diff
changeset
|
4230 |
|
13872
f01798038c2e
Rename amDuck and related symbols to amCreeper, gtCreeper, etc.
Wuzzy <Wuzzy2@mail.ru>
parents:
13863
diff
changeset
|
4231 |
// Add aliases for amDuck and gtDuck because rubber duck was removed. |
f01798038c2e
Rename amDuck and related symbols to amCreeper, gtCreeper, etc.
Wuzzy <Wuzzy2@mail.ru>
parents:
13863
diff
changeset
|
4232 |
// amDuck and gtDuck are deprecated and should be removed later. |
f01798038c2e
Rename amDuck and related symbols to amCreeper, gtCreeper, etc.
Wuzzy <Wuzzy2@mail.ru>
parents:
13863
diff
changeset
|
4233 |
// TODO: Remove these aliases in a later version. |
f01798038c2e
Rename amDuck and related symbols to amCreeper, gtCreeper, etc.
Wuzzy <Wuzzy2@mail.ru>
parents:
13863
diff
changeset
|
4234 |
ScriptSetInteger('amDuck', Ord(amCreeper)); |
f01798038c2e
Rename amDuck and related symbols to amCreeper, gtCreeper, etc.
Wuzzy <Wuzzy2@mail.ru>
parents:
13863
diff
changeset
|
4235 |
ScriptSetInteger('gtDuck', Ord(gtCreeper)); |
f01798038c2e
Rename amDuck and related symbols to amCreeper, gtCreeper, etc.
Wuzzy <Wuzzy2@mail.ru>
parents:
13863
diff
changeset
|
4236 |
|
3043
3acdb4dac6eb
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 |
// import game flags |
13272
5984e8c6cbeb
Add new game flag gfSwitchHog, enable hog switching at turn start
Wuzzy <Wuzzy2@mail.ru>
parents:
13270
diff
changeset
|
4238 |
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
|
4239 |
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
|
4240 |
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
|
4241 |
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
|
4242 |
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
|
4243 |
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
|
4244 |
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
|
4245 |
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
|
4246 |
ScriptSetInteger('gfInvulnerable', gfInvulnerable); |
10671 | 4247 |
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
|
4248 |
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
|
4249 |
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
|
4250 |
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
|
4251 |
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
|
4252 |
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
|
4253 |
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
|
4254 |
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
|
4255 |
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
|
4256 |
ScriptSetInteger('gfDisableGirders', gfDisableGirders); |
4162 | 4257 |
ScriptSetInteger('gfDisableLandObjects', gfDisableLandObjects); |
4258 |
ScriptSetInteger('gfAISurvival', gfAISurvival); |
|
4259 |
ScriptSetInteger('gfInfAttack', gfInfAttack); |
|
4260 |
ScriptSetInteger('gfResetWeps', gfResetWeps); |
|
4261 |
ScriptSetInteger('gfPerHogAmmo', gfPerHogAmmo); |
|
4219 | 4262 |
ScriptSetInteger('gfDisableWind', gfDisableWind); |
4319 | 4263 |
ScriptSetInteger('gfMoreWind', gfMoreWind); |
5016
9347d82a26cc
added game mode Tag Team, mostly untested, please test :)
Henek
parents:
5013
diff
changeset
|
4264 |
ScriptSetInteger('gfTagTeam', gfTagTeam); |
9387 | 4265 |
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
|
4266 |
|
3894 | 4267 |
ScriptSetInteger('gmLeft', gmLeft); |
4268 |
ScriptSetInteger('gmRight', gmRight); |
|
4269 |
ScriptSetInteger('gmUp', gmUp); |
|
4270 |
ScriptSetInteger('gmDown', gmDown); |
|
4271 |
ScriptSetInteger('gmSwitch', gmSwitch); |
|
4272 |
ScriptSetInteger('gmAttack', gmAttack); |
|
4273 |
ScriptSetInteger('gmLJump', gmLJump); |
|
4274 |
ScriptSetInteger('gmHJump', gmHJump); |
|
4275 |
ScriptSetInteger('gmDestroy', gmDestroy); |
|
4276 |
ScriptSetInteger('gmSlot', gmSlot); |
|
4277 |
ScriptSetInteger('gmWeapon', gmWeapon); |
|
4278 |
ScriptSetInteger('gmTimer', gmTimer); |
|
4279 |
ScriptSetInteger('gmAnimate', gmAnimate); |
|
4280 |
ScriptSetInteger('gmPrecise', gmPrecise); |
|
3892 | 4281 |
ScriptSetInteger('gmAllStoppable', gmAllStoppable); |
4282 |
||
3761 | 4283 |
// speech bubbles |
4284 |
ScriptSetInteger('SAY_SAY', 1); |
|
4285 |
ScriptSetInteger('SAY_THINK', 2); |
|
4286 |
ScriptSetInteger('SAY_SHOUT', 3); |
|
4287 |
||
13593
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
4288 |
// other |
13595
0adc82afb784
Add Lua globals: AMMO_INFINITE and NoPointX
Wuzzy <Wuzzy2@mail.ru>
parents:
13593
diff
changeset
|
4289 |
ScriptSetInteger('AMMO_INFINITE', AMMO_INFINITE); |
13593
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
4290 |
ScriptSetInteger('JETPACK_FUEL_INFINITE', JETPACK_FUEL_INFINITE); |
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
4291 |
ScriptSetInteger('BIRDY_ENERGY_INFINITE', BIRDY_ENERGY_INFINITE); |
13752
110d6c1e817f
Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents:
13747
diff
changeset
|
4292 |
ScriptSetInteger('NO_CURSOR', NoPointX); |
110d6c1e817f
Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents:
13747
diff
changeset
|
4293 |
ScriptSetInteger('MAX_HOG_HEALTH', cMaxHogHealth); |
110d6c1e817f
Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents:
13747
diff
changeset
|
4294 |
ScriptSetInteger('MAX_TURN_TIME', cMaxTurnTime); |
13593
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13582
diff
changeset
|
4295 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4296 |
// 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
|
4297 |
for at:= Low(TGearType) to High(TGearType) do |
3337 | 4298 |
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
|
4299 |
|
4453 | 4300 |
for vgt:= Low(TVisualGearType) to High(TVisualGearType) do |
4301 |
ScriptSetInteger(EnumToStr(vgt), ord(vgt)); |
|
4302 |
||
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4303 |
// 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
|
4304 |
for st:= Low(TSound) to High(TSound) do |
3337 | 4305 |
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
|
4306 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4307 |
// 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
|
4308 |
for am:= Low(TAmmoType) to High(TAmmoType) do |
3337 | 4309 |
ScriptSetInteger(EnumToStr(am), ord(am)); |
3697 | 4310 |
|
9642
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
4311 |
for si:= Low(TStatInfoType) to High(TStatInfoType) do |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
4312 |
ScriptSetInteger(EnumToStr(si), ord(si)); |
8a691e0f117a
use consts for TStatInfo enum
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9291
diff
changeset
|
4313 |
|
3756 | 4314 |
for he:= Low(THogEffect) to High(THogEffect) do |
4315 |
ScriptSetInteger(EnumToStr(he), ord(he)); |
|
4316 |
||
5118 | 4317 |
for cg:= Low(TCapGroup) to High(TCapGroup) do |
4318 |
ScriptSetInteger(EnumToStr(cg), ord(cg)); |
|
4319 |
||
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
|
4320 |
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
|
4321 |
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
|
4322 |
|
10603
bda5c7caf396
switch mapgen to enum. should still try and make sure the values are backwards compatible if possible.
nemo
parents:
10589
diff
changeset
|
4323 |
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
|
4324 |
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
|
4325 |
|
11879
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11849
diff
changeset
|
4326 |
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:
11849
diff
changeset
|
4327 |
ScriptSetInteger(EnumToStr(we), ord(we)); |
c6eafb6f2735
Add WorldEdge to Lua API to expose/change world edge type
Wuzzy <almikes@aol.com>
parents:
11849
diff
changeset
|
4328 |
|
13642
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13627
diff
changeset
|
4329 |
ScriptSetInteger('capcolDefault' , capcolDefault); |
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13627
diff
changeset
|
4330 |
ScriptSetInteger('capcolSetting' , capcolSetting); |
3d14950641a4
Refactor text color variable names, export 2 color values to Lua
Wuzzy <Wuzzy2@mail.ru>
parents:
13627
diff
changeset
|
4331 |
|
10289 | 4332 |
ScriptSetInteger('gstDrowning' , gstDrowning); |
4333 |
ScriptSetInteger('gstHHDriven' , gstHHDriven); |
|
4334 |
ScriptSetInteger('gstMoving' , gstMoving); |
|
4335 |
ScriptSetInteger('gstAttacked' , gstAttacked); |
|
4336 |
ScriptSetInteger('gstAttacking' , gstAttacking); |
|
4337 |
ScriptSetInteger('gstCollision' , gstCollision); |
|
11052 | 4338 |
ScriptSetInteger('gstChooseTarget' , gstChooseTarget); |
10289 | 4339 |
ScriptSetInteger('gstHHJumping' , gstHHJumping); |
4340 |
ScriptSetInteger('gsttmpFlag' , gsttmpFlag); |
|
4341 |
ScriptSetInteger('gstHHThinking' , gstHHThinking); |
|
4342 |
ScriptSetInteger('gstNoDamage' , gstNoDamage); |
|
4343 |
ScriptSetInteger('gstHHHJump' , gstHHHJump); |
|
4344 |
ScriptSetInteger('gstAnimation' , gstAnimation); |
|
4345 |
ScriptSetInteger('gstHHDeath' , gstHHDeath); |
|
4346 |
ScriptSetInteger('gstWinner' , gstWinner); |
|
4347 |
ScriptSetInteger('gstWait' , gstWait); |
|
4348 |
ScriptSetInteger('gstNotKickable' , gstNotKickable); |
|
4349 |
ScriptSetInteger('gstLoser' , gstLoser); |
|
4350 |
ScriptSetInteger('gstHHGone' , gstHHGone); |
|
4351 |
ScriptSetInteger('gstInvisible' , gstInvisible); |
|
11052 | 4352 |
ScriptSetInteger('gstSubmersible' , gstSubmersible); |
4353 |
ScriptSetInteger('gstFrozen' , gstFrozen); |
|
4354 |
ScriptSetInteger('gstNoGravity' , gstNoGravity); |
|
5527 | 4355 |
|
8145
6408c0ba4ba1
Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents:
8077
diff
changeset
|
4356 |
// ai hints |
10289 | 4357 |
ScriptSetInteger('aihUsualProcessing', aihUsualProcessing); |
4358 |
ScriptSetInteger('aihDoesntMatter' , aihDoesntMatter); |
|
7996 | 4359 |
|
13037
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13036
diff
changeset
|
4360 |
// land flags (partial) |
10283 | 4361 |
ScriptSetInteger('lfIndestructible', lfIndestructible); |
10421 | 4362 |
ScriptSetInteger('lfIce' , lfIce); |
4363 |
ScriptSetInteger('lfBouncy' , lfBouncy); |
|
4364 |
||
13037
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13036
diff
changeset
|
4365 |
ScriptSetInteger('lfLandMask' , lfLandMask); |
13469
f1d349a52bc7
Refactor: lfCurrentHog→lfCurHogCrate, lfNotCurrentMask→lfNotCurHogCrate
Wuzzy <Wuzzy2@mail.ru>
parents:
13467
diff
changeset
|
4366 |
ScriptSetInteger('lfCurHogCrate' , lfCurHogCrate); |
13037
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13036
diff
changeset
|
4367 |
ScriptSetInteger('lfHHMask' , lfHHMask); |
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13036
diff
changeset
|
4368 |
ScriptSetInteger('lfNotHHObjMask' , lfNotHHObjMask); |
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13036
diff
changeset
|
4369 |
ScriptSetInteger('lfAllObjMask' , lfAllObjMask); |
3718637c14be
Expose 5 land flags to Lua for use with SetGearCollisionMask
Wuzzy <Wuzzy2@mail.ru>
parents:
13036
diff
changeset
|
4370 |
|
13270 | 4371 |
// explosion constants |
4372 |
ScriptSetInteger('EXPLAutoSound' , EXPLAutoSound); |
|
4373 |
ScriptSetInteger('EXPLNoDamage' , EXPLNoDamage); |
|
4374 |
ScriptSetInteger('EXPLDoNotTouchHH' , EXPLDoNotTouchHH); |
|
4375 |
ScriptSetInteger('EXPLDontDraw' , EXPLDontDraw); |
|
4376 |
ScriptSetInteger('EXPLNoGfx' , EXPLNoGfx); |
|
4377 |
ScriptSetInteger('EXPLPoisoned' , EXPLPoisoned); |
|
4378 |
ScriptSetInteger('EXPLDoNotTouchAny', EXPLDoNotTouchAny); |
|
13604
73b096e1d895
Fix hammer/pickhammer not digging land with gfSolidLand on
Wuzzy <Wuzzy2@mail.ru>
parents:
13597
diff
changeset
|
4379 |
ScriptSetInteger('EXPLForceDraw' , EXPLForceDraw); |
13270 | 4380 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4381 |
// register functions |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
7156
diff
changeset
|
4382 |
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
|
4383 |
lua_register(luaState, _P'RestoreHog', @lc_restorehog); |
13577 | 4384 |
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
|
4385 |
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
|
4386 |
lua_register(luaState, _P'GetCampaignVar', @lc_getcampaignvar); |
14484
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
4387 |
lua_register(luaState, _P'SaveMissionVar', @lc_savemissionvar); |
bd1db668b7c0
Add Lua functions to save/get mission variables
Wuzzy <Wuzzy2@mail.ru>
parents:
14415
diff
changeset
|
4388 |
lua_register(luaState, _P'GetMissionVar', @lc_getmissionvar); |
7072 | 4389 |
lua_register(luaState, _P'band', @lc_band); |
4390 |
lua_register(luaState, _P'bor', @lc_bor); |
|
4391 |
lua_register(luaState, _P'bnot', @lc_bnot); |
|
4392 |
lua_register(luaState, _P'div', @lc_div); |
|
4393 |
lua_register(luaState, _P'GetInputMask', @lc_getinputmask); |
|
4394 |
lua_register(luaState, _P'SetInputMask', @lc_setinputmask); |
|
4395 |
lua_register(luaState, _P'AddGear', @lc_addgear); |
|
10290 | 4396 |
lua_register(luaState, _P'DismissTeam', @lc_dismissteam); |
8366
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
4397 |
lua_register(luaState, _P'EnableGameFlags', @lc_enablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
4398 |
lua_register(luaState, _P'DisableGameFlags', @lc_disablegameflags); |
67c7ba2b82a3
lua API functions to enable or disable game flags
martin_bede
parents:
8228
diff
changeset
|
4399 |
lua_register(luaState, _P'ClearGameFlags', @lc_cleargameflags); |
10035 | 4400 |
lua_register(luaState, _P'GetGameFlag', @lc_getgameflag); |
7072 | 4401 |
lua_register(luaState, _P'DeleteGear', @lc_deletegear); |
4402 |
lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); |
|
4403 |
lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11879
diff
changeset
|
4404 |
lua_register(luaState, _P'GetVisualGearType', @lc_getvisualgeartype); |
7072 | 4405 |
lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); |
4406 |
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
|
4407 |
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
|
4408 |
lua_register(luaState, _P'SetGearValues', @lc_setgearvalues); |
7072 | 4409 |
lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); |
4410 |
lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); |
|
4411 |
lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); |
|
12932 | 4412 |
lua_register(luaState, _P'SpawnSupplyCrate', @lc_spawnsupplycrate); |
7072 | 4413 |
lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); |
4414 |
lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); |
|
4415 |
lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); |
|
4416 |
lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); |
|
12910 | 4417 |
lua_register(luaState, _P'WriteLnToChat', @lc_writelntochat); |
7072 | 4418 |
lua_register(luaState, _P'GetGearType', @lc_getgeartype); |
4419 |
lua_register(luaState, _P'EndGame', @lc_endgame); |
|
12286
b4dde7035fe2
New Lua call: EndTurn to end turn
Wuzzy <almikes@aol.com>
parents:
12162
diff
changeset
|
4420 |
lua_register(luaState, _P'EndTurn', @lc_endturn); |
13340
85644a45e988
New Lua call: Retreat, to force turn into Retreat time
Wuzzy <Wuzzy2@mail.ru>
parents:
13272
diff
changeset
|
4421 |
lua_register(luaState, _P'Retreat', @lc_retreat); |
13170
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13122
diff
changeset
|
4422 |
lua_register(luaState, _P'SkipTurn', @lc_skipturn); |
12536
e54039ea3934
New Lua API function: GetTeamStats, to get team stats
Wuzzy <almikes@aol.com>
parents:
12494
diff
changeset
|
4423 |
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
|
4424 |
lua_register(luaState, _P'SendStat', @lc_sendstat); |
12332
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
4425 |
lua_register(luaState, _P'SendGameResultOff', @lc_sendgameresultoff); |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
4426 |
lua_register(luaState, _P'SendRankingStatsOff', @lc_sendrankingstatsoff); |
657a8d63c99d
Lua API: SendAchevementsStatsOff, SendGameResultOff, SendRankingStatsOff
Wuzzy <almikes@aol.com>
parents:
12316
diff
changeset
|
4427 |
lua_register(luaState, _P'SendAchievementsStatsOff', @lc_sendachievementsstatsoff); |
9180
d19c09670ec8
changed variable and function name
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9179
diff
changeset
|
4428 |
lua_register(luaState, _P'SendHealthStatsOff', @lc_sendhealthstatsoff); |
7072 | 4429 |
lua_register(luaState, _P'FindPlace', @lc_findplace); |
4430 |
lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); |
|
4431 |
lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); |
|
4432 |
lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); |
|
4433 |
lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget); |
|
4434 |
lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity); |
|
4435 |
lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity); |
|
4436 |
lua_register(luaState, _P'ParseCommand', @lc_parsecommand); |
|
4437 |
lua_register(luaState, _P'ShowMission', @lc_showmission); |
|
4438 |
lua_register(luaState, _P'HideMission', @lc_hidemission); |
|
11939
c7ec309cd685
Add Lua API function SetAmmoTexts (see issue 82)
Wuzzy <almikes@aol.com>
parents:
11880
diff
changeset
|
4439 |
lua_register(luaState, _P'SetAmmoTexts', @lc_setammotexts); |
11941
7ece39a537bd
Add SetAmmoDescriptionAppendix to Lua API, see issue 82
Wuzzy <almikes@aol.com>
parents:
11939
diff
changeset
|
4440 |
lua_register(luaState, _P'SetAmmoDescriptionAppendix', @lc_setammodescriptionappendix); |
7072 | 4441 |
lua_register(luaState, _P'AddCaption', @lc_addcaption); |
4442 |
lua_register(luaState, _P'SetAmmo', @lc_setammo); |
|
13456
794dcf69a5aa
New Lua API function: GetAmmo, to get ammo config
Wuzzy <Wuzzy2@mail.ru>
parents:
13434
diff
changeset
|
4443 |
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
|
4444 |
lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay); |
7072 | 4445 |
lua_register(luaState, _P'PlaySound', @lc_playsound); |
13997
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
4446 |
lua_register(luaState, _P'PlayMusicSound', @lc_playmusicsound); |
2828ec67c47c
Add PlayMusicSound/StopMusicSound to Lua API
Wuzzy <Wuzzy2@mail.ru>
parents:
13975
diff
changeset
|
4447 |
lua_register(luaState, _P'StopMusicSound', @lc_stopmusicsound); |
13121
de07c8423beb
Lua API: Add SetSoundMask to disable playing certain sounds
Wuzzy <Wuzzy2@mail.ru>
parents:
13088
diff
changeset
|
4448 |
lua_register(luaState, _P'SetSoundMask', @lc_setsoundmask); |
12931 | 4449 |
lua_register(luaState, _P'GetTeamName', @lc_getteamname); |
13020
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
4450 |
lua_register(luaState, _P'GetTeamIndex', @lc_getteamindex); |
d1e7f2420f00
Lua API: Add functons: GetTeamIndex and GetTeamClan
Wuzzy <Wuzzy2@mail.ru>
parents:
13018
diff
changeset
|
4451 |
lua_register(luaState, _P'GetTeamClan', @lc_getteamclan); |
7072 | 4452 |
lua_register(luaState, _P'AddTeam', @lc_addteam); |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
4453 |
lua_register(luaState, _P'AddMissionTeam', @lc_addmissionteam); |
13018
0248cf0da834
Add SetTeamLabel to Lua API, can set arbitrary string as team label
Wuzzy <Wuzzy2@mail.ru>
parents:
12947
diff
changeset
|
4454 |
lua_register(luaState, _P'SetTeamLabel', @lc_setteamlabel); |
14632
3cf7799e04b5
Add SetTeamPassive. Passive teams are treated like frozen teams
Wuzzy <Wuzzy2@mail.ru>
parents:
14619
diff
changeset
|
4455 |
lua_register(luaState, _P'SetTeamPassive', @lc_setteampassive); |
7072 | 4456 |
lua_register(luaState, _P'AddHog', @lc_addhog); |
14498
4b678aad50e9
Lua API: Add functions to add team selected in campaign/mission page
Wuzzy <Wuzzy2@mail.ru>
parents:
14484
diff
changeset
|
4457 |
lua_register(luaState, _P'AddMissionHog', @lc_addmissionhog); |
7072 | 4458 |
lua_register(luaState, _P'AddAmmo', @lc_addammo); |
4459 |
lua_register(luaState, _P'GetAmmoCount', @lc_getammocount); |
|
12939
0112ef349ddc
Lua API: Add HealHog to heal hog with visual effects + message
Wuzzy <Wuzzy2@mail.ru>
parents:
12932
diff
changeset
|
4460 |
lua_register(luaState, _P'HealHog', @lc_healhog); |
7072 | 4461 |
lua_register(luaState, _P'SetHealth', @lc_sethealth); |
4462 |
lua_register(luaState, _P'GetHealth', @lc_gethealth); |
|
4463 |
lua_register(luaState, _P'SetEffect', @lc_seteffect); |
|
4464 |
lua_register(luaState, _P'GetEffect', @lc_geteffect); |
|
4465 |
lua_register(luaState, _P'GetHogClan', @lc_gethogclan); |
|
4466 |
lua_register(luaState, _P'GetClanColor', @lc_getclancolor); |
|
4467 |
lua_register(luaState, _P'SetClanColor', @lc_setclancolor); |
|
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
4468 |
lua_register(luaState, _P'GetHogVoicepack', @lc_gethogvoicepack); |
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
4469 |
lua_register(luaState, _P'GetHogFlag', @lc_gethogflag); |
12046 | 4470 |
lua_register(luaState, _P'GetHogFort', @lc_gethogfort); |
11029
854f30498a98
GetHogVoicepack,GetHogFlag,GetHogGrave
mikade <redgrinner@gmail.com>
parents:
11022
diff
changeset
|
4471 |
lua_register(luaState, _P'GetHogGrave', @lc_gethoggrave); |
11847 | 4472 |
lua_register(luaState, _P'IsHogLocal', @lc_ishoglocal); |
7072 | 4473 |
lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname); |
9788 | 4474 |
lua_register(luaState, _P'SetHogTeamName', @lc_sethogteamname); |
7072 | 4475 |
lua_register(luaState, _P'GetHogName', @lc_gethogname); |
4476 |
lua_register(luaState, _P'SetHogName', @lc_sethogname); |
|
4477 |
lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel); |
|
4478 |
lua_register(luaState, _P'SetHogLevel', @lc_sethoglevel); |
|
4479 |
lua_register(luaState, _P'GetX', @lc_getx); |
|
4480 |
lua_register(luaState, _P'GetY', @lc_gety); |
|
4481 |
lua_register(luaState, _P'CopyPV', @lc_copypv); |
|
4482 |
lua_register(luaState, _P'FollowGear', @lc_followgear); |
|
4483 |
lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear); |
|
4484 |
lua_register(luaState, _P'SetState', @lc_setstate); |
|
4485 |
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
|
4486 |
lua_register(luaState, _P'GetTag', @lc_gettag); |
7072 | 4487 |
lua_register(luaState, _P'SetTag', @lc_settag); |
4488 |
lua_register(luaState, _P'SetTimer', @lc_settimer); |
|
4489 |
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
|
4490 |
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
|
4491 |
lua_register(luaState, _P'GetFlightTime', @lc_getflighttime); |
7072 | 4492 |
lua_register(luaState, _P'SetZoom', @lc_setzoom); |
4493 |
lua_register(luaState, _P'GetZoom', @lc_getzoom); |
|
4494 |
lua_register(luaState, _P'HogSay', @lc_hogsay); |
|
4495 |
lua_register(luaState, _P'SwitchHog', @lc_switchhog); |
|
13378
c53530142442
Lua API: Add EnableSwitchHog to manually enable hog switching
Wuzzy <Wuzzy2@mail.ru>
parents:
13373
diff
changeset
|
4496 |
lua_register(luaState, _P'EnableSwitchHog', @lc_enableswitchhog); |
7072 | 4497 |
lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); |
4498 |
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
|
4499 |
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
|
4500 |
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
|
4501 |
lua_register(luaState, _P'SetGearFriction', @lc_setgearfriction); |
7072 | 4502 |
lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); |
4503 |
lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); |
|
4504 |
lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); |
|
4505 |
lua_register(luaState, _P'GetGearPos', @lc_getgearpos); |
|
4506 |
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
|
4507 |
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
|
4508 |
lua_register(luaState, _P'SetGearCollisionMask', @lc_setgearcollisionmask); |
7072 | 4509 |
lua_register(luaState, _P'GetRandom', @lc_getrandom); |
4510 |
lua_register(luaState, _P'SetWind', @lc_setwind); |
|
12930
330b6c353093
Lua API: Add GetWind function to get current wind
Wuzzy <Wuzzy2@mail.ru>
parents:
12929
diff
changeset
|
4511 |
lua_register(luaState, _P'GetWind', @lc_getwind); |
7072 | 4512 |
lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
4513 |
lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
|
4514 |
lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
|
10901 | 4515 |
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
|
4516 |
lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
7072 | 4517 |
lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
12090 | 4518 |
lua_register(luaState, _P'PlaceRubber', @lc_placerubber); |
7072 | 4519 |
lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
4520 |
lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
|
9815 | 4521 |
lua_register(luaState, _P'GetGravity', @lc_getgravity); |
4522 |
lua_register(luaState, _P'SetGravity', @lc_setgravity); |
|
9914 | 4523 |
lua_register(luaState, _P'SetWaterLine', @lc_setwaterline); |
10291 | 4524 |
lua_register(luaState, _P'SetNextWeapon', @lc_setnextweapon); |
10289 | 4525 |
lua_register(luaState, _P'SetWeapon', @lc_setweapon); |
11520 | 4526 |
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
|
4527 |
lua_register(luaState, _P'SetMaxBuildDistance', @lc_setmaxbuilddistance); |
11846 | 4528 |
lua_register(luaState, _P'GetAmmoName', @lc_getammoname); |
13371
da913fc1d350
Lua API: GetAmmoTimer, to get the player-set timer for an ammo
Wuzzy <Wuzzy2@mail.ru>
parents:
13370
diff
changeset
|
4529 |
lua_register(luaState, _P'GetAmmoTimer', @lc_getammotimer); |
12929
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
4530 |
lua_register(luaState, _P'SetVampiric', @lc_setvampiric); |
13576
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
4531 |
lua_register(luaState, _P'GetVampiric', @lc_getvampiric); |
12929
1d7d7d21914a
Lua API: Add SetVampiric and SetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
12910
diff
changeset
|
4532 |
lua_register(luaState, _P'SetLaserSight', @lc_setlasersight); |
13576
e5761b37e99c
Lua: Add GetVampiric, GetLaserSight
Wuzzy <Wuzzy2@mail.ru>
parents:
13469
diff
changeset
|
4533 |
lua_register(luaState, _P'GetLaserSight', @lc_getlasersight); |
13270 | 4534 |
lua_register(luaState, _P'Explode', @lc_explode); |
13741
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
4535 |
lua_register(luaState, _P'SetTurnTimeLeft', @lc_setturntimeleft); |
b3b55b03d499
Lua API: Add SetTurnTimeLeft, SetReadyTimeLeft
Wuzzy <Wuzzy2@mail.ru>
parents:
13728
diff
changeset
|
4536 |
lua_register(luaState, _P'SetReadyTimeLeft', @lc_setreadytimeleft); |
14415
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
4537 |
lua_register(luaState, _P'SetTurnTimePaused', @lc_setturntimepaused); |
d670e4efe1ed
Lua API: SetTurnTimePaused/GetTurnTimePaused
Wuzzy <Wuzzy2@mail.ru>
parents:
14414
diff
changeset
|
4538 |
lua_register(luaState, _P'GetTurnTimePaused', @lc_getturntimepaused); |
10611 | 4539 |
// drawn map functions |
4540 |
lua_register(luaState, _P'AddPoint', @lc_addPoint); |
|
4541 |
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
|
4542 |
|
11066 | 4543 |
lua_register(luaState, _P'SetGearAIHints', @lc_setgearaihints); |
8043 | 4544 |
lua_register(luaState, _P'HedgewarsScriptLoad', @lc_hedgewarsscriptload); |
9397 | 4545 |
lua_register(luaState, _P'DeclareAchievement', @lc_declareachievement); |
11569 | 4546 |
lua_register(luaState, _P'StartGhostPoints', @lc_startghostpoints); |
4547 |
lua_register(luaState, _P'DumpPoint', @lc_dumppoint); |
|
7996 | 4548 |
|
10618 | 4549 |
ScriptSetInteger('TEST_SUCCESSFUL' , HaltTestSuccess); |
4550 |
ScriptSetInteger('TEST_FAILED' , HaltTestFailed); |
|
4551 |
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
|
4552 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4553 |
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
|
4554 |
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
|
4555 |
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
|
4556 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4557 |
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
|
4558 |
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
|
4559 |
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
|
4560 |
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
|
4561 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4562 |
{$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
|
4563 |
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
|
4564 |
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
|
4565 |
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
|
4566 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4567 |
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
|
4568 |
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
|
4569 |
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
|
4570 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4571 |
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
|
4572 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4573 |
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
|
4574 |
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
|
4575 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4576 |
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
|
4577 |
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
|
4578 |
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
|
4579 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4580 |
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
|
4581 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4582 |
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
|
4583 |
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
|
4584 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4585 |
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
|
4586 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4587 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4588 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4589 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4590 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4591 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4592 |
par4:= par4; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4593 |
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
|
4594 |
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
|
4595 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4596 |
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
|
4597 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4598 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4599 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4600 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4601 |
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
|
4602 |
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
|
4603 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4604 |
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
|
4605 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4606 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4607 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4608 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4609 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4610 |
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
|
4611 |
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
|
4612 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4613 |
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
|
4614 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4615 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4616 |
fname:= fname; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4617 |
par1:= par1; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4618 |
par2:= par2; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4619 |
par3:= par3; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4620 |
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
|
4621 |
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
|
4622 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4623 |
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
|
4624 |
begin |
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4625 |
fname:= fname; // avoid hint |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4626 |
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
|
4627 |
end; |
7805 | 4628 |
(* |
5410 | 4629 |
function ParseCommandOverride(key, value : shortstring) : shortstring; |
4630 |
begin |
|
7030
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4631 |
// avoid hints |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4632 |
key:= key; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4633 |
value:= value; |
09984acadece
invert LUA symbol meaning and avoid hints when compiling without it
koda
parents:
7010
diff
changeset
|
4634 |
ParseCommandOverride:= '' |
5410 | 4635 |
end; |
7805 | 4636 |
*) |
5410 | 4637 |
|
6430 | 4638 |
procedure ScriptOnScreenResize; |
4639 |
begin |
|
4640 |
end; |
|
4641 |
||
11678
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4642 |
procedure ScriptOnPreviewInit; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4643 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4644 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4645 |
|
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4646 |
procedure ScriptSetInteger(name : shortstring; value : LongInt); |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4647 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4648 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4649 |
|
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4650 |
procedure ScriptSetString(name : shortstring; value : shortstring); |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4651 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4652 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4653 |
|
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4654 |
procedure LuaParseString(s : ShortString); |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4655 |
begin |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4656 |
end; |
b76b7372a2a6
Add missing functions to fully disable lua at compile time
koda
parents:
11677
diff
changeset
|
4657 |
|
3043
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4658 |
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
|
4659 |
begin |
10611 | 4660 |
PointsBuffer:= ''; |
13216
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
4661 |
PrevCursorX:= NoPointX; |
95311e220eb6
Lua API: Fix not updating CursorX/CursorY properly when moving cursor at screen border
Wuzzy <Wuzzy2@mail.ru>
parents:
13170
diff
changeset
|
4662 |
PrevCursorY:= NoPointX; |
13743
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4663 |
isPendingTurnTimeLeft:= false; |
e8f26bc793d9
Add deprecation warning for setting TurnTimeLeft/ReadyTimeLeft directly, fix SetTurnTimeLeft/SetReadyTimeLeft not setting vars reliably
Wuzzy <Wuzzy2@mail.ru>
parents:
13741
diff
changeset
|
4664 |
isPendingReadyTimeLeft:= 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
|
4665 |
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
|
4666 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4667 |
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
|
4668 |
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
|
4669 |
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
|
4670 |
|
3acdb4dac6eb
Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents:
3038
diff
changeset
|
4671 |
{$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
|
4672 |
end. |