mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
Lunatic: add "for s, what in sectorsofbunch(bunchnum, gv.BOTH_CF)" iterator.
git-svn-id: https://svn.eduke32.com/eduke32@4198 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
6c00f0e822
commit
9e4f10f3e1
3 changed files with 51 additions and 14 deletions
|
@ -366,8 +366,9 @@ enum {
|
|||
MAXSPRITESONSCREEN = 4096,
|
||||
|
||||
MAXBUNCHES = 512,
|
||||
CEILING = 0,
|
||||
FLOOR = 1,
|
||||
CEILING = 0, // must be 0
|
||||
FLOOR = 1, // must be 1
|
||||
BOTH_CF = 2,
|
||||
|
||||
CLIPMASK0 = (1<<16)+1, // blocking
|
||||
CLIPMASK1 = (256<<16)+64, // hittable
|
||||
|
@ -1191,16 +1192,41 @@ local function iter_sectorsofbunch(cf, i)
|
|||
if (i >= 0) then return i end
|
||||
end
|
||||
|
||||
local function iter_sectorsofbunch_both(cftab, i)
|
||||
local cf = cftab[1]
|
||||
|
||||
if (i < 0) then
|
||||
i = ffiC.headsectbunch[cf][-i-1];
|
||||
else
|
||||
i = ffiC.nextsectbunch[cf][i];
|
||||
end
|
||||
|
||||
if (i < 0 and cf==0) then
|
||||
cftab[1] = 1
|
||||
i = ffiC.headsectbunch[1][cftab[2]]
|
||||
assert(i >= 0, "TROR bunch lists corrupt")
|
||||
end
|
||||
|
||||
if (i >= 0) then
|
||||
return i, cftab[1]==0 and "ceiling" or "floor"
|
||||
end
|
||||
end
|
||||
|
||||
function sectorsofbunch(bunchnum, cf)
|
||||
if (not (bunchnum >= 0 and bunchnum < ffiC.numyaxbunches)) then
|
||||
error("passed invalid bunchnum to sectorsofbunch iterator", 2)
|
||||
end
|
||||
|
||||
if (cf == ffiC.BOTH_CF) then
|
||||
return iter_sectorsofbunch_both, { 0, bunchnum }, -bunchnum-1
|
||||
else
|
||||
if (not (cf == 0 or cf == 1)) then
|
||||
error("passed invalid 'cf' to sectorsofbunch iterator, must be 0 or 1", 2)
|
||||
end
|
||||
|
||||
return iter_sectorsofbunch, cf, -bunchnum-1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---=== Engine functions, wrapped for Lua convenience ===---
|
||||
|
|
|
@ -295,11 +295,14 @@ The hard engine limits on the number of sectors, walls, and sprites. These
|
|||
constants *must* be used instead of any literal numeric values because they
|
||||
can change depending on how EDuke32 was configured and built.
|
||||
|
||||
`gv.CEILING`, `gv.FLOOR`, `gv.BOTH_CF`::
|
||||
Constants permissible to the <<sectorsofbunch_1,`sectorsofbunch`>> iterator.
|
||||
|
||||
//////////
|
||||
`gv.MAXSTATUS`, `gv.MAXTILES`, `gv.MAXSPRITESONSCREEN`::
|
||||
TODO
|
||||
|
||||
`gv.MAXBUNCHES`, `gv.CEILING`, `gv.FLOOR`::
|
||||
`gv.MAXBUNCHES`::
|
||||
TODO
|
||||
//////////
|
||||
|
||||
|
@ -1239,6 +1242,18 @@ allowed. Inserting sprites is always allowed.
|
|||
Iterates over the indices of all sprites contained in the sector with index
|
||||
`sectnum` with the same meaning for `maydelete` as with `spritesofstat`.
|
||||
|
||||
[[sectorsofbunch_1]] +*for* s *in* sectorsofbunch(bunchnum, cf)+::
|
||||
|
||||
Iterates over the indices of the sectors whose ceiling's or floor's bunch
|
||||
equals `bunchnum`, selected by passing `gv.CEILING` or `gv.FLOOR`
|
||||
(respectively) to `cf`.
|
||||
|
||||
[[sectorsofbunch_2]] +*for* s, what *in* sectorsofbunch(bunchnum, gv.BOTH_CF)+::
|
||||
Iterates over the indices of the sectors whose ceiling's and floor's bunch
|
||||
equals `bunchnum`. On each iteration, `what` is one of the strings `'ceiling'`
|
||||
or `'floor'`, denoting whether it's the ceiling or floor of sector `s` that has
|
||||
the given bunch number.
|
||||
|
||||
Sector containment functions
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -90,16 +90,12 @@ gameevent
|
|||
--actor = {}
|
||||
actor[562].flags = bit.bor(actor[562].flags, 2); -- pal 6 with goggles on front SEENINE
|
||||
end
|
||||
--[[
|
||||
-- TODO: better API for all TROR things?
|
||||
---[[
|
||||
if (vol==1 and lev==8) then
|
||||
print('tweaking bunch 1');
|
||||
-- trueror1.map
|
||||
for i in sectorsofbunch(1, gv.CEILING) do
|
||||
sector[i].ceilingz = sector[i].ceilingz - 3*1024;
|
||||
end
|
||||
for i in sectorsofbunch(1, gv.FLOOR) do
|
||||
sector[i].floorz = sector[i].floorz - 3*1024;
|
||||
for i, what in sectorsofbunch(1, gv.BOTH_CF) do
|
||||
sector[i][what].z = sector[i][what].z - 3*1024;
|
||||
end
|
||||
end
|
||||
--]]
|
||||
|
|
Loading…
Reference in a new issue