hedgewars/uScript.pas
author smaxx
Wed, 23 Jun 2010 13:43:56 +0200
changeset 3539 c3d1fccbe0ed
parent 3407 dcc129c4352e
child 3697 d5b30d6373fc
permissions -rw-r--r--
General: * Disabled building of libopenalbridge (why build/link everywhere even if not used?; fails due to cc1 being unable to find some files on Win32) Engine: * Show Lua errors as 'chat messages' * Added ability to write to chat buffer even while the engine is still loading (limited to 26 lines)
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>
4533c6e02240 General:
smxx
parents: 3197
diff changeset
     4
 * Lua integration (c) 2010 Mario Liebisch <mario.liebisch@googlemail.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
     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
     6
 * 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
     7
 * 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
     8
 * 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
     9
 *
3acdb4dac6eb 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
 * 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
    11
 * 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
    12
 * 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
    13
 * 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
    14
 *
3acdb4dac6eb 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
 * 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
    16
 * 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
    17
 * 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
    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
3acdb4dac6eb 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
{$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
    21
3acdb4dac6eb 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
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
    23
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
    24
3acdb4dac6eb 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 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
    26
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
    27
3acdb4dac6eb 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 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
    29
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
    30
3acdb4dac6eb 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
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
    32
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
    33
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
    34
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
    35
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
    36
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
    37
3acdb4dac6eb 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 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
    39
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
    40
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    41
implementation
3acdb4dac6eb 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
{$IFNDEF IPHONEOS}
3acdb4dac6eb 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
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
    44
    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
    45
    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
    46
    uConsts,
3acdb4dac6eb 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,
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    54
    uChat;
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    55
    
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    56
var luaState : Plua_State;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    57
    ScriptAmmoLoadout : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    58
    ScriptAmmoProbability : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    59
    ScriptAmmoDelay : shortstring;
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    60
    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
    61
    ScriptLoaded : 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
    62
    
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    63
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
    64
procedure ScriptApplyAmmoStore; forward;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
    65
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
    66
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    67
procedure LuaError(s: shortstring);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    68
begin
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    69
    WriteLnToConsole(s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    70
    AddChatString(#5 + s);
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    71
end;
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    72
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    73
// 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
    74
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    75
// 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
    76
// 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
    77
// 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
    78
// 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
    79
3acdb4dac6eb 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 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
    81
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
    82
    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
    83
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    84
        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
    85
        end
3acdb4dac6eb 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
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    87
        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
    88
    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
    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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
    91
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
    92
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
    93
    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
    94
        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
    95
        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
    96
        end
3acdb4dac6eb 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
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
    98
        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
    99
    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
   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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   102
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
   103
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
   104
    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
   105
        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
   106
        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
   107
        end
3acdb4dac6eb 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
    else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   109
        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
   110
    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
   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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   113
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
   114
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   115
    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
   116
    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
   117
    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
   118
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   119
3acdb4dac6eb 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
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
   121
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
   122
    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
   123
    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
   124
    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
   125
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
   126
    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
   127
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   128
        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
   129
        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
   130
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   131
    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
   132
        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
   133
        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
   134
        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
   135
        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
   136
        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
   137
        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
   138
        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
   139
        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
   140
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   141
        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
   142
        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
   143
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   144
    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
   145
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   146
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   147
function lc_getfollowgear(L : Plua_State) : LongInt; Cdecl;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   148
begin
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   149
    if lua_gettop(L) <> 0 then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   150
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   151
        LuaError('Lua: Wrong number of parameters passed to GetFollowGear!');
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   152
        lua_pushnil(L); // return value on stack (nil)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   153
        end
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   154
    else
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   155
        if FollowGear = nil then
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   156
            lua_pushnil(L)
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   157
        else
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   158
            lua_pushnumber(L, FollowGear^.uid);
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   159
    lc_getfollowgear:= 1; // 1 return value
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   160
end;
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   161
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   162
function lc_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
   163
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
   164
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
   165
    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
   166
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   167
        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
   168
        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
   169
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   170
    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
   171
        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
   172
        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
   173
        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
   174
            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
   175
        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
   176
            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
   177
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   178
    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
   179
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   180
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   181
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
   182
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
   183
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
   184
    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
   185
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   186
        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
   187
        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
   188
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   189
    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
   190
        begin
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   191
        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
   192
        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
   193
            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
   194
            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
   195
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   196
        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
   197
            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
   198
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   199
    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
   200
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   201
3acdb4dac6eb 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_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
   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
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
   205
    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
   206
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   207
        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
   208
        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
   209
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   210
    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
   211
        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
   212
        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
   213
        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
   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
            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
   216
            end
3acdb4dac6eb 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
        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
   218
            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
   219
        end;
3acdb4dac6eb 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
    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
   221
end;
3acdb4dac6eb 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
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
   224
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
   225
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
   226
    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
   227
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   228
        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
   229
        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
   230
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   231
    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
   232
        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
   233
        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
   234
        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
   235
            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
   236
        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
   237
            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
   238
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   239
    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
   240
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   241
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   242
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
   243
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
   244
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
   245
    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
   246
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   247
        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
   248
        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
   249
        end
3acdb4dac6eb 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
    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
   251
        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
   252
        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
   253
        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
   254
            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
   255
        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
   256
            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
   257
        end;
3acdb4dac6eb 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
    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
   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
3acdb4dac6eb 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
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
   262
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
   263
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
   264
    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
   265
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   266
        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
   267
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   268
    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
   269
        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
   270
        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
   271
        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
   272
        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
   273
            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
   274
            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
   275
            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
   276
            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
   277
            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
   278
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   279
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   280
    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
   281
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   282
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   283
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
   284
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
   285
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
   286
    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
   287
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   288
        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
   289
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   290
    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
   291
        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
   292
        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
   293
        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
   294
        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
   295
            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
   296
            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
   297
            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
   298
            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
   299
            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
   300
            end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   301
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   302
    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
   303
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   304
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   305
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
   306
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
   307
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
   308
    if lua_gettop(L) <> 1 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   309
        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
   310
    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
   311
        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
   312
        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
   313
        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
   314
        end;
3acdb4dac6eb 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
    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
   316
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   319
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
   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
    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
   322
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   323
        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
   324
        end
3acdb4dac6eb 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
    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
   326
        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
   327
        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
   328
        if gear <> nil then gear^.Health:= 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
   329
        end;
3acdb4dac6eb 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
    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
   331
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   332
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   333
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
   334
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
   335
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
   336
    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
   337
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   338
        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
   339
        end
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   340
    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
   341
        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
   342
        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
   343
        if gear <> nil then gear^.State:= 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
   344
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   345
    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
   346
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   347
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   348
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
   349
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
   350
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
   351
    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
   352
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   353
        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
   354
        end
3acdb4dac6eb 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
    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
   356
        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
   357
        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
   358
        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
   359
            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
   360
        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
   361
            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
   362
        end;
3acdb4dac6eb 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
    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
   364
end;
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   366
function 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
   367
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
   368
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
   369
    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
   370
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   371
        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
   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
    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
   374
        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
   375
        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
   376
        if gear <> nil then gear^.Tag:= 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
   377
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   378
    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
   379
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   380
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   381
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
   382
begin
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   383
    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
   384
    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
   385
    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
   386
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   387
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   388
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
   389
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
   390
    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
   391
    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
   392
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
   393
    if lua_gettop(L) <> 4 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   394
        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
   395
    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
   396
        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
   397
        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
   398
        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
   399
        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
   400
        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
   401
        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
   402
            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
   403
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   404
    lc_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
   405
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   406
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   407
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
   408
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
   409
    if lua_gettop(L) <> 1 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   410
        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
   411
    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
   412
        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
   413
    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
   414
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   417
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
   418
    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
   419
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   420
        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
   421
        //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
   422
        end
3acdb4dac6eb 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
    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
   424
        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
   425
        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
   426
        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
   427
        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
   428
        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
   429
        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
   430
        // 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
   431
        //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
   432
        end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   433
    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
   434
end;
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   436
function lc_addhog(L : Plua_State) : LongInt; Cdecl;
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
   437
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
   438
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
   439
    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
   440
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   441
        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
   442
        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
   443
        end
3acdb4dac6eb 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
        begin
3271
0405e07ca44b * add some kind of SniperRifle training mission
sheepluva
parents: 3209
diff changeset
   446
        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
   447
        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
   448
        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
   449
        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
   450
        end;
3acdb4dac6eb 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
    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
   452
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   455
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
   456
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
   457
    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
   458
        begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   459
        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
   460
        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
   461
        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
   462
        end
3acdb4dac6eb 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
    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
   464
        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
   465
        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
   466
        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
   467
            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
   468
            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
   469
            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
   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
        end;
3acdb4dac6eb 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
    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
   473
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   476
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
   477
    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
   478
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
   479
    if lua_gettop(L) <> 3 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   480
        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
   481
    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
   482
        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
   483
        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
   484
        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
   485
            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
   486
            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
   487
            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
   488
            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
   489
            gear^.Y:= int2hwfloat(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
   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
        end;
3acdb4dac6eb 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
    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
   493
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
function lc_setammo(L : Plua_State) : LongInt; Cdecl;
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   496
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
   497
begin
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   498
    np:= lua_gettop(L);
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   499
    if (np < 4) or (np > 5) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   500
        LuaError('Lua: Wrong number of parameters passed to SetAmmo!')
3368
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   501
    else if np = 4 then
791fa4664209 Engine:
smxx
parents: 3346
diff changeset
   502
        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
   503
    else
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   504
        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
   505
    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
   506
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   507
///////////////////
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   508
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   509
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
   510
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
   511
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
   512
    n:= lua_gettop(luaState);
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   513
    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
   514
    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
   515
        if not lua_isboolean(luaState, i) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   516
            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
   517
        else if lua_toboolean(luaState, i) then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   518
            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
   519
        else
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   520
            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
   521
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   522
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   523
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
   524
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
   525
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
   526
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   527
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   528
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
   529
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
   530
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
   531
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
   532
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   533
3acdb4dac6eb 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
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
   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
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
   537
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
   538
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   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
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
   543
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
   544
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   545
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   546
function 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
   547
begin
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   548
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
   549
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
   550
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
   551
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   552
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   553
function 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
   554
begin
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   555
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
   556
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
   557
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
   558
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   559
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   560
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
   561
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
   562
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
   563
// 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
   564
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
   565
    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
   566
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   567
// 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
   568
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
   569
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
   570
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
   571
ScriptSetInteger('CaseFreq', cCaseFactor);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   572
ScriptSetInteger('LandAdds', cLandAdditions);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   573
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
   574
ScriptSetInteger('Delay', cInactDelay);
3197
smxx
parents: 3058
diff changeset
   575
ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns);
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   576
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
   577
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
   578
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   579
// 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
   580
s:= cLocaleFName;
3407
dcc129c4352e Engine:
smxx
parents: 3368
diff changeset
   581
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
   582
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
   583
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
   584
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   585
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
   586
3acdb4dac6eb 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
// 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
   588
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
   589
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
   590
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
   591
ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), 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
   592
ParseCommand('$landadds ' + ScriptGetString('LandAdds'), 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
   593
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
   594
ParseCommand('$delay ' + ScriptGetString('Delay'), true);
3197
smxx
parents: 3058
diff changeset
   595
ParseCommand('$sd_turns ' + ScriptGetString('SuddenDeathTurns'), 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
   596
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
   597
    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
   598
if ScriptGetString('Theme') <> '' 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
   599
    ParseCommand('theme ' + ScriptGetString('Theme'), 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
   600
3acdb4dac6eb 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
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
   602
    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
   603
    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
   604
    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
   605
    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
   606
    end;
3acdb4dac6eb 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
3acdb4dac6eb 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
ScriptSetInteger('ClansCount', ClansCount)
3acdb4dac6eb 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
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   612
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
   613
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
   614
ret:= luaL_loadfile(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
   615
if ret <> 0 then
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   616
    LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')')
3043
3acdb4dac6eb 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
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
   618
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   619
    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
   620
    // 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
   621
    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
   622
    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
   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
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   627
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
   628
ScriptSetInteger('TurnTimeLeft', 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
   629
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
   630
    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
   631
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
   632
    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
   633
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   636
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
   637
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
   638
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   641
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
   642
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
   643
    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
   644
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
   645
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
   646
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
   647
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   648
    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
   649
    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
   650
    end;
3acdb4dac6eb 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
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
   652
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   655
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
   656
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
   657
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   660
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
   661
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
   662
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   665
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
   666
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
   667
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   670
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
   671
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
   672
    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
   673
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
   674
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
   675
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
   676
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
   677
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
   678
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
   679
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
   680
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
   681
    begin
3539
c3d1fccbe0ed General:
smaxx
parents: 3407
diff changeset
   682
    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
   683
    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
   684
    end
3acdb4dac6eb 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
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
   686
    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
   687
    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
   688
    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
   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
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
   691
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   692
3acdb4dac6eb 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
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
   694
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
   695
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
   696
    begin
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   697
    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
   698
    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
   699
    end;
3acdb4dac6eb 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
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
   701
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
   702
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
   703
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   706
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
   707
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
   708
// 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
   709
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
   710
uAmmos.initModule;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   711
ScriptAmmoLoadout:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   712
ScriptAmmoDelay:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   713
ScriptAmmoProbability:= '';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   714
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
   715
for i:=1 to ord(High(TAmmoType)) do
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   716
    begin
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   717
    ScriptAmmoLoadout:= ScriptAmmoLoadout + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   718
    ScriptAmmoProbability:= ScriptAmmoProbability + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   719
    ScriptAmmoDelay:= ScriptAmmoDelay + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   720
    ScriptAmmoReinforcement:= ScriptAmmoReinforcement + '0';
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   721
    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
   722
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   723
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   724
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
   725
begin
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   726
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
   727
    exit;
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   728
ScriptAmmoLoadout[ord(ammo)]:= inttostr(count)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   729
ScriptAmmoProbability[ord(ammo)]:= inttostr(propability)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   730
ScriptAmmoDelay[ord(ammo)]:= inttostr(delay)[1];
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   731
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
   732
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   735
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
   736
begin
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   737
SetAmmoLoadout(ScriptAmmoLoadout);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   738
SetAmmoProbability(ScriptAmmoProbability);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   739
SetAmmoDelay(ScriptAmmoDelay);
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   740
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
   741
for i:= 0 to Pred(TeamsCount) do
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3337
diff changeset
   742
    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
   743
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   744
3acdb4dac6eb 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
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
   746
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
   747
    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
   748
    st : TSound;
3acdb4dac6eb 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
// 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
   751
luaState:= lua_open;
3045
41732f986b4f Clean Augean stables
unc0rr
parents: 3043
diff changeset
   752
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
   753
3acdb4dac6eb 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
// 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
   755
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
   756
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
   757
luaopen_math(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
   758
3acdb4dac6eb 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
// 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
   760
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
   761
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
   762
3acdb4dac6eb 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
// 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
   764
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
   765
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
   766
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
   767
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
   768
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
   769
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
   770
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
   771
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
   772
ScriptSetInteger('gfMines', gfMines);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   773
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
   774
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
   775
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
   776
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
   777
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
   778
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
   779
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
   780
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
   781
ScriptSetInteger('gfDisableGirders', gfDisableGirders);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   782
ScriptSetInteger('gfExplosives', gfExplosives);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   783
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   784
// 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
   785
for at:= Low(TGearType) to High(TGearType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
   786
    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
   787
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   788
// 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
   789
for st:= Low(TSound) to High(TSound) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
   790
    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
   791
3acdb4dac6eb 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
// 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
   793
for am:= Low(TAmmoType) to High(TAmmoType) do
3337
75e7455c69ed Engine:
smxx
parents: 3271
diff changeset
   794
    ScriptSetInteger(EnumToStr(am), ord(am));
3043
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   795
    
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   796
// 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
   797
lua_register(luaState, 'AddGear', @lc_addgear);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   798
lua_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
   799
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
   800
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
   801
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
   802
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
   803
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
   804
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
   805
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
   806
lua_register(luaState, 'HideMission', @lc_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
   807
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
   808
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
   809
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
   810
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
   811
lua_register(luaState, 'SetHealth', @lc_sethealth);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   812
lua_register(luaState, 'GetHogClan', @lc_gethogclan);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   813
lua_register(luaState, 'GetHogName', @lc_gethogname);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   814
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
   815
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
   816
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
   817
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
   818
lua_register(luaState, 'FollowGear', @lc_followgear);
3058
2ebc20485344 Engine:
smxx
parents: 3045
diff changeset
   819
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
   820
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
   821
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
   822
lua_register(luaState, 'SetTag', @lc_settag);
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   823
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   824
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   825
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
   826
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
   827
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   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
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
   832
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
{$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
   835
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
   836
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
   837
end;
3acdb4dac6eb 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
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   839
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
   840
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
   841
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   842
3acdb4dac6eb 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
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
   844
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
   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 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
   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
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   852
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
   853
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   856
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
   857
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
   858
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   861
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
   862
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
   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 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
   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
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
   868
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   871
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
   872
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
   873
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   876
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
   877
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
   878
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
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
   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
end;
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   883
3acdb4dac6eb Just tidying up a bit. Comments, moving uMisc to end of frees in case ones above it need logging
nemo
parents: 3038
diff changeset
   884
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
   885
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
   886
end;
3acdb4dac6eb 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
3acdb4dac6eb 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
{$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
   889
end.