Jump to content
System downtime for updates - Sunday 13 July 2025 ×
The Dark Mod Forums

Recommended Posts

Posted (edited)

Hello, something I've always been curious about:

Is there a way to get name or class of items within a certain location or volume and store this list somewhere?  Can anyone think of a map or something in the core mod that does this that I could look at. Scripts examples are preferred, rather than source code.

Related to this:

Can I look for entities by name or class within a map? For instance if I want to search for all entity names beginning with string "Guard" and return a list of names "$Guard_01, $Guard_02, ect.."

 

Would be really helpful to know,

Thanks!

 

Edited by kingsal
Posted
13 minutes ago, kingsal said:

get name or class of all items within a certain location  or volume

You can probably use a brush with trigger_touch to achieve that effect. When activated it calls its script on all touching_ents (entities touching its volume), so you could let that script print the names of all those entities to the console and then make a condump. (this is assuming you want a list outside of the game).

Create a trigger_touch brush entity, name it "trigger_touch_brush", give it the spawnarg "call" "retrieve_names", add the below script to your map script, run the map and then use the console command "condump name_list.txt" to get a .txt into your darkmod folder.

void retrieve_names(entity touching_ent)									//gets called for each entity within the trigger_touch
{
	string touching_ent_name	=	touching_ent.getKey("name");
	string touching_ent_classname	=	touching_ent.getKey("classname");

	sys.println("classname is: " + touching_ent_classname + ", name is: " + touching_ent_name);
}


void main()
{
	sys.waitFrame();
	sys.trigger($trigger_touch_brush);	//activate trigger touch
	sys.waitFrame();
	sys.trigger($trigger_touch_brush);	//deactivate trigger touch after one frame because it's very expensive
}

Come to think of it, it'd actually be helpful for both your questions to know if you need this list as a .txt. for your reference or if you want to use these names ingame for scripting.

 

Posted (edited)

Ah okay great! I didn't realize  trigger touches call down to entities. This is exactly what I am looking for! I'll be using the list in game, probably stored in blank strings variables to use later.

Ill give this a try and report back, thanks!

Edited by kingsal
  • 1 month later...
Posted

(Late reply, I know.) The painful bit if you want anything useable in-game is storing/using your list, because of DoomScript's lack of arrays/lists/etc. But it can be done:

On the other question, check the Script Reference docs for getNextEntity().

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Posted
5 hours ago, VanishedOne said:

The painful bit if you want anything useable in-game is storing/using your list, because of DoomScript's lack of arrays/lists/etc.

Haven't looked at the linked script, but arrays can be faked using in game entities to store them, for example by storing them as spawnargs on worldspawn (can be referred via $world) or if you want a behaviour like typical array-styled containers by writing a scriptobject that mimics the behaviour.

 

Trigger_touches as proposed by Dragofer are an option, but iirc they only react to entities that can get into the volume on their own (player, ai and probably moveables). Also, having several of them can become performance houngry. In addition I guess youdon't want to check what's inside the boundaries continuosly but only in specific situations?!

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Posted
6 hours ago, Obsttorte said:

Trigger_touches as proposed by Dragofer are an option, but iirc they only react to entities that can get into the volume on their own (player, ai and probably moveables). Also, having several of them can become performance houngry. In addition I guess youdon't want to check what's inside the boundaries continuosly but only in specific situations?!

It's the regular trigger brushes that only react to either AIs or the player walking into them, trigger_touch works differently by checking for all entities that are in contact with it (within or "touching"). I always only activate it for a single frame before deactivating it.

I suppose a clean & flexible way to check for entitities in a volume would be to use getNextEntity and check whether its origin lies within a certain volume(s) demarcated by 2 points. If it needs to be more precise, you could maybe use getMins and getMaxs to find the dimensions of the entity's bounding box to check whether it overlaps with the volume, or else use a trigger_touch brush to do this for you.

Btw, I found findActorsInBounds(vector mins, vector maxs); in the TDM script reference, that could come in handy at some point depending on what kingsal is doing.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • JackFarmer

      "The Year of the Rat." 
      😄

      Al Stewart must be proud of you!
      Happy testing!
      @MirceaKitsune
      · 1 reply
    • datiswous

      I posted about it before, but I think the default tdm logo video looks outdated. For a (i.m.o.) better looking version, you can download the pk4 attached to this post and plonk it in your tdm root folder. Every mission that starts with the tdm logo then starts with the better looking one. Try for example mission COS1 Pearls and Swine.
      tdm_logo_video.pk4
      · 2 replies
    • JackFarmer

      Kill the bots! (see the "Who is online" bar)
      · 3 replies
    • STiFU

      I finished DOOM - The Dark Ages the other day. It is a decent shooter, but not as great as its predecessors, especially because of the soundtrack.
      · 5 replies
    • JackFarmer

      What do you know about a 40 degree day?
      @demagogue
      · 4 replies
×
×
  • Create New...