Getting a reference to a specific entity #114
Labels
C-Low Hanging Fruit
Ideal issue for new contributors.
G-Entities
An issue having to do with game entities.
L-Commands
Built-in commands (e.g. move, try, if, ...) in the Swarm language.
S-Moderate
The fix or feature would substantially improve user experience.
Z-Feature
A new feature to be added to the game.
Normally, entities can be looked up and referred to by their name, even though entity names are not actually guaranteed to be unique. This works fine most of the time---if you refer to a
log
, it really doesn't matter which one you get since they are all identical. However, in some scenarios specific entities will need to be differentiated. The motivating use case isbox
es: if you have severalbox
es in your inventory and put some items in one of them, you now want to be able to refer to the specific box containing your items as opposed to the others. I propose two operations to assist with this:rename : string -> string -> cmd ()
takes one entity with the first name (it's undefined which) and renames it to have the second name. For example if you want to pick out a specificbox
to put some items in, you could first executerename "box" "mybox"
. Nowmybox
will show up in your inventory separate from the otherbox
es.unique_name : string -> cmd string
will generate a name based on the given one which is guaranteed to be globally unique. Maybe you are programming some robots to do an automated task and you don't plan to ever look at their inventories, so you would rather just name some boxes automatically and pass around their names in variables.I'm very open to other suggestions re: API.
The text was updated successfully, but these errors were encountered: