equal
deleted
inserted
replaced
34 procedure ScriptPrintStack; |
34 procedure ScriptPrintStack; |
35 procedure ScriptClearStack; |
35 procedure ScriptClearStack; |
36 |
36 |
37 procedure ScriptLoad(name : shortstring); |
37 procedure ScriptLoad(name : shortstring); |
38 procedure ScriptOnGameInit; |
38 procedure ScriptOnGameInit; |
|
39 procedure ScriptOnScreenResize(); |
39 |
40 |
40 procedure ScriptCall(fname : shortstring); |
41 procedure ScriptCall(fname : shortstring); |
41 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
42 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; |
42 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
43 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; |
43 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
44 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; |
1503 LuaError('Lua: Wrong number of parameters passed to GetCurAmmoType!') |
1504 LuaError('Lua: Wrong number of parameters passed to GetCurAmmoType!') |
1504 else |
1505 else |
1505 lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)); |
1506 lua_pushinteger(L, ord(CurrentHedgehog^.CurAmmoType)); |
1506 lc_getcurammotype := 1; |
1507 lc_getcurammotype := 1; |
1507 end; |
1508 end; |
|
1509 |
|
1510 // boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) |
|
1511 function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; |
|
1512 var rtn: Boolean; |
|
1513 begin |
|
1514 if lua_gettop(L) <> 5 then |
|
1515 begin |
|
1516 LuaError('Lua: Wrong number of parameters passed to TestRectForObstacle!'); |
|
1517 lua_pushnil(L); // return value on stack (nil) |
|
1518 end |
|
1519 else |
|
1520 begin |
|
1521 rtn:= TestRectancleForObstacle( |
|
1522 lua_tointeger(L, 1), |
|
1523 lua_tointeger(L, 2), |
|
1524 lua_tointeger(L, 3), |
|
1525 lua_tointeger(L, 4), |
|
1526 lua_toboolean(L, 5) |
|
1527 ); |
|
1528 lua_pushboolean(L, rtn); |
|
1529 end; |
|
1530 lc_testrectforobstacle:= 1 |
|
1531 end; |
1508 /////////////////// |
1532 /////////////////// |
1509 |
1533 |
1510 procedure ScriptPrintStack; |
1534 procedure ScriptPrintStack; |
1511 var n, i : LongInt; |
1535 var n, i : LongInt; |
1512 begin |
1536 begin |
1625 |
1649 |
1626 ScriptSetInteger('ClansCount', ClansCount); |
1650 ScriptSetInteger('ClansCount', ClansCount); |
1627 ScriptSetInteger('TeamsCount', TeamsCount) |
1651 ScriptSetInteger('TeamsCount', TeamsCount) |
1628 end; |
1652 end; |
1629 |
1653 |
|
1654 |
|
1655 // Update values of screen dimensions and allow script to react to resolution change |
|
1656 procedure ScriptOnScreenResize(); |
|
1657 begin |
|
1658 ScriptSetInteger('ScreenHeight', cScreenHeight); |
|
1659 ScriptSetInteger('ScreenWidth', cScreenWidth); |
|
1660 ScriptCall('onScreenResize'); |
|
1661 end; |
|
1662 |
|
1663 |
1630 procedure ScriptLoad(name : shortstring); |
1664 procedure ScriptLoad(name : shortstring); |
1631 var ret : LongInt; |
1665 var ret : LongInt; |
1632 s : shortstring; |
1666 s : shortstring; |
1633 begin |
1667 begin |
1634 s:= UserPathz[ptData] + '/' + name; |
1668 s:= UserPathz[ptData] + '/' + name; |
1818 luaopen_table(luaState); |
1852 luaopen_table(luaState); |
1819 |
1853 |
1820 // import some variables |
1854 // import some variables |
1821 ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
1855 ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); |
1822 ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
1856 ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); |
1823 |
|
1824 ScriptSetString('L', cLocale); |
1857 ScriptSetString('L', cLocale); |
1825 |
1858 |
1826 // import game flags |
1859 // import game flags |
1827 ScriptSetInteger('gfForts', gfForts); |
1860 ScriptSetInteger('gfForts', gfForts); |
1828 ScriptSetInteger('gfMultiWeapon', gfMultiWeapon); |
1861 ScriptSetInteger('gfMultiWeapon', gfMultiWeapon); |
1992 lua_register(luaState, 'MapHasBorder', @lc_maphasborder); |
2025 lua_register(luaState, 'MapHasBorder', @lc_maphasborder); |
1993 lua_register(luaState, 'GetHogHat', @lc_gethoghat); |
2026 lua_register(luaState, 'GetHogHat', @lc_gethoghat); |
1994 lua_register(luaState, 'SetHogHat', @lc_sethoghat); |
2027 lua_register(luaState, 'SetHogHat', @lc_sethoghat); |
1995 lua_register(luaState, 'PlaceGirder', @lc_placegirder); |
2028 lua_register(luaState, 'PlaceGirder', @lc_placegirder); |
1996 lua_register(luaState, 'GetCurAmmoType', @lc_getcurammotype); |
2029 lua_register(luaState, 'GetCurAmmoType', @lc_getcurammotype); |
|
2030 lua_register(luaState, 'TestRectForObstacle', @lc_testrectforobstacle); |
1997 |
2031 |
1998 |
2032 |
1999 ScriptClearStack; // just to be sure stack is empty |
2033 ScriptClearStack; // just to be sure stack is empty |
2000 ScriptLoaded:= false; |
2034 ScriptLoaded:= false; |
2001 end; |
2035 end; |