hedgewars/uScript.pas
author unC0Rr
Wed, 17 Nov 2010 17:45:55 +0300
changeset 4359 83ef50815535
parent 4357 a1fcfc341a52
child 4368 b89235e401e5
permissions -rw-r--r--
Move variables from uMisc to uVariables
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
3209
4533c6e02240 General:
smxx
parents: 3197
diff changeset
     3
 * Copyright (c) 2004-2010 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
    uMisc,
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    45
    uConsts,
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
    46
    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
    47
    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
    48
    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
    49
    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
    50
    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
    51
    uSound,
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    52
    uTeams,
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    53
    uKeys,
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
    54
    uChat,
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
    55
    uStats,
4357
a1fcfc341a52 Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents: 4319
diff changeset
    56
    uRandom,
4359
83ef50815535 Move variables from uMisc to uVariables
unC0Rr
parents: 4357
diff changeset
    57
    uTypes,
83ef50815535 Move variables from uMisc to uVariables
unC0Rr
parents: 4357
diff changeset
    58
    uVariables;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
    59
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    60
var luaState : Plua_State;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    61
    ScriptAmmoLoadout : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    62
    ScriptAmmoProbability : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    63
    ScriptAmmoDelay : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    64
    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
    65
    ScriptLoaded : boolean;
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
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
    68
procedure ScriptApplyAmmoStore; forward;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    69
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
    70
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    71
procedure LuaError(s: shortstring);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    72
begin
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    73
    WriteLnToConsole(s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    74
    AddChatString(#5 + s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    75
end;
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    76
3043
3acdb4dac6eb 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
// 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
    78
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    79
// 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
    80
// 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
    81
// 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
    82
// 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
    83
3acdb4dac6eb 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
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
    85
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
    86
    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
    87
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    88
        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
    89
        end
3acdb4dac6eb 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
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    91
        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
    92
    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
    93
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    94
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    95
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
    96
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
    97
    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
    98
        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
    99
        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
   100
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   101
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   102
        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
   103
    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
   104
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   105
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   106
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
   107
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
   108
    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
   109
        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
   110
        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
   111
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   112
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   113
        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
   114
    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
   115
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   116
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   117
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
   118
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   119
    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
   120
    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
   121
    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
   122
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   123
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   124
function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   125
begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   126
    if lua_gettop(L) = 1 then
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   127
        begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   128
        AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage);
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   129
        end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   130
    else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   131
        LuaError('Lua: Wrong number of parameters passed to AddCaption!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   132
    lc_addcaption:= 0;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   133
end;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   134
3848
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   135
function lc_campaignlock(L : Plua_State) : LongInt; Cdecl;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   136
begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   137
    if lua_gettop(L) = 1 then
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   138
        begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   139
        // to be done
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   140
        end
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   141
    else
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   142
        LuaError('Lua: Wrong number of parameters passed to CampaignLock!');
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   143
    lc_campaignlock:= 0;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   144
end;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   145
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   146
function lc_campaignunlock(L : Plua_State) : LongInt; Cdecl;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   147
begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   148
    if lua_gettop(L) = 1 then
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   149
        begin
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   150
        // to be done
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   151
        end
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   152
    else
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   153
        LuaError('Lua: Wrong number of parameters passed to CampaignUnlock!');
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   154
    lc_campaignunlock:= 0;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   155
end;
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
   156
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   157
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
   158
var gear: PGear;
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   159
begin
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   160
    if lua_gettop(L) <> 2 then begin
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   161
        LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!');
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   162
        lua_pushnil(L);
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   163
    end
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   164
    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
   165
        gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   166
            HealthCrate, 0);
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
   167
        lua_pushnumber(L, gear^.uid);
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   168
    end;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   169
    lc_spawnhealthcrate := 1;        
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   170
end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   171
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   172
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
   173
var gear: PGear;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   174
begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   175
    if lua_gettop(L) <> 3 then begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   176
        LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!');
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   177
        lua_pushnil(L);
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   178
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   179
    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
   180
        gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   181
            AmmoCrate, lua_tointeger(L, 3));
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
   182
        lua_pushnumber(L, gear^.uid);
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   183
    end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   184
    lc_spawnammocrate := 1;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   185
end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   186
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   187
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
   188
var gear: PGear;
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   189
begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   190
    if lua_gettop(L) <> 3 then begin
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   191
        LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!');
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   192
        lua_pushnil(L);
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   193
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   194
    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
   195
        gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   196
            UtilityCrate, lua_tointeger(L, 3));
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
   197
        lua_pushnumber(L, gear^.uid);
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   198
    end;
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
   199
    lc_spawnutilitycrate := 1;
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   200
end;
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
   201
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   202
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
   203
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
   204
    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
   205
    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
   206
    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
   207
begin
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   208
    if lua_gettop(L) <> 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
   209
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   210
        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
   211
        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
   212
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   213
    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
   214
        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
   215
        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
   216
        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
   217
        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
   218
        s:= lua_tointeger(L, 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
   219
        dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   220
        dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   221
        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
   222
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   223
        gear:= AddGear(x, y, gt, s, dx, dy, t);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   224
        lua_pushnumber(L, 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
   225
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   226
    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
   227
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   228
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   229
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   230
begin
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   231
    if lua_gettop(L) <> 0 then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   232
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   233
        LuaError('Lua: Wrong number of parameters passed to GetFollowGear!');
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   234
        lua_pushnil(L); // return value on stack (nil)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   235
        end
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   236
    else
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   237
        if FollowGear = nil then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   238
            lua_pushnil(L)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   239
        else
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   240
            lua_pushnumber(L, FollowGear^.uid);
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   241
    lc_getfollowgear:= 1; // 1 return value
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   242
end;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   243
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   244
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
   245
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
   246
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
   247
    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
   248
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   249
        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
   250
        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
   251
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   252
    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
   253
        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
   254
        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
   255
        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
   256
            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
   257
        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
   258
            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
   259
        end;
3acdb4dac6eb 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
    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
   261
end;
3acdb4dac6eb 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
3892
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   263
function lc_getgearmessage(L : Plua_State) : LongInt; Cdecl;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   264
var gear : PGear;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   265
begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   266
    if lua_gettop(L) <> 1 then
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   267
        begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   268
        LuaError('Lua: Wrong number of parameters passed to GetGearMessage!');
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   269
        lua_pushnil(L); // return value on stack (nil)
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   270
        end
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   271
    else
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   272
        begin
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   273
        gear:= GearByUID(lua_tointeger(L, 1));
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   274
        if gear <> nil then
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   275
            lua_pushinteger(L, gear^.message)
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   276
        else
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   277
            lua_pushnil(L);
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   278
        end;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   279
    lc_getgearmessage:= 1
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   280
end;
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
   281
3896
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   282
function lc_setgearmessage(L : Plua_State) : LongInt; Cdecl;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   283
var gear : PGear;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   284
begin
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   285
    if lua_gettop(L) <> 2 then
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   286
        LuaError('Lua: Wrong number of parameters passed to SetGearMessage!')
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   287
    else
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   288
        begin
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   289
        gear:= GearByUID(lua_tointeger(L, 1));
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   290
        if gear <> nil then
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   291
            gear^.message:= lua_tointeger(L, 2);
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   292
        end;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   293
    lc_setgearmessage:= 0
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   294
end;
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
   295
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   296
function lc_gethoglevel(L : Plua_State): LongInt; Cdecl;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   297
var gear : PGear;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   298
begin
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   299
    if lua_gettop(L) <> 1 then
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   300
        LuaError('Lua: Wrong number of parameters passed to GetHogLevel!')
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   301
    else begin
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   302
        gear := GearByUID(lua_tointeger(L, 1));
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   303
        if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   304
            lua_pushinteger(L, PHedgehog(gear^.Hedgehog)^.BotLevel)
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   305
        else
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   306
            lua_pushnil(L);
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   307
    end;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   308
    lc_gethoglevel := 1;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   309
end;
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
   310
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   311
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
   312
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
   313
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
   314
    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
   315
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   316
        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
   317
        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
   318
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   319
    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
   320
        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
   321
        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
   322
        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
   323
            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
   324
            lua_pushinteger(L, PHedgehog(gear^.Hedgehog)^.Team^.Clan^.ClanIndex)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   325
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   326
        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
   327
            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
   328
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   329
    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
   330
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   331
4236
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   332
function lc_gethogteamname(L : Plua_State) : LongInt; Cdecl;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   333
var gear : PGear;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   334
begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   335
    if lua_gettop(L) <> 1 then
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   336
        begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   337
        LuaError('Lua: Wrong number of parameters passed to GetHogTeamName!');
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   338
        lua_pushnil(L); // return value on stack (nil)
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   339
        end
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   340
    else
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   341
        begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   342
        gear:= GearByUID(lua_tointeger(L, 1));
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   343
        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
   344
            begin
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   345
            lua_pushstring(L, str2pchar(PHedgehog(gear^.Hedgehog)^.Team^.TeamName))
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   346
            end
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   347
        else
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   348
            lua_pushnil(L);
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   349
        end;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   350
    lc_gethogteamname:= 1
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   351
end;
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
   352
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   353
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
   354
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
   355
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
   356
    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
   357
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   358
        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
   359
        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
   360
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   361
    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
   362
        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
   363
        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
   364
        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
   365
            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
   366
            lua_pushstring(L, str2pchar(PHedgehog(gear^.Hedgehog)^.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
   367
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   368
        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
   369
            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
   370
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   371
    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
   372
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   373
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   374
function lc_gettimer(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   375
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   376
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   377
    if lua_gettop(L) <> 1 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   378
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   379
        LuaError('Lua: Wrong number of parameters passed to GetTimer!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   380
        lua_pushnil(L); // return value on stack (nil)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   381
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   382
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   383
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   384
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   385
        if gear <> nil then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   386
            lua_pushnumber(L, gear^.Timer)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   387
        else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   388
            lua_pushnil(L);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   389
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   390
    lc_gettimer:= 1
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   391
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   392
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   393
function lc_gethealth(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   394
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   395
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   396
    if lua_gettop(L) <> 1 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   397
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   398
        LuaError('Lua: Wrong number of parameters passed to GetHealth!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   399
        lua_pushnil(L); // return value on stack (nil)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   400
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   401
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   402
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   403
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   404
        if gear <> nil then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   405
            lua_pushnumber(L, gear^.Health)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   406
        else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   407
            lua_pushnil(L);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   408
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   409
    lc_gethealth:= 1
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   410
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   411
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   412
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
   413
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
   414
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
   415
    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
   416
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   417
        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
   418
        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
   419
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   420
    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
   421
        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
   422
        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
   423
        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
   424
            lua_pushnumber(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
   425
        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
   426
            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
   427
        end;
3acdb4dac6eb 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
    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
   429
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   430
3acdb4dac6eb 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
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
   432
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
   433
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
   434
    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
   435
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   436
        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
   437
        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
   438
        end
3acdb4dac6eb 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
    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
   440
        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
   441
        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
   442
        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
   443
            lua_pushnumber(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
   444
        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
   445
            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
   446
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   447
    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
   448
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   449
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   450
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
   451
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
   452
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
   453
    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
   454
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   455
        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
   456
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   457
    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
   458
        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
   459
        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
   460
        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
   461
        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
   462
            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
   463
            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
   464
            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
   465
            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
   466
            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
   467
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   468
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   469
    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
   470
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   471
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   472
function lc_copypv2(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
   473
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
   474
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
   475
    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
   476
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   477
        LuaError('Lua: Wrong number of parameters passed to CopyPV2!');
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   478
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   479
    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
   480
        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
   481
        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
   482
        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
   483
        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
   484
            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
   485
            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
   486
            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
   487
            geard^.dX:= gears^.dX * 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
   488
            geard^.dY:= gears^.dY * 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
   489
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   490
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   491
    lc_copypv2:= 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
   492
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   493
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   494
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
   495
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
   496
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
   497
    if lua_gettop(L) <> 1 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   498
        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
   499
    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
   500
        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
   501
        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
   502
        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
   503
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   504
    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
   505
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   506
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   507
function lc_hogsay(L : Plua_State) : LongInt; Cdecl;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   508
var gear : PGear;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   509
   vgear : PVisualGear;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   510
begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   511
    if lua_gettop(L) <> 3 then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   512
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   513
        LuaError('Lua: Wrong number of parameters passed to HogSay!');
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   514
        end
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   515
    else
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   516
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   517
        gear:= GearByUID(lua_tointeger(L, 1));
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   518
        if gear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   519
            begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   520
            vgear:= AddVisualGear(0, 0, vgtSpeechBubble);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   521
            if vgear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   522
               begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   523
               vgear^.Text:= lua_tostring(L, 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   524
               vgear^.Hedgehog:= gear^.Hedgehog;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   525
               vgear^.FrameTicks:= lua_tointeger(L, 3);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   526
               if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then vgear^.FrameTicks:= 1;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   527
               end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   528
            end
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   529
        end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   530
    lc_hogsay:= 0
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   531
end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   532
3043
3acdb4dac6eb 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
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
   534
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
   535
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
   536
    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
   537
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   538
        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
   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
        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
   542
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   543
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   544
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   545
            gear^.Health:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   546
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   547
            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
   548
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   549
    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
   550
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   551
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   552
function lc_settimer(L : Plua_State) : LongInt; Cdecl;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   553
var gear : PGear;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   554
begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   555
    if lua_gettop(L) <> 2 then
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   556
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   557
        LuaError('Lua: Wrong number of parameters passed to SetTimer!');
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   558
        end
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   559
    else
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   560
        begin
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   561
        gear:= GearByUID(lua_tointeger(L, 1));
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   562
        if gear <> nil then gear^.Timer:= lua_tointeger(L, 2)
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   563
        end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   564
    lc_settimer:= 0
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   565
end;
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
   566
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   567
function lc_seteffect(L : Plua_State) : LongInt; Cdecl;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   568
var gear: PGear;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   569
begin
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   570
    if lua_gettop(L) <> 3 then
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   571
        LuaError('Lua: Wrong number of parameters passed to SetEffect!')
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   572
    else begin
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   573
        gear := GearByUID(lua_tointeger(L, 1));
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   574
        if gear <> nil then
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   575
            PHedgehog(gear^.Hedgehog)^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3) <> 0;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   576
    end;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   577
    lc_seteffect := 0;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   578
end;
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
   579
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   580
function lc_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
   581
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
   582
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
   583
    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
   584
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   585
        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
   586
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   587
    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
   588
        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
   589
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   590
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   591
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   592
            gear^.State:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   593
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   594
            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
   595
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   596
    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
   597
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   598
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   599
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
   600
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
   601
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
   602
    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
   603
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   604
        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
   605
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   606
    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
   607
        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
   608
        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
   609
        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
   610
            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
   611
        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
   612
            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
   613
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   614
    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
   615
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   616
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   617
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
   618
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
   619
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
   620
    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
   621
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   622
        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
   623
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   624
    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
   625
        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
   626
        gear:= GearByUID(lua_tointeger(L, 1));
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   627
        if gear <> nil then
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   628
            begin
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   629
            gear^.Tag:= lua_tointeger(L, 2);
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   630
            SetAllToActive;
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   631
            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
   632
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   633
    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
   634
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   637
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   638
    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
   639
    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
   640
    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
   641
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   644
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
   645
    fall: 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
   646
    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
   647
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
   648
    if lua_gettop(L) <> 4 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   649
        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
   650
    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
   651
        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
   652
        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
   653
        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
   654
        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
   655
        right:= lua_tointeger(L, 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
   656
        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
   657
            FindPlace(gear, fall, left, right)
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   658
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   659
    lc_findplace:= 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
   660
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   661
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   662
function lc_playsound(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
   663
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
   664
    if lua_gettop(L) <> 1 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   665
        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
   666
    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
   667
        PlaySound(TSound(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
   668
    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
   669
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   670
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   671
function lc_addteam(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
   672
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
   673
    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
   674
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   675
        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
   676
        //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
   677
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   678
    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
   679
        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
   680
        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
   681
        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
   682
        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
   683
        ParseCommand('voicepack ' + lua_tostring(L, 5), 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
   684
        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
   685
        // 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
   686
        //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
   687
        end;
3acdb4dac6eb 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
    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
   689
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
function lc_addhog(L : Plua_State) : LongInt; Cdecl;
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
   692
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
   693
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
   694
    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
   695
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   696
        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
   697
        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
   698
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   699
    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
   700
        begin
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
   701
        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
   702
        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
   703
        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
   704
        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
   705
        end;
3acdb4dac6eb 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
    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
   707
end;
3acdb4dac6eb 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
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   709
function lc_hogturnleft(L : Plua_State) : LongInt; Cdecl;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   710
var gear: PGear;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   711
begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   712
    if lua_gettop(L) <> 2 then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   713
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   714
        LuaError('Lua: Wrong number of parameters passed to HogTurnLeft!');
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   715
        end
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   716
    else
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   717
        begin
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   718
        gear:= GearByUID(lua_tointeger(L, 1));
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   719
        if gear <> nil then
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   720
            gear^.dX.isNegative:= lua_toboolean(L, 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   721
        end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   722
    lc_hogturnleft:= 0;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   723
end;
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   724
3043
3acdb4dac6eb 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_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
   726
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
   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) <> 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
   729
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   730
        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
   731
        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
   732
        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
   733
        end
3acdb4dac6eb 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
    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
   735
        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
   736
        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
   737
        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
   738
            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
   739
            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
   740
            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
   741
            end
3acdb4dac6eb 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
    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
   744
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   747
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
   748
    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
   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) <> 3 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   751
        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
   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
3acdb4dac6eb 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
            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
   757
            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
   758
            y:= 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
   759
            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
   760
            gear^.Y:= int2hwfloat(y);
3723
958eeaf84714 Engine:
smaxx
parents: 3722
diff changeset
   761
            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
   762
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   763
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   764
    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
   765
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   766
3736
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   767
function lc_setzoom(L : Plua_State) : LongInt; Cdecl;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   768
begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   769
    if lua_gettop(L) <> 1 then
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   770
        LuaError('Lua: Wrong number of parameters passed to SetZoom!')
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   771
    else
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   772
        begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   773
        ZoomValue:= lua_tonumber(L, 1);
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   774
        if ZoomValue < cMaxZoomLevel then ZoomValue:= cMaxZoomLevel;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   775
        if ZoomValue > cMinZoomLevel then ZoomValue:= cMinZoomLevel;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   776
        end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   777
    lc_setzoom:= 0
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   778
end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   779
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   780
function lc_getzoom(L : Plua_State) : LongInt; Cdecl;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   781
begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   782
    if lua_gettop(L) <> 0 then
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   783
        begin
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   784
        LuaError('Lua: Wrong number of parameters passed to GetZoom!');
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   785
        lua_pushnil(L)
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   786
        end
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   787
    else
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   788
        lua_pushnumber(L, ZoomValue);
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   789
    lc_getzoom:= 1
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   790
end;
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
   791
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   792
function lc_setammo(L : Plua_State) : LongInt; Cdecl;
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   793
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
   794
begin
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   795
    np:= lua_gettop(L);
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   796
    if (np < 4) or (np > 5) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   797
        LuaError('Lua: Wrong number of parameters passed to SetAmmo!')
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   798
    else if np = 4 then
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   799
        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
   800
    else
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   801
        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
   802
    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
   803
end;
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   804
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   805
function lc_getrandom(L : Plua_State) : LongInt; Cdecl;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   806
var m : LongInt;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   807
begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   808
    if lua_gettop(L) <> 1 then
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   809
        begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   810
        LuaError('Lua: Wrong number of parameters passed to GetRandom!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   811
        lua_pushnil(L); // return value on stack (nil)
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   812
        end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   813
    else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   814
        begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   815
        m:= lua_tointeger(L, 1);
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   816
        if (m > 0) then
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   817
            lua_pushinteger(L, GetRandom(m))
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   818
        else
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   819
            begin
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   820
            LuaError('Lua: Tried to pass 0 to GetRandom!');
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   821
            lua_pushnil(L);
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   822
            end
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   823
        end;
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   824
    lc_getrandom:= 1
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
   825
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
   826
///////////////////
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   827
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   828
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
   829
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
   830
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
   831
    n:= lua_gettop(luaState);
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   832
    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
   833
    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
   834
        if not lua_isboolean(luaState, i) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   835
            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
   836
        else if lua_toboolean(luaState, i) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   837
            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
   838
        else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   839
            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
   840
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   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
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
   845
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   846
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   847
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
   848
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
   849
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
   850
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
   851
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   854
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
   855
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
   856
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
   857
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   858
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   859
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
   860
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
   861
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
   862
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
   863
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   864
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   865
function 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
   866
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
   867
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
   868
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
   869
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
   870
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   871
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   872
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
   873
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
   874
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
   875
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
   876
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
   877
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   878
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   879
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
   880
var s, t : ansistring;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   881
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
   882
// 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
   883
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
   884
    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
   885
3acdb4dac6eb 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
// 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
   887
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
   888
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
   889
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
   890
ScriptSetInteger('CaseFreq', cCaseFactor);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   891
ScriptSetInteger('HealthCaseProb', cHealthCaseProb);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   892
ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
   893
ScriptSetInteger('DamagePercent', cDamagePercent);
4003
ca0600ab38bf disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents: 3999
diff changeset
   894
ScriptSetInteger('MinesNum', cLandMines);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
   895
ScriptSetInteger('MinesTime', cMinesTime);
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
   896
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
   897
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
   898
ScriptSetInteger('Delay', cInactDelay);
3774
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
   899
ScriptSetInteger('Ready', cReadyDelay);
3197
smxx
parents: 3058
diff changeset
   900
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   901
ScriptSetInteger('WaterRise', cWaterRise);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   902
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
   903
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
   904
ScriptSetString('Theme', '');
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   906
// import locale
3acdb4dac6eb 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
s:= cLocaleFName;
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   908
t:= '';
3043
3acdb4dac6eb 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
SplitByChar(s, t, '.');
3acdb4dac6eb 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
ScriptSetString('L', s);
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   913
3acdb4dac6eb 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
// 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
   915
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
   916
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
   917
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
   918
ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   919
ParseCommand('$healthprob ' + ScriptGetString('HealthCaseProb'), true);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   920
ParseCommand('$hcaseamount ' + ScriptGetString('HealthCaseAmount'), true);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
   921
ParseCommand('$damagepct ' + ScriptGetString('DamagePercent'), true);
4003
ca0600ab38bf disable gfMines and update variable names (landadds -> minesnum, cLandAdditions -> cLandMines)
koda
parents: 3999
diff changeset
   922
ParseCommand('$minesnum ' + ScriptGetString('MinesNum'), true);
4221
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
   923
ParseCommand('$minestime ' + ScriptGetString('MinesTime'), true);
a1bf0f6b0d65 added missing game modifiers to lua
Henek
parents: 4219
diff changeset
   924
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
   925
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
   926
ParseCommand('$delay ' + ScriptGetString('Delay'), true);
3777
5276f2150d65 Engine:
smaxx
parents: 3774
diff changeset
   927
ParseCommand('$ready ' + ScriptGetString('Ready'), true);
3197
smxx
parents: 3058
diff changeset
   928
ParseCommand('$sd_turns ' + ScriptGetString('SuddenDeathTurns'), true);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   929
ParseCommand('$waterrise ' + ScriptGetString('WaterRise'), true);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
   930
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
   931
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
   932
    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
   933
if ScriptGetString('Theme') <> '' then
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
   934
    ParseCommand('theme ' + ScriptGetString('Theme'), 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
   935
3acdb4dac6eb 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
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
   937
    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
   938
    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
   939
    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
   940
    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
   941
    end;
3acdb4dac6eb 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
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
   943
ScriptSetInteger('ClansCount', ClansCount);
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
   944
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
   945
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   948
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
   949
begin
3919
76d5b32758d9 Engine/Frontend:
smaxx
parents: 3906
diff changeset
   950
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
   951
if ret <> 0 then
3774
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
   952
    begin
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
   953
    LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
   954
    LuaError('Lua: ' + lua_tostring(luaState, -1));
af0e68ca273e Engine:
smaxx
parents: 3761
diff changeset
   955
    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
   956
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
   957
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   958
    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
   959
    // 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
   960
    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
   961
    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
   962
    end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   963
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   964
3acdb4dac6eb 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
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
   966
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
   967
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   968
ScriptSetInteger('GameTime', GameTicks);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
   969
ScriptSetInteger('RealTime', RealTicks);
4235
6b1dfbd60a45 added TeamsCount and TotalTurns to lua as requested by mikade
Henek
parents: 4221
diff changeset
   970
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
   971
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
   972
    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
   973
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
   974
    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
   975
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   976
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   977
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
   978
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
   979
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
   980
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   983
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
   984
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
   985
    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
   986
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
   987
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
   988
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
   989
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   990
    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
   991
    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
   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
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
   994
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   997
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
   998
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
   999
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1002
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
  1003
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
  1004
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1007
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
  1008
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
  1009
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1012
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
  1013
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
  1014
    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
  1015
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
  1016
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
  1017
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
  1018
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
  1019
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
  1020
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
  1021
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
  1022
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
  1023
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
  1024
    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
  1025
    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
  1026
    end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1027
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
  1028
    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
  1029
    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
  1030
    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
  1031
    end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1032
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
  1033
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1034
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1035
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
  1036
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
  1037
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
  1038
    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
  1039
    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
  1040
    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
  1041
    end;
3acdb4dac6eb 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
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
  1043
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
  1044
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
  1045
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1046
3acdb4dac6eb 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
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
  1048
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
  1049
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
  1050
// 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
  1051
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
  1052
uAmmos.initModule;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1053
ScriptAmmoLoadout:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1054
ScriptAmmoDelay:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1055
ScriptAmmoProbability:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1056
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
  1057
for i:=1 to ord(High(TAmmoType)) do
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1058
    begin
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1059
    ScriptAmmoLoadout:= ScriptAmmoLoadout + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1060
    ScriptAmmoProbability:= ScriptAmmoProbability + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1061
    ScriptAmmoDelay:= ScriptAmmoDelay + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1062
    ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1063
    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
  1064
end;
3acdb4dac6eb 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
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1066
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
  1067
begin
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1068
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
  1069
    exit;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1070
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1071
ScriptAmmoProbability[ord(ammo)]:= inttostr(propability)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1072
ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1073
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
  1074
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
  1077
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
  1078
begin
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1079
SetAmmoLoadout(ScriptAmmoLoadout);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1080
SetAmmoProbability(ScriptAmmoProbability);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1081
SetAmmoDelay(ScriptAmmoDelay);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1082
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
  1083
for i:= 0 to Pred(TeamsCount) do
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
  1084
    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
  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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1087
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
  1088
var at : 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
  1089
    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
  1090
    st : TSound;
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1091
    he: THogEffect;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1092
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
  1093
// 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
  1094
luaState:= lua_open;
3045
41732f986b4f Clean Augean stables
unc0rr
parents: 3043
diff changeset
  1095
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
  1096
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1097
// 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
  1098
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
  1099
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
  1100
luaopen_math(luaState);
3724
b8678667e7dc Engine:
smaxx
parents: 3723
diff changeset
  1101
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
  1102
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1103
// 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
  1104
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
  1105
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
  1106
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1107
// 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
  1108
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
  1109
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
  1110
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
  1111
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
  1112
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
  1113
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
  1114
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
  1115
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
  1116
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
  1117
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
  1118
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
  1119
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
  1120
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
  1121
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
  1122
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
  1123
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
  1124
ScriptSetInteger('gfDisableGirders', gfDisableGirders);
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1125
ScriptSetInteger('gfDisableLandObjects', gfDisableLandObjects);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1126
ScriptSetInteger('gfAISurvival', gfAISurvival);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1127
ScriptSetInteger('gfInfAttack', gfInfAttack);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1128
ScriptSetInteger('gfResetWeps', gfResetWeps);
923db448ad16 update and fix some lua stuff
Henek
parents: 4003
diff changeset
  1129
ScriptSetInteger('gfPerHogAmmo', gfPerHogAmmo);
4219
4162db7c11bb fix so gfDisableWind can infact be used in lua
Henek
parents: 4162
diff changeset
  1130
ScriptSetInteger('gfDisableWind', gfDisableWind);
4319
81391b54b078 clean up and lua update, very minor
Henek
parents: 4243
diff changeset
  1131
ScriptSetInteger('gfMoreWind', gfMoreWind);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1132
3894
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1133
ScriptSetInteger('gmLeft', gmLeft);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1134
ScriptSetInteger('gmRight', gmRight);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1135
ScriptSetInteger('gmUp', gmUp);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1136
ScriptSetInteger('gmDown', gmDown);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1137
ScriptSetInteger('gmSwitch', gmSwitch);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1138
ScriptSetInteger('gmAttack', gmAttack);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1139
ScriptSetInteger('gmLJump', gmLJump);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1140
ScriptSetInteger('gmHJump', gmHJump);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1141
ScriptSetInteger('gmDestroy', gmDestroy);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1142
ScriptSetInteger('gmSlot', gmSlot);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1143
ScriptSetInteger('gmWeapon', gmWeapon);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1144
ScriptSetInteger('gmTimer', gmTimer);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1145
ScriptSetInteger('gmAnimate', gmAnimate);
9abce5468583 Engine:
smaxx
parents: 3892
diff changeset
  1146
ScriptSetInteger('gmPrecise', gmPrecise);
3892
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  1147
ScriptSetInteger('gmAllStoppable', gmAllStoppable);
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  1148
60d9709f2d8e Engine:
smaxx
parents: 3848
diff changeset
  1149
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1150
// speech bubbles
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1151
ScriptSetInteger('SAY_SAY', 1);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1152
ScriptSetInteger('SAY_THINK', 2);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1153
ScriptSetInteger('SAY_SHOUT', 3);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1154
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1155
// 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
  1156
for at:= Low(TGearType) to High(TGearType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  1157
    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
  1158
3acdb4dac6eb 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
// 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
  1160
for st:= Low(TSound) to High(TSound) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  1161
    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
  1162
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1163
// 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
  1164
for am:= Low(TAmmoType) to High(TAmmoType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
  1165
    ScriptSetInteger(EnumToStr(am), ord(am));
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3539
diff changeset
  1166
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1167
for he:= Low(THogEffect) to High(THogEffect) do
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1168
    ScriptSetInteger(EnumToStr(he), ord(he));
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1169
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1170
// register functions
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1171
lua_register(luaState, 'AddGear', @lc_addgear);
3730
aecea9aa53dc Engine:
smaxx
parents: 3724
diff changeset
  1172
lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate);
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
  1173
lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate);
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3730
diff changeset
  1174
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
  1175
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
  1176
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
  1177
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
  1178
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
  1179
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
  1180
lua_register(luaState, 'GetGearPosition', @lc_getgearposition);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1181
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
  1182
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
  1183
lua_register(luaState, 'HideMission', @lc_hidemission);
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1184
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
  1185
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
  1186
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
  1187
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
  1188
lua_register(luaState, 'AddHog', @lc_addhog);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1189
lua_register(luaState, 'SetHealth', @lc_sethealth);
4319
81391b54b078 clean up and lua update, very minor
Henek
parents: 4243
diff changeset
  1190
lua_register(luaState, 'GetHealth', @lc_gethealth);
3756
d42571e2e6c9 lua function SetEffect to set and remove THogEffects
burp
parents: 3755
diff changeset
  1191
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
  1192
lua_register(luaState, 'GetHogClan', @lc_gethogclan);
4236
fa2680cfff86 added function GetHogTeamName to lua, makes TeamsCount more useful
Henek
parents: 4235
diff changeset
  1193
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
  1194
lua_register(luaState, 'GetHogName', @lc_gethogname);
3755
02dc9fcb6477 GetHogLevel lua function
burp
parents: 3750
diff changeset
  1195
lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1196
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
  1197
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
  1198
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
  1199
lua_register(luaState, 'CopyPV2', @lc_copypv2);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1200
lua_register(luaState, 'FollowGear', @lc_followgear);
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
  1201
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
  1202
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
  1203
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
  1204
lua_register(luaState, 'SetTag', @lc_settag);
3722
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1205
lua_register(luaState, 'SetTimer', @lc_settimer);
eadebe4c45c9 Engine:
smaxx
parents: 3697
diff changeset
  1206
lua_register(luaState, 'GetTimer', @lc_gettimer);
3736
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1207
lua_register(luaState, 'SetZoom', @lc_setzoom);
d8982f9e7e2c Engine:
smaxx
parents: 3734
diff changeset
  1208
lua_register(luaState, 'GetZoom', @lc_getzoom);
3761
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1209
lua_register(luaState, 'HogSay', @lc_hogsay);
f96b99f944e6 Engine:
smaxx
parents: 3756
diff changeset
  1210
lua_register(luaState, 'HogTurnLeft', @lc_hogturnleft);
3848
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
  1211
lua_register(luaState, 'CampaignLock', @lc_campaignlock);
32ceb775906b Engine:
smaxx
parents: 3836
diff changeset
  1212
lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock);
3896
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
  1213
lua_register(luaState, 'GetGearMessage', @lc_getgearmessage);
59de68d541f1 Engine:
smaxx
parents: 3894
diff changeset
  1214
lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
4243
bbf7451f6b4e added getrandom and addcaption to lua
Henek
parents: 4236
diff changeset
  1215
lua_register(luaState, 'GetRandom', @lc_getrandom);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1216
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1217
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1218
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
  1219
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
  1220
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1221
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1222
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
  1223
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
  1224
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
  1225
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1226
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1227
{$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
  1228
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
  1229
begin
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1230
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1231
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1232
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
  1233
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
  1234
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1235
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1236
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
  1237
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
  1238
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1239
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1240
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
  1241
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
  1242
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1243
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1244
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
  1245
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
  1246
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1247
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1248
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
  1249
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
  1250
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
  1251
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1252
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1253
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
  1254
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
  1255
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
  1256
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1257
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1258
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
  1259
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
  1260
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
  1261
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1262
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1263
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
  1264
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
  1265
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
  1266
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1267
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1268
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
  1269
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
  1270
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
  1271
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1272
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1273
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
  1274
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
  1275
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1276
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1277
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
  1278
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
  1279
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1280
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
  1281
{$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
  1282
end.