hedgewars/uScript.pas
author nemo
Thu, 07 Apr 2011 11:30:56 -0400
changeset 5118 9cfdb9bc6140
parent 5075 59b13b38a827
child 5120 c4d5ddf939fc
permissions -rw-r--r--
For mikade - bit more flexibility in script captions
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
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4893
diff changeset
     3
 * Copyright (c) 2004-2011 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;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    22
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
    23
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    24
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
    25
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
    26
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    27
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
    28
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
    29
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    30
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
    31
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
    32
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
    33
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
    34
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
    35
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
    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 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
    38
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
    39
3acdb4dac6eb 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
implementation
3906
c5da430cb3fd enable Lua for iOS (hooks for frontend to be done)
koda
parents: 3896
diff changeset
    41
{$IFNDEF LUA_DISABLED}
3043
3acdb4dac6eb 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
uses LuaPas in 'LuaPas.pas',
3acdb4dac6eb 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
    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
    44
    uConsts,
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
    45
    uVisualGears,
3043
3acdb4dac6eb 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
    uGears,
3acdb4dac6eb 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
    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
    48
    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
    49
    uAmmos,
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    50
    uSound,
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
    51
    uChat,
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
    52
    uStats,
4875
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
    53
    uStore,
4357
a1fcfc341a52 Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents: 4319
diff changeset
    54
    uRandom,
4359
83ef50815535 Move variables from uMisc to uVariables
unC0Rr
parents: 4357
diff changeset
    55
    uTypes,
4373
fe0e3903bb9e Introduce uCommands.pas
unC0Rr
parents: 4372
diff changeset
    56
    uVariables,
4374
bcefeeabaa33 Move some stuff from uMisc to uUtils
unC0Rr
parents: 4373
diff changeset
    57
    uCommands,
4377
43945842da0c Haven't found a better place than uIO for OutError
unC0Rr
parents: 4374
diff changeset
    58
    uUtils,
4403
unc0rr
parents: 4399
diff changeset
    59
    uCaptions,
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
    60
    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
    61
    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
    62
    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
    63
    uTextures,
4985
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
    64
    uLandGraphics,
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
    65
    SDLh; 
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
    66
3043
3acdb4dac6eb 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
var luaState : Plua_State;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    68
    ScriptAmmoLoadout : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    69
    ScriptAmmoProbability : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    70
    ScriptAmmoDelay : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    71
    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
    72
    ScriptLoaded : boolean;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
    73
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    74
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
    75
procedure ScriptApplyAmmoStore; forward;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    76
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
    77
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    78
procedure LuaError(s: shortstring);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    79
begin
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    80
    WriteLnToConsole(s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    81
    AddChatString(#5 + s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    82
end;
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    83
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    84
// 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
    85
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    86
// 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
    87
// 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
    88
// 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
    89
// 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
    90
4483
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
    91
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
    92
begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
    93
    if lua_gettop(L) <> 2 then 
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
    94
        begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
    95
        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
    96
        lua_pushnil(L);
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
    97
        end
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
    98
    else lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1));
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
    99
    lc_band := 1;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   100
end;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   101
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   102
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
   103
begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   104
    if lua_gettop(L) <> 2 then 
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   105
        begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   106
        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
   107
        lua_pushnil(L);
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   108
        end
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   109
    else lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1));
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   110
    lc_bor := 1;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   111
end;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   112
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   113
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
   114
begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   115
    if lua_gettop(L) <> 1 then 
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   116
        begin
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   117
        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
   118
        lua_pushnil(L);
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
    else lua_pushinteger(L, not lua_tointeger(L, 1));
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   121
    lc_bnot := 1;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   122
end;
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
   123
4523
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   124
function lc_getinputmask(L : Plua_State) : LongInt; Cdecl;
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   125
begin
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   126
    if lua_gettop(L) <> 0 then
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   127
        LuaError('Lua: Wrong number of parameters passed to GetInputMask!')
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   128
    else lua_pushinteger(L, InputMask);
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   129
    lc_getinputmask:= 1
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   130
end;
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
   131
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
   132
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
   133
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
   134
    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
   135
        LuaError('Lua: Wrong number of parameters passed to SetInputMask!')
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
   136
    else InputMask:= lua_tointeger(L, 1);
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
   137
    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
   138
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
   139
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   140
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
   141
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
   142
    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
   143
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   144
        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
   145
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   146
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   147
        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
   148
    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
   149
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   150
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   151
function lc_parsecommand(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
   152
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
   153
    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
   154
        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
   155
        ParseCommand(lua_tostring(L ,1), 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
   156
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   157
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   158
        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
   159
    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
   160
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   161
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   162
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
   163
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
   164
    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
   165
        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
   166
        ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   167
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   168
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   169
        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
   170
    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
   171
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   172
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   173
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
   174
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   175
    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
   176
    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
   177
    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
   178
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   179
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   180
function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   181
begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   182
    if lua_gettop(L) = 1 then
5118
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
   183
        AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage)
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
   184
    else if lua_gettop(L) = 3 then
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   185
        begin
5118
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
   186
        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
   187
        end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   188
    else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   189
        LuaError('Lua: Wrong number of parameters passed to AddCaption!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   190
    lc_addcaption:= 0;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   191
end;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   192
3848
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   193
function lc_campaignlock(L : Plua_State) : LongInt; Cdecl;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   194
begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   195
    if lua_gettop(L) = 1 then
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   196
        begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   197
        // to be done
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   198
        end
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   199
    else
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   200
        LuaError('Lua: Wrong number of parameters passed to CampaignLock!');
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   201
    lc_campaignlock:= 0;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   202
end;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   203
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   204
function lc_campaignunlock(L : Plua_State) : LongInt; Cdecl;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   205
begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   206
    if lua_gettop(L) = 1 then
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   207
        begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   208
        // to be done
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   209
        end
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   210
    else
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   211
        LuaError('Lua: Wrong number of parameters passed to CampaignUnlock!');
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   212
    lc_campaignunlock:= 0;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   213
end;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   214
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   215
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
   216
var gear: PGear;
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   217
begin
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   218
    if lua_gettop(L) <> 2 then begin
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   219
        LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!');
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   220
        lua_pushnil(L);
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   221
    end
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   222
    else begin
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
   223
        gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   224
            HealthCrate, 0);
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   225
        lua_pushinteger(L, gear^.uid);
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   226
    end;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   227
    lc_spawnhealthcrate := 1;        
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   228
end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   229
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   230
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
   231
var gear: PGear;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   232
begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   233
    if lua_gettop(L) <> 3 then begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   234
        LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!');
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   235
        lua_pushnil(L);
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   236
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   237
    else begin
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
   238
        gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   239
            AmmoCrate, lua_tointeger(L, 3));
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   240
        lua_pushinteger(L, gear^.uid);
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   241
    end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   242
    lc_spawnammocrate := 1;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   243
end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   244
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   245
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
   246
var gear: PGear;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   247
begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   248
    if lua_gettop(L) <> 3 then begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   249
        LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!');
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   250
        lua_pushnil(L);
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   251
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   252
    else begin  
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
   253
        gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   254
            UtilityCrate, lua_tointeger(L, 3));
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   255
        lua_pushinteger(L, gear^.uid);
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   256
    end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   257
    lc_spawnutilitycrate := 1;
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   258
end;
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   259
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   260
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
   261
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
   262
    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
   263
    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
   264
    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
   265
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
   266
    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
   267
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   268
        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
   269
        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
   270
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   271
    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
   272
        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
   273
        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
   274
        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
   275
        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
   276
        s:= lua_tointeger(L, 4);
5074
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
   277
        dx:= int2hwFloat(lua_tointeger(L, 5)) / 1000000;
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
   278
        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
   279
        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
   280
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   281
        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
   282
        lastGearByUID:= gear;
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   283
        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
   284
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   285
    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
   286
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   287
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
   288
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
   289
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
   290
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
   291
    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
   292
        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
   293
        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
   294
        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
   295
    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
   296
        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
   297
        gear:= GearByUID(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
   298
        if gear <> nil then DeleteGear(gear);
d393b9ccd328 Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents: 4411
diff changeset
   299
        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
   300
    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
   301
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
   302
d393b9ccd328 Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents: 4411
diff changeset
   303
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
   304
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
   305
    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
   306
    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
   307
    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
   308
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
   309
    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
   310
        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
   311
        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
   312
        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
   313
        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
   314
    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
   315
        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
   316
        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
   317
        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
   318
        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
   319
        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
   320
        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
   321
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
   322
        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
   323
        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
   324
            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
   325
            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
   326
            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
   327
            end
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   328
        else 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
   329
        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
   330
    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
   331
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
   332
d393b9ccd328 Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents: 4411
diff changeset
   333
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
   334
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
   335
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
   336
    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
   337
        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
   338
        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
   339
        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
   340
    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
   341
        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
   342
        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
   343
        if vg <> nil then DeleteVisualGear(vg);
d393b9ccd328 Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents: 4411
diff changeset
   344
        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
   345
    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
   346
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
   347
d393b9ccd328 Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents: 4411
diff changeset
   348
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
   349
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
   350
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
   351
    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
   352
        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
   353
        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
   354
        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
   355
        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
   356
        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
   357
    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
   358
        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
   359
        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
   360
        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
   361
            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
   362
            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
   363
            lua_pushinteger(L, round(vg^.Y));
5075
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   364
            lua_pushnumber(L, vg^.dX);
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   365
            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
   366
            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
   367
            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
   368
            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
   369
            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
   370
            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
   371
            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
   372
            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
   373
        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
   374
            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
   375
            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
   376
            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
   377
            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
   378
        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
   379
    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
   380
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
   381
d393b9ccd328 Add an extra pass in FindPlace for AI resurrection mode to try to make it unwinnable, add DeleteGear, DeleteVisualGear, AddVisualGear, GetVisualGearValues, SetVisualGearValues to Lua
nemo
parents: 4411
diff changeset
   382
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
   383
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
   384
begin
4450
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   385
    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
   386
        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
   387
        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
   388
        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
   389
        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
   390
    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
   391
        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
   392
        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
   393
        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
   394
            begin
4450
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   395
            vg^.X:= lua_tointeger(L, 2);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   396
            vg^.Y:= lua_tointeger(L, 3);
5075
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   397
            vg^.dX:= lua_tonumber(L, 4);
59b13b38a827 not useful for visual gears, and apparently not helpful for consistency
nemo
parents: 5074
diff changeset
   398
            vg^.dY:= lua_tonumber(L, 5);
4450
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   399
            vg^.Angle:= lua_tonumber(L, 6);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   400
            vg^.Frame:= lua_tointeger(L, 7);
4546
a6402b8c2b24 oops, forgot world offset, also add a kind of hack to the already hackish set function for visual gears
nemo
parents: 4533
diff changeset
   401
            if lua_tointeger(L, 8) <> 0 then 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
   402
            vg^.State:= lua_tointeger(L, 9);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   403
            vg^.Timer:= lua_tointeger(L, 10);
b8d30b0e4829 forgot the passed in uid
nemo
parents: 4443
diff changeset
   404
            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
   405
            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
   406
        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
   407
    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
   408
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
   409
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   410
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   411
begin
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   412
    if lua_gettop(L) <> 0 then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   413
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   414
        LuaError('Lua: Wrong number of parameters passed to GetFollowGear!');
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   415
        lua_pushnil(L); // return value on stack (nil)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   416
        end
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   417
    else
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   418
        if FollowGear = nil then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   419
            lua_pushnil(L)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   420
        else
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   421
            lua_pushinteger(L, FollowGear^.uid);
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   422
    lc_getfollowgear:= 1; // 1 return value
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   423
end;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   424
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   425
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
   426
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
   427
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
   428
    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
   429
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   430
        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
   431
        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
   432
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   433
    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
   434
        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
   435
        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
   436
        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
   437
            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
   438
        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
   439
            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
   440
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   441
    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
   442
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   443
3892
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   444
function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   445
var gear : PGear;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   446
begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   447
    if lua_gettop(L) <> 1 then
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   448
        begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   449
        LuaError('Lua: Wrong number of parameters passed to GetGearMessage!');
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   450
        lua_pushnil(L); // return value on stack (nil)
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   451
        end
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   452
    else
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   453
        begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   454
        gear:= GearByUID(lua_tointeger(L, 1));
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   455
        if gear <> nil then
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   456
            lua_pushinteger(L, gear^.message)
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   457
        else
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   458
            lua_pushnil(L);
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   459
        end;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   460
    lc_getgearmessage:= 1
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   461
end;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   462
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
   463
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
   464
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
   465
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
   466
    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
   467
        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
   468
        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
   469
        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
   470
        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
   471
    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
   472
        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
   473
        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
   474
        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
   475
            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
   476
        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
   477
            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
   478
        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
   479
    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
   480
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
   481
3896
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   482
function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   483
var gear : PGear;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   484
begin
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   485
    if lua_gettop(L) <> 2 then
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   486
        LuaError('Lua: Wrong number of parameters passed to SetGearMessage!')
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   487
    else
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   488
        begin
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   489
        gear:= GearByUID(lua_tointeger(L, 1));
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   490
        if gear <> nil then
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   491
            gear^.message:= lua_tointeger(L, 2);
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   492
        end;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   493
    lc_setgearmessage:= 0
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   494
end;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   495
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   496
function lc_gethoglevel(L : Plua_State): LongInt; Cdecl;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   497
var gear : PGear;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   498
begin
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   499
    if lua_gettop(L) <> 1 then
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   500
        LuaError('Lua: Wrong number of parameters passed to GetHogLevel!')
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   501
    else begin
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   502
        gear := GearByUID(lua_tointeger(L, 1));
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   503
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   504
            lua_pushinteger(L, gear^.Hedgehog^.BotLevel)
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   505
        else
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   506
            lua_pushnil(L);
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   507
    end;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   508
    lc_gethoglevel := 1;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   509
end;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   510
4496
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   511
function lc_sethoglevel(L : Plua_State) : LongInt; Cdecl;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   512
var gear : PGear;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   513
begin
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   514
    if lua_gettop(L) <> 2 then
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   515
        LuaError('Lua: Wrong number of parameters passed to SetHogLevel!')
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   516
    else
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   517
        begin
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   518
        gear:= GearByUID(lua_tointeger(L, 1));
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   519
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   520
            gear^.Hedgehog^.BotLevel:= lua_tointeger(L, 2);
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   521
        end;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   522
    lc_sethoglevel:= 0
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   523
end;
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
   524
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   525
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
   526
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
   527
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
   528
    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
   529
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   530
        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
   531
        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
   532
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   533
    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
   534
        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
   535
        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
   536
        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
   537
            begin
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   538
            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
   539
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   540
        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
   541
            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
   542
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   543
    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
   544
end;
3acdb4dac6eb 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
4498
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   546
function lc_getclancolor(L : Plua_State) : LongInt; Cdecl;
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   547
begin
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   548
    if lua_gettop(L) <> 1 then
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   549
        begin
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   550
        LuaError('Lua: Wrong number of parameters passed to GetClanColor!');
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   551
        lua_pushnil(L); // return value on stack (nil)
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   552
        end
4499
d2454e4dbd03 return RGBA
nemo
parents: 4498
diff changeset
   553
    else lua_pushinteger(L, ClansArray[lua_tointeger(L, 1)]^.Color shl 8 or $FF);
4498
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   554
    lc_getclancolor:= 1
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   555
end;
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
   556
4882
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   557
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
   558
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
   559
    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
   560
    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
   561
    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
   562
    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
   563
    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
   564
begin
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   565
    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
   566
        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
   567
    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
   568
        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
   569
        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
   570
        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
   571
        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
   572
            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
   573
            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
   574
            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
   575
                begin
4891
nemo
parents: 4890
diff changeset
   576
                hh:= team^.Hedgehogs[j];
4890
nemo
parents: 4889
diff changeset
   577
                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
   578
                    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
   579
                    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
   580
                    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
   581
                    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
   582
                    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
   583
                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
   584
            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
   585
            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
   586
            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
   587
            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
   588
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
   589
            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
   590
            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
   591
            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
   592
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
   593
            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
   594
            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
   595
            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
   596
            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
   597
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
   598
            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
   599
            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
   600
            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
   601
            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
   602
            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
   603
        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
   604
    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
   605
end;
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
   606
4236
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   607
function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   608
var gear : PGear;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   609
begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   610
    if lua_gettop(L) <> 1 then
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   611
        begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   612
        LuaError('Lua: Wrong number of parameters passed to GetHogTeamName!');
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   613
        lua_pushnil(L); // return value on stack (nil)
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   614
        end
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   615
    else
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   616
        begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   617
        gear:= GearByUID(lua_tointeger(L, 1));
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   618
        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
   619
            begin
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   620
            lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName))
4236
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   621
            end
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   622
        else
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   623
            lua_pushnil(L);
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   624
        end;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   625
    lc_gethogteamname:= 1
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   626
end;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   627
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   628
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
   629
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
   630
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
   631
    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
   632
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   633
        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
   634
        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
   635
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   636
    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
   637
        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
   638
        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
   639
        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
   640
            begin
4372
3836973380b9 remove some more PHedgehog casts
nemo
parents: 4371
diff changeset
   641
            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
   642
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   643
        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
   644
            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
   645
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   646
    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
   647
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   648
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   649
function lc_gettimer(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   650
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   651
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   652
    if lua_gettop(L) <> 1 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   653
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   654
        LuaError('Lua: Wrong number of parameters passed to GetTimer!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   655
        lua_pushnil(L); // return value on stack (nil)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   656
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   657
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   658
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   659
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   660
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   661
            lua_pushinteger(L, gear^.Timer)
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   662
        else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   663
            lua_pushnil(L);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   664
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   665
    lc_gettimer:= 1
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   666
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   667
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   668
function lc_gethealth(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   669
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   670
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   671
    if lua_gettop(L) <> 1 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   672
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   673
        LuaError('Lua: Wrong number of parameters passed to GetHealth!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   674
        lua_pushnil(L); // return value on stack (nil)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   675
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   676
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   677
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   678
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   679
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   680
            lua_pushinteger(L, gear^.Health)
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   681
        else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   682
            lua_pushnil(L);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   683
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   684
    lc_gethealth:= 1
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   685
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   686
3043
3acdb4dac6eb 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
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
   688
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
   689
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
   690
    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
   691
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   692
        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
   693
        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
   694
        end
3acdb4dac6eb 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
    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
   696
        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
   697
        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
   698
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   699
            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
   700
        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
   701
            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
   702
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   703
    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
   704
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   705
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   706
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
   707
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
   708
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
   709
    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
   710
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   711
        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
   712
        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
   713
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   714
    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
   715
        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
   716
        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
   717
        if gear <> nil then
4484
b7a098f2649a these should probably be expressly integer
nemo
parents: 4483
diff changeset
   718
            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
   719
        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
   720
            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
   721
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   722
    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
   723
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   724
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   725
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
   726
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
   727
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
   728
    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
   729
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   730
        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
   731
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   732
    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
   733
        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
   734
        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
   735
        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
   736
        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
   737
            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
   738
            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
   739
            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
   740
            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
   741
            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
   742
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   743
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   744
    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
   745
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   746
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   747
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
   748
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
   749
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
   750
    if lua_gettop(L) <> 1 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   751
        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
   752
    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
   753
        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
   754
        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
   755
        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
   756
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   757
    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
   758
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   759
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   760
function lc_hogsay(L : Plua_State) : LongInt; Cdecl;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   761
var gear : PGear;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   762
   vgear : PVisualGear;
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   763
       s : LongWord;
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   764
begin
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   765
    if lua_gettop(L) = 4 then s:= lua_tointeger(L, 4)
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   766
    else s:= 0;
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   767
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   768
    if (lua_gettop(L) = 4) or (lua_gettop(L) = 3) then
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   769
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   770
        gear:= GearByUID(lua_tointeger(L, 1));
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   771
        if gear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   772
            begin
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   773
            vgear:= AddVisualGear(0, 0, vgtSpeechBubble, s, true);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   774
            if vgear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   775
               begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   776
               vgear^.Text:= lua_tostring(L, 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   777
               vgear^.Hedgehog:= gear^.Hedgehog;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   778
               vgear^.FrameTicks:= lua_tointeger(L, 3);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   779
               if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then vgear^.FrameTicks:= 1;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   780
               end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   781
            end
4533
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   782
        end
8d35c3e0e6ba add optional state parameter to hogsay
nemo
parents: 4523
diff changeset
   783
    else LuaError('Lua: Wrong number of parameters passed to HogSay!');
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   784
    lc_hogsay:= 0
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   785
end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   786
4851
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   787
function lc_switchhog(L : Plua_State) : LongInt; Cdecl;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   788
var gear, prevgear : PGear;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   789
begin
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   790
    if lua_gettop(L) <> 1 then
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   791
        LuaError('Lua: Wrong number of parameters passed to SwitchHog!')
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   792
    else
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   793
        begin
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   794
        gear:= GearByUID(lua_tointeger(L, 1));
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   795
// 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
   796
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   797
            begin
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   798
            prevgear := CurrentHedgehog^.Gear;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   799
            prevgear^.Active := false;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   800
            prevgear^.State:= prevgear^.State and not gstHHDriven;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   801
            prevgear^.Z := cHHZ;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   802
            RemoveGearFromList(prevgear);
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   803
            InsertGearToList(prevgear);
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   804
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   805
            CurrentHedgehog := gear^.Hedgehog;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   806
// yes, this will muck up turn sequence
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   807
            CurrentTeam := gear^.Hedgehog^.Team;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   808
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   809
            gear^.State:= gear^.State or gstHHDriven;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   810
            gear^.Active := true;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   811
            gear^.Z := cCurrHHZ;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   812
            RemoveGearFromList(gear);
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   813
            InsertGearToList(gear);
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   814
            end
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   815
        end;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   816
    lc_switchhog:= 0
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   817
end;
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
   818
4481
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   819
function lc_addammo(L : Plua_State) : LongInt; Cdecl;
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   820
var gear : PGear;
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   821
begin
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   822
    if lua_gettop(L) <> 2 then
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   823
        begin
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   824
        LuaError('Lua: Wrong number of parameters passed to AddAmmo!');
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   825
        end
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   826
    else
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   827
        begin
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   828
        gear:= GearByUID(lua_tointeger(L, 1));
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   829
        if (gear <> nil) and (gear^.Hedgehog <> nil) then
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   830
            AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)));
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   831
        end;
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   832
    lc_addammo:= 0
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   833
end;
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
   834
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   835
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
   836
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
   837
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
   838
    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
   839
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   840
        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
   841
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   842
    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
   843
        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
   844
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   845
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   846
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   847
            gear^.Health:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   848
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   849
            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
   850
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   851
    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
   852
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   853
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   854
function lc_settimer(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   855
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   856
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   857
    if lua_gettop(L) <> 2 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   858
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   859
        LuaError('Lua: Wrong number of parameters passed to SetTimer!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   860
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   861
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   862
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   863
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   864
        if gear <> nil then gear^.Timer:= lua_tointeger(L, 2)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   865
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   866
    lc_settimer:= 0
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   867
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   868
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   869
function lc_seteffect(L : Plua_State) : LongInt; Cdecl;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   870
var gear: PGear;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   871
begin
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   872
    if lua_gettop(L) <> 3 then
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   873
        LuaError('Lua: Wrong number of parameters passed to SetEffect!')
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   874
    else begin
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   875
        gear := GearByUID(lua_tointeger(L, 1));
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   876
        if gear <> nil then
4411
79fbc444584c fix SetEffect, last parameter was not a boolean
Henek
parents: 4403
diff changeset
   877
            gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_toboolean(L, 3);
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   878
    end;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   879
    lc_seteffect := 0;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   880
end;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   881
3043
3acdb4dac6eb 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
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
   883
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
   884
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
   885
    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
   886
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   887
        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
   888
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   889
    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
   890
        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
   891
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   892
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   893
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   894
            gear^.State:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   895
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   896
            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
   897
        end;
3acdb4dac6eb 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
    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
   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
3acdb4dac6eb 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
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
   902
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
   903
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
   904
    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
   905
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   906
        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
   907
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   908
    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
   909
        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
   910
        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
   911
        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
   912
            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
   913
        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
   914
            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
   915
        end;
3acdb4dac6eb 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
    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
   917
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   920
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
   921
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
   922
    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
   923
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   924
        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
   925
        end
3acdb4dac6eb 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
    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
   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
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   929
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   930
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   931
            gear^.Tag:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   932
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   933
            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
   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_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
   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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   938
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
   939
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   940
    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
   941
    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
   942
    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
   943
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   944
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   945
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
   946
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
   947
    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
   948
    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
   949
    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
   950
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
   951
    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
   952
    if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   953
        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
   954
    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
   955
        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
   956
        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
   957
        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
   958
        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
   959
        right:= lua_tointeger(L, 4);
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
   960
        if lua_gettop(L) = 5 then 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
   961
        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
   962
            FindPlace(gear, fall, left, right, tryhard);
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
   963
        if gear <> nil then lua_pushinteger(L, gear^.uid)
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
   964
        else 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
   965
        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
   966
    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
   967
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   968
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   969
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
   970
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
   971
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
   972
    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
   973
        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
   974
    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
   975
        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
   976
        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
   977
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) 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
   978
            PlaySound(TSound(lua_tointeger(L, 1)),gear^.Hedgehog^.Team^.Voicepack)
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
   979
        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
   980
    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
   981
    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
   982
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   983
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   984
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
   985
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
   986
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
   987
    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
   988
    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
   989
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   990
        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
   991
        //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
   992
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   993
    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
   994
        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
   995
        ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), 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
   996
        ParseCommand('grave ' + lua_tostring(L, 3), 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
   997
        ParseCommand('fort ' + lua_tostring(L, 4), 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
   998
        ParseCommand('voicepack ' + lua_tostring(L, 5), true);
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
   999
        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
  1000
        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
  1001
        // 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
  1002
        //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
  1003
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1004
    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
  1005
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1006
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1007
function lc_addhog(L : Plua_State) : LongInt; Cdecl;
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
  1008
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
  1009
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
  1010
    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
  1011
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1012
        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
  1013
        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
  1014
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1015
    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
  1016
        begin
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
  1017
        temp:= lua_tostring(L, 4);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1018
        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
  1019
        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
  1020
        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
  1021
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1022
    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
  1023
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1024
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1025
function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1026
var gear: PGear;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1027
begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1028
    if lua_gettop(L) <> 2 then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1029
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1030
        LuaError('Lua: Wrong number of parameters passed to HogTurnLeft!');
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1031
        end
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1032
    else
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1033
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1034
        gear:= GearByUID(lua_tointeger(L, 1));
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1035
        if gear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1036
            gear^.dX.isNegative:= lua_toboolean(L, 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1037
        end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1038
    lc_hogturnleft:= 0;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1039
end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1040
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1041
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
  1042
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
  1043
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
  1044
    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
  1045
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1046
        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
  1047
        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
  1048
        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
  1049
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1050
    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
  1051
        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
  1052
        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
  1053
        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
  1054
            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
  1055
            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
  1056
            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
  1057
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1058
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1059
    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
  1060
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1061
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1062
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
  1063
var gear: PGear;
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1064
    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
  1065
    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
  1066
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
  1067
    if lua_gettop(L) <> 3 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1068
        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
  1069
    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
  1070
        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
  1071
        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
  1072
        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
  1073
            begin
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1074
            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
  1075
            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
  1076
            y:= lua_tointeger(L, 3);
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1077
            if col then 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
  1078
            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
  1079
            gear^.Y:= int2hwfloat(y);
4832
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1080
            if col then AddGearCI(gear);
e55e2b6f59b0 update collision in set gear position
nemo
parents: 4780
diff changeset
  1081
            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
  1082
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1083
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1084
    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
  1085
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1086
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
  1087
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
  1088
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
  1089
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
  1090
    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
  1091
        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
  1092
        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
  1093
        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
  1094
        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
  1095
        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
  1096
    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
  1097
        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
  1098
        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
  1099
        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
  1100
            begin
5074
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
  1101
            lua_pushinteger(L, hwRound(gear^.dX * 1000000));
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
  1102
            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
  1103
            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
  1104
        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
  1105
    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
  1106
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
  1107
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
  1108
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
  1109
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
  1110
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
  1111
    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
  1112
        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
  1113
    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
  1114
        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
  1115
        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
  1116
        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
  1117
            begin
5074
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
  1118
            gear^.dX:= int2hwFloat(lua_tointeger(L, 2)) / 1000000;
16f9e2d1f3b2 eh. 1,000,000 might be better...
nemo
parents: 5073
diff changeset
  1119
            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
  1120
            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
  1121
            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
  1122
        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
  1123
    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
  1124
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
  1125
3736
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1126
function lc_setzoom(L : Plua_State) : LongInt; Cdecl;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1127
begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1128
    if lua_gettop(L) <> 1 then
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1129
        LuaError('Lua: Wrong number of parameters passed to SetZoom!')
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1130
    else
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1131
        begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1132
        ZoomValue:= lua_tonumber(L, 1);
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1133
        if ZoomValue < cMaxZoomLevel then ZoomValue:= cMaxZoomLevel;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1134
        if ZoomValue > cMinZoomLevel then ZoomValue:= cMinZoomLevel;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1135
        end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1136
    lc_setzoom:= 0
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1137
end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1138
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1139
function lc_getzoom(L : Plua_State) : LongInt; Cdecl;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1140
begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1141
    if lua_gettop(L) <> 0 then
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1142
        begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1143
        LuaError('Lua: Wrong number of parameters passed to GetZoom!');
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1144
        lua_pushnil(L)
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1145
        end
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1146
    else
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1147
        lua_pushnumber(L, ZoomValue);
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1148
    lc_getzoom:= 1
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1149
end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1150
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1151
function lc_setammo(L : Plua_State) : LongInt; Cdecl;
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1152
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
  1153
begin
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1154
    np:= lua_gettop(L);
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1155
    if (np < 4) or (np > 5) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1156
        LuaError('Lua: Wrong number of parameters passed to SetAmmo!')
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1157
    else if np = 4 then
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
  1158
        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
  1159
    else
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1160
        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
  1161
    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
  1162
end;
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1163
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1164
function lc_getrandom(L : Plua_State) : LongInt; Cdecl;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1165
var m : LongInt;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1166
begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1167
    if lua_gettop(L) <> 1 then
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1168
        begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1169
        LuaError('Lua: Wrong number of parameters passed to GetRandom!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1170
        lua_pushnil(L); // return value on stack (nil)
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1171
        end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1172
    else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1173
        begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1174
        m:= lua_tointeger(L, 1);
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1175
        if (m > 0) then
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1176
            lua_pushinteger(L, GetRandom(m))
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1177
        else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1178
            begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1179
            LuaError('Lua: Tried to pass 0 to GetRandom!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1180
            lua_pushnil(L);
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1181
            end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1182
        end;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1183
    lc_getrandom:= 1
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1184
end;
4399
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1185
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1186
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
  1187
begin
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1188
    if lua_gettop(L) <> 1 then
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1189
        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
  1190
    else
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1191
        begin
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1192
        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
  1193
        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
  1194
        if cWindSpeed.isNegative then
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1195
            CWindSpeedf := -cWindSpeedf;
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1196
        AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1)^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1197
        end;
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1198
    lc_setwind:= 0
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1199
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
  1200
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
  1201
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
  1202
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
  1203
    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
  1204
        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
  1205
        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
  1206
        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
  1207
        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
  1208
    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
  1209
        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
  1210
    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
  1211
end;
4590
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1212
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1213
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
  1214
begin
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1215
    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
  1216
        begin
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1217
        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
  1218
        lua_pushnil(L);
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1219
        end
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1220
    else
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1221
        lua_pushboolean(L, hasBorder);
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1222
    lc_maphasborder:= 1
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1223
end;
4869
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1224
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1225
function lc_getgearradius(L : Plua_State) : LongInt; Cdecl;
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1226
var gear : PGear;
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1227
begin
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1228
    if lua_gettop(L) <> 1 then
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1229
        begin
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1230
        LuaError('Lua: Wrong number of parameters passed to GetGearRadius!');
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1231
        lua_pushnil(L); // return value on stack (nil)
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1232
        end
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1233
    else
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1234
        begin
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1235
        gear:= GearByUID(lua_tointeger(L, 1));
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1236
        if gear <> nil then
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1237
            lua_pushinteger(L, gear^.Radius)
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1238
        else
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1239
            lua_pushnil(L);
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1240
        end;
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1241
    lc_getgearradius:= 1
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1242
end;
4875
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1243
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1244
function lc_gethoghat(L : Plua_State): LongInt; Cdecl;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1245
var gear : PGear;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1246
begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1247
    if lua_gettop(L) <> 1 then
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1248
        LuaError('Lua: Wrong number of parameters passed to GetHogHat!')
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1249
    else begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1250
        gear := GearByUID(lua_tointeger(L, 1));
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1251
        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
  1252
            lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat))
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1253
        else
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1254
            lua_pushnil(L);
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1255
    end;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1256
    lc_gethoghat := 1;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1257
end;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1258
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1259
function lc_sethoghat(L : Plua_State) : LongInt; Cdecl;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1260
var gear : PGear;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1261
    hat: ShortString;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1262
begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1263
    if lua_gettop(L) <> 2 then
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1264
        begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1265
        LuaError('Lua: Wrong number of parameters passed to SetHogHat!');
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1266
        lua_pushnil(L)
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1267
        end
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1268
    else
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1269
        begin
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1270
        gear:= GearByUID(lua_tointeger(L, 1));
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1271
        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
  1272
            hat:= lua_tostring(L, 2);
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1273
            gear^.Hedgehog^.Hat:= hat;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1274
            LoadHedgehogHat(gear, hat);
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1275
        end;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1276
    lc_sethoghat:= 0;
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1277
end;
4985
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1278
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1279
function lc_placegirder(L : Plua_State) : LongInt; Cdecl;
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1280
begin
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1281
    if lua_gettop(L) <> 3 then
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1282
        LuaError('Lua: Wrong number of parameters passed to PlaceGirder!')
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1283
    else
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1284
        TryPlaceOnLand(
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1285
            lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2,
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1286
            lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2,
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1287
            sprAmGirder, lua_tointeger(L, 3), true, false);
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1288
    lc_placegirder:= 0
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1289
end;
5013
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1290
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1291
function lc_getcurammotype(L : Plua_State): LongInt; Cdecl;
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1292
begin
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1293
    if lua_gettop(L) <> 0 then
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1294
        LuaError('Lua: Wrong number of parameters passed to GetCurAmmoType!')
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1295
    else
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1296
        lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType));
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1297
    lc_getcurammotype := 1;
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1298
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
  1299
///////////////////
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1302
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
  1303
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
  1304
    n:= lua_gettop(luaState);
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1305
    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
  1306
    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
  1307
        if not lua_isboolean(luaState, i) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1308
            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
  1309
        else if lua_toboolean(luaState, i) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1310
            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
  1311
        else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1312
            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
  1313
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1314
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1315
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
  1316
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
  1317
lua_settop(luaState, 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
  1318
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1321
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
  1322
lua_pushnil(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
  1323
lua_setglobal(luaState, Str2PChar(name));
3acdb4dac6eb 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
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1327
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
  1328
lua_pushinteger(luaState, 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
  1329
lua_setglobal(luaState, Str2PChar(name));
3acdb4dac6eb 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
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1333
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
  1334
lua_pushstring(luaState, Str2PChar(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
  1335
lua_setglobal(luaState, Str2PChar(name));
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1336
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1337
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1338
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
  1339
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
  1340
lua_getglobal(luaState, Str2PChar(name));
3acdb4dac6eb 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
ScriptGetInteger:= 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
  1342
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
  1343
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1346
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
  1347
lua_getglobal(luaState, Str2PChar(name));
3acdb4dac6eb 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
ScriptGetString:= lua_tostring(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
  1349
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
  1350
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1353
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
  1354
// 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
  1355
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
  1356
    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
  1357
3acdb4dac6eb 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
// push game variables so they may be modified by the script
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1359
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
  1360
ScriptSetString('Seed', cSeed);
3acdb4dac6eb 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
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
  1362
ScriptSetInteger('CaseFreq', cCaseFactor);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1363
ScriptSetInteger('HealthCaseProb', cHealthCaseProb);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1364
ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1365
ScriptSetInteger('DamagePercent', cDamagePercent);
4003
ca0600ab38bf disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents: 3999
diff changeset
  1366
ScriptSetInteger('MinesNum', cLandMines);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1367
ScriptSetInteger('MinesTime', cMinesTime);
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1368
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
  1369
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
  1370
ScriptSetInteger('Delay', cInactDelay);
3774
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1371
ScriptSetInteger('Ready', cReadyDelay);
3197
smxx
parents: 3058
diff changeset
  1372
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1373
ScriptSetInteger('WaterRise', cWaterRise);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1374
ScriptSetInteger('HealthDecrease', cHealthDecrease);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1375
ScriptSetString('Map', '');
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1376
ScriptSetString('Theme', '');
4883
7cddc9201a1d added dummy for tardis and ugly icons for tardis and structure
Henek
parents: 4882
diff changeset
  1377
ScriptSetString('Goals', '');
7cddc9201a1d added dummy for tardis and ugly icons for tardis and structure
Henek
parents: 4882
diff changeset
  1378
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1379
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
  1380
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1381
// 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
  1382
ParseCommand('seed ' + ScriptGetString('Seed'), 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
  1383
ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), 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
  1384
ParseCommand('$turntime ' + ScriptGetString('TurnTime'), 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
  1385
ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1386
ParseCommand('$healthprob ' + ScriptGetString('HealthCaseProb'), true);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1387
ParseCommand('$hcaseamount ' + ScriptGetString('HealthCaseAmount'), true);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1388
ParseCommand('$damagepct ' + ScriptGetString('DamagePercent'), true);
4003
ca0600ab38bf disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents: 3999
diff changeset
  1389
ParseCommand('$minesnum ' + ScriptGetString('MinesNum'), true);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1390
ParseCommand('$minestime ' + ScriptGetString('MinesTime'), true);
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
  1391
ParseCommand('$minedudpct ' + ScriptGetString('MineDudPercent'), 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
  1392
ParseCommand('$explosives ' + ScriptGetString('Explosives'), 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
  1393
ParseCommand('$delay ' + ScriptGetString('Delay'), true);
3777
5276f2150d65 Engine:
smaxx
parents: 3774
diff changeset
  1394
ParseCommand('$ready ' + ScriptGetString('Ready'), true);
3197
smxx
parents: 3058
diff changeset
  1395
ParseCommand('$sd_turns ' + ScriptGetString('SuddenDeathTurns'), true);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1396
ParseCommand('$waterrise ' + ScriptGetString('WaterRise'), true);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1397
ParseCommand('$healthdec ' + ScriptGetString('HealthDecrease'), 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
  1398
if ScriptGetString('Map') <> '' 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
  1399
    ParseCommand('map ' + ScriptGetString('Map'), 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
  1400
if ScriptGetString('Theme') <> '' then
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
  1401
    ParseCommand('theme ' + ScriptGetString('Theme'), true);
4883
7cddc9201a1d added dummy for tardis and ugly icons for tardis and structure
Henek
parents: 4882
diff changeset
  1402
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
  1403
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1404
if ScriptExists('onAmmoStoreInit') 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
  1405
    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
  1406
    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
  1407
    ScriptCall('onAmmoStoreInit');
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1408
    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
  1409
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1410
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
  1411
ScriptSetInteger('ClansCount', ClansCount);
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
  1412
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
  1413
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1414
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1415
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
  1416
var ret : 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
  1417
begin
3919
76d5b32758d9 Engine/Frontend:
smaxx
parents: 3906
diff changeset
  1418
ret:= luaL_loadfile(luaState, Str2PChar(Pathz[ptData] + '/' + 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
  1419
if ret <> 0 then
3774
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1420
    begin
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1421
    LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1422
    LuaError('Lua: ' + lua_tostring(luaState, -1));
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
  1423
    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
  1424
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
  1425
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1426
    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
  1427
    // 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
  1428
    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
  1429
    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
  1430
    end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1431
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1432
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1433
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
  1434
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
  1435
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1436
ScriptSetInteger('GameTime', GameTicks);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1437
ScriptSetInteger('RealTime', RealTicks);
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
  1438
ScriptSetInteger('TotalRounds', TotalRounds);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1439
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
  1440
    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
  1441
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
  1442
    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
  1443
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1444
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1445
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
  1446
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
  1447
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
  1448
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1449
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1450
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
  1451
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
  1452
if not ScriptLoaded or not ScriptExists(fname) 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
  1453
    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
  1454
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
  1455
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
  1456
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
  1457
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1458
    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
  1459
    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
  1460
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1461
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
  1462
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1463
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1464
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
  1465
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
  1466
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
  1467
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1468
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1469
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
  1470
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
  1471
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
  1472
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1473
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1474
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
  1475
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
  1476
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
  1477
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1478
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1479
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
  1480
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
  1481
if not ScriptLoaded or not ScriptExists(fname) 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
  1482
    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
  1483
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
  1484
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
  1485
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
  1486
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
  1487
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
  1488
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
  1489
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
  1490
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
  1491
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1492
    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
  1493
    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
  1494
    end
3acdb4dac6eb 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
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
  1496
    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
  1497
    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
  1498
    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
  1499
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1500
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
  1501
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1502
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1503
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
  1504
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
  1505
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
  1506
    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
  1507
    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
  1508
    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
  1509
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1510
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
  1511
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
  1512
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
  1513
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1514
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1515
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
  1516
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
  1517
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
  1518
// reset ammostore (quite unclean, but works?)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1519
uAmmos.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
  1520
uAmmos.initModule;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1521
ScriptAmmoLoadout:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1522
ScriptAmmoDelay:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1523
ScriptAmmoProbability:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1524
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
  1525
for i:=1 to ord(High(TAmmoType)) do
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1526
    begin
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1527
    ScriptAmmoLoadout:= ScriptAmmoLoadout + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1528
    ScriptAmmoProbability:= ScriptAmmoProbability + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1529
    ScriptAmmoDelay:= ScriptAmmoDelay + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1530
    ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1531
    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
  1532
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1533
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1534
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
  1535
begin
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1536
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
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1537
    exit;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1538
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1539
ScriptAmmoProbability[ord(ammo)]:= inttostr(propability)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1540
ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1541
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
  1542
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1543
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1544
procedure 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
  1545
var 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
  1546
begin
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1547
SetAmmoLoadout(ScriptAmmoLoadout);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1548
SetAmmoProbability(ScriptAmmoProbability);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1549
SetAmmoDelay(ScriptAmmoDelay);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1550
SetAmmoReinforcement(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
  1551
for i:= 0 to Pred(TeamsCount) do
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1552
    AddAmmoStore;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1553
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1554
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1555
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
  1556
var at : TGearType;
4453
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  1557
    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
  1558
    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
  1559
    st : TSound;
5118
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  1560
    he : THogEffect;
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  1561
    cg : TCapGroup;
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
  1562
    s, t : ansistring;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1563
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
  1564
// 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
  1565
luaState:= lua_open;
3045
41732f986b4f Clean Augean stables
unc0rr
parents: 3043
diff changeset
  1566
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
  1567
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1568
// 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
  1569
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
  1570
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
  1571
luaopen_math(luaState);
3724
b8678667e7dc Engine:
smaxx
parents: 3723
diff changeset
  1572
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
  1573
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1574
// 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
  1575
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
  1576
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1577
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
  1578
// import locale
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
  1579
s:= cLocaleFName;
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
  1580
t:= '';
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
  1581
SplitByChar(s, t, '.');
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
  1582
ScriptSetString('L', s);
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
  1583
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1584
// 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
  1585
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
  1586
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
  1587
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
  1588
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
  1589
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
  1590
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
  1591
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
  1592
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
  1593
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
  1594
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
  1595
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
  1596
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
  1597
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
  1598
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
  1599
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
  1600
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
  1601
ScriptSetInteger('gfDisableGirders', gfDisableGirders);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1602
ScriptSetInteger('gfDisableLandObjects', gfDisableLandObjects);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1603
ScriptSetInteger('gfAISurvival', gfAISurvival);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1604
ScriptSetInteger('gfInfAttack', gfInfAttack);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1605
ScriptSetInteger('gfResetWeps', gfResetWeps);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1606
ScriptSetInteger('gfPerHogAmmo', gfPerHogAmmo);
4219
4162db7c11bb fix so gfDisableWind can infact be used in lua
Henek
parents: 4162
diff changeset
  1607
ScriptSetInteger('gfDisableWind', gfDisableWind);
4319
81391b54b078 clean up and lua update, very minor
Henek
parents: 4243
diff changeset
  1608
ScriptSetInteger('gfMoreWind', gfMoreWind);
5016
9347d82a26cc added game mode Tag Team, mostly untested, please test :)
Henek
parents: 5013
diff changeset
  1609
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
  1610
3894
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1611
ScriptSetInteger('gmLeft', gmLeft);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1612
ScriptSetInteger('gmRight', gmRight);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1613
ScriptSetInteger('gmUp', gmUp);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1614
ScriptSetInteger('gmDown', gmDown);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1615
ScriptSetInteger('gmSwitch', gmSwitch);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1616
ScriptSetInteger('gmAttack', gmAttack);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1617
ScriptSetInteger('gmLJump', gmLJump);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1618
ScriptSetInteger('gmHJump', gmHJump);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1619
ScriptSetInteger('gmDestroy', gmDestroy);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1620
ScriptSetInteger('gmSlot', gmSlot);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1621
ScriptSetInteger('gmWeapon', gmWeapon);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1622
ScriptSetInteger('gmTimer', gmTimer);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1623
ScriptSetInteger('gmAnimate', gmAnimate);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1624
ScriptSetInteger('gmPrecise', gmPrecise);
3892
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  1625
ScriptSetInteger('gmAllStoppable', gmAllStoppable);
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  1626
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  1627
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1628
// speech bubbles
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1629
ScriptSetInteger('SAY_SAY', 1);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1630
ScriptSetInteger('SAY_THINK', 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1631
ScriptSetInteger('SAY_SHOUT', 3);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1632
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1633
// 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
  1634
for at:= Low(TGearType) to High(TGearType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  1635
    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
  1636
4453
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  1637
for vgt:= Low(TVisualGearType) to High(TVisualGearType) do
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  1638
    ScriptSetInteger(EnumToStr(vgt), ord(vgt));
15a483b2558a add visual gear registration
nemo
parents: 4450
diff changeset
  1639
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1640
// 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
  1641
for st:= Low(TSound) to High(TSound) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  1642
    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
  1643
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1644
// 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
  1645
for am:= Low(TAmmoType) to High(TAmmoType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  1646
    ScriptSetInteger(EnumToStr(am), ord(am));
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
  1647
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1648
for he:= Low(THogEffect) to High(THogEffect) do
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1649
    ScriptSetInteger(EnumToStr(he), ord(he));
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1650
5118
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  1651
for cg:= Low(TCapGroup) to High(TCapGroup) do
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  1652
    ScriptSetInteger(EnumToStr(cg), ord(cg));
9cfdb9bc6140 For mikade - bit more flexibility in script captions
nemo
parents: 5075
diff changeset
  1653
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1654
// register functions
4483
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
  1655
lua_register(luaState, 'band', @lc_band);
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
  1656
lua_register(luaState, 'bor', @lc_bor);
ad1524a177bd band/bor/bnot to support Lua 5.1 lack of binary ops
nemo
parents: 4481
diff changeset
  1657
lua_register(luaState, 'bnot', @lc_bnot);
4523
23ed16e6c7d2 oops. forgot the getter.
nemo
parents: 4522
diff changeset
  1658
lua_register(luaState, 'GetInputMask', @lc_getinputmask);
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
  1659
lua_register(luaState, 'SetInputMask', @lc_setinputmask);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1660
lua_register(luaState, 'AddGear', @lc_addgear);
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
  1661
lua_register(luaState, 'DeleteGear', @lc_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
  1662
lua_register(luaState, 'AddVisualGear', @lc_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
  1663
lua_register(luaState, 'DeleteVisualGear', @lc_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
  1664
lua_register(luaState, 'GetVisualGearValues', @lc_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
  1665
lua_register(luaState, 'SetVisualGearValues', @lc_setvisualgearvalues);
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
  1666
lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate);
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
  1667
lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate);
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
  1668
lua_register(luaState, 'SpawnUtilityCrate', @lc_spawnutilitycrate);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1669
lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1670
lua_register(luaState, 'GetGearType', @lc_getgeartype);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1671
lua_register(luaState, 'EndGame', @lc_endgame);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1672
lua_register(luaState, 'FindPlace', @lc_findplace);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1673
lua_register(luaState, 'SetGearPosition', @lc_setgearposition);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1674
lua_register(luaState, 'GetGearPosition', @lc_getgearposition);
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
  1675
lua_register(luaState, 'SetGearVelocity', @lc_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
  1676
lua_register(luaState, 'GetGearVelocity', @lc_getgearvelocity);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1677
lua_register(luaState, 'ParseCommand', @lc_parsecommand);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1678
lua_register(luaState, 'ShowMission', @lc_showmission);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1679
lua_register(luaState, 'HideMission', @lc_hidemission);
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1680
lua_register(luaState, 'AddCaption', @lc_addcaption);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1681
lua_register(luaState, 'SetAmmo', @lc_setammo);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1682
lua_register(luaState, 'PlaySound', @lc_playsound);
3acdb4dac6eb 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
lua_register(luaState, 'AddTeam', @lc_addteam);
3acdb4dac6eb 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
lua_register(luaState, 'AddHog', @lc_addhog);
4481
0d73e7db3d59 Eh. Since you asked. AddAmmo hook for Lua
nemo
parents: 4456
diff changeset
  1685
lua_register(luaState, 'AddAmmo', @lc_addammo);
3043
3acdb4dac6eb 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
lua_register(luaState, 'SetHealth', @lc_sethealth);
4319
81391b54b078 clean up and lua update, very minor
Henek
parents: 4243
diff changeset
  1687
lua_register(luaState, 'GetHealth', @lc_gethealth);
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1688
lua_register(luaState, 'SetEffect', @lc_seteffect);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1689
lua_register(luaState, 'GetHogClan', @lc_gethogclan);
4498
8c9595e39539 clan color fetch
nemo
parents: 4496
diff changeset
  1690
lua_register(luaState, 'GetClanColor', @lc_getclancolor);
4882
b4c84db92d8f expose set clan color for Cairo. might also be useful for betrayals in campaign mode or somesuch
nemo
parents: 4875
diff changeset
  1691
lua_register(luaState, 'SetClanColor', @lc_setclancolor);
4236
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
  1692
lua_register(luaState, 'GetHogTeamName', @lc_gethogteamname);
3043
3acdb4dac6eb 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
lua_register(luaState, 'GetHogName', @lc_gethogname);
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
  1694
lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);
4496
ba5da3388110 add missing setter for botlevel
nemo
parents: 4484
diff changeset
  1695
lua_register(luaState, 'SetHogLevel', @lc_sethoglevel);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1696
lua_register(luaState, 'GetX', @lc_getx);
3acdb4dac6eb 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
lua_register(luaState, 'GetY', @lc_gety);
3acdb4dac6eb 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
lua_register(luaState, 'CopyPV', @lc_copypv);
3acdb4dac6eb 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
lua_register(luaState, 'FollowGear', @lc_followgear);
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
  1700
lua_register(luaState, 'GetFollowGear', @lc_getfollowgear);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1701
lua_register(luaState, 'SetState', @lc_setstate);
3acdb4dac6eb 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
lua_register(luaState, 'GetState', @lc_getstate);
3acdb4dac6eb 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
lua_register(luaState, 'SetTag', @lc_settag);
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1704
lua_register(luaState, 'SetTimer', @lc_settimer);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1705
lua_register(luaState, 'GetTimer', @lc_gettimer);
3736
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1706
lua_register(luaState, 'SetZoom', @lc_setzoom);
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1707
lua_register(luaState, 'GetZoom', @lc_getzoom);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1708
lua_register(luaState, 'HogSay', @lc_hogsay);
4851
3ba1ecc06dc6 SwitchHog in scripting
nemo
parents: 4850
diff changeset
  1709
lua_register(luaState, 'SwitchHog', @lc_switchhog);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1710
lua_register(luaState, 'HogTurnLeft', @lc_hogturnleft);
3848
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
  1711
lua_register(luaState, 'CampaignLock', @lc_campaignlock);
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
  1712
lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock);
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
  1713
lua_register(luaState, 'GetGearElasticity', @lc_getgearelasticity);
4869
7a720b5d2247 added GetGearRaduis and minor Tracker things
Henek
parents: 4851
diff changeset
  1714
lua_register(luaState, 'GetGearRadius', @lc_getgearradius);
3896
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
  1715
lua_register(luaState, 'GetGearMessage', @lc_getgearmessage);
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
  1716
lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1717
lua_register(luaState, 'GetRandom', @lc_getrandom);
4399
87bc4a9e6ef0 fix key binds for lua created teams and added wind control
Henek
parents: 4393
diff changeset
  1718
lua_register(luaState, 'SetWind', @lc_setwind);
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
  1719
lua_register(luaState, 'GetDataPath', @lc_getdatapath);
4590
d9fed5a816e9 added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents: 4546
diff changeset
  1720
lua_register(luaState, 'MapHasBorder', @lc_maphasborder);
4875
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1721
lua_register(luaState, 'GetHogHat', @lc_gethoghat);
2a37a0e0892d lua: getter and setter for hedgehog hats
sheepluva
parents: 4869
diff changeset
  1722
lua_register(luaState, 'SetHogHat', @lc_sethoghat);
4985
304d149bb3dd added PlaceGirder to lua
Henek
parents: 4976
diff changeset
  1723
lua_register(luaState, 'PlaceGirder', @lc_placegirder);
5013
04789ba3f200 added GetCurAmmoType to lua
Henek
parents: 4985
diff changeset
  1724
lua_register(luaState, 'GetCurAmmoType', @lc_getcurammotype);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1725
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1726
3acdb4dac6eb 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
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
  1728
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
  1729
end;
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1731
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
  1732
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
  1733
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
  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
{$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
  1737
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
  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
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1742
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
  1743
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1744
3acdb4dac6eb 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
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
  1746
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
  1747
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1748
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1749
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
  1750
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
  1751
end;
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1753
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
  1754
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
  1755
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1756
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1757
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
  1758
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
  1759
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
  1760
end;
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1762
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
  1763
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
  1764
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
  1765
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1766
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1767
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
  1768
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
  1769
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
  1770
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1773
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
  1774
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
  1775
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1776
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1777
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
  1778
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
  1779
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
  1780
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1781
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1782
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
  1783
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
  1784
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1785
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1786
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
  1787
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
  1788
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1789
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1790
{$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
  1791
end.