Prefabs

From The DarkMod Wiki
Revision as of 20:02, 27 January 2022 by Geep (talk | contribs) (Link to more up to date article at top)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This article is mainly describes DarkRadiant before 2.8.0. For a more recent treatment, see the Prefabs section of The Parts and Whole: Overview and its links to import and export pages, which incorporates the information below as appropriate.

Originally written by all on http://forums.thedarkmod.com/topic/3008

(see also Prefab Comments)

A prefab is basically a map file with a different extension (.pfb). It can be used to pack a collection of brushes/patches and entities into a file so that it can be re-used again. This can be useful for complex setups like doors or entities with a complex Stim/Response setup and might save a bit of work.

To create a prefab, just select your items in DarkRadiant and choose File > Save Selected as Prefab.... It's recommended to save them into the darkmod/prefabs folder which is the default in DarkRadiant.

To import a prefab, go to File > Import Prefab. (Note that you may need to extract provided Dark Mod prefabs first from the zip file darkmod/tdm_prefabs01.pk4 before they are visible to earlier versions of Dark Radiant.)

If you want to save a collection of entities as a group, you just select them all, go to file-save selected as... save them as a .map, ideally called something appropriate like prefab_myobject.map

This means I can set up something like a streetlight mesh, two particle effects for the electric, a sound speaker, and the light entity for it, and then save it as one prefab object, so mappers can just drop it into their map.

To open the prefab you use file--load rather than file--open.

Notice there's also a 'save selection as prefab' and 'load prefab' buttons in the edit menu.

When creating prefabs with multiple components of the same name, eg, a cupboard with two doors, don't name them eg, door1 & door2 as although the prefab may insert and work correctly you may find the renumbering confusing, especially if they have handles bound to them and targets. door2 handle may work correctly and be bound to the correct door but it might be named handle1. Instead, name them eg, doorA & doorB so if they then get renumbering on insertion doorA2 & doorB2 with handleA2 & handleB2 then there is no confusion as to what goes where.

See also Prefab Comments

Grouped Prefabs

With Dark Radiant 2.2.1 it is possible to group multiple entities, so they can be handled as one. As many prefabs are intended to work as one entity, the grouping feature is applied to prefabs upon import from this version on. It is possible to insert prefabs ungrouped by unticking the box labled "Create Group out of Prefab parts" in the bottom left corner of the prefab import screen. It is also possible to ungroup the prefab later on by right-clicking on the group and selecting "Ungroup Selection" or via "Edit -> Ungroup Selection".

Rotating Prefabs

Hit CTRL+R to change rotation modes. They'll collectively use a single axis.