View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003802 | The Dark Mod | Coding | public | 28.07.2014 17:52 | 05.08.2014 21:36 |
Reporter | SteveL | Assigned To | SteveL | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | resolved | Resolution | fixed | ||
Product Version | TDM 2.02 | ||||
Target Version | TDM 2.03 | Fixed in Version | TDM 2.03 | ||
Summary | 0003802: Allow scripts to discover entities in the map | ||||
Description | Allow scripts to get hold of a reference to any or all entities in the map. This will allow the creation of scripts that don't need the mapper or scripter to hard-code references to entities, or to do anything special in DR to connect them with a main map script. Forum discussion: http://forums.thedarkmod.com/topic/16437-scripting-feature-proposal-discovering-entities/page__view__findpost__p__350919 | ||||
Additional Information | We might as well support an optional filter to speed up some queries. Chosen filter is key and/or value applied to spawnargs. Syntax: sys.getNextEntity(string key, string value, entity lastMatch); Internally the script event will use the gameLocal.entities array, since all entities know their position in that array so resuming the search from lastMatch will be easy and efficient (unlike the linked lists of spawned and active entities). | ||||
Tags | No tags attached. | ||||
Created new wiki page for 2.03 script event documentation: http://wiki.thedarkmod.com/index.php?title=TDM_Script_Reference/2.03 Addition for this script event: scriptEvent entity getNextEntity(string key, string value, entity lastMatch); Discover entities in the map. Returns $null_entity when no more found. key: Optional string: prefix for spawnarg key match. E.g. "target" will match "target", "target1" etc. value: Optional string: spawnarg value to match. Can be used independently of key. If key is not set, all spawnargs will be checked for the value. lastMatch: Last match: search will start after this entity. Use $null_entity or pass an uninitialized entity variable to start a new search. Spawnclasses responding to this event: idThread |
|
Example usage ============= void listEntities() { entity e; sys.println("**** Listing all entities ****"); while( e = sys.getNextEntity("", "", e) ) { sys.println(": " + e.getName() + " (" + e.getKey("classname") + ")" ); } sys.println("**** Listing all entities with classname atdm:switch_rotate_lever ****"); while( e = sys.getNextEntity("classname", "atdm:switch_rotate_lever", e) ) { sys.println(": " + e.getName() + " (" + e.getKey("classname") + ")" ); } sys.println("**** Listing all entities with targets ****"); while( e = sys.getNextEntity("target", "", e) ) { sys.println(": " + e.getName() + " (" + e.getKey("classname") + ")" ); } sys.println("**** Listing all entities with a spawnarg with value '1' ****"); while( e = sys.getNextEntity("", "1", e) ) { sys.println(": " + e.getName() + " (" + e.getKey("classname") + ")" ); } } |
|
Committed at rev 6079 / 6080 |
|
Date Modified | Username | Field | Change |
---|---|---|---|
28.07.2014 17:52 | SteveL | New Issue | |
28.07.2014 17:52 | SteveL | Status | new => assigned |
28.07.2014 17:52 | SteveL | Assigned To | => SteveL |
05.08.2014 20:07 | SteveL | Note Added: 0006823 | |
05.08.2014 20:09 | SteveL | Note Added: 0006824 | |
05.08.2014 20:11 | SteveL | Note Edited: 0006823 | |
05.08.2014 20:17 | SteveL | Note Added: 0006825 | |
05.08.2014 20:19 | SteveL | Status | assigned => resolved |
05.08.2014 20:19 | SteveL | Fixed in Version | => TDM 2.03 |
05.08.2014 20:19 | SteveL | Resolution | open => fixed |
05.08.2014 21:36 | SteveL | Status | resolved => assigned |
05.08.2014 21:36 | SteveL | Note Edited: 0006825 | |
05.08.2014 21:36 | SteveL | Status | assigned => resolved |