Instance: Difference between revisions
(This is not a stub) |
Kestrelguy (talk | contribs) m (updated language bar. also some formatting.) |
||
Line 1: | Line 1: | ||
{{ | {{lang|Instance}} | ||
An '''instance''' is a [[VMF|map file]] (<code>.vmf</code>) referenced inside another map through a {{ent|func_instance}}, possibly aided by a {{ent|func_instance_parms}} and/or {{ent|func_instance_io_proxy}}. | |||
| | {{note|In order for instances to be compiled into maps, a <code>GameData</code> key must be present in {{ent|gameinfo.txt}} pointing to the game's [[FGD]] file. Only {{l4d2|4}} and later, along with {{tf2|4}}, include this by default. Instances can be enabled in other games by adding this, or using a pre-compiler as described below.}} | ||
{{note|In pre-{{l4d2|2}} branches, instances have some broken or missing functionality: instance I/O system is unsupported, instances cannot be nested, displacements within an instance may not compile properly and any {{ent|env_cubemap}}s inside of an instance will not be compiled into the final map.}} | |||
{{note|In pre-{{l4d2}} | |||
Instances are helpful in many ways: | Instances are helpful in many ways: | ||
Line 14: | Line 10: | ||
* They provide a more dynamic alternative to [[prefabs]], as any changes to the instanced map will be reflected in all instances of it. | * They provide a more dynamic alternative to [[prefabs]], as any changes to the instanced map will be reflected in all instances of it. | ||
* They provide an alternative to [[visgroups]], as they can be used to divide a large, unwieldy map into several smaller, manageable ones (that can even be worked on by multiple authors simultaneously). | * They provide an alternative to [[visgroups]], as they can be used to divide a large, unwieldy map into several smaller, manageable ones (that can even be worked on by multiple authors simultaneously). | ||
* They provide a simple way to edit portions of a map that needs to be at a non-orthogonal angle. (Build the map on-grid inside a separate map, and then instance it into another map through a | * They provide a simple way to edit portions of a map that needs to be at a non-orthogonal angle. (Build the map on-grid inside a separate map, and then instance it into another map through a <code>func_instance</code> rotated at the correct angle. | ||
* They provide a way for maps to work on multiple platforms, such as | * They provide a way for maps to work on multiple platforms, such as {{l4d|2}} and {{l4d2|2}} versions of the same map. | ||
== Instance I/O == | == Instance I/O == | ||
In {{l4d2}} | In {{l4d2}|2}} and later, instances can send and receive inputs and outputs. To use this functionality, a {{ent|func_instance_io_proxy}} entity named <code>proxy</code> must be present and properly configured in the instance. To send an input to an entity within the instance, the following output would be used: | ||
::{| class=standard-table | ::{| class=standard-table | ||
! || My Output || Target Entity || Target Input || Parameter || Delay || Only Once | ! || My Output || Target Entity || Target Input || Parameter || Delay || Only Once | ||
Line 35: | Line 31: | ||
{{note|Hammer should auto-complete these inputs and outputs. They may also appear as invalid, but will work fine in-game.}} | {{note|Hammer should auto-complete these inputs and outputs. They may also appear as invalid, but will work fine in-game.}} | ||
=== In | === In Older Branches === | ||
Pre-L4D2 engine branches do not support the instance I/O system, so workarounds are needed to send and receive inputs and outputs in instances. For inputs, the fixed up entity name can be referenced directly. | Pre-L4D2 engine branches do not support the instance I/O system, so workarounds are needed to send and receive inputs and outputs in instances. For inputs, the fixed up entity name can be referenced directly. | ||
Line 67: | Line 63: | ||
== Also see == | == Also see == | ||
* [[L4D2 Level Design/VMF Instances]] - A Valve tutorial on how to use instances in | * [[L4D2 Level Design/VMF Instances]] - A Valve tutorial on how to use instances in {{l4d2|2}}. | ||
* [[Working with instances]] - A tutorial on how to use instances in | * [[Working with instances]] - A tutorial on how to use instances in {{Portal2|2}}. | ||
== External | == External Links == | ||
* [http://www.youtube.com/watch?v=YvSZ2NEX1Y0 Source SDK Tutorial - Manifest Tool (YouTube)] | * [http://www.youtube.com/watch?v=YvSZ2NEX1Y0 Source SDK Tutorial - Manifest Tool (YouTube)] | ||
* [http://tf2maps.net/threads/mapping-collaboration-or-using-manifest-and-version-control.24787/ Manifests and Version Control Tutorial (TF2Maps.net)] | * [http://tf2maps.net/threads/mapping-collaboration-or-using-manifest-and-version-control.24787/ Manifests and Version Control Tutorial (TF2Maps.net)] |
Revision as of 20:28, 26 April 2022
An instance is a map file (.vmf
) referenced inside another map through a func_instance, possibly aided by a func_instance_parms and/or func_instance_io_proxy.

GameData
key must be present in gameinfo.txt pointing to the game's FGD file. Only 



Instances are helpful in many ways:
- They provide a more dynamic alternative to prefabs, as any changes to the instanced map will be reflected in all instances of it.
- They provide an alternative to visgroups, as they can be used to divide a large, unwieldy map into several smaller, manageable ones (that can even be worked on by multiple authors simultaneously).
- They provide a simple way to edit portions of a map that needs to be at a non-orthogonal angle. (Build the map on-grid inside a separate map, and then instance it into another map through a
func_instance
rotated at the correct angle. - They provide a way for maps to work on multiple platforms, such as
Left 4 Dead and
Left 4 Dead 2 versions of the same map.
Instance I/O
In {{l4d2}|2}} and later, instances can send and receive inputs and outputs. To use this functionality, a func_instance_io_proxy entity named proxy
must be present and properly configured in the instance. To send an input to an entity within the instance, the following output would be used:
To receive an output from an entity in the instance, this output would be used on the func_instance:

In Older Branches
Pre-L4D2 engine branches do not support the instance I/O system, so workarounds are needed to send and receive inputs and outputs in instances. For inputs, the fixed up entity name can be referenced directly.

Manifests
Instances can be taken a step further with manifests. A manifest splits all of the contents of a map into special instances known as "sub-maps". Unlike regular instances, Hammer can seamlessly switch between sub-maps without having to open the VMFs separately. Sub-maps are treated as extensions of the map itself and cannot use name fixup or have any offset, although sub-maps are capable of being used in multiple manifests simultaneously.
Manifests can be helpful in many ways:
- They allow multiple people to work on a map at the same time.
- They help protect a map against corruption, as problems with a VMF are limited to a single sub-map.
- They can be used to assign user-friendly names to different areas of a map.
- They can make a map's source files easier to track in version control software like Git.
A manifest can be created in the "Instancing" menu.




Precompiler
Metapyziks wrote a program that merges instances into the main VMF before each compile. This was originally created to enable instance support in older engine branches, but the GameData
method has since rendered it mostly obsolete. However, it would theoretically be possible for someone to fork the program to add additional functionality, such as instance I/O support or the ability to toggle VisGroups with a fixup variable.
Also see
- L4D2 Level Design/VMF Instances - A Valve tutorial on how to use instances in
Left 4 Dead 2.
- Working with instances - A tutorial on how to use instances in
Portal 2.