11 |
-- finally possible to call functions from init.lua or any functions declared like func(x, y, args), |
-- finally possible to call functions from init.lua or any functions declared like func(x, y, args), |
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 |
15 |
|
|
16 |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
17 |
-- MISCELANEOUS - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
-- MISCELANEOUS - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
120 |
local cell0 = {} |
local cell0 = {} |
121 |
|
|
122 |
cell0.tag = (structure.tag or "?") |
cell0.tag = (structure.tag or "?") |
|
cell0.setactor = structure.setactor |
|
123 |
cell0.floor = cell_item(structure.floor or {}) |
cell0.floor = cell_item(structure.floor or {}) |
124 |
cell0.stone = cell_item(structure.stone or {}) |
cell0.stone = cell_item(structure.stone or {}) |
125 |
cell0.item = cell_item(structure.item or {}) |
cell0.item = cell_item(structure.item or {}) |
258 |
|
|
259 |
-- to fill each square of map with given function |
-- to fill each square of map with given function |
260 |
function fill_world_func(fillfunc, x0, y0, w, h) |
function fill_world_func(fillfunc, x0, y0, w, h) |
261 |
for x=(x0 or 0), ((w or level_width)-1) do |
local x0, y0 = (x0 or 0), (y0 or 0) |
262 |
for y=(y0 or 0), ((h or level_height)-1) do |
local w, h = (w or 0), (h or 0) |
263 |
|
if w<=0 then w = level_width+w end |
264 |
|
if h<=0 then h = level_width+h end |
265 |
|
|
266 |
|
for x=x0, x0+w-1 do |
267 |
|
for y=y0, y0+h-1 do |
268 |
fillfunc(x, y) |
fillfunc(x, y) |
269 |
end |
end |
270 |
end |
end |
275 |
local x0, y0 = (x0 or 0), (y0 or 0) |
local x0, y0 = (x0 or 0), (y0 or 0) |
276 |
local w, h = (w or level_width), (h or level_height) |
local w, h = (w or level_width), (h or level_height) |
277 |
|
|
278 |
for x=x0,w-1 do |
for x=x0,x0+w-1 do |
279 |
fillfunc(x, y0) |
fillfunc(x, y0) |
280 |
fillfunc(x, y0+h-1) |
fillfunc(x, y0+h-1) |
281 |
end |
end |
282 |
|
|
283 |
for y=y0,h-1 do |
for y=y0,y0+h-1 do |
284 |
fillfunc(x0, y) |
fillfunc(x0, y) |
285 |
fillfunc(x0+w-1, y) |
fillfunc(x0+w-1, y) |
286 |
end |
end |
287 |
end |
end |
288 |
|
|
289 |
|
-- like set_stones, but calling a function |
290 |
|
-- like: set_funcs(oxyd, {{1,2},{3,4},...}) |
291 |
|
function set_funcs(fillfunc, poslist) |
292 |
|
for i,xy in poslist do |
293 |
|
fillfunc(xy[1], xy[2]) |
294 |
|
end |
295 |
|
end |
296 |
|
|
297 |
|
-- like draw_stones, draw_floor and others, but calls a func |
298 |
|
function draw_func(fillfunc, xy0, xystep, n) |
299 |
|
local x,y = xy0[1], xy0[2] |
300 |
|
for i=1,n do |
301 |
|
fillfunc(x, y) |
302 |
|
x = x+xystep[1] |
303 |
|
y = y+xystep[2] |
304 |
|
end |
305 |
|
end |
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|