2200 end; |
2200 end; |
2201 |
2201 |
2202 function lc_placesprite(L : Plua_State) : LongInt; Cdecl; |
2202 function lc_placesprite(L : Plua_State) : LongInt; Cdecl; |
2203 var spr : TSprite; |
2203 var spr : TSprite; |
2204 lf : Word; |
2204 lf : Word; |
|
2205 tint : LongWord; |
2205 i, n : LongInt; |
2206 i, n : LongInt; |
2206 placed: boolean; |
2207 placed, behind, flipHoriz, flipVert : boolean; |
2207 const |
2208 const |
2208 call = 'PlaceSprite'; |
2209 call = 'PlaceSprite'; |
2209 params = 'x, y, sprite, frameIdx [, landFlag, ... ]'; |
2210 params = 'x, y, sprite, frameIdx, tint, behind, flipHoriz, flipVert, [, landFlag, ... ]'; |
2210 begin |
2211 begin |
2211 placed:= false; |
2212 placed:= false; |
2212 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2213 if CheckAndFetchLuaParamMinCount(L, 4, call, params, n) then |
2213 begin |
2214 begin |
|
2215 if not lua_isnoneornil(L, 5) then |
|
2216 tint := lua_tointeger(L, 5) |
|
2217 else tint := $FFFFFFFF; |
|
2218 if not lua_isnoneornil(L, 6) then |
|
2219 flipHoriz := lua_toboolean(L, 6) |
|
2220 else flipHoriz := false; |
|
2221 if not lua_isnoneornil(L, 6) then |
|
2222 flipVert := lua_toboolean(L, 6) |
|
2223 else flipVert := false; |
2214 lf:= 0; |
2224 lf:= 0; |
2215 |
2225 |
2216 // accept any amount of landflags, loop is never executed if n>5 |
2226 // accept any amount of landflags, loop is never executed if n>6 |
2217 for i:= 5 to n do |
2227 for i:= 6 to n do |
2218 lf:= lf or lua_tointeger(L, i); |
2228 lf:= lf or lua_tointeger(L, i); |
2219 |
2229 |
2220 n:= LuaToSpriteOrd(L, 3, call, params); |
2230 n:= LuaToSpriteOrd(L, 3, call, params); |
2221 if n >= 0 then |
2231 if n >= 0 then |
2222 begin |
2232 begin |
2225 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2235 LuaError(call + ': ' + EnumToStr(spr) + ' cannot be placed! (required information not loaded)' ) |
2226 else |
2236 else |
2227 placed:= ForcePlaceOnLand( |
2237 placed:= ForcePlaceOnLand( |
2228 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
2238 lua_tointeger(L, 1) - SpritesData[spr].Width div 2, |
2229 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
2239 lua_tointeger(L, 2) - SpritesData[spr].Height div 2, |
2230 spr, lua_tointeger(L, 4), lf); |
2240 spr, lua_tointeger(L, 4), lf, tint, behind, flipHoriz, flipVert); |
2231 end; |
2241 end; |
2232 end; |
2242 end; |
2233 |
2243 |
2234 lua_pushboolean(L, placed); |
2244 lua_pushboolean(L, placed); |
2235 lc_placesprite:= 1 |
2245 lc_placesprite:= 1 |