12 |
-- for example oxyd(), fakeoxyd(), laser(), ... and others. |
-- for example oxyd(), fakeoxyd(), laser(), ... and others. |
13 |
-- While I was rewriting, I finally implemented multichar maps, which I planned since the beginning... |
-- While I was rewriting, I finally implemented multichar maps, which I planned since the beginning... |
14 |
-- 2003-02-11 -- fixes in filling functions |
-- 2003-02-11 -- fixes in filling functions |
15 |
|
-- 2003-02-12 -- cell() now returns last created object; functional-drawing functions accept table; and fixes |
16 |
|
|
17 |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
18 |
-- MISCELANEOUS - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
-- MISCELANEOUS - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
174 |
end |
end |
175 |
|
|
176 |
--map elements |
--map elements |
177 |
if (%structure.stone) then set_stone(%cell0.stone.face, x, y, %cell0.stone.attr) end |
local ret = nil |
178 |
if (%structure.floor) then set_floor(%cell0.floor.face, x, y, %cell0.floor.attr) end |
|
179 |
|
if (%structure.stone) then ret = set_stone(%cell0.stone.face, x, y, %cell0.stone.attr) end |
180 |
|
if (%structure.floor) then ret = set_floor(%cell0.floor.face, x, y, %cell0.floor.attr) end |
181 |
if (%structure.item) then |
if (%structure.item) then |
182 |
if ((%structure.item.actor or 0) == 0) then |
if ((%structure.item.actor or 0) == 0) then |
183 |
set_item(%cell0.item.face, x, y, %cell0.item.attr) |
ret = set_item(%cell0.item.face, x, y, %cell0.item.attr) |
184 |
else |
else |
185 |
set_actor |
ret = set_actor(%cell0.item.face, |
186 |
(%cell0.item.face, |
get_actor_x(x, %structure.item.actor), |
187 |
get_actor_x(x, %structure.item.actor), |
get_actor_y(y, %structure.item.actor), |
188 |
get_actor_y(y, %structure.item.actor), |
%cell0.item.attr) |
|
%cell0.item.attr) |
|
189 |
end |
end |
190 |
end |
end |
191 |
|
|
192 |
|
return ret |
193 |
end |
end |
194 |
end |
end |
195 |
|
|
265 |
local x0, y0 = (x0 or 0), (y0 or 0) |
local x0, y0 = (x0 or 0), (y0 or 0) |
266 |
local w, h = (w or 0), (h or 0) |
local w, h = (w or 0), (h or 0) |
267 |
if w<=0 then w = level_width+w end |
if w<=0 then w = level_width+w end |
268 |
if h<=0 then h = level_width+h end |
if h<=0 then h = level_height+h end |
269 |
|
if (type(fillfunc)=="function") then fillfunc={fillfunc} end |
270 |
|
|
271 |
for x=x0, x0+w-1 do |
for _,func in fillfunc do |
272 |
for y=y0, y0+h-1 do |
for x=x0, x0+w-1 do |
273 |
fillfunc(x, y) |
for y=y0, y0+h-1 do |
274 |
|
func(x, y) |
275 |
|
end |
276 |
end |
end |
277 |
end |
end |
278 |
end |
end |
280 |
-- to draw border of map by given function |
-- to draw border of map by given function |
281 |
function draw_border_func(fillfunc, x0, y0, w, h) |
function draw_border_func(fillfunc, x0, y0, w, h) |
282 |
local x0, y0 = (x0 or 0), (y0 or 0) |
local x0, y0 = (x0 or 0), (y0 or 0) |
283 |
local w, h = (w or level_width), (h or level_height) |
local w, h = (w or 0), (h or 0) |
284 |
|
if w<=0 then w = level_width+w end |
285 |
|
if h<=0 then h = level_height+h end |
286 |
|
if (type(fillfunc)=="function") then fillfunc={fillfunc} end |
287 |
|
|
288 |
for x=x0,x0+w-1 do |
for _,func in fillfunc do |
289 |
fillfunc(x, y0) |
for x=x0,x0+w-1 do |
290 |
fillfunc(x, y0+h-1) |
func(x, y0) |
291 |
end |
func(x, y0+h-1) |
292 |
|
end |
293 |
|
|
294 |
for y=y0,y0+h-1 do |
for y=y0,y0+h-1 do |
295 |
fillfunc(x0, y) |
func(x0, y) |
296 |
fillfunc(x0+w-1, y) |
func(x0+w-1, y) |
297 |
|
end |
298 |
end |
end |
299 |
end |
end |
300 |
|
|
301 |
-- like set_stones, but calling a function |
-- like set_stones, but calling a function |
302 |
-- like: set_funcs(oxyd, {{1,2},{3,4},...}) |
-- like: set_funcs(oxyd, {{1,2},{3,4},...}) |
303 |
function set_funcs(fillfunc, poslist) |
function set_funcs(fillfunc, poslist) |
304 |
for i,xy in poslist do |
if (type(fillfunc)=="function") then fillfunc={fillfunc} end |
305 |
fillfunc(xy[1], xy[2]) |
|
306 |
end |
for _,func in fillfunc do |
307 |
|
for i,xy in poslist do |
308 |
|
func(xy[1], xy[2]) |
309 |
|
end |
310 |
|
end |
311 |
end |
end |
312 |
|
|
313 |
-- like draw_stones, draw_floor and others, but calls a func |
-- like draw_stones, draw_floor and others, but calls a func |
314 |
function draw_func(fillfunc, xy0, xystep, n) |
function draw_func(fillfunc, xy0, xystep, n) |
315 |
|
if (type(fillfunc)=="function") then fillfunc={fillfunc} end |
316 |
local x,y = xy0[1], xy0[2] |
local x,y = xy0[1], xy0[2] |
317 |
for i=1,n do |
|
318 |
fillfunc(x, y) |
for _,func in fillfunc do |
319 |
x = x+xystep[1] |
for i=1,n do |
320 |
y = y+xystep[2] |
func(x, y) |
321 |
|
x = x+xystep[1] |
322 |
|
y = y+xystep[2] |
323 |
|
end |
324 |
end |
end |
325 |
end |
end |
326 |
|
|