Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] a way to "pull" entities on the map into template instances #11

Open
mfaizsyahmi opened this issue Jan 30, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@mfaizsyahmi
Copy link

mfaizsyahmi commented Jan 30, 2024

Let's say I pass a keyvalue to a macro_insert whose value is the name of an entity. Then inside the template a custom mess point entity, or a _mess custom keyvalue, takes that value resulting in an entity already present in the map, with that name, being "pulled" into the instance and replaces the point entity.

A use case of this are templates having ambient_generics or env_sprites. Rather than exposing every keyvalue and flag for those entities to a .ted entity or a macro_insert's keyvalues for maximum customizability, you just give those a name of an external entity to be used in its stead. A sort of BYOB but for entities, if you will.

@pwitvoet
Copy link
Owner

Interesting idea, I think this could be very useful.

It is possible to pass MScript values of any type into a template (strings, numbers, arrays, objects, functions, etc.), and with a macro_brush you can 'bring your own brushwork' to some degree. It's also possible to create an entity from an MScript object with the help of array property keys and the obj_fields and obj_value functions. But it's currently not possible to fetch an entity from somewhere else in the map.

I have been thinking about an MScript API that would give you access to the content of a map. With that, you could write something like {map.get_entities({targetname: 'my_sprite'})[0]} to grab an entity and pass it into a template, and then use the above mechanism to create a copy of that entity.

Something similar could be done for templates as well. It would be interesting to have 'higher-order templates', for example an elevator template that lets the user pass in a custom button template.

@mfaizsyahmi
Copy link
Author

mfaizsyahmi commented Jan 31, 2024

Some ideas on implementation:

  • using a _mess_copy_entity_properties_of property, copy all the properties of such named entity. The original entity is preserved. Additionally any extra keyvalues set in the template entity overrides the ones it copies e.g. targetname={instance_consistent_name}.
  • using macro_copyentity or macro_replaceentity, copy or replace entity in its place. the entities would have the same configuration for brush entities placement as macro_insert. Again, extra keyvalues set in the template entity overrides the ones it copies.

Come to think of it, the last point sounds really similar to the macro_insert/macro_template system. Maybe I should just use that instead. :P

@pwitvoet pwitvoet added the enhancement New feature or request label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants