2211 begin |
2211 begin |
2212 placed:= false; |
2212 placed:= false; |
2213 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2213 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2214 begin |
2214 begin |
2215 if not lua_isnoneornil(L, 5) then |
2215 if not lua_isnoneornil(L, 5) then |
2216 tint := lua_tointeger(L, 5) |
2216 tint := lua_tointeger(L, 5) |
2217 else tint := $FFFFFFFF; |
2217 else tint := $FFFFFFFF; |
2218 if not lua_isnoneornil(L, 6) then |
2218 if not lua_isnoneornil(L, 6) then |
2219 flipHoriz := lua_toboolean(L, 6) |
2219 behind := lua_toboolean(L, 6) |
|
2220 else behind := false; |
|
2221 if not lua_isnoneornil(L, 7) then |
|
2222 flipHoriz := lua_toboolean(L, 7) |
2220 else flipHoriz := false; |
2223 else flipHoriz := false; |
2221 if not lua_isnoneornil(L, 7) then |
2224 if not lua_isnoneornil(L, 8) then |
2222 flipVert := lua_toboolean(L, 7) |
2225 flipVert := lua_toboolean(L, 8) |
2223 else flipVert := false; |
2226 else flipVert := false; |
2224 lf:= 0; |
2227 lf:= 0; |
2225 |
2228 |
2226 // accept any amount of landflags, loop is never executed if n>6 |
2229 // accept any amount of landflags, loop is never executed if n>6 |
2227 for i:= 8 to n do |
2230 for i:= 9 to n do |
2228 lf:= lf or lua_tointeger(L, i); |
2231 lf:= lf or lua_tointeger(L, i); |
2229 |
2232 |
2230 n:= LuaToSpriteOrd(L, 3, call, params); |
2233 n:= LuaToSpriteOrd(L, 3, call, params); |
2231 if n >= 0 then |
2234 if n >= 0 then |
2232 begin |
2235 begin |
2241 end; |
2244 end; |
2242 end; |
2245 end; |
2243 |
2246 |
2244 lua_pushboolean(L, placed); |
2247 lua_pushboolean(L, placed); |
2245 lc_placesprite:= 1 |
2248 lc_placesprite:= 1 |
|
2249 end; |
|
2250 |
|
2251 function lc_erasesprite(L : Plua_State) : LongInt; Cdecl; |
|
2252 var spr : TSprite; |
|
2253 lf : Word; |
|
2254 i, n : LongInt; |
|
2255 eraseOnLFMatch, flipHoriz, flipVert : boolean; |
|
2256 const |
|
2257 call = 'EraseSprite'; |
|
2258 params = 'x, y, sprite, frameIdx, eraseOnLFMatch, flipHoriz, flipVert, [, landFlag, ... ]'; |
|
2259 begin |
|
2260 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
|
2261 begin |
|
2262 if not lua_isnoneornil(L, 5) then |
|
2263 eraseOnLFMatch := lua_toboolean(L, 5) |
|
2264 else eraseOnLFMatch := false; |
|
2265 if not lua_isnoneornil(L, 6) then |
|
2266 flipHoriz := lua_toboolean(L, 6) |
|
2267 else flipHoriz := false; |
|
2268 if not lua_isnoneornil(L, 7) then |
|
2269 flipVert := lua_toboolean(L, 7) |
|
2270 else flipVert := false; |
|
2271 lf:= 0; |
|
2272 |
|
2273 // accept any amount of landflags, loop is never executed if n>6 |
|
2274 for i:= 8 to n do |
|
2275 lf:= lf or lua_tointeger(L, i); |
|
2276 |
|
2277 n:= LuaToSpriteOrd(L, 3, call, params); |
|
2278 if n >= 0 then |
|
2279 begin |
|
2280 spr:= TSprite(n); |
|
2281 if SpritesData[spr].Surface = nil then |
|
2282 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
|
2283 else |
|
2284 EraseLand( |
|
2285 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
|
2286 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
|
2287 spr, lua_tointeger(L, 4), lf, eraseOnLFMatch, flipHoriz, flipVert); |
|
2288 end; |
|
2289 end; |
|
2290 lc_erasesprite:= 0 |
2246 end; |
2291 end; |
2247 |
2292 |
2248 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
2293 function lc_placegirder(L : Plua_State) : LongInt; Cdecl; |
2249 var placed: boolean; |
2294 var placed: boolean; |
2250 begin |
2295 begin |
3164 lua_register(luaState, _P'GetDataPath', @lc_getdatapath); |
3209 lua_register(luaState, _P'GetDataPath', @lc_getdatapath); |
3165 lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath); |
3210 lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath); |
3166 lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
3211 lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); |
3167 lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
3212 lua_register(luaState, _P'GetHogHat', @lc_gethoghat); |
3168 lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
3213 lua_register(luaState, _P'SetHogHat', @lc_sethoghat); |
|
3214 lua_register(luaState, _P'EraseSprite', @lc_erasesprite); |
3169 lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
3215 lua_register(luaState, _P'PlaceSprite', @lc_placesprite); |
3170 lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
3216 lua_register(luaState, _P'PlaceGirder', @lc_placegirder); |
3171 lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
3217 lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); |
3172 lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
3218 lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); |
3173 lua_register(luaState, _P'GetGravity', @lc_getgravity); |
3219 lua_register(luaState, _P'GetGravity', @lc_getgravity); |