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