go.get_name()
- Dominant language
- C++
- Stars
- 6.3k
- Forks
- 455
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 130
Description
Case:
There are levels made through `collectionfactory.create()` method.
The game object inside this collection has an Id property. This Id can be used for addressing this object. Also this Id is unique within the collection. It'd be fine to have a chance to use this attribute (uniques) in code. For now `go.get_id()` and` msg.url().path` return a full path or hash of a name like a "/_collection0_/go_name". And there are no methods to get a "go_name" only. Also each new generation of level through `collectionfactory.create()` gives us a new path like "/collection1/go_name". then "/collection2/go_name" etc.
For example:
Collections have objects that we want to destroy or other change their state.
We can manage their state info inside a table (cache). And in the next loading of this level we want to change the state of objects using info from the cache table. For that we need an unique key for the object. Name of the object is a great candidate but we haven't access to it... see above.
Quick gameplay example: hero destroys a barrel on level, next time that a hero accesses this level a barrel should be shown as destroyed.
Another example:
we generate collection: `ids = collectionfactory.create(...)`
we destroy the object (`go.delete()`) in the lifetime of collection.
Then we destroy the generated collection: `go.delete(ids, true)` - this generates a warning message in the console, because we didn't remove the object from ids table.
To do that we need to make resource intensive `for_in_pair(ids)` cycle and compare the _go_ path with variables inside the _ids_ table . That is not the same as `ids[go.get_id()] = nil`.
So, something like a new method like `go.get_name()` or new property for `go.get_id()` would be a nice feature.
Contributor guide
Research direction
Start by reviewing the existing go.get_id(), msg.url().path, collectionfactory.create(), and go.delete() behavior described in the issue. Define the intended unique-name accessor or property across generated collections, then verify that object lookup and collection deletion no longer require path comparisons or leave the reported warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, lua
- Domain
- api, game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100