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