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