hedgewars/uScript.pas
author Stepan777 <stepik-777@mail.ru>
Thu, 09 Aug 2012 19:52:21 +0400
changeset 7534 ccb9c2906160
parent 7517 f287f00063e8
child 7546 b50556f2a0e8
permissions -rw-r--r--
fix FindFFMPEG
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3043
3acdb4dac6eb 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
6700
e04da46ee43c the most important commit of the year
koda
parents: 6580
diff changeset
     3
 * Copyright (c) 2004-2012 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3acdb4dac6eb 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
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    22
(*
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    23
 * This unit defines, implements and registers functions and
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    24
 * variables/constants bindings for usage in Lua scripts.
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    25
 *
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    26
 * Please keep http://code.google.com/p/hedgewars/wiki/LuaAPI up to date!
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    27
 *
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    28
 * Note: If you add a new function, make sure to test if _all_ parameters
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    29
 *       work as intended! (Especially conversions errors can sneak in
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    30
 *       unnoticed and render the parameter useless!)
84267f79879b comments
sheepluva
parents: 5120
diff changeset
    31
 *)
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    32
interface
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    33
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    34
procedure ScriptPrintStack;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    35
procedure ScriptClearStack;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    36
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    37
procedure ScriptLoad(name : shortstring);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    38
procedure ScriptOnGameInit;
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
    39
procedure ScriptOnScreenResize;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    40
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    41
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
    42
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
    43
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
    44
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
    45
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
    46
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
    47
5410
8e7787065e2d small fix to have LUA_DISABLED working again
Xeli
parents: 5366
diff changeset
    48
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
    49
function ParseCommandOverride(key, value : shortstring) : shortstring;
5577
Xeli
parents: 5548 5554
diff changeset
    50
3043
3acdb4dac6eb 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
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
    52
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
    53
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    54
implementation
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
    55
{$IFDEF USE_LUA_SCRIPT}
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6430
diff changeset
    56
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
    57
    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
    58
    uConsts,
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
    59
    uVisualGears,
6543
697e9b730189 Fix build
unc0rr
parents: 6529
diff changeset
    60
    uGears,
6468
da1e7fe7cff7 Start refactoring uGears. Breaks build.
unc0rr
parents: 6453
diff changeset
    61
    uGearsList,
6543
697e9b730189 Fix build
unc0rr
parents: 6529
diff changeset
    62
    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
    63
    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
    64
    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
    65
    uAmmos,
6763
8a06161ede49 Recount team health if modifying hedgehog health
nemo
parents: 6752
diff changeset
    66
    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
    67
    uSound,
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
    68
    uChat,
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
    69
    uStats,
4875
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
    70
    uStore,
4357
a1fcfc341a52 Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents: 4319
diff changeset
    71
    uRandom,
4359
83ef50815535 Move variables from uMisc to uVariables
unC0Rr
parents: 4357
diff changeset
    72
    uTypes,
4373
fe0e3903bb9e Introduce uCommands.pas
unC0Rr
parents: 4372
diff changeset
    73
    uVariables,
4374
bcefeeabaa33 Move some stuff from uMisc to uUtils
unC0Rr
parents: 4373
diff changeset
    74
    uCommands,
4377
43945842da0c Haven't found a better place than uIO for OutError
unC0Rr
parents: 4374
diff changeset
    75
    uUtils,
4403
unc0rr
parents: 4399
diff changeset
    76
    uCaptions,
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
    77
    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
    78
    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
    79
    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
    80
    uTextures,
4985
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
    81
    uLandGraphics,
5243
f2e31a7f953a check alternate script loading path
nemo
parents: 5238
diff changeset
    82
    SDLh,
7063
a0326412e96a sysutils -> SysUtils
unc0rr
parents: 7030
diff changeset
    83
    SysUtils; 
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
    84
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    85
var luaState : Plua_State;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    86
    ScriptAmmoLoadout : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    87
    ScriptAmmoProbability : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    88
    ScriptAmmoDelay : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    89
    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
    90
    ScriptLoaded : boolean;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
    91
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    92
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
    93
procedure ScriptApplyAmmoStore; forward;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    94
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay, reinforcement: 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
    95
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    96
procedure LuaError(s: shortstring);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    97
begin
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    98
    WriteLnToConsole(s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    99
    AddChatString(#5 + s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   100
end;
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   101
3043
3acdb4dac6eb 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
// wrapped calls //
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   103
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   104
// 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
   105
// 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
   106
// where L contains the state, returns the number of return values on the stack
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   107
// call lua_gettop(L) to receive number of parameters passed
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   108
4483
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   109
function lc_band(L: PLua_State): LongInt; Cdecl;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   110
begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   111
    if lua_gettop(L) <> 2 then 
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   112
        begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   113
        LuaError('Lua: Wrong number of parameters passed to band!');
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   114
        lua_pushnil(L);
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   115
        end
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   116
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   117
        lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1));
4483
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   118
    lc_band := 1;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   119
end;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   120
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   121
function lc_bor(L: PLua_State): LongInt; Cdecl;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   122
begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   123
    if lua_gettop(L) <> 2 then 
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   124
        begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   125
        LuaError('Lua: Wrong number of parameters passed to bor!');
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   126
        lua_pushnil(L);
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   127
        end
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   128
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   129
        lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1));
4483
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   130
    lc_bor := 1;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   131
end;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   132
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   133
function lc_bnot(L: PLua_State): LongInt; Cdecl;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   134
begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   135
    if lua_gettop(L) <> 1 then 
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   136
        begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   137
        LuaError('Lua: Wrong number of parameters passed to bnot!');
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   138
        lua_pushnil(L);
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   139
        end
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   140
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   141
        lua_pushinteger(L, not lua_tointeger(L, 1));
4483
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   142
    lc_bnot := 1;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   143
end;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   144
6764
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   145
function lc_div(L: PLua_State): LongInt; Cdecl;
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   146
begin
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   147
    if lua_gettop(L) <> 2 then 
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   148
        begin
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   149
        LuaError('Lua: Wrong number of parameters passed to div!');
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   150
        lua_pushnil(L);
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   151
        end
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   152
    else
7135
4d863aadd0b2 Add onGameTick20 to try and encourage lua to be a bit more efficient. Rewrite Space Invasion to use it. Top speed of aliens is 25% higher now, although that could be changed, I kinda liked it. Change parameter order of div().
nemo
parents: 7072
diff changeset
   153
        lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2));
6764
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   154
    lc_div := 1;
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   155
end;
e56ff0231540 Add div to allow safe integer division from lua
nemo
parents: 6763
diff changeset
   156
4523
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   157
function lc_getinputmask(L : Plua_State) : LongInt; Cdecl;
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   158
begin
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   159
    if lua_gettop(L) <> 0 then
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   160
        LuaError('Lua: Wrong number of parameters passed to GetInputMask!')
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   161
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   162
        lua_pushinteger(L, InputMask);
4523
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   163
    lc_getinputmask:= 1
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   164
end;
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   165
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
   166
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
   167
begin
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
   168
    if lua_gettop(L) <> 1 then
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
   169
        LuaError('Lua: Wrong number of parameters passed to SetInputMask!')
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   170
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   171
        InputMask:= lua_tointeger(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
   172
    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
   173
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
   174
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   175
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
   176
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
   177
    if lua_gettop(L) = 1 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
   178
        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
   179
        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
   180
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   181
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   182
        LuaError('Lua: Wrong number of parameters passed to WriteLnToConsole!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   183
    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
   184
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   185
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   186
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
   187
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
   188
    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
   189
    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
   190
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
   191
    if lua_gettop(L) = 1 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
   192
        begin
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
   193
        t:= lua_tolstring(L,1,@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
   194
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
   195
        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
   196
        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
   197
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
   198
        ParseCommand(s, true);
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
   199
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   200
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   201
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   202
        LuaError('Lua: Wrong number of parameters passed to ParseCommand!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   203
    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
   204
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   205
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   206
function lc_showmission(L : Plua_State) : LongInt; Cdecl;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   207
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
   208
    if lua_gettop(L) = 5 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
   209
        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
   210
        ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   211
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   212
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   213
        LuaError('Lua: Wrong number of parameters passed to ShowMission!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   214
    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
   215
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   216
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   217
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
   218
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   219
    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
   220
    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
   221
    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
   222
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   223
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   224
function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   225
begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   226
    if lua_gettop(L) = 1 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
   227
        AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage)
5118
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
   228
    else if lua_gettop(L) = 3 then
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   229
        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
   230
        AddCaption(lua_tostring(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3)));
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   231
        end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   232
    else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   233
        LuaError('Lua: Wrong number of parameters passed to AddCaption!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   234
    lc_addcaption:= 0;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   235
end;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   236
3848
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   237
function lc_campaignlock(L : Plua_State) : LongInt; Cdecl;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   238
begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   239
    if lua_gettop(L) = 1 then
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   240
        begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   241
        // to be done
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   242
        end
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   243
    else
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   244
        LuaError('Lua: Wrong number of parameters passed to CampaignLock!');
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   245
    lc_campaignlock:= 0;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   246
end;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   247
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   248
function lc_campaignunlock(L : Plua_State) : LongInt; Cdecl;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   249
begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   250
    if lua_gettop(L) = 1 then
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   251
        begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   252
        // to be done
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   253
        end
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   254
    else
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   255
        LuaError('Lua: Wrong number of parameters passed to CampaignUnlock!');
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   256
    lc_campaignunlock:= 0;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   257
end;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   258
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
   259
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
   260
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
   261
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   262
    if lua_gettop(L) <> 4 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   263
        begin
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
   264
        LuaError('Lua: Wrong number of parameters passed to SpawnFakeHealthCrate!');
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
   265
        lua_pushnil(L);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   266
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   267
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   268
        begin
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
   269
        gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(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
   270
        HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
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
   271
        lua_pushinteger(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
   272
        end;
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
   273
    lc_spawnfakehealthcrate := 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
   274
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
   275
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
   276
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
   277
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
   278
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   279
    if lua_gettop(L) <> 4 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   280
        begin
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
   281
        LuaError('Lua: Wrong number of parameters passed to SpawnFakeAmmoCrate!');
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
   282
        lua_pushnil(L);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   283
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   284
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   285
        begin
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
   286
        gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(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
   287
        AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
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
   288
        lua_pushinteger(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
   289
        end;
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
   290
    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
   291
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
   292
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
   293
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
   294
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
   295
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   296
    if lua_gettop(L) <> 4 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   297
        begin
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
   298
        LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!');
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
   299
        lua_pushnil(L);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   300
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   301
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   302
        begin  
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
   303
        gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(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
   304
        UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4));
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
   305
        lua_pushinteger(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
   306
        end;
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
   307
    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
   308
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
   309
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   310
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
   311
var gear: PGear;
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
   312
var health: LongInt;
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   313
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   314
    if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   315
        begin
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   316
        LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!');
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   317
        lua_pushnil(L);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   318
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   319
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   320
        begin
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   321
        if lua_gettop(L) = 3 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   322
            health:= lua_tointeger(L, 3)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   323
        else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   324
            health:= cHealthCaseAmount;
7337
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   325
        gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(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
   326
        if gear <> nil then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   327
            lua_pushinteger(L, gear^.uid)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   328
        else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   329
            lua_pushnil(L);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   330
        end;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   331
    lc_spawnhealthcrate := 1;        
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   332
end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   333
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   334
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
   335
var gear: PGear;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   336
begin
7337
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   337
    if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   338
        begin
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   339
        LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!');
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   340
        lua_pushnil(L);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   341
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   342
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   343
        begin
7339
5984b749ad9b free up power for use by script
nemo
parents: 7337
diff changeset
   344
        if (lua_gettop(L) = 3) then 
7337
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   345
             gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0)
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   346
        else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(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
   347
        if gear <> nil then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   348
            lua_pushinteger(L, gear^.uid)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   349
        else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   350
            lua_pushnil(L);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   351
        end;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   352
    lc_spawnammocrate := 1;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   353
end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   354
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   355
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
   356
var gear: PGear;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   357
begin
7337
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   358
    if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   359
        begin
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   360
        LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!');
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   361
        lua_pushnil(L);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   362
        end
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   363
    else
7337
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   364
        begin
7339
5984b749ad9b free up power for use by script
nemo
parents: 7337
diff changeset
   365
        if (lua_gettop(L) = 3) then
7337
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   366
             gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0)
c224cd2d32f3 Allow script to set number of ammo in a crate. untested.
nemo
parents: 7307
diff changeset
   367
        else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(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
   368
        if gear <> nil then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   369
            lua_pushinteger(L, gear^.uid)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   370
        else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   371
            lua_pushnil(L);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   372
       end;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   373
    lc_spawnutilitycrate := 1;
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   374
end;
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   375
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   376
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
   377
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
   378
    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
   379
    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
   380
    gt: TGearType;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   381
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
   382
    if lua_gettop(L) <> 7 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
   383
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   384
        LuaError('Lua: Wrong number of parameters passed to AddGear!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   385
        lua_pushnil(L); // return value on stack (nil)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   386
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   387
    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
   388
        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
   389
        x:= lua_tointeger(L, 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
   390
        y:= lua_tointeger(L, 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
   391
        gt:= TGearType(lua_tointeger(L, 3));
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   392
        s:= lua_tointeger(L, 4);
5074
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
   393
        dx:= int2hwFloat(lua_tointeger(L, 5)) / 1000000;
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
   394
        dy:= int2hwFloat(lua_tointeger(L, 6)) / 1000000;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   395
        t:= lua_tointeger(L, 7);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   396
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   397
        gear:= AddGear(x, y, gt, s, dx, dy, t);
4780
8571151411b3 add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents: 4767
diff changeset
   398
        lastGearByUID:= gear;
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   399
        lua_pushinteger(L, gear^.uid)
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   400
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   401
    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
   402
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   403
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
   404
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
   405
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
   406
begin
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
   407
    if lua_gettop(L) <> 1 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
   408
        begin
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
   409
        LuaError('Lua: Wrong number of parameters passed to DeleteGear!');
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
   410
        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
   411
    else
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
   412
        begin
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
   413
        gear:= GearByUID(lua_tointeger(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
   414
        if gear <> nil then
7517
f287f00063e8 Allow scripting to delete gears
nemo
parents: 7426
diff changeset
   415
            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
   416
        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
   417
    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
   418
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
   419
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
   420
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
   421
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
   422
    x, y, s: LongInt;
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
   423
    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
   424
    vgt: TVisualGearType;
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
   425
begin
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
   426
    if lua_gettop(L) <> 5 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
   427
        begin
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
   428
        LuaError('Lua: Wrong number of parameters passed to AddVisualGear!');
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
   429
        lua_pushnil(L); // return value on stack (nil)
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
   430
        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
   431
    else
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
   432
        begin
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
   433
        x:= lua_tointeger(L, 1);
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
   434
        y:= lua_tointeger(L, 2);
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
   435
        vgt:= TVisualGearType(lua_tointeger(L, 3));
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
   436
        s:= lua_tointeger(L, 4);
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
   437
        c:= lua_toboolean(L, 5);
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
   438
4780
8571151411b3 add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents: 4767
diff changeset
   439
        vg:= AddVisualGear(x, y, vgt, s, c);
8571151411b3 add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents: 4767
diff changeset
   440
        if vg <> nil then 
8571151411b3 add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents: 4767
diff changeset
   441
            begin
8571151411b3 add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents: 4767
diff changeset
   442
            lastVisualGearByUID:= vg;
8571151411b3 add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents: 4767
diff changeset
   443
            lua_pushinteger(L, vg^.uid)
8571151411b3 add a couple of variables to speed up UID lookups. Based on the assumption new visual gears and gears will tend to be at the end of the list. Set them on successful lookup or script gear creation, clear on delete. Oh also pick up a couple of TrevInc's translation changes
nemo
parents: 4767
diff changeset
   444
            end
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   445
        else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   446
            lua_pushinteger(L, 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
   447
        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
   448
    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
   449
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
   450
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
   451
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
   452
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
   453
begin
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
   454
    if lua_gettop(L) <> 1 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
   455
        begin
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
   456
        LuaError('Lua: Wrong number of parameters passed to DeleteVisualGear!');
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
   457
        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
   458
    else
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
   459
        begin
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
   460
        vg:= VisualGearByUID(lua_tointeger(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
   461
        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
   462
            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
   463
        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
   464
    lc_deletevisualgear:= 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
   465
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
   466
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
   467
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
   468
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
   469
begin
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
   470
    if lua_gettop(L) <> 1 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
   471
        begin
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
   472
        LuaError('Lua: Wrong number of parameters passed to GetVisualGearValues!');
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
   473
        lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L);
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
   474
        lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L)
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
   475
        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
   476
    else
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
   477
        begin
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
   478
        vg:= VisualGearByUID(lua_tointeger(L, 1));
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
   479
        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
   480
            begin
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
   481
            lua_pushinteger(L, round(vg^.X));
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
   482
            lua_pushinteger(L, round(vg^.Y));
5075
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   483
            lua_pushnumber(L, vg^.dX);
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   484
            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
   485
            lua_pushnumber(L, vg^.Angle);
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
   486
            lua_pushinteger(L, vg^.Frame);
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
   487
            lua_pushinteger(L, vg^.FrameTicks);
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
   488
            lua_pushinteger(L, vg^.State);
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
   489
            lua_pushinteger(L, vg^.Timer);
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
   490
            lua_pushinteger(L, vg^.Tint);
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
   491
            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
   492
        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
   493
            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
   494
            lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L);
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
   495
            lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); lua_pushnil(L)
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
   496
            end
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
   497
        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
   498
    lc_getvisualgearvalues:= 10;
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
   499
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
   500
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
   501
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
   502
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
   503
begin
4450
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   504
    if lua_gettop(L) <> 11 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
   505
        begin
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
   506
        LuaError('Lua: Wrong number of parameters passed to SetVisualGearValues!');
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
   507
        lua_pushnil(L); // return value on stack (nil)
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
   508
        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
   509
    else
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
   510
        begin
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
   511
        vg:= VisualGearByUID(lua_tointeger(L, 1));
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
   512
        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
   513
            begin
4450
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   514
            vg^.X:= lua_tointeger(L, 2);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   515
            vg^.Y:= lua_tointeger(L, 3);
5075
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   516
            vg^.dX:= lua_tonumber(L, 4);
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   517
            vg^.dY:= lua_tonumber(L, 5);
4450
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   518
            vg^.Angle:= lua_tonumber(L, 6);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   519
            vg^.Frame:= lua_tointeger(L, 7);
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   520
            if lua_tointeger(L, 8) <> 0 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   521
                vg^.FrameTicks:= lua_tointeger(L, 8);  // find a better way to do this. maybe need to break all these up.
4450
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   522
            vg^.State:= lua_tointeger(L, 9);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   523
            vg^.Timer:= lua_tointeger(L, 10);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   524
            vg^.Tint:= lua_tointeger(L, 11);
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
   525
            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
   526
        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
   527
    lc_setvisualgearvalues:= 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
   528
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
   529
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   530
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   531
begin
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   532
    if lua_gettop(L) <> 0 then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   533
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   534
        LuaError('Lua: Wrong number of parameters passed to GetFollowGear!');
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   535
        lua_pushnil(L); // return value on stack (nil)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   536
        end
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   537
    else
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   538
        if FollowGear = nil then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   539
            lua_pushnil(L)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   540
        else
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   541
            lua_pushinteger(L, FollowGear^.uid);
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   542
    lc_getfollowgear:= 1; // 1 return value
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   543
end;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   544
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   545
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
   546
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
   547
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
   548
    if lua_gettop(L) <> 1 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
   549
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   550
        LuaError('Lua: Wrong number of parameters passed to GetGearType!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   551
        lua_pushnil(L); // return value on stack (nil)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   552
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   553
    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
   554
        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
   555
        gear:= GearByUID(lua_tointeger(L, 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
   556
        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
   557
            lua_pushinteger(L, ord(gear^.Kind))
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   558
        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
   559
            lua_pushnil(L);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   560
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   561
    lc_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
   562
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   563
3892
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   564
function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   565
var gear : PGear;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   566
begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   567
    if lua_gettop(L) <> 1 then
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   568
        begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   569
        LuaError('Lua: Wrong number of parameters passed to GetGearMessage!');
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   570
        lua_pushnil(L); // return value on stack (nil)
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   571
        end
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   572
    else
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   573
        begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   574
        gear:= GearByUID(lua_tointeger(L, 1));
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   575
        if gear <> nil then
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   576
            lua_pushinteger(L, gear^.message)
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   577
        else
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   578
            lua_pushnil(L);
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   579
        end;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   580
    lc_getgearmessage:= 1
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   581
end;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   582
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
   583
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
   584
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
   585
begin
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
   586
    if lua_gettop(L) <> 1 then
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
   587
        begin
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
   588
        LuaError('Lua: Wrong number of parameters passed to GetGearElasticity!');
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
   589
        lua_pushnil(L); // return value on stack (nil)
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
   590
        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
   591
    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
   592
        begin
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
   593
        gear:= GearByUID(lua_tointeger(L, 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
   594
        if gear <> nil then
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
   595
            lua_pushinteger(L, hwRound(gear^.elasticity * _10000))
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
   596
        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
   597
            lua_pushnil(L);
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
   598
        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
   599
    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
   600
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
   601
3896
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   602
function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   603
var gear : PGear;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   604
begin
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   605
    if lua_gettop(L) <> 2 then
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   606
        LuaError('Lua: Wrong number of parameters passed to SetGearMessage!')
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   607
    else
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   608
        begin
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   609
        gear:= GearByUID(lua_tointeger(L, 1));
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   610
        if gear <> nil then
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   611
            gear^.message:= lua_tointeger(L, 2);
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   612
        end;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   613
    lc_setgearmessage:= 0
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   614
end;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   615
6523
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   616
function lc_getgearpos(L : Plua_State) : LongInt; Cdecl;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   617
var gear : PGear;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   618
begin
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   619
    if lua_gettop(L) <> 1 then
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   620
        begin
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   621
        LuaError('Lua: Wrong number of parameters passed to GetGearPos!');
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   622
        lua_pushnil(L); // return value on stack (nil)
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   623
        end
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   624
    else
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   625
        begin
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   626
        gear:= GearByUID(lua_tointeger(L, 1));
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   627
        if gear <> nil then
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   628
            lua_pushinteger(L, gear^.Pos)
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   629
        else
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   630
            lua_pushnil(L);
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   631
        end;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   632
    lc_getgearpos:= 1
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   633
end;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   634
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   635
function lc_setgearpos(L : Plua_State) : LongInt; Cdecl;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   636
var gear : PGear;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   637
begin
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   638
    if lua_gettop(L) <> 2 then
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   639
        LuaError('Lua: Wrong number of parameters passed to SetGearPos!')
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   640
    else
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   641
        begin
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   642
        gear:= GearByUID(lua_tointeger(L, 1));
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   643
        if gear <> nil then
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   644
            gear^.Pos:= lua_tointeger(L, 2);
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   645
        end;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   646
    lc_setgearpos:= 0
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   647
end;
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
   648
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   649
function lc_gethoglevel(L : Plua_State): LongInt; Cdecl;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   650
var gear : PGear;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   651
begin
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   652
    if lua_gettop(L) <> 1 then
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   653
        LuaError('Lua: Wrong number of parameters passed to GetHogLevel!')
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   654
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   655
        begin
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   656
        gear := GearByUID(lua_tointeger(L, 1));
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   657
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   658
            lua_pushinteger(L, gear^.Hedgehog^.BotLevel)
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   659
        else
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   660
            lua_pushnil(L);
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   661
    end;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   662
    lc_gethoglevel := 1;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   663
end;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   664
4496
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   665
function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   666
var gear : PGear;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   667
begin
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   668
    if lua_gettop(L) <> 2 then
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   669
        LuaError('Lua: Wrong number of parameters passed to SetHogLevel!')
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   670
    else
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   671
        begin
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   672
        gear:= GearByUID(lua_tointeger(L, 1));
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   673
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   674
            gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2);
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   675
        end;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   676
    lc_sethoglevel:= 0
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   677
end;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   678
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   679
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
   680
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
   681
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
   682
    if lua_gettop(L) <> 1 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
   683
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   684
        LuaError('Lua: Wrong number of parameters passed to GetHogClan!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   685
        lua_pushnil(L); // return value on stack (nil)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   686
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   687
    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
   688
        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
   689
        gear:= GearByUID(lua_tointeger(L, 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
   690
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> 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
   691
            begin
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   692
            lua_pushinteger(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
   693
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   694
        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
   695
            lua_pushnil(L);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   696
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   697
    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
   698
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   699
4498
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   700
function lc_getclancolor(L : Plua_State) : LongInt; Cdecl;
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   701
begin
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   702
    if lua_gettop(L) <> 1 then
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   703
        begin
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   704
        LuaError('Lua: Wrong number of parameters passed to GetClanColor!');
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   705
        lua_pushnil(L); // return value on stack (nil)
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   706
        end
4499
d2454e4dbd03 return RGBA
nemo
parents: 4498
diff changeset
   707
    else lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF);
4498
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   708
    lc_getclancolor:= 1
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   709
end;
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   710
4882
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   711
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
   712
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
   713
    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
   714
    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
   715
    i, j : LongInt;
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
   716
    r, rr: TSDL_Rect;
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
   717
    texsurf: PSDL_Surface;
4882
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   718
begin
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   719
    if lua_gettop(L) <> 2 then
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   720
        LuaError('Lua: Wrong number of parameters passed to SetClanColor!')
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
   721
    else
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
   722
        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
   723
        clan := ClansArray[lua_tointeger(L, 1)];
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
   724
        clan^.Color:= lua_tointeger(L, 2) shr 8;
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
   725
        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
   726
            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
   727
            team:= clan^.Teams[i];
f71e30eb1d37 Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents: 4883
diff changeset
   728
            for j:= 0 to 7 do
f71e30eb1d37 Reset things using team colour on change in SetClanColor in lua. This routine had better have been worth it.
nemo
parents: 4883
diff changeset
   729
                begin
4891
nemo
parents: 4890
diff changeset
   730
                hh:= team^.Hedgehogs[j];
4890
nemo
parents: 4889
diff changeset
   731
                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
   732
                    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
   733
                    FreeTexture(hh.NameTagTex);
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
   734
                    hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16);
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
   735
                    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
   736
                    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
   737
                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
   738
            FreeTexture(team^.NameTagTex);
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
   739
            team^.NameTagTex:= RenderStringTex(clan^.Teams[i]^.TeamName, clan^.Color, fnt16);
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
   740
            r.w:= cTeamHealthWidth + 5;
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
   741
            r.h:= team^.NameTagTex^.h;
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
   742
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
   743
            texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask);
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
   744
            TryDo(texsurf <> nil, errmsgCreateSurface, true);
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
   745
            TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
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
   746
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
   747
            DrawRoundRect(@r, cWhiteColor, cNearBlackColorChannels.value, texsurf, true);
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
   748
            rr:= r;
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
   749
            inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
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
   750
            DrawRoundRect(@rr, clan^.Color, clan^.Color, texsurf, false);
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
   751
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
   752
            FreeTexture(team^.HealthTex);
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
   753
            team^.HealthTex:= Surface2Tex(texsurf, false);
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
   754
            SDL_FreeSurface(texsurf);
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
   755
            MakeCrossHairs
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
   756
            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
   757
        end;
4882
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   758
    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
   759
end;
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   760
4236
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   761
function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   762
var gear : PGear;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   763
begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   764
    if lua_gettop(L) <> 1 then
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   765
        begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   766
        LuaError('Lua: Wrong number of parameters passed to GetHogTeamName!');
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   767
        lua_pushnil(L); // return value on stack (nil)
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   768
        end
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   769
    else
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   770
        begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   771
        gear:= GearByUID(lua_tointeger(L, 1));
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   772
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   773
            begin
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   774
            lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName))
4236
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   775
            end
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   776
        else
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   777
            lua_pushnil(L);
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   778
        end;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   779
    lc_gethogteamname:= 1
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   780
end;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   781
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   782
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
   783
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
   784
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
   785
    if lua_gettop(L) <> 1 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
   786
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   787
        LuaError('Lua: Wrong number of parameters passed to GetHogName!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   788
        lua_pushnil(L); // return value on stack (nil)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   789
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   790
    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
   791
        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
   792
        gear:= GearByUID(lua_tointeger(L, 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
   793
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> 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
   794
            begin
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   795
            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
   796
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   797
        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
   798
            lua_pushnil(L);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   799
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   800
    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
   801
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   802
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   803
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
   804
var gear : PGear;
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   805
  hogName: ShortString;
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   806
begin
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   807
    if lua_gettop(L) <> 2 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   808
        begin
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   809
        LuaError('Lua: Wrong number of parameters passed to SetHogName!');
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   810
        lua_pushnil(L)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   811
        end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   812
    else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   813
        begin
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   814
        gear:= GearByUID(lua_tointeger(L, 1));
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   815
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   816
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   817
        hogName:= lua_tostring(L, 2);
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   818
            gear^.Hedgehog^.Name:= hogName;
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   819
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   820
        FreeTexture(gear^.Hedgehog^.NameTagTex);
6380
1ff5ad1d771b Remove a bunch of unnecessary nil checks. FreeTexture does its own nil check.
nemo
parents: 6358
diff changeset
   821
        gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16);
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   822
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   823
        end;
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   824
    lc_sethogname:= 0;
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   825
end;
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
   826
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   827
function lc_gettimer(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   828
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   829
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   830
    if lua_gettop(L) <> 1 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   831
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   832
        LuaError('Lua: Wrong number of parameters passed to GetTimer!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   833
        lua_pushnil(L); // return value on stack (nil)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   834
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   835
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   836
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   837
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   838
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   839
            lua_pushinteger(L, gear^.Timer)
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   840
        else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   841
            lua_pushnil(L);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   842
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   843
    lc_gettimer:= 1
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   844
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   845
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   846
function lc_gethealth(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   847
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   848
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   849
    if lua_gettop(L) <> 1 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   850
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   851
        LuaError('Lua: Wrong number of parameters passed to GetHealth!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   852
        lua_pushnil(L); // return value on stack (nil)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   853
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   854
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   855
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   856
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   857
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   858
            lua_pushinteger(L, gear^.Health)
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   859
        else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   860
            lua_pushnil(L);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   861
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   862
    lc_gethealth:= 1
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   863
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   864
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   865
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
   866
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
   867
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
   868
    if lua_gettop(L) <> 1 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
   869
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   870
        LuaError('Lua: Wrong number of parameters passed to GetX!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   871
        lua_pushnil(L); // return value on stack (nil)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   872
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   873
    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
   874
        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
   875
        gear:= GearByUID(lua_tointeger(L, 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
   876
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   877
            lua_pushinteger(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
   878
        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
   879
            lua_pushnil(L);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   880
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   881
    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
   882
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   883
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   884
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
   885
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
   886
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
   887
    if lua_gettop(L) <> 1 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
   888
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   889
        LuaError('Lua: Wrong number of parameters passed to GetY!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   890
        lua_pushnil(L); // return value on stack (nil)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   891
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   892
    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
   893
        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
   894
        gear:= GearByUID(lua_tointeger(L, 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
   895
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   896
            lua_pushinteger(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
   897
        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
   898
            lua_pushnil(L);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   899
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   900
    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
   901
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   902
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   903
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
   904
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
   905
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
   906
    if lua_gettop(L) <> 2 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
   907
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   908
        LuaError('Lua: Wrong number of parameters passed to CopyPV!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   909
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   910
    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
   911
        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
   912
        gears:= GearByUID(lua_tointeger(L, 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
   913
        geard:= GearByUID(lua_tointeger(L, 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
   914
        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
   915
            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
   916
            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
   917
            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
   918
            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
   919
            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
   920
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   921
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   922
    lc_copypv:= 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
   923
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   924
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   925
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
   926
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
   927
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
   928
    if lua_gettop(L) <> 1 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   929
        LuaError('Lua: Wrong number of parameters passed to FollowGear!')
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   930
    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
   931
        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
   932
        gear:= GearByUID(lua_tointeger(L, 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
   933
        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
   934
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   935
    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
   936
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   937
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   938
function lc_hogsay(L : Plua_State) : LongInt; Cdecl;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   939
var gear : PGear;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   940
   vgear : PVisualGear;
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   941
       s : LongWord;
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   942
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   943
    if lua_gettop(L) = 4 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   944
        s:= lua_tointeger(L, 4)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   945
    else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   946
        s:= 0;
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   947
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   948
    if (lua_gettop(L) = 4) or (lua_gettop(L) = 3) then
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   949
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   950
        gear:= GearByUID(lua_tointeger(L, 1));
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   951
        if gear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   952
            begin
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   953
            vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   954
            if vgear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   955
               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
   956
               vgear^.Text:= lua_tostring(L, 2);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   957
               vgear^.Hedgehog:= gear^.Hedgehog;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   958
               vgear^.FrameTicks:= lua_tointeger(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
   959
               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
   960
                   vgear^.FrameTicks:= 1;
5529
9a47cff3910a return visual gear in hogsay
nemo
parents: 5527
diff changeset
   961
               lua_pushinteger(L, vgear^.Uid)
9a47cff3910a return visual gear in hogsay
nemo
parents: 5527
diff changeset
   962
               end
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   963
            end
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   964
            else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
   965
                lua_pushnil(L)
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   966
        end
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   967
    else LuaError('Lua: Wrong number of parameters passed to HogSay!');
5529
9a47cff3910a return visual gear in hogsay
nemo
parents: 5527
diff changeset
   968
    lc_hogsay:= 1
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   969
end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   970
4851
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   971
function lc_switchhog(L : Plua_State) : LongInt; Cdecl;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   972
var gear, prevgear : PGear;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   973
begin
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   974
    if lua_gettop(L) <> 1 then
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   975
        LuaError('Lua: Wrong number of parameters passed to SwitchHog!')
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   976
    else
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   977
        begin
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   978
        gear:= GearByUID(lua_tointeger(L, 1));
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   979
// should we allow this when there is no current hedgehog? might do some odd(er) things to turn sequence.
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   980
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   981
            begin
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   982
            prevgear := CurrentHedgehog^.Gear;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   983
            prevgear^.Active := false;
7426
55b49cc1f33a Changes for the benefit of pas2c. Use downto in for loops to avoid repeated calls of Random/GetRandom. Wrap nots.
nemo
parents: 7401
diff changeset
   984
            prevgear^.State:= prevgear^.State and (not gstHHDriven);
4851
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   985
            prevgear^.Z := cHHZ;
7401
4c3ec3dca0c7 oh yeah, these too
nemo
parents: 7339
diff changeset
   986
            prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList;
7270
93e92e82d5c8 Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents: 7156
diff changeset
   987
            
93e92e82d5c8 Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents: 7156
diff changeset
   988
            SwitchCurrentHedgehog(gear^.Hedgehog);
93e92e82d5c8 Step 1. Add current hedgehog as top bit of bottom byte.
nemo
parents: 7156
diff changeset
   989
            CurrentTeam:= CurrentHedgehog^.Team;
4851
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   990
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   991
            gear^.State:= gear^.State or gstHHDriven;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   992
            gear^.Active := true;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   993
            gear^.Z := cCurrHHZ;
7401
4c3ec3dca0c7 oh yeah, these too
nemo
parents: 7339
diff changeset
   994
            gear^.Message:= gear^.Message or gmRemoveFromList or gmAddToList;
4851
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   995
            end
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   996
        end;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   997
    lc_switchhog:= 0
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   998
end;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   999
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1000
{function lc_addammo(L : Plua_State) : LongInt; Cdecl;
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1001
var gear : PGear;
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1002
begin
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1003
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1004
    if lua_gettop(L) = 3 then
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1005
    begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1006
    gear:= GearByUID(lua_tointeger(L, 1));
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1007
        if (gear <> nil) and (gear^.Hedgehog <> nil) then
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1008
            AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) );
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1009
    end else
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1010
    
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1011
    if lua_gettop(L) = 2 then
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1012
    begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1013
    gear:= GearByUID(lua_tointeger(L, 1));
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1014
        if (gear <> nil) and (gear^.Hedgehog <> nil) then
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1015
            AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)));
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1016
    end else
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1017
    begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1018
        LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1019
    end;
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1020
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1021
    lc_addammo:= 0;
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1022
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1023
end;}
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 5272
diff changeset
  1024
4481
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1025
function lc_addammo(L : Plua_State) : LongInt; Cdecl;
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1026
var gear : PGear;
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1027
begin
5272
a85d331ab5bb Allow scripting to set arbitrary weapon counts
nemo
parents: 5245
diff changeset
  1028
    if (lua_gettop(L) = 3) or (lua_gettop(L) = 2) then
4481
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1029
        begin
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1030
        gear:= GearByUID(lua_tointeger(L, 1));
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1031
        if (gear <> nil) and (gear^.Hedgehog <> nil) then
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1032
            if lua_gettop(L) = 2 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1033
                AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)))
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1034
            else
6924
57b66ee3bff3 Get rid of overloaded functions in uAmmo
unc0rr
parents: 6828
diff changeset
  1035
                SetAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3))
5272
a85d331ab5bb Allow scripting to set arbitrary weapon counts
nemo
parents: 5245
diff changeset
  1036
        end
a85d331ab5bb Allow scripting to set arbitrary weapon counts
nemo
parents: 5245
diff changeset
  1037
    else LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
4481
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1038
    lc_addammo:= 0
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1039
end;
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1040
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
  1041
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
  1042
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
  1043
    ammo : PAmmo;
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
  1044
begin
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
  1045
    if (lua_gettop(L) = 2) then
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
  1046
        begin
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
  1047
        gear:= GearByUID(lua_tointeger(L, 1));
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
  1048
        if (gear <> nil) and (gear^.Hedgehog <> nil) then 
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
  1049
            begin
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
  1050
            ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(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
  1051
            if ammo^.AmmoType = amNothing then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1052
                lua_pushinteger(L, 0)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1053
            else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1054
                lua_pushinteger(L, ammo^.Count)
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
  1055
            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
  1056
        else lua_pushinteger(L, 0)
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
  1057
        end
6046
d681b8127523 this needs to actually return something
nemo
parents: 6019
diff changeset
  1058
    else 
d681b8127523 this needs to actually return something
nemo
parents: 6019
diff changeset
  1059
        begin
d681b8127523 this needs to actually return something
nemo
parents: 6019
diff changeset
  1060
        LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!');
d681b8127523 this needs to actually return something
nemo
parents: 6019
diff changeset
  1061
        lua_pushnil(L)
d681b8127523 this needs to actually return something
nemo
parents: 6019
diff changeset
  1062
        end;
d681b8127523 this needs to actually return something
nemo
parents: 6019
diff changeset
  1063
    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
  1064
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
  1065
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1066
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
  1067
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
  1068
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
  1069
    if lua_gettop(L) <> 2 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
  1070
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1071
        LuaError('Lua: Wrong number of parameters passed to SetHealth!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1072
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1073
    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
  1074
        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
  1075
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1076
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1077
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1078
            gear^.Health:= lua_tointeger(L, 2);
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
  1079
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1080
        if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
  1081
            begin  
6763
8a06161ede49 Recount team health if modifying hedgehog health
nemo
parents: 6752
diff changeset
  1082
            RenderHealth(gear^.Hedgehog^);
8a06161ede49 Recount team health if modifying hedgehog health
nemo
parents: 6752
diff changeset
  1083
            RecountTeamHealth(gear^.Hedgehog^.Team)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
  1084
            end;
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents: 5243
diff changeset
  1085
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1086
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1087
            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
  1088
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1089
    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
  1090
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1091
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1092
function lc_settimer(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1093
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1094
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1095
    if lua_gettop(L) <> 2 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1096
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1097
        LuaError('Lua: Wrong number of parameters passed to SetTimer!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1098
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1099
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1100
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1101
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1102
        if gear <> nil then gear^.Timer:= lua_tointeger(L, 2)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1103
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1104
    lc_settimer:= 0
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1105
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1106
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1107
function lc_seteffect(L : Plua_State) : LongInt; Cdecl;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1108
var gear: PGear;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1109
begin
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1110
    if lua_gettop(L) <> 3 then
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1111
        LuaError('Lua: Wrong number of parameters passed to SetEffect!')
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1112
    else begin
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1113
        gear := GearByUID(lua_tointeger(L, 1));
5489
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1114
        if (gear <> nil) and (gear^.Hedgehog <> nil) then
7010
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6982
diff changeset
  1115
            gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3);
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1116
    end;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1117
    lc_seteffect := 0;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1118
end;
5489
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1119
function lc_geteffect(L : Plua_State) : LongInt; Cdecl;
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1120
var gear : PGear;
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1121
begin
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1122
    if lua_gettop(L) <> 2 then
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1123
        begin
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1124
        LuaError('Lua: Wrong number of parameters passed to GetEffect!');
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1125
        end
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1126
    else
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1127
        begin
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1128
        gear:= GearByUID(lua_tointeger(L, 1));
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1129
        if (gear <> nil) and (gear^.Hedgehog <> nil) then
7010
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6982
diff changeset
  1130
            lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))])
5489
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1131
        else
7010
10a0a31804f3 Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents: 6982
diff changeset
  1132
            lua_pushinteger(L, 0)
5489
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1133
        end;
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1134
    lc_geteffect:= 1
f7ec6e5ad054 add getter for effects. untested.
nemo
parents: 5366
diff changeset
  1135
end;
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1136
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1137
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
  1138
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
  1139
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
  1140
    if lua_gettop(L) <> 2 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
  1141
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1142
        LuaError('Lua: Wrong number of parameters passed to SetState!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1143
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1144
    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
  1145
        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
  1146
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1147
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1148
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1149
            gear^.State:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1150
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1151
            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
  1152
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1153
    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
  1154
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1155
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1156
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
  1157
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
  1158
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
  1159
    if lua_gettop(L) <> 1 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
  1160
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1161
        LuaError('Lua: Wrong number of parameters passed to GetState!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1162
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1163
    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
  1164
        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
  1165
        gear:= GearByUID(lua_tointeger(L, 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
  1166
        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
  1167
            lua_pushinteger(L, gear^.State)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1168
        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
  1169
            lua_pushnil(L)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1170
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1171
    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
  1172
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1173
7156
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1174
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
  1175
var gear : PGear;
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1176
begin
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1177
    if lua_gettop(L) <> 1 then
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1178
        begin
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1179
        LuaError('Lua: Wrong number of parameters passed to GetX!');
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1180
        lua_pushnil(L); // return value on stack (nil)
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1181
        end
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1182
    else
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1183
        begin
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1184
        gear:= GearByUID(lua_tointeger(L, 1));
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1185
        if gear <> nil then
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1186
            lua_pushinteger(L, gear^.Tag)
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1187
        else
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1188
            lua_pushnil(L);
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1189
        end;
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1190
    lc_gettag:= 1
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1191
end;
09262f82e99d Add a GetTag method so that SetTag doesn't feel lonely.
mikade <redgrinner@gmail.com>
parents: 7135
diff changeset
  1192
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1193
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
  1194
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
  1195
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
  1196
    if lua_gettop(L) <> 2 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
  1197
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1198
        LuaError('Lua: Wrong number of parameters passed to SetTag!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1199
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1200
    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
  1201
        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
  1202
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1203
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1204
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1205
            gear^.Tag:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1206
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
  1207
            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
  1208
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1209
    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
  1210
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1211
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1212
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
  1213
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
  1214
    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
  1215
    GameState:= gsExit;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1216
    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
  1217
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1218
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1219
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
  1220
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
  1221
    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
  1222
    tryhard: 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
  1223
    left, right: 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
  1224
begin
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
  1225
    tryhard:= false;
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
  1226
    if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1227
        LuaError('Lua: Wrong number of parameters passed to FindPlace!')
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1228
    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
  1229
        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
  1230
        gear:= GearByUID(lua_tointeger(L, 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
  1231
        fall:= lua_toboolean(L, 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
  1232
        left:= lua_tointeger(L, 3);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1233
        right:= lua_tointeger(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
  1234
        if lua_gettop(L) = 5 then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1235
            tryhard:= lua_toboolean(L, 5);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1236
        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
  1237
            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
  1238
        if gear <> nil then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1239
            lua_pushinteger(L, gear^.uid)
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1240
        else
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1241
            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
  1242
        end;
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
  1243
    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
  1244
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1245
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1246
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
  1247
var gear: PGear;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1248
begin
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
  1249
    if lua_gettop(L) = 1 then
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
  1250
        PlaySound(TSound(lua_tointeger(L, 1)))
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
  1251
    else if lua_gettop(L) = 2 then
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
  1252
        begin
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
  1253
        gear:= GearByUID(lua_tointeger(L, 2));
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
  1254
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
5638
e35ba2a400d8 Try to avoid overlapping voices for major statements (not things like byebye or oof)
nemo
parents: 5612
diff changeset
  1255
            AddVoice(TSound(lua_tointeger(L, 1)),gear^.Hedgehog^.Team^.Voicepack)
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
  1256
        end
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
  1257
    else LuaError('Lua: Wrong number of parameters passed to PlaySound!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1258
    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
  1259
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1260
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1261
function lc_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
  1262
var np: LongInt;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1263
begin
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
  1264
    np:= lua_gettop(L);
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
  1265
    if (np < 5) or (np > 6) 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
  1266
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1267
        LuaError('Lua: Wrong number of parameters passed to AddTeam!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1268
        //lua_pushnil(L)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1269
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1270
    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
  1271
        begin
5554
b27ed6c6f538 Revert ParseCommandOverride change since it appears to be badly screwing up scripting. Need to find out why. This backs out 7f57d0c7816a and the recent workaround.
nemo
parents: 5553
diff changeset
  1272
        ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true);
b27ed6c6f538 Revert ParseCommandOverride change since it appears to be badly screwing up scripting. Need to find out why. This backs out 7f57d0c7816a and the recent workaround.
nemo
parents: 5553
diff changeset
  1273
        ParseCommand('grave ' + lua_tostring(L, 3), true);
b27ed6c6f538 Revert ParseCommandOverride change since it appears to be badly screwing up scripting. Need to find out why. This backs out 7f57d0c7816a and the recent workaround.
nemo
parents: 5553
diff changeset
  1274
        ParseCommand('fort ' + lua_tostring(L, 4), true);
b27ed6c6f538 Revert ParseCommandOverride change since it appears to be badly screwing up scripting. Need to find out why. This backs out 7f57d0c7816a and the recent workaround.
nemo
parents: 5553
diff changeset
  1275
        ParseCommand('voicepack ' + lua_tostring(L, 5), true);
b27ed6c6f538 Revert ParseCommandOverride change since it appears to be badly screwing up scripting. Need to find out why. This backs out 7f57d0c7816a and the recent workaround.
nemo
parents: 5553
diff changeset
  1276
        if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), 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
  1277
        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
  1278
        // fails on x64
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1279
        //lua_pushinteger(L, LongInt(CurrentTeam));
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1280
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1281
    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
  1282
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1283
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1284
function lc_addhog(L : Plua_State) : LongInt; Cdecl;
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
  1285
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
  1286
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
  1287
    if lua_gettop(L) <> 4 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
  1288
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1289
        LuaError('Lua: Wrong number of parameters passed to AddHog!');
3043
3acdb4dac6eb 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
        lua_pushnil(L)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1291
        end
3acdb4dac6eb 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
    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
  1293
        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
  1294
        temp:= lua_tostring(L, 4);
ccfb9b8ab9d1 sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents: 5547
diff changeset
  1295
        ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true);
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
  1296
        ParseCommand('hat ' + temp, 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
  1297
        lua_pushinteger(L, 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
  1298
        end;
3acdb4dac6eb 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
    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
  1300
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1301
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1302
function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1303
var gear: PGear;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1304
begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1305
    if lua_gettop(L) <> 2 then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1306
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1307
        LuaError('Lua: Wrong number of parameters passed to HogTurnLeft!');
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1308
        end
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1309
    else
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1310
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1311
        gear:= GearByUID(lua_tointeger(L, 1));
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1312
        if gear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1313
            gear^.dX.isNegative:= lua_toboolean(L, 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1314
        end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1315
    lc_hogturnleft:= 0;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1316
end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1317
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1318
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
  1319
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
  1320
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
  1321
    if lua_gettop(L) <> 1 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
  1322
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1323
        LuaError('Lua: Wrong number of parameters passed to GetGearPosition!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1324
        lua_pushnil(L);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1325
        lua_pushnil(L)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1326
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1327
    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
  1328
        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
  1329
        gear:= GearByUID(lua_tointeger(L, 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
  1330
        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
  1331
            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
  1332
            lua_pushinteger(L, hwRound(gear^.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
  1333
            lua_pushinteger(L, hwRound(gear^.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
  1334
            end
5964
44d2dc3b438f return nil for position if no gear
nemo
parents: 5900
diff changeset
  1335
        else
44d2dc3b438f return nil for position if no gear
nemo
parents: 5900
diff changeset
  1336
            begin
44d2dc3b438f return nil for position if no gear
nemo
parents: 5900
diff changeset
  1337
            lua_pushnil(L);
44d2dc3b438f return nil for position if no gear
nemo
parents: 5900
diff changeset
  1338
            lua_pushnil(L)
44d2dc3b438f return nil for position if no gear
nemo
parents: 5900
diff changeset
  1339
            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
  1340
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1341
    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
  1342
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1343
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1344
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
  1345
var gear: PGear;
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1346
    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
  1347
    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
  1348
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
  1349
    if lua_gettop(L) <> 3 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1350
        LuaError('Lua: Wrong number of parameters passed to SetGearPosition!')
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1351
    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
  1352
        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
  1353
        gear:= GearByUID(lua_tointeger(L, 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
  1354
        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
  1355
            begin
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1356
            col:= gear^.CollisionIndex >= 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
  1357
            x:= lua_tointeger(L, 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
  1358
            y:= lua_tointeger(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
  1359
            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
  1360
                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
  1361
            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
  1362
            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
  1363
            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
  1364
                AddGearCI(gear);
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1365
            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
  1366
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1367
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1368
    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
  1369
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1370
5517
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1371
function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1372
var gear: PGear;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1373
begin
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1374
    if lua_gettop(L) <> 1 then
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1375
        begin
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1376
        LuaError('Lua: Wrong number of parameters passed to GetGearTarget!');
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1377
        lua_pushnil(L);
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1378
        lua_pushnil(L)
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1379
        end
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1380
    else
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1381
        begin
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1382
        gear:= GearByUID(lua_tointeger(L, 1));
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1383
        if gear <> nil then
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1384
            begin
5612
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1385
            lua_pushinteger(L, gear^.Target.X);
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1386
            lua_pushinteger(L, gear^.Target.Y)
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1387
            end
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1388
        else
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1389
            begin
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1390
            lua_pushnil(L);
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1391
            lua_pushnil(L)
5517
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1392
            end
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1393
        end;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1394
    lc_getgeartarget:= 2;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1395
end;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1396
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1397
function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1398
var gear: PGear;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1399
begin
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1400
    if lua_gettop(L) <> 3 then
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1401
        LuaError('Lua: Wrong number of parameters passed to SetGearTarget!')
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1402
    else
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1403
        begin
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1404
        gear:= GearByUID(lua_tointeger(L, 1));
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1405
        if gear <> nil then
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1406
            begin
5612
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1407
            gear^.Target.X:= lua_tointeger(L, 2);
2638dec1b323 This really should have been a TPoint for consistency
nemo
parents: 5583
diff changeset
  1408
            gear^.Target.Y:= lua_tointeger(L, 3)
5517
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1409
            end
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1410
        end;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1411
    lc_setgeartarget:= 0
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1412
end;
80bc6c0be5d4 Expose TargetX/TargetY to scripting
nemo
parents: 5489
diff changeset
  1413
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
  1414
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
  1415
var gear: PGear;
6780
166ee5275915 tweak take 2
nemo
parents: 6779
diff changeset
  1416
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
  1417
begin
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
  1418
    if lua_gettop(L) <> 1 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
  1419
        begin
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
  1420
        LuaError('Lua: Wrong number of parameters passed to GetGearVelocity!');
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
  1421
        lua_pushnil(L);
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
  1422
        lua_pushnil(L)
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
  1423
        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
  1424
    else
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
  1425
        begin
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
  1426
        gear:= GearByUID(lua_tointeger(L, 1));
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
  1427
        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
  1428
            begin
6780
166ee5275915 tweak take 2
nemo
parents: 6779
diff changeset
  1429
            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
  1430
            // gear dX determines hog orientation
6780
166ee5275915 tweak take 2
nemo
parents: 6779
diff changeset
  1431
            if (gear^.dX.isNegative) and (t = 0) then t:= -1;
166ee5275915 tweak take 2
nemo
parents: 6779
diff changeset
  1432
            lua_pushinteger(L, t);
5074
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
  1433
            lua_pushinteger(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
  1434
            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
  1435
        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
  1436
    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
  1437
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
  1438
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
  1439
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
  1440
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
  1441
begin
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
  1442
    if lua_gettop(L) <> 3 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
  1443
        LuaError('Lua: Wrong number of parameters passed to SetGearVelocity!')
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
  1444
    else
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
  1445
        begin
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
  1446
        gear:= GearByUID(lua_tointeger(L, 1));
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
  1447
        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
  1448
            begin
5074
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
  1449
            gear^.dX:= int2hwFloat(lua_tointeger(L, 2)) / 1000000;
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
  1450
            gear^.dY:= int2hwFloat(lua_tointeger(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
  1451
            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
  1452
            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
  1453
        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
  1454
    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
  1455
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
  1456
3736
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1457
function lc_setzoom(L : Plua_State) : LongInt; Cdecl;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1458
begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1459
    if lua_gettop(L) <> 1 then
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1460
        LuaError('Lua: Wrong number of parameters passed to SetZoom!')
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1461
    else
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1462
        begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1463
        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
  1464
        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
  1465
            ZoomValue:= cMaxZoomLevel;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1466
        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
  1467
            ZoomValue:= cMinZoomLevel;
3736
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1468
        end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1469
    lc_setzoom:= 0
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1470
end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1471
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1472
function lc_getzoom(L : Plua_State) : LongInt; Cdecl;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1473
begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1474
    if lua_gettop(L) <> 0 then
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1475
        begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1476
        LuaError('Lua: Wrong number of parameters passed to GetZoom!');
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1477
        lua_pushnil(L)
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1478
        end
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1479
    else
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1480
        lua_pushnumber(L, ZoomValue);
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1481
    lc_getzoom:= 1
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1482
end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1483
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1484
function lc_setammo(L : Plua_State) : LongInt; Cdecl;
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1485
var np: LongInt;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1486
begin
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1487
    np:= lua_gettop(L);
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1488
    if (np < 4) or (np > 5) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1489
        LuaError('Lua: Wrong number of parameters passed to SetAmmo!')
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1490
    else if np = 4 then
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1491
        ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), 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
  1492
    else
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1493
        ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1494
    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
  1495
end;
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1496
6529
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1497
function lc_setammostore(L : Plua_State) : LongInt; Cdecl;
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1498
var np: LongInt;
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1499
begin
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1500
    np:= lua_gettop(L);
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1501
    if (np <> 4) then
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1502
        LuaError('Lua: Wrong number of parameters passed to SetAmmoStore!')
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1503
    else
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1504
        begin
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1505
        ScriptAmmoLoadout:= lua_tostring(L, 1);
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1506
        ScriptAmmoProbability:= lua_tostring(L, 2);
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1507
        ScriptAmmoDelay:= lua_tostring(L, 3);
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1508
        ScriptAmmoReinforcement:= lua_tostring(L, 4);
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1509
        end;
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1510
    lc_setammostore:= 0
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1511
end;
40f9ef7d824d added SetAmmoStore to lua for convinience
Henek
parents: 6523
diff changeset
  1512
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1513
function lc_getrandom(L : Plua_State) : LongInt; Cdecl;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1514
var m : LongInt;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1515
begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1516
    if lua_gettop(L) <> 1 then
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1517
        begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1518
        LuaError('Lua: Wrong number of parameters passed to GetRandom!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1519
        lua_pushnil(L); // return value on stack (nil)
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1520
        end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1521
    else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1522
        begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1523
        m:= lua_tointeger(L, 1);
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1524
        if (m > 0) then
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1525
            lua_pushinteger(L, GetRandom(m))
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1526
        else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1527
            begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1528
            LuaError('Lua: Tried to pass 0 to GetRandom!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1529
            lua_pushnil(L);
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1530
            end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1531
        end;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1532
    lc_getrandom:= 1
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1533
end;
4399
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1534
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1535
function lc_setwind(L : Plua_State) : LongInt; Cdecl;
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1536
begin
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1537
    if lua_gettop(L) <> 1 then
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1538
        LuaError('Lua: Wrong number of parameters passed to SetWind!')
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1539
    else
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1540
        begin
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1541
        cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed;
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1542
        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
  1543
        if cWindSpeed.isNegative then
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1544
            CWindSpeedf := -cWindSpeedf;
5357
ec36f3d53f3c Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents: 5313
diff changeset
  1545
        AddVisualGear(0, 0, vgtSmoothWindBar);
4399
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1546
        end;
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1547
    lc_setwind:= 0
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1548
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
  1549
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
  1550
function lc_getdatapath(L : Plua_State) : LongInt; Cdecl;
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
  1551
begin
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
  1552
    if lua_gettop(L) <> 0 then
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
  1553
        begin
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
  1554
        LuaError('Lua: Wrong number of parameters passed to GetDataPath!');
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
  1555
        lua_pushnil(L);
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
  1556
        end
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
  1557
    else
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
  1558
        lua_pushstring(L, str2pchar(Pathz[ptData]));
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
  1559
    lc_getdatapath:= 1
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
  1560
end;
4590
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1561
5238
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1562
function lc_getuserdatapath(L : Plua_State) : LongInt; Cdecl;
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1563
begin
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1564
    if lua_gettop(L) <> 0 then
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1565
        begin
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1566
        LuaError('Lua: Wrong number of parameters passed to GetUserDataPath!');
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1567
        lua_pushnil(L);
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1568
        end
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1569
    else
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1570
        lua_pushstring(L, str2pchar(UserPathz[ptData]));
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1571
    lc_getuserdatapath:= 1
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1572
end;
46ddaf14509d Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents: 5124
diff changeset
  1573
4590
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1574
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
  1575
begin
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1576
    if lua_gettop(L) <> 0 then
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1577
        begin
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1578
        LuaError('Lua: Wrong number of parameters passed to MapHasBorder!');
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1579
        lua_pushnil(L);
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1580
        end
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1581
    else
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1582
        lua_pushboolean(L, hasBorder);
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1583
    lc_maphasborder:= 1
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1584
end;
4869
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1585
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1586
function lc_getgearradius(L : Plua_State) : LongInt; Cdecl;
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1587
var gear : PGear;
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1588
begin
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1589
    if lua_gettop(L) <> 1 then
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1590
        begin
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1591
        LuaError('Lua: Wrong number of parameters passed to GetGearRadius!');
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1592
        lua_pushnil(L); // return value on stack (nil)
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1593
        end
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1594
    else
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1595
        begin
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1596
        gear:= GearByUID(lua_tointeger(L, 1));
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1597
        if gear <> nil then
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1598
            lua_pushinteger(L, gear^.Radius)
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1599
        else
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1600
            lua_pushnil(L);
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1601
        end;
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1602
    lc_getgearradius:= 1
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1603
end;
4875
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1604
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1605
function lc_gethoghat(L : Plua_State): LongInt; Cdecl;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1606
var gear : PGear;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1607
begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1608
    if lua_gettop(L) <> 1 then
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1609
        LuaError('Lua: Wrong number of parameters passed to GetHogHat!')
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1610
    else begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1611
        gear := GearByUID(lua_tointeger(L, 1));
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1612
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1613
            lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat))
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1614
        else
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1615
            lua_pushnil(L);
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1616
    end;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1617
    lc_gethoghat := 1;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1618
end;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1619
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1620
function lc_sethoghat(L : Plua_State) : LongInt; Cdecl;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1621
var gear : PGear;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1622
    hat: ShortString;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1623
begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1624
    if lua_gettop(L) <> 2 then
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1625
        begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1626
        LuaError('Lua: Wrong number of parameters passed to SetHogHat!');
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1627
        lua_pushnil(L)
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1628
        end
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1629
    else
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1630
        begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1631
        gear:= GearByUID(lua_tointeger(L, 1));
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1632
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) 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
  1633
            hat:= lua_tostring(L, 2);
4875
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1634
            gear^.Hedgehog^.Hat:= hat;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1635
            LoadHedgehogHat(gear, hat);
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1636
        end;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1637
    lc_sethoghat:= 0;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1638
end;
4985
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1639
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1640
function lc_placegirder(L : Plua_State) : LongInt; Cdecl;
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1641
begin
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1642
    if lua_gettop(L) <> 3 then
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1643
        LuaError('Lua: Wrong number of parameters passed to PlaceGirder!')
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1644
    else
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1645
        TryPlaceOnLand(
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1646
            lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2,
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1647
            lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2,
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1648
            sprAmGirder, lua_tointeger(L, 3), true, false);
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1649
    lc_placegirder:= 0
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1650
end;
5013
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1651
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1652
function lc_getcurammotype(L : Plua_State): LongInt; Cdecl;
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1653
begin
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1654
    if lua_gettop(L) <> 0 then
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1655
        LuaError('Lua: Wrong number of parameters passed to GetCurAmmoType!')
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1656
    else
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1657
        lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType));
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1658
    lc_getcurammotype := 1;
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1659
end;
5896
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1660
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1661
// boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1662
function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1663
var rtn: Boolean;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1664
begin
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1665
    if lua_gettop(L) <> 5 then
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1666
        begin
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1667
        LuaError('Lua: Wrong number of parameters passed to TestRectForObstacle!');
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1668
        lua_pushnil(L); // return value on stack (nil)
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1669
        end
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1670
    else
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1671
        begin
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1672
        rtn:= TestRectancleForObstacle(
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1673
                    lua_tointeger(L, 1),
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1674
                    lua_tointeger(L, 2),
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1675
                    lua_tointeger(L, 3),
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1676
                    lua_tointeger(L, 4),
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1677
                    lua_toboolean(L, 5)
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1678
                    );
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1679
        lua_pushboolean(L, rtn);
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1680
        end;
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1681
    lc_testrectforobstacle:= 1
9ce1cf4e5a32 lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents: 5825
diff changeset
  1682
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
  1683
///////////////////
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1684
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1685
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
  1686
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
  1687
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
  1688
    n:= lua_gettop(luaState);
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1689
    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
  1690
    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
  1691
        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
  1692
            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
  1693
        else if lua_toboolean(luaState, i) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1694
            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
  1695
        else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1696
            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
  1697
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1698
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1699
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
  1700
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1701
    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
  1702
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1703
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1704
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
  1705
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1706
    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
  1707
    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
  1708
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1709
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1710
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
  1711
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1712
    lua_pushinteger(luaState, value);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1713
    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
  1714
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1715
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1716
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
  1717
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1718
    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
  1719
    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
  1720
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1721
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1722
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
  1723
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1724
    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
  1725
    ScriptGetInteger:= lua_tointeger(luaState, -1);
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1726
    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
  1727
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1728
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1729
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
  1730
begin
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1731
    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
  1732
    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
  1733
    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
  1734
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1735
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1736
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
  1737
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
  1738
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
  1739
// 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
  1740
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
  1741
    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
  1742
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1743
// push game variables so they may be modified by the script
6982
8d41d22a291d breaking news, we don't support typed consts anymore
koda
parents: 6924
diff changeset
  1744
ScriptSetInteger('BorderColor', ExplosionBorderColor);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1745
ScriptSetInteger('GameFlags', GameFlags);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1746
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
  1747
ScriptSetInteger('TemplateFilter', cTemplateFilter);
a655dfab27d7 Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents: 5638
diff changeset
  1748
ScriptSetInteger('MapGen', cMapGen);
5583
63b274a4fb01 At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents: 5554
diff changeset
  1749
ScriptSetInteger('ScreenHeight', cScreenHeight);
63b274a4fb01 At mikade's request, expose screenheight/screenwidth and allow setting tag zoom level
nemo
parents: 5554
diff changeset
  1750
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
  1751
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
  1752
ScriptSetInteger('CaseFreq', cCaseFactor);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1753
ScriptSetInteger('HealthCaseProb', cHealthCaseProb);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1754
ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1755
ScriptSetInteger('DamagePercent', cDamagePercent);
6557
e3cad9020778 Push RopePercent to lua to fix rope if not set
enveezee
parents: 6543
diff changeset
  1756
ScriptSetInteger('RopePercent', cRopePercent);
4003
ca0600ab38bf disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents: 3999
diff changeset
  1757
ScriptSetInteger('MinesNum', cLandMines);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1758
ScriptSetInteger('MinesTime', cMinesTime);
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1759
ScriptSetInteger('MineDudPercent', cMineDudPercent);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1760
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
  1761
ScriptSetInteger('Delay', cInactDelay);
3774
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1762
ScriptSetInteger('Ready', cReadyDelay);
3197
smxx
parents: 3058
diff changeset
  1763
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1764
ScriptSetInteger('WaterRise', cWaterRise);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1765
ScriptSetInteger('HealthDecrease', cHealthDecrease);
6828
6a5d33bff0b0 At mikade's request. give scripting access to the map name prior to override.
nemo
parents: 6790
diff changeset
  1766
ScriptSetString('Map', cMapName);
6a5d33bff0b0 At mikade's request. give scripting access to the map name prior to override.
nemo
parents: 6790
diff changeset
  1767
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1768
ScriptSetString('Theme', '');
4883
7cddc9201a1d added dummy for tardis and ugly icons for tardis and structure
Henek
parents: 4882
diff changeset
  1769
ScriptSetString('Goals', '');
7cddc9201a1d added dummy for tardis and ugly icons for tardis and structure
Henek
parents: 4882
diff changeset
  1770
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1771
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
  1772
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1773
// pop game variables
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1774
ParseCommand('seed ' + ScriptGetString('Seed'), true);
6312
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1775
cTemplateFilter  := ScriptGetInteger('TemplateFilter');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1776
cMapGen          := ScriptGetInteger('MapGen');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1777
GameFlags        := ScriptGetInteger('GameFlags');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1778
cHedgehogTurnTime:= ScriptGetInteger('TurnTime');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1779
cCaseFactor      := ScriptGetInteger('CaseFreq');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1780
cHealthCaseProb  := ScriptGetInteger('HealthCaseProb');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1781
cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1782
cDamagePercent   := ScriptGetInteger('DamagePercent');
6523
666fccd5cb3a enable lua to also set rope length percent
Henek
parents: 6468
diff changeset
  1783
cRopePercent     := ScriptGetInteger('RopePercent');
6312
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1784
cLandMines       := ScriptGetInteger('MinesNum');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1785
cMinesTime       := ScriptGetInteger('MinesTime');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1786
cMineDudPercent  := ScriptGetInteger('MineDudPercent');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1787
cExplosives      := ScriptGetInteger('Explosives');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1788
cInactDelay      := ScriptGetInteger('Delay');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1789
cReadyDelay      := ScriptGetInteger('Ready');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1790
cSuddenDTurns    := ScriptGetInteger('SuddenDeathTurns');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1791
cWaterRise       := ScriptGetInteger('WaterRise');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1792
cHealthDecrease  := ScriptGetInteger('HealthDecrease');
658055a3f160 fix map/template override, remove some pointless command calls
nemo
parents: 6131
diff changeset
  1793
6828
6a5d33bff0b0 At mikade's request. give scripting access to the map name prior to override.
nemo
parents: 6790
diff changeset
  1794
ParseCommand('map ' + ScriptGetString('Map'), 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
  1795
if ScriptGetString('Theme') <> '' then
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
  1796
    ParseCommand('theme ' + ScriptGetString('Theme'), true);
4883
7cddc9201a1d added dummy for tardis and ugly icons for tardis and structure
Henek
parents: 4882
diff changeset
  1797
LuaGoals:= ScriptGetString('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
  1798
6578
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1799
// 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
  1800
k:= 0;
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1801
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
  1802
    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
  1803
        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
  1804
            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
  1805
                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
  1806
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
  1807
    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
  1808
        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
  1809
            begin
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1810
            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
  1811
            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
  1812
            inc(k)
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1813
            end
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1814
else 
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1815
    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
  1816
        begin
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1817
        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
  1818
            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
  1819
        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
  1820
        inc(k)
d4ad42283125 Also allow lua to change gfPerHogAmmo/gfSharedAmmo even if lua does not define new ammo stores
nemo
parents: 6563
diff changeset
  1821
        end;
6743
864bf0f52a8c make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents: 6742
diff changeset
  1822
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
  1823
    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
  1824
    // 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
  1825
    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
  1826
    uAmmos.initModule;
6743
864bf0f52a8c make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents: 6742
diff changeset
  1827
    if ScriptExists('onAmmoStoreInit') then
864bf0f52a8c make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents: 6742
diff changeset
  1828
        begin
6752
nemo
parents: 6746
diff changeset
  1829
        ScriptPrepareAmmoStore;
6743
864bf0f52a8c make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents: 6742
diff changeset
  1830
        ScriptCall('onAmmoStoreInit');
6746
nemo
parents: 6743
diff changeset
  1831
        SetAmmoLoadout(ScriptAmmoLoadout);
nemo
parents: 6743
diff changeset
  1832
        SetAmmoProbability(ScriptAmmoProbability);
nemo
parents: 6743
diff changeset
  1833
        SetAmmoDelay(ScriptAmmoDelay);
nemo
parents: 6743
diff changeset
  1834
        SetAmmoReinforcement(ScriptAmmoReinforcement)
6743
864bf0f52a8c make onAmmoStoreInit optional in the case of onNewAmmoStore
nemo
parents: 6742
diff changeset
  1835
        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
  1836
    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
  1837
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1838
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
  1839
ScriptSetInteger('ClansCount', ClansCount);
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
  1840
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
  1841
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1842
5825
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1843
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1844
// 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
  1845
procedure ScriptOnScreenResize();
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1846
begin
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1847
ScriptSetInteger('ScreenHeight', cScreenHeight);
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1848
ScriptSetInteger('ScreenWidth', cScreenWidth);
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1849
ScriptCall('onScreenResize');
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1850
end;
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1851
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5703
diff changeset
  1852
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1853
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
  1854
var ret : LongInt;
5243
f2e31a7f953a check alternate script loading path
nemo
parents: 5238
diff changeset
  1855
      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
  1856
begin
5243
f2e31a7f953a check alternate script loading path
nemo
parents: 5238
diff changeset
  1857
s:= UserPathz[ptData] + '/' + name;
6580
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1858
if not FileExists(s) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1859
    s:= Pathz[ptData] + '/' + name;
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1860
if not FileExists(s) then
6155187bf599 A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents: 6578
diff changeset
  1861
    exit;
6088
47d1b04003d1 - Frontend: don't pass /script for missions
unc0rr
parents: 6046
diff changeset
  1862
5243
f2e31a7f953a check alternate script loading path
nemo
parents: 5238
diff changeset
  1863
ret:= luaL_loadfile(luaState, Str2PChar(s));
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1864
if ret <> 0 then
3774
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1865
    begin
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1866
    LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
5549
ccfb9b8ab9d1 sheepluva pointed out there are 2 StrPas in pascal, in different units. Do conversion in LuaPas instead
nemo
parents: 5547
diff changeset
  1867
    LuaError('Lua: ' + lua_tostring(luaState, -1));
3774
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1868
    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
  1869
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
  1870
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1871
    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
  1872
    // 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
  1873
    lua_pcall(luaState, 0, 0, 0);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1874
    ScriptLoaded:= true
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1875
    end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1876
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1877
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1878
procedure 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
  1879
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
  1880
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1881
ScriptSetInteger('GameTime', GameTicks);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1882
ScriptSetInteger('RealTime', RealTicks);
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
  1883
ScriptSetInteger('TotalRounds', TotalRounds);
5676
a655dfab27d7 Scripting changes. Add override of mapgen, templatefilter. Expose waterline, add "GetAmmoCount". Default to amNothing in uAmmos if entry is not found.
nemo
parents: 5638
diff changeset
  1884
ScriptSetInteger('WaterLine', cWaterLine);
6790
e688db01bc9c eh. guess they really should be here
nemo
parents: 6789
diff changeset
  1885
ScriptSetInteger('LeftX', leftX);
e688db01bc9c eh. guess they really should be here
nemo
parents: 6789
diff changeset
  1886
ScriptSetInteger('RightX', rightX);
e688db01bc9c eh. guess they really should be here
nemo
parents: 6789
diff changeset
  1887
ScriptSetInteger('TopY', topY);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1888
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
  1889
    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
  1890
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
  1891
    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
  1892
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1893
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1894
procedure GetGlobals;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1895
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
  1896
TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1897
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1898
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1899
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
  1900
begin
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6430
diff changeset
  1901
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
  1902
    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
  1903
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
  1904
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
  1905
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
  1906
    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
  1907
    LuaError('Lua: 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
  1908
    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
  1909
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1910
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
  1911
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1912
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
  1913
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
  1914
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
  1915
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
  1916
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
  1917
    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
  1918
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
  1919
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
  1920
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
  1921
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
  1922
    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
  1923
    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
  1924
    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
  1925
    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
  1926
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
  1927
    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
  1928
    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
  1929
    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
  1930
    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
  1931
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
  1932
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1933
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
  1934
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
  1935
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
  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
3acdb4dac6eb 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
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
  1939
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
  1940
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
  1941
end;
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1943
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
  1944
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
  1945
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
  1946
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1947
3acdb4dac6eb 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
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
  1949
begin
6453
11c578d30bd3 Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents: 6430
diff changeset
  1950
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
  1951
    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
  1952
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
  1953
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
  1954
lua_pushinteger(luaState, par1);
3acdb4dac6eb 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
lua_pushinteger(luaState, par2);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1956
lua_pushinteger(luaState, par3);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1957
lua_pushinteger(luaState, par4);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1958
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
  1959
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
  1960
    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
  1961
    LuaError('Lua: 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
  1962
    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
  1963
    end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1964
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
  1965
    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
  1966
    ScriptCall:= lua_tointeger(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
  1967
    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
  1968
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1969
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
  1970
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1971
3acdb4dac6eb 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 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
  1973
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
  1974
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
  1975
    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
  1976
    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
  1977
    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
  1978
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1979
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
  1980
ScriptExists:= not lua_isnoneornil(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
  1981
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
  1982
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1985
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
  1986
begin
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1987
ScriptAmmoLoadout:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1988
ScriptAmmoDelay:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1989
ScriptAmmoProbability:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1990
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
  1991
for i:=1 to ord(High(TAmmoType)) do
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1992
    begin
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1993
    ScriptAmmoLoadout:= ScriptAmmoLoadout + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1994
    ScriptAmmoProbability:= ScriptAmmoProbability + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1995
    ScriptAmmoDelay:= ScriptAmmoDelay + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1996
    ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1997
    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
  1998
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1999
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  2000
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, 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
  2001
begin
6019
8843ea756cfc warnings round also for ios
koda
parents: 5964
diff changeset
  2002
//if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) or (delay < 0) or (delay > 9) or (reinforcement < 0) or (reinforcement > 8) then
8843ea756cfc warnings round also for ios
koda
parents: 5964
diff changeset
  2003
if (ord(ammo) < 1) or (count > 9) or (propability > 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
  2004
    exit;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  2005
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  2006
ScriptAmmoProbability[ord(ammo)]:= inttostr(propability)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  2007
ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  2008
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
  2009
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2010
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2011
procedure ScriptApplyAmmoStore;
6563
30e042398411 Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents: 6557
diff changeset
  2012
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
  2013
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
  2014
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
  2015
    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
  2016
        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
  2017
        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
  2018
            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
  2019
            ScriptPrepareAmmoStore;
6746
nemo
parents: 6743
diff changeset
  2020
            ScriptCall('onNewAmmoStore',i,-1);
nemo
parents: 6743
diff changeset
  2021
            SetAmmoLoadout(ScriptAmmoLoadout);
nemo
parents: 6743
diff changeset
  2022
            SetAmmoProbability(ScriptAmmoProbability);
nemo
parents: 6743
diff changeset
  2023
            SetAmmoDelay(ScriptAmmoDelay);
nemo
parents: 6743
diff changeset
  2024
            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
  2025
            end;
6563
30e042398411 Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents: 6557
diff changeset
  2026
        AddAmmoStore;
30e042398411 Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents: 6557
diff changeset
  2027
        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
  2028
            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
  2029
                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
  2030
        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
  2031
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
  2032
    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
  2033
        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
  2034
            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
  2035
            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
  2036
                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
  2037
                ScriptPrepareAmmoStore;
6746
nemo
parents: 6743
diff changeset
  2038
                ScriptCall('onNewAmmoStore',i,j);
nemo
parents: 6743
diff changeset
  2039
                SetAmmoLoadout(ScriptAmmoLoadout);
nemo
parents: 6743
diff changeset
  2040
                SetAmmoProbability(ScriptAmmoProbability);
nemo
parents: 6743
diff changeset
  2041
                SetAmmoDelay(ScriptAmmoDelay);
nemo
parents: 6743
diff changeset
  2042
                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
  2043
                end;
6563
30e042398411 Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents: 6557
diff changeset
  2044
            AddAmmoStore;
30e042398411 Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents: 6557
diff changeset
  2045
            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
  2046
            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
  2047
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
  2048
    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
  2049
        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
  2050
        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
  2051
            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
  2052
            ScriptPrepareAmmoStore;
6746
nemo
parents: 6743
diff changeset
  2053
            ScriptCall('onNewAmmoStore',i,-1);
nemo
parents: 6743
diff changeset
  2054
            SetAmmoLoadout(ScriptAmmoLoadout);
nemo
parents: 6743
diff changeset
  2055
            SetAmmoProbability(ScriptAmmoProbability);
nemo
parents: 6743
diff changeset
  2056
            SetAmmoDelay(ScriptAmmoDelay);
nemo
parents: 6743
diff changeset
  2057
            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
  2058
            end;
6563
30e042398411 Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents: 6557
diff changeset
  2059
        AddAmmoStore;
30e042398411 Assign ammo counts as well, in case the game flags were changed by the script
nemo
parents: 6557
diff changeset
  2060
        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
  2061
            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
  2062
        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
  2063
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2064
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2065
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
  2066
var at : TGearType;
4453
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  2067
    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
  2068
    am : TAmmoType;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2069
    st : TSound;
5118
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  2070
    he : THogEffect;
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  2071
    cg : TCapGroup;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2072
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
  2073
// initialize lua
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2074
luaState:= lua_open;
3045
41732f986b4f Clean Augean stables
unc0rr
parents: 3043
diff changeset
  2075
TryDo(luaState <> nil, 'lua_open failed', 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
  2076
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2077
// open internal libraries
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2078
luaopen_base(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
  2079
luaopen_string(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
  2080
luaopen_math(luaState);
3724
b8678667e7dc Engine:
smaxx
parents: 3723
diff changeset
  2081
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
  2082
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2083
// import some variables
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2084
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2085
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
7072
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2086
ScriptSetString(_S'L', 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
  2087
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2088
// import game flags
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2089
ScriptSetInteger('gfForts', gfForts);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2090
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
  2091
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
  2092
ScriptSetInteger('gfBorder', gfBorder);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2093
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
  2094
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
  2095
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
  2096
ScriptSetInteger('gfInvulnerable', gfInvulnerable);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2097
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
  2098
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
  2099
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
  2100
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
  2101
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
  2102
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
  2103
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
  2104
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
  2105
ScriptSetInteger('gfDisableGirders', gfDisableGirders);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  2106
ScriptSetInteger('gfDisableLandObjects', gfDisableLandObjects);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  2107
ScriptSetInteger('gfAISurvival', gfAISurvival);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  2108
ScriptSetInteger('gfInfAttack', gfInfAttack);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  2109
ScriptSetInteger('gfResetWeps', gfResetWeps);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  2110
ScriptSetInteger('gfPerHogAmmo', gfPerHogAmmo);
4219
4162db7c11bb fix so gfDisableWind can infact be used in lua
Henek
parents: 4162
diff changeset
  2111
ScriptSetInteger('gfDisableWind', gfDisableWind);
4319
81391b54b078 clean up and lua update, very minor
Henek
parents: 4243
diff changeset
  2112
ScriptSetInteger('gfMoreWind', gfMoreWind);
5016
9347d82a26cc added game mode Tag Team, mostly untested, please test :)
Henek
parents: 5013
diff changeset
  2113
ScriptSetInteger('gfTagTeam', gfTagTeam);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2114
3894
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2115
ScriptSetInteger('gmLeft', gmLeft);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2116
ScriptSetInteger('gmRight', gmRight);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2117
ScriptSetInteger('gmUp', gmUp);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2118
ScriptSetInteger('gmDown', gmDown);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2119
ScriptSetInteger('gmSwitch', gmSwitch);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2120
ScriptSetInteger('gmAttack', gmAttack);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2121
ScriptSetInteger('gmLJump', gmLJump);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2122
ScriptSetInteger('gmHJump', gmHJump);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2123
ScriptSetInteger('gmDestroy', gmDestroy);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2124
ScriptSetInteger('gmSlot', gmSlot);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2125
ScriptSetInteger('gmWeapon', gmWeapon);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2126
ScriptSetInteger('gmTimer', gmTimer);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2127
ScriptSetInteger('gmAnimate', gmAnimate);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  2128
ScriptSetInteger('gmPrecise', gmPrecise);
3892
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  2129
ScriptSetInteger('gmAllStoppable', gmAllStoppable);
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  2130
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  2131
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  2132
// speech bubbles
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  2133
ScriptSetInteger('SAY_SAY', 1);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  2134
ScriptSetInteger('SAY_THINK', 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  2135
ScriptSetInteger('SAY_SHOUT', 3);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  2136
3043
3acdb4dac6eb 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
// 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
  2138
for at:= Low(TGearType) to High(TGearType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  2139
    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
  2140
4453
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  2141
for vgt:= Low(TVisualGearType) to High(TVisualGearType) do
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  2142
    ScriptSetInteger(EnumToStr(vgt), ord(vgt));
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  2143
3043
3acdb4dac6eb 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
// 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
  2145
for st:= Low(TSound) to High(TSound) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  2146
    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
  2147
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2148
// 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
  2149
for am:= Low(TAmmoType) to High(TAmmoType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  2150
    ScriptSetInteger(EnumToStr(am), ord(am));
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
  2151
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  2152
for he:= Low(THogEffect) to High(THogEffect) do
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  2153
    ScriptSetInteger(EnumToStr(he), ord(he));
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  2154
5118
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  2155
for cg:= Low(TCapGroup) to High(TCapGroup) do
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  2156
    ScriptSetInteger(EnumToStr(cg), ord(cg));
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  2157
5527
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2158
ScriptSetInteger('gstDrowning'       ,$00000001);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2159
ScriptSetInteger('gstHHDriven'       ,$00000002);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2160
ScriptSetInteger('gstMoving'         ,$00000004);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2161
ScriptSetInteger('gstAttacked'       ,$00000008);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2162
ScriptSetInteger('gstAttacking'      ,$00000010);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2163
ScriptSetInteger('gstCollision'      ,$00000020);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2164
ScriptSetInteger('gstHHChooseTarget' ,$00000040);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2165
ScriptSetInteger('gstHHJumping'      ,$00000100);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2166
ScriptSetInteger('gsttmpFlag'        ,$00000200);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2167
ScriptSetInteger('gstHHThinking'     ,$00000800);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2168
ScriptSetInteger('gstNoDamage'       ,$00001000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2169
ScriptSetInteger('gstHHHJump'        ,$00002000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2170
ScriptSetInteger('gstAnimation'      ,$00004000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2171
ScriptSetInteger('gstHHDeath'        ,$00008000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2172
ScriptSetInteger('gstWinner'         ,$00010000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2173
ScriptSetInteger('gstWait'           ,$00020000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2174
ScriptSetInteger('gstNotKickable'    ,$00040000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2175
ScriptSetInteger('gstLoser'          ,$00080000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2176
ScriptSetInteger('gstHHGone'         ,$00100000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2177
ScriptSetInteger('gstInvisible'      ,$00200000);
418741abd209 gear state flag names for scripting
nemo
parents: 5517
diff changeset
  2178
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2179
// register functions
7072
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2180
lua_register(luaState, _P'band', @lc_band);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2181
lua_register(luaState, _P'bor', @lc_bor);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2182
lua_register(luaState, _P'bnot', @lc_bnot);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2183
lua_register(luaState, _P'div', @lc_div);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2184
lua_register(luaState, _P'GetInputMask', @lc_getinputmask);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2185
lua_register(luaState, _P'SetInputMask', @lc_setinputmask);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2186
lua_register(luaState, _P'AddGear', @lc_addgear);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2187
lua_register(luaState, _P'DeleteGear', @lc_deletegear);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2188
lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2189
lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2190
lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2191
lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2192
lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2193
lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2194
lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2195
lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2196
lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2197
lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2198
lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2199
lua_register(luaState, _P'GetGearType', @lc_getgeartype);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2200
lua_register(luaState, _P'EndGame', @lc_endgame);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2201
lua_register(luaState, _P'FindPlace', @lc_findplace);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2202
lua_register(luaState, _P'SetGearPosition', @lc_setgearposition);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2203
lua_register(luaState, _P'GetGearPosition', @lc_getgearposition);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2204
lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2205
lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2206
lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2207
lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2208
lua_register(luaState, _P'ParseCommand', @lc_parsecommand);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2209
lua_register(luaState, _P'ShowMission', @lc_showmission);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2210
lua_register(luaState, _P'HideMission', @lc_hidemission);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2211
lua_register(luaState, _P'AddCaption', @lc_addcaption);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2212
lua_register(luaState, _P'SetAmmo', @lc_setammo);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2213
lua_register(luaState, _P'SetAmmoStore', @lc_setammostore);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2214
lua_register(luaState, _P'PlaySound', @lc_playsound);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2215
lua_register(luaState, _P'AddTeam', @lc_addteam);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2216
lua_register(luaState, _P'AddHog', @lc_addhog);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2217
lua_register(luaState, _P'AddAmmo', @lc_addammo);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2218
lua_register(luaState, _P'GetAmmoCount', @lc_getammocount);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2219
lua_register(luaState, _P'SetHealth', @lc_sethealth);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2220
lua_register(luaState, _P'GetHealth', @lc_gethealth);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2221
lua_register(luaState, _P'SetEffect', @lc_seteffect);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2222
lua_register(luaState, _P'GetEffect', @lc_geteffect);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2223
lua_register(luaState, _P'GetHogClan', @lc_gethogclan);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2224
lua_register(luaState, _P'GetClanColor', @lc_getclancolor);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2225
lua_register(luaState, _P'SetClanColor', @lc_setclancolor);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2226
lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2227
lua_register(luaState, _P'GetHogName', @lc_gethogname);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2228
lua_register(luaState, _P'SetHogName', @lc_sethogname);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2229
lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2230
lua_register(luaState, _P'SetHogLevel', @lc_sethoglevel);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2231
lua_register(luaState, _P'GetX', @lc_getx);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2232
lua_register(luaState, _P'GetY', @lc_gety);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2233
lua_register(luaState, _P'CopyPV', @lc_copypv);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2234
lua_register(luaState, _P'FollowGear', @lc_followgear);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2235
lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2236
lua_register(luaState, _P'SetState', @lc_setstate);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2237
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
  2238
lua_register(luaState, _P'GetTag', @lc_gettag);
7072
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2239
lua_register(luaState, _P'SetTag', @lc_settag);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2240
lua_register(luaState, _P'SetTimer', @lc_settimer);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2241
lua_register(luaState, _P'GetTimer', @lc_gettimer);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2242
lua_register(luaState, _P'SetZoom', @lc_setzoom);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2243
lua_register(luaState, _P'GetZoom', @lc_getzoom);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2244
lua_register(luaState, _P'HogSay', @lc_hogsay);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2245
lua_register(luaState, _P'SwitchHog', @lc_switchhog);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2246
lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2247
lua_register(luaState, _P'CampaignLock', @lc_campaignlock);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2248
lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2249
lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2250
lua_register(luaState, _P'GetGearRadius', @lc_getgearradius);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2251
lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2252
lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2253
lua_register(luaState, _P'GetGearPos', @lc_getgearpos);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2254
lua_register(luaState, _P'SetGearPos', @lc_setgearpos);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2255
lua_register(luaState, _P'GetRandom', @lc_getrandom);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2256
lua_register(luaState, _P'SetWind', @lc_setwind);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2257
lua_register(luaState, _P'GetDataPath', @lc_getdatapath);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2258
lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2259
lua_register(luaState, _P'MapHasBorder', @lc_maphasborder);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2260
lua_register(luaState, _P'GetHogHat', @lc_gethoghat);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2261
lua_register(luaState, _P'SetHogHat', @lc_sethoghat);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2262
lua_register(luaState, _P'PlaceGirder', @lc_placegirder);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2263
lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype);
159616c24bb8 More magic
unc0rr
parents: 7063
diff changeset
  2264
lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2265
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2266
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2267
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
  2268
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
  2269
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2270
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2271
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
  2272
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
  2273
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
  2274
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2275
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2276
{$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
  2277
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
  2278
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
  2279
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2280
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2281
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
  2282
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
  2283
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2284
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2285
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
  2286
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2287
    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
  2288
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2289
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2290
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
  2291
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
  2292
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2293
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2294
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
  2295
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2296
    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
  2297
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2298
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2299
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
  2300
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2301
    // avoid hints
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2302
    fname:= fname;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2303
    par1:= par1;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2304
    par2:= par2;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2305
    par3:= par3;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2306
    par4:= par4;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2307
    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
  2308
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2309
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2310
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
  2311
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2312
    // avoid hints
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2313
    fname:= fname;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2314
    par1:= par1;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2315
    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
  2316
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2317
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2318
function 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
  2319
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2320
    // avoid hints
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2321
    fname:= fname;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2322
    par1:= par1;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2323
    par2:= par2;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2324
    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
  2325
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2326
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2327
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
  2328
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2329
    // avoid hints
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2330
    fname:= fname;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2331
    par1:= par1;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2332
    par2:= par2;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2333
    par3:= par3;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2334
    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
  2335
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2336
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2337
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
  2338
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2339
    fname:= fname; // avoid hint
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2340
    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
  2341
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2342
5410
8e7787065e2d small fix to have LUA_DISABLED working again
Xeli
parents: 5366
diff changeset
  2343
function ParseCommandOverride(key, value : shortstring) : shortstring;
8e7787065e2d small fix to have LUA_DISABLED working again
Xeli
parents: 5366
diff changeset
  2344
begin
7030
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2345
    // avoid hints
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2346
    key:= key;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2347
    value:= value;
09984acadece invert LUA symbol meaning and avoid hints when compiling without it
koda
parents: 7010
diff changeset
  2348
    ParseCommandOverride:= ''
5410
8e7787065e2d small fix to have LUA_DISABLED working again
Xeli
parents: 5366
diff changeset
  2349
end;
8e7787065e2d small fix to have LUA_DISABLED working again
Xeli
parents: 5366
diff changeset
  2350
6430
93eefff23bcd fix compiling with LUA_DISABLED
koda
parents: 6415
diff changeset
  2351
procedure ScriptOnScreenResize;
93eefff23bcd fix compiling with LUA_DISABLED
koda
parents: 6415
diff changeset
  2352
begin
93eefff23bcd fix compiling with LUA_DISABLED
koda
parents: 6415
diff changeset
  2353
end;
93eefff23bcd fix compiling with LUA_DISABLED
koda
parents: 6415
diff changeset
  2354
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2355
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
  2356
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
  2357
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2358
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2359
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
  2360
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
  2361
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2362
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  2363
{$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
  2364
end.