T4 Modules Howto Guide/Resolvers

From Tales of Maj'Eyal
Jump to: navigation, search

Resolvers

Entities work with resolvers. Basically, every time you need a given entity to be different from other entities created from the same table. For instance, this allows every orc to have a slightly different equipment - by using an equip resolver.

Resolvers can have a _resolve_last flag set, this means they only get resolved on the last pass in entity creation (after all egos are applied).

Entities can also have an instant_resolve flag, which is especially useful for appending to names and/or egos.

As explained by DarkGod:

Resolvers basically are there to let you postpone some stuff in entities. You *could* write a field like that in an entity:

foo = rng.range(1,10)

But the call to rng.range would happen when the entity files is loaded and thus set the value in stone for all entities cloned from it. If instead you used

foo = resolvers.rngrange(1, 10)

Then it would take its value only when the entity has been cloned, making sure every clone has its own random value.