Find all lines with a given tag and function?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Find all lines with a given tag and function?

Post by Matt »

I know BlockLinesIterator exists but is there a way to include cross-over lines as well?

EDIT: I've discovered LineIdIterator but now I've got another problem: how do you get the appropriate sector tag?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Find all lines with a given tag and function?

Post by Matt »

Okay, I've been staring at the sector struct definition in mapdata.txt for several hours now and I'm completely at the end of my rope.

How the fuck do you get a sector's tag!?

(EDIT: So far I'm working around this by calling SectorTagIterator under a for loop until one of the items gets me the selected sector. This seems...... suboptimal for something I should be able to get by accessing the pointer.)
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Find all lines with a given tag and function?

Post by _mental_ »

Tags are stored separately from sectors and lines. That's why you cannot find them there. That's why designated iterator classes exist.
Could you please explain what you want to achieve?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Find all lines with a given tag and function?

Post by Graf Zahl »

Remember that a sector can have multiple tags. The use case where you have a sector and need to find its tag is never being needed by the engine. The regular use case is to have a tag and then get a list of sectors - and that's precisely what the iterators do.

Also, Line IDs have nothing to do with sector tags or activation. You should never look up a line ID and then all sectors with a matching tag. You cannot possibly do anything with such a setup. If you have an activatable line you have to know precisely what it does and which arg represents the tag. Needless to say, since this list can change in the future it's something better left alone and leave trigger semantics to the engine code.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Find all lines with a given tag and function?

Post by Matt »

_mental_ wrote:Tags are stored separately from sectors and lines. That's why you cannot find them there. That's why designated iterator classes exist.
Could you please explain what you want to achieve?
I'm trying to get a general way of testing whether a sector represents a door.

Which, from my understanding, requires that I be able to see if any line on the map does any of the following:

- opens or closes this sector when used
- opens or closes this sector when shot
- opens or closes this sector when crossed

independently of whether that line is actually part of that sector (since you might have a switch or a walk trigger like the secrets in map01). My understanding is that BlockLinesIterator won't catch the third case (since cross-activation by definition implies it is not a blocking line). In any event, I need to see if these door-special lines are tagged for the sector in question.
Post Reply

Return to “Scripting”