hedgewars/uScript.pas
author smxx
Sat, 06 Mar 2010 13:22:52 +0000
changeset 2949 d137a9da7701
parent 2948 3f21a9dc93d0
child 2996 dfc7507a21a0
permissions -rw-r--r--
Engine: * Added localisation support to LUA (see example hwt files)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     1
(*
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     3
 * Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com>
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     4
 *
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     8
 *
85f6425a4d74 Engine:
smxx
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    12
 * GNU General Public License for more details.
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    13
 *
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    17
 *)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    18
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    19
{$INCLUDE "options.inc"}
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    20
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    21
unit uScript;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    22
interface
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    23
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    24
procedure ScriptPrintStack;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    25
procedure ScriptClearStack;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    26
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
    27
procedure ScriptLoad(name : shortstring);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    28
procedure ScriptOnGameInit;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    29
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
    30
procedure ScriptCall(fname : shortstring);
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
    31
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
    32
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt;
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
    33
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
    34
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    35
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    36
procedure init_uScript;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    37
procedure free_uScript;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    38
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    39
implementation
2798
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
    40
{$IFNDEF IPHONEOS}
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    41
uses LuaPas in 'LuaPas.pas',
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    42
    uConsole,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    43
    uMisc,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    44
    uConsts,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    45
    uGears,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    46
    uFloat,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    47
    uWorld,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    48
    uAmmos,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    49
    uSound,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    50
    uTeams,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    51
    uKeys,
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    52
    typinfo;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    53
    
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    54
var luaState : Plua_State;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    55
    ScriptAmmoStore : shortstring;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    56
    ScriptLoaded : boolean;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    57
    
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    58
procedure ScriptPrepareAmmoStore; forward;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    59
procedure ScriptApplyAmmoStore; forward;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    60
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); forward;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    61
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    62
// wrapped calls //
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    63
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    64
// functions called from lua:
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    65
// function(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    66
// where L contains the state, returns the number of return values on the stack
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    67
// call lua_gettop(L) to receive number of parameters passed
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    68
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    69
function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    70
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    71
    if lua_gettop(L) = 1 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    72
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    73
        WriteLnToConsole('LUA: ' + lua_tostring(L ,1));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    74
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    75
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    76
        WriteLnToConsole('LUA: Wrong number of parameters passed to WriteLnToConsole!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    77
    lc_writelntoconsole:= 0;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    78
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    79
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    80
function lc_parsecommand(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    81
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    82
    if lua_gettop(L) = 1 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    83
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    84
        ParseCommand(lua_tostring(L ,1), true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    85
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    86
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    87
        WriteLnToConsole('LUA: Wrong number of parameters passed to ParseCommand!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    88
    lc_parsecommand:= 0;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    89
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    90
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    91
function lc_showmission(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
    92
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    93
    if lua_gettop(L) = 5 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    94
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    95
        ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    96
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    97
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    98
        WriteLnToConsole('LUA: Wrong number of parameters passed to ShowMission!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
    99
    lc_showmission:= 0;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   100
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   101
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   102
function lc_hidemission(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   103
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   104
    HideMission;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   105
    lc_hidemission:= 0;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   106
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   107
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   108
function lc_addgear(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   109
var gear : PGear;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   110
    x, y, s, t: LongInt;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   111
    dx, dy: hwFloat;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   112
    gt: TGearType;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   113
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   114
    if lua_gettop(L) <> 7 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   115
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   116
        WriteLnToConsole('LUA: Wrong number of parameters passed to AddGear!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   117
        lua_pushnil(L); // return value on stack (nil)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   118
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   119
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   120
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   121
        x:= lua_tointeger(L, 1);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   122
        y:= lua_tointeger(L, 2);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   123
        gt:= TGearType(lua_tointeger(L, 3));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   124
        s:= lua_tointeger(L, 4);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   125
        dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   126
        dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   127
        t:= lua_tointeger(L, 7);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   128
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   129
        gear:= AddGear(x, y, gt, s, dx, dy, t);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   130
        lua_pushnumber(L, gear^.uid)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   131
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   132
    lc_addgear:= 1; // 1 return value
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   133
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   134
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   135
function lc_getgeartype(L : Plua_State) : LongInt; Cdecl;
2790
83630d5f94db Engine:
smxx
parents: 2786
diff changeset
   136
var gear : PGear;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   137
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   138
    if lua_gettop(L) <> 1 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   139
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   140
        WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearType!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   141
        lua_pushnil(L); // return value on stack (nil)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   142
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   143
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   144
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   145
        gear:= GearByUID(lua_tointeger(L, 1));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   146
        if gear <> nil then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   147
            lua_pushinteger(L, ord(gear^.Kind))
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   148
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   149
    lc_getgeartype:= 1
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   150
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   151
2814
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   152
function lc_sethealth(L : Plua_State) : LongInt; Cdecl;
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   153
var gear : PGear;
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   154
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   155
    if lua_gettop(L) <> 2 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   156
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   157
        WriteLnToConsole('LUA: Wrong number of parameters passed to SetHealth!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   158
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   159
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   160
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   161
        gear:= GearByUID(lua_tointeger(L, 1));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   162
        if (gear <> nil) and (gear^.Kind = gtHedgehog) then gear^.Health:= lua_tointeger(L, 2)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   163
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   164
    lc_sethealth:= 0
2814
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   165
end;
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   166
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   167
function lc_endgame(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   168
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   169
    GameState:= gsExit;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   170
    lc_endgame:= 0
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   171
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   172
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   173
function lc_findplace(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   174
var gear: PGear;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   175
    fall: boolean;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   176
    left, right: LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   177
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   178
    if lua_gettop(L) <> 4 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   179
        WriteLnToConsole('LUA: Wrong number of parameters passed to FindPlace!')
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   180
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   181
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   182
        gear:= GearByUID(lua_tointeger(L, 1));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   183
        fall:= lua_toboolean(L, 2);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   184
        left:= lua_tointeger(L, 3);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   185
        right:= lua_tointeger(L, 4);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   186
        if gear <> nil then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   187
            FindPlace(gear, fall, left, right)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   188
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   189
    lc_findplace:= 0
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   190
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   191
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   192
function lc_playsound(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   193
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   194
    if lua_gettop(L) <> 1 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   195
        WriteLnToConsole('LUA: Wrong number of parameters passed to PlaySound!')
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   196
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   197
        PlaySound(TSound(lua_tointeger(L, 1)));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   198
    lc_playsound:= 0;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   199
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   200
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   201
function lc_addteam(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   202
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   203
    if lua_gettop(L) <> 5 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   204
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   205
        WriteLnToConsole('LUA: Wrong number of parameters passed to AddTeam!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   206
        //lua_pushnil(L)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   207
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   208
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   209
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   210
        ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   211
        ParseCommand('grave ' + lua_tostring(L, 3), true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   212
        ParseCommand('fort ' + lua_tostring(L, 4), true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   213
        ParseCommand('voicepack ' + lua_tostring(L, 5), true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   214
        CurrentTeam^.Binds:= DefaultBinds;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   215
        // fails on x64
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   216
        //lua_pushinteger(L, LongInt(CurrentTeam));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   217
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   218
    lc_addteam:= 0;//1;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   219
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   220
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   221
function lc_addhog(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   222
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   223
    if lua_gettop(L) <> 4 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   224
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   225
        WriteLnToConsole('LUA: Wrong number of parameters passed to AddHog!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   226
        lua_pushnil(L)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   227
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   228
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   229
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   230
        ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   231
        ParseCommand('hat ' + lua_tostring(L, 4), true);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   232
        lua_pushinteger(L, CurrentHedgehog^.Gear^.uid);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   233
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   234
    lc_addhog:= 1;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   235
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   236
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   237
function lc_getgearposition(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   238
var gear: PGear;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   239
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   240
    if lua_gettop(L) <> 1 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   241
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   242
        WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearPosition!');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   243
        lua_pushnil(L);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   244
        lua_pushnil(L)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   245
        end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   246
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   247
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   248
        gear:= GearByUID(lua_tointeger(L, 1));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   249
        if gear <> nil then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   250
            begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   251
            lua_pushinteger(L, hwRound(gear^.X));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   252
            lua_pushinteger(L, hwRound(gear^.Y))
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   253
            end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   254
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   255
    lc_getgearposition:= 2;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   256
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   257
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   258
function lc_setgearposition(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   259
var gear: PGear;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   260
    x, y: LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   261
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   262
    if lua_gettop(L) <> 3 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   263
        WriteLnToConsole('LUA: Wrong number of parameters passed to SetGearPosition!')
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   264
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   265
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   266
        gear:= GearByUID(lua_tointeger(L, 1));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   267
        if gear <> nil then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   268
            begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   269
            x:= lua_tointeger(L, 2);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   270
            y:= lua_tointeger(L, 3);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   271
            gear^.X:= int2hwfloat(x);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   272
            gear^.Y:= int2hwfloat(y);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   273
            end
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   274
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   275
    lc_setgearposition:= 0
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   276
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   277
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   278
function lc_setammo(L : Plua_State) : LongInt; Cdecl;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   279
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   280
    if lua_gettop(L) <> 3 then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   281
        WriteLnToConsole('LUA: Wrong number of parameters passed to SetAmmo!')
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   282
    else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   283
        begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   284
        ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   285
        end;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   286
    lc_setammo:= 0
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   287
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   288
///////////////////
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   289
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   290
procedure ScriptPrintStack;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   291
var n, i : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   292
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   293
    n:= lua_gettop(luaState);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   294
    WriteLnToConsole('LUA: Stack (' + inttostr(n) + ' elements):');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   295
    for i:= 1 to n do
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   296
        if not lua_isboolean(luaState, i) then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   297
            WriteLnToConsole('LUA:  ' + inttostr(i) + ': ' + lua_tostring(luaState, i))
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   298
        else if lua_toboolean(luaState, i) then
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   299
            WriteLnToConsole('LUA:  ' + inttostr(i) + ': true')
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   300
        else
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   301
            WriteLnToConsole('LUA:  ' + inttostr(i) + ': false');
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   302
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   303
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   304
procedure ScriptClearStack;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   305
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   306
lua_settop(luaState, 0)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   307
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   308
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   309
procedure ScriptSetInteger(name : shortstring; value : LongInt);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   310
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   311
lua_pushinteger(luaState, value);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   312
lua_setglobal(luaState, Str2PChar(name));
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   313
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   314
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   315
procedure ScriptSetString(name : shortstring; value : shortstring);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   316
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   317
lua_pushstring(luaState, Str2PChar(value));
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   318
lua_setglobal(luaState, Str2PChar(name));
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   319
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   320
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   321
function ScriptGetInteger(name : shortstring) : LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   322
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   323
lua_getglobal(luaState, Str2PChar(name));
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   324
ScriptGetInteger:= lua_tointeger(luaState, -1);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   325
lua_pop(luaState, 1);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   326
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   327
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   328
function ScriptGetString(name : shortstring) : shortstring;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   329
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   330
lua_getglobal(luaState, Str2PChar(name));
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   331
ScriptGetString:= lua_tostring(luaState, -1);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   332
lua_pop(luaState, 1);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   333
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   334
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   335
procedure ScriptOnGameInit;
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   336
var s, t : ansistring;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   337
begin
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   338
// not required if there's no script to run
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   339
if not ScriptLoaded then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   340
    exit;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   341
        
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   342
// push game variables so they may be modified by the script
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   343
ScriptSetInteger('GameFlags', GameFlags);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   344
ScriptSetString('Seed', cSeed);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   345
ScriptSetInteger('TurnTime', cHedgehogTurnTime);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   346
ScriptSetInteger('CaseFreq', cCaseFactor);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   347
ScriptSetInteger('LandAdds', cLandAdditions);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   348
ScriptSetInteger('Delay', cInactDelay);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   349
ScriptSetString('Map', '');
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   350
ScriptSetString('Theme', '');
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   351
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   352
// import locale
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   353
s:= cLocaleFName;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   354
SplitByChar(s, t, '.');
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   355
ScriptSetString('L', s);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   356
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   357
ScriptCall('onGameInit');
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   358
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   359
// pop game variables
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   360
ParseCommand('seed ' + ScriptGetString('Seed'), true);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   361
ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   362
ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   363
ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   364
ParseCommand('$landadds ' + ScriptGetString('LandAdds'), true);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   365
ParseCommand('$delay ' + ScriptGetString('Delay'), true);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   366
if ScriptGetString('Map') <> '' then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   367
    ParseCommand('map ' + ScriptGetString('Map'), true);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   368
if ScriptGetString('Theme') <> '' then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   369
    ParseCommand('theme ' + ScriptGetString('Theme'), true);    
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   370
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   371
ScriptPrepareAmmoStore;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   372
ScriptCall('onAmmoStoreInit');
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   373
ScriptApplyAmmoStore;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   374
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   375
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   376
procedure ScriptLoad(name : shortstring);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   377
var ret : LongInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   378
begin
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   379
ret:= luaL_loadfile(luaState, Str2PChar(name));
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   380
if ret <> 0 then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   381
    WriteLnToConsole('LUA: Failed to load ' + name + '(error ' + IntToStr(ret) + ')')
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   382
else
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   383
    begin
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   384
    WriteLnToConsole('LUA: ' + name + ' loaded');
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   385
    // call the script file
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   386
    lua_pcall(luaState, 0, 0, 0);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   387
    ScriptLoaded:= true
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   388
    end
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   389
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   390
2814
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   391
procedure SetGlobals;
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   392
begin
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   393
ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
2814
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   394
end;
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   395
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   396
procedure GetGlobals;
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   397
begin
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   398
TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft');
2814
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   399
end;
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   400
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   401
procedure ScriptCall(fname : shortstring);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   402
begin
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   403
if not ScriptLoaded then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   404
    exit;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   405
SetGlobals;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   406
lua_getglobal(luaState, Str2PChar(fname));
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   407
if lua_pcall(luaState, 0, 0, 0) <> 0 then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   408
    begin
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   409
    WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   410
    lua_pop(luaState, 1)
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   411
    end;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   412
GetGlobals;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   413
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   414
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   415
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   416
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   417
ScriptCall:= ScriptCall(fname, par1, 0, 0, 0)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   418
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   419
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   420
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   421
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   422
ScriptCall:= ScriptCall(fname, par1, par2, 0, 0)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   423
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   424
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   425
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   426
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   427
ScriptCall:= ScriptCall(fname, par1, par2, par3, 0)
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   428
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   429
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   430
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   431
begin
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   432
if not ScriptLoaded then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   433
    exit;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   434
SetGlobals;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   435
lua_getglobal(luaState, Str2PChar(fname));
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   436
lua_pushinteger(luaState, par1);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   437
lua_pushinteger(luaState, par2);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   438
lua_pushinteger(luaState, par3);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   439
lua_pushinteger(luaState, par4);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   440
ScriptCall:= 0;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   441
if lua_pcall(luaState, 4, 1, 0) <> 0 then
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   442
    begin
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   443
    WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1));
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   444
    lua_pop(luaState, 1)
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   445
    end
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   446
else
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   447
    begin
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   448
    ScriptCall:= lua_tointeger(luaState, -1);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   449
    lua_pop(luaState, 1)
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   450
    end;
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   451
GetGlobals;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   452
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   453
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   454
procedure ScriptPrepareAmmoStore;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   455
var i: ShortInt;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   456
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   457
ScriptAmmoStore:= '';
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   458
for i:=1 to ord(High(TAmmoType)) do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   459
    ScriptAmmoStore:= ScriptAmmoStore + '0000';
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   460
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   461
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   462
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   463
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   464
if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   465
    exit;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   466
ScriptAmmoStore[ord(ammo)]:= inttostr(count)[1];
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   467
ScriptAmmoStore[ord(ammo) + ord(high(TAmmoType))]:= inttostr(propability)[1];
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   468
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   469
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   470
procedure ScriptApplyAmmoStore;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   471
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   472
    AddAmmoStore(ScriptAmmoStore);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   473
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   474
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   475
// small helper functions making registering enums a lot easier
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   476
function str(const en : TGearType) : shortstring; overload;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   477
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   478
str:= GetEnumName(TypeInfo(TGearType), ord(en))
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   479
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   480
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   481
function str(const en : TSound) : shortstring; overload;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   482
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   483
str:= GetEnumName(TypeInfo(TSound), ord(en))
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   484
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   485
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   486
function str(const en : TAmmoType) : shortstring; overload;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   487
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   488
str:= GetEnumName(TypeInfo(TAmmoType), ord(en))
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   489
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   490
///////////////////
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   491
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   492
procedure init_uScript;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   493
var at : TGearType;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   494
    am : TAmmoType;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   495
    st : TSound;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   496
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   497
// initialize lua
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   498
luaState:= lua_open;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   499
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   500
// open internal libraries
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   501
luaopen_base(luaState);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   502
luaopen_string(luaState);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   503
luaopen_math(luaState);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   504
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   505
// import some variables
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   506
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   507
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   508
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   509
// import game flags
2949
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   510
ScriptSetInteger('gfForts', gfForts);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   511
ScriptSetInteger('gfMultiWeapon', gfMultiWeapon);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   512
ScriptSetInteger('gfSolidLand', gfSolidLand);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   513
ScriptSetInteger('gfBorder', gfBorder);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   514
ScriptSetInteger('gfDivideTeams', gfDivideTeams);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   515
ScriptSetInteger('gfLowGravity', gfLowGravity);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   516
ScriptSetInteger('gfLaserSight', gfLaserSight);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   517
ScriptSetInteger('gfInvulnerable', gfInvulnerable);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   518
ScriptSetInteger('gfMines', gfMines);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   519
ScriptSetInteger('gfVampiric', gfVampiric);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   520
ScriptSetInteger('gfKarma', gfKarma);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   521
ScriptSetInteger('gfArtillery', gfArtillery);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   522
ScriptSetInteger('gfOneClanMode', gfOneClanMode);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   523
ScriptSetInteger('gfRandomOrder', gfRandomOrder);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   524
ScriptSetInteger('gfKing', gfKing);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   525
ScriptSetInteger('gfPlaceHog', gfPlaceHog);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   526
ScriptSetInteger('gfSharedAmmo', gfSharedAmmo);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   527
ScriptSetInteger('gfDisableGirders', gfDisableGirders);
d137a9da7701 Engine:
smxx
parents: 2948
diff changeset
   528
ScriptSetInteger('gfExplosives', gfExplosives);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   529
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   530
// register gear types
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   531
for at:= Low(TGearType) to High(TGearType) do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   532
    ScriptSetInteger(str(at), ord(at));
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   533
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   534
// register sounds
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   535
for st:= Low(TSound) to High(TSound) do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   536
    ScriptSetInteger(str(st), ord(st));
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   537
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   538
// register ammo types
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   539
for am:= Low(TAmmoType) to High(TAmmoType) do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   540
    ScriptSetInteger(str(am), ord(am));
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2924
diff changeset
   541
    
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   542
// register functions
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   543
lua_register(luaState, 'AddGear', @lc_addgear);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   544
lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   545
lua_register(luaState, 'GetGearType', @lc_getgeartype);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   546
lua_register(luaState, 'EndGame', @lc_endgame);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   547
lua_register(luaState, 'FindPlace', @lc_findplace);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   548
lua_register(luaState, 'SetGearPosition', @lc_setgearposition);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   549
lua_register(luaState, 'GetGearPosition', @lc_getgearposition);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   550
lua_register(luaState, 'ParseCommand', @lc_parsecommand);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   551
lua_register(luaState, 'ShowMission', @lc_showmission);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   552
lua_register(luaState, 'HideMission', @lc_hidemission);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   553
lua_register(luaState, 'SetAmmo', @lc_setammo);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   554
lua_register(luaState, 'PlaySound', @lc_playsound);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   555
lua_register(luaState, 'AddTeam', @lc_addteam);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   556
lua_register(luaState, 'AddHog', @lc_addhog);
2814
71e80c6e74bb Engine:
smxx
parents: 2799
diff changeset
   557
lua_register(luaState, 'SetHealth', @lc_sethealth);
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   558
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   559
ScriptClearStack; // just to be sure stack is empty
2793
6bcf173ba9be Engine:
smxx
parents: 2791
diff changeset
   560
ScriptLoaded:= false;
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   561
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   562
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   563
procedure free_uScript;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   564
begin
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   565
lua_close(luaState);
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   566
end;
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   567
2798
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   568
{$ELSE}
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   569
procedure ScriptPrintStack;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   570
begin
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   571
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   572
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   573
procedure ScriptClearStack;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   574
begin
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   575
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   576
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   577
procedure ScriptLoad(name : shortstring);
2798
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   578
begin
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   579
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   580
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   581
procedure ScriptOnGameInit;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   582
begin
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   583
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   584
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   585
procedure ScriptCall(fname : shortstring);
2798
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   586
begin
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   587
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   588
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   589
function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
2798
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   590
begin
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   591
ScriptCall:= 0
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   592
end;
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   593
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   594
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   595
begin
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   596
ScriptCall:= 0
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   597
end;
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   598
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   599
function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   600
begin
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   601
ScriptCall:= 0
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   602
end;
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   603
2905
f3c79f7193a9 Engine:
smxx
parents: 2862
diff changeset
   604
function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
2799
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   605
begin
558b29bf00c5 add a new way to fetch version info from pascal to c
koda
parents: 2798
diff changeset
   606
ScriptCall:= 0
2798
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   607
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   608
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   609
procedure init_uScript;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   610
begin
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   611
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   612
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   613
procedure free_uScript;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   614
begin
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   615
end;
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   616
d48bbe4518e6 Engine:
smxx
parents: 2795
diff changeset
   617
{$ENDIF}
2786
85f6425a4d74 Engine:
smxx
parents:
diff changeset
   618
end.