131 begin |
131 begin |
132 LuaCallError('Invalid gear type!', call, paramsyntax); |
132 LuaCallError('Invalid gear type!', call, paramsyntax); |
133 exit(false); |
133 exit(false); |
134 end; |
134 end; |
135 IsValidGearType:= true; |
135 IsValidGearType:= true; |
|
136 end; |
|
137 |
|
138 function IsValidSprite(sprite: lua_Integer; call, paramsyntax: shortstring): boolean; inline; |
|
139 begin |
|
140 if (sprite < ord(Low(TSprite))) or (sprite > ord(High(TSprite))) then |
|
141 begin |
|
142 LuaCallError('Invalid sprite id!', call, paramsyntax); |
|
143 exit(false); |
|
144 end; |
|
145 IsValidSprite:= true; |
136 end; |
146 end; |
137 |
147 |
138 // wrapped calls // |
148 // wrapped calls // |
139 |
149 |
140 // functions called from Lua: |
150 // functions called from Lua: |
1871 end |
1881 end |
1872 end; |
1882 end; |
1873 lc_sethoghat:= 0; |
1883 lc_sethoghat:= 0; |
1874 end; |
1884 end; |
1875 |
1885 |
|
1886 function lc_placesprite(L : Plua_State) : LongInt; Cdecl; |
|
1887 var spr : TSprite; |
|
1888 lf : Word; |
|
1889 n : LongInt; |
|
1890 placed: boolean; |
|
1891 const |
|
1892 call = 'PlaceSprite'; |
|
1893 params = 'x, y, sprite, frameIdx [, landFlags]'; |
|
1894 begin |
|
1895 placed:= false; |
|
1896 n:= lua_gettop(L); |
|
1897 if (n < 4) or (n > 5) then |
|
1898 LuaParameterCountError(call, params, lua_gettop(L)) |
|
1899 else |
|
1900 begin |
|
1901 // get landflags, if specified |
|
1902 if n = 5 then |
|
1903 lf:= lua_tointeger(L, 5) |
|
1904 else |
|
1905 lf:= 0; |
|
1906 |
|
1907 n:= lua_tointeger(L, 3); |
|
1908 if IsValidSprite(n, call, params) then |
|
1909 spr:= TSprite(n); |
|
1910 if SpritesData[spr].Surface = nil then |
|
1911 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
|
1912 else |
|
1913 placed:= TryPlaceOnLand( |
|
1914 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
|
1915 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
|
1916 spr, lua_tointeger(L, 4), true, false, lfBouncy); |
|
1917 end; |
|
1918 |
|
1919 lua_pushboolean(L, placed); |
|
1920 lc_placesprite:= 1 |
|
1921 end; |
|
1922 |
1876 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
1923 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
1877 begin |
1924 var placed: boolean; |
|
1925 begin |
|
1926 placed:= false; |
1878 if lua_gettop(L) <> 3 then |
1927 if lua_gettop(L) <> 3 then |
1879 LuaParameterCountError('PlaceGirder', 'x, y, frameIdx', lua_gettop(L)) |
1928 LuaParameterCountError('PlaceGirder', 'x, y, frameIdx', lua_gettop(L)) |
1880 else |
1929 else |
1881 TryPlaceOnLand( |
1930 placed:= TryPlaceOnLand( |
1882 lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
1931 lua_tointeger(L, 1) - SpritesData[sprAmGirder].Width div 2, |
1883 lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
1932 lua_tointeger(L, 2) - SpritesData[sprAmGirder].Height div 2, |
1884 sprAmGirder, lua_tointeger(L, 3), true, false); |
1933 sprAmGirder, lua_tointeger(L, 3), true, false); |
1885 lc_placegirder:= 0 |
1934 |
|
1935 lua_pushboolean(L, placed); |
|
1936 lc_placegirder:= 1 |
1886 end; |
1937 end; |
1887 |
1938 |
1888 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
1939 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl; |
1889 begin |
1940 begin |
1890 if lua_gettop(L) <> 0 then |
1941 if lua_gettop(L) <> 0 then |
2605 for he:= Low(THogEffect) to High(THogEffect) do |
2657 for he:= Low(THogEffect) to High(THogEffect) do |
2606 ScriptSetInteger(EnumToStr(he), ord(he)); |
2658 ScriptSetInteger(EnumToStr(he), ord(he)); |
2607 |
2659 |
2608 for cg:= Low(TCapGroup) to High(TCapGroup) do |
2660 for cg:= Low(TCapGroup) to High(TCapGroup) do |
2609 ScriptSetInteger(EnumToStr(cg), ord(cg)); |
2661 ScriptSetInteger(EnumToStr(cg), ord(cg)); |
|
2662 |
|
2663 for spr:= Low(TSprite) to High(TSprite) do |
|
2664 ScriptSetInteger(EnumToStr(spr), ord(spr)); |
|
2665 |
2610 |
2666 |
2611 ScriptSetInteger('gstDrowning' ,$00000001); |
2667 ScriptSetInteger('gstDrowning' ,$00000001); |
2612 ScriptSetInteger('gstHHDriven' ,$00000002); |
2668 ScriptSetInteger('gstHHDriven' ,$00000002); |
2613 ScriptSetInteger('gstMoving' ,$00000004); |
2669 ScriptSetInteger('gstMoving' ,$00000004); |
2614 ScriptSetInteger('gstAttacked' ,$00000008); |
2670 ScriptSetInteger('gstAttacked' ,$00000008); |
2728 lua_register(luaState, _P'GetDataPath', @lc_getdatapath); |
2784 lua_register(luaState, _P'GetDataPath', @lc_getdatapath); |
2729 lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath); |
2785 lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath); |
2730 lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
2786 lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
2731 lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
2787 lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
2732 lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
2788 lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
|
2789 lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
2733 lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
2790 lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
2734 lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
2791 lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
2735 lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
2792 lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
2736 lua_register(luaState, _P'GetGravity', @lc_getgravity); |
2793 lua_register(luaState, _P'GetGravity', @lc_getgravity); |
2737 lua_register(luaState, _P'SetGravity', @lc_setgravity); |
2794 lua_register(luaState, _P'SetGravity', @lc_setgravity); |