825 end; |
825 end; |
826 |
826 |
827 function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
827 function lc_findplace(L : Plua_State) : LongInt; Cdecl; |
828 var gear: PGear; |
828 var gear: PGear; |
829 fall: boolean; |
829 fall: boolean; |
|
830 tryhard: boolean; |
830 left, right: LongInt; |
831 left, right: LongInt; |
831 begin |
832 begin |
832 if lua_gettop(L) <> 4 then |
833 tryhard:= false; |
|
834 if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then |
833 LuaError('Lua: Wrong number of parameters passed to FindPlace!') |
835 LuaError('Lua: Wrong number of parameters passed to FindPlace!') |
834 else |
836 else |
835 begin |
837 begin |
836 gear:= GearByUID(lua_tointeger(L, 1)); |
838 gear:= GearByUID(lua_tointeger(L, 1)); |
837 fall:= lua_toboolean(L, 2); |
839 fall:= lua_toboolean(L, 2); |
838 left:= lua_tointeger(L, 3); |
840 left:= lua_tointeger(L, 3); |
839 right:= lua_tointeger(L, 4); |
841 right:= lua_tointeger(L, 4); |
840 if gear <> nil then |
842 if lua_gettop(L) = 5 then tryhard:= lua_toboolean(L, 5); |
841 FindPlace(gear, fall, left, right) |
843 if gear <> nil then |
842 end; |
844 FindPlace(gear, fall, left, right, tryhard); |
843 lc_findplace:= 0 |
845 if gear <> nil then lua_pushinteger(L, gear^.uid) |
|
846 else lua_pushnil(L); |
|
847 end; |
|
848 lc_findplace:= 1 |
844 end; |
849 end; |
845 |
850 |
846 function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
851 function lc_playsound(L : Plua_State) : LongInt; Cdecl; |
847 var gear: PGear; |
852 var gear: PGear; |
848 begin |
853 begin |
1490 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage); |
1507 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage); |
1491 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage); |
1508 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage); |
1492 lua_register(luaState, 'GetRandom', @lc_getrandom); |
1509 lua_register(luaState, 'GetRandom', @lc_getrandom); |
1493 lua_register(luaState, 'SetWind', @lc_setwind); |
1510 lua_register(luaState, 'SetWind', @lc_setwind); |
1494 lua_register(luaState, 'GetDataPath', @lc_getdatapath); |
1511 lua_register(luaState, 'GetDataPath', @lc_getdatapath); |
|
1512 lua_register(luaState, 'MapHasBorder', @lc_maphasborder); |
1495 |
1513 |
1496 |
1514 |
1497 ScriptClearStack; // just to be sure stack is empty |
1515 ScriptClearStack; // just to be sure stack is empty |
1498 ScriptLoaded:= false; |
1516 ScriptLoaded:= false; |
1499 end; |
1517 end; |