Templates

From Legends of Aria Admin and Modding Wiki
Revision as of 02:24, 5 November 2016 by Yorlik (talk | contribs) (Properties you can define in templates)
Jump to: navigation, search

Basics

  • Templates are files which describe properties of objects to be created in the world.
  • A template is the building plan, the blueprint for an object
  • You can create as many instances of these objects as your server allows:
    1000 rabbits, if you wish from a single rabbit template, or cultists or whatever.
  • Templates are described in files, one template per file only, so there are many.
  • These file live in a special directory called "templates" inside your mods directory.
  • The basic file format is XML, so you have the rules for XML tags and attributes.
  • Do not use special characters in the names for your templates, it can cause weird bugs
    Forbidden characters in template names: "&"

Template Properties

Templates describe GameObjects to be created, so a fundamental understanding of GameObjects is necessary: GameObj

Templates and Default Properties

Example of a very simple template:

<ObjectTemplate>
	<ClientId>461</ClientId>
	<Name>[FF9500]Green Book[-]</Name>
	<SharedStateEntry name="Weight" type="int" value="1"/>
	<Hue>0xFFFFFFFF</Hue>
</ObjectTemplate>

All templates MUST have the opening and closing tags:

<ObjectTemplate>
</ObjectTemplate>

The ClientId tag also is mandatory:

<ObjectTemplate>
    <ClientId>2</ClientId>
</ObjectTemplate>

I saved that as MostDumbTemplateEver.xml in my templates folder.
The example above probably is the most primitive template possible.
The ClientId tells that the invisible NoDraw object is to be displayed.
Apart from that it has no properties, scripts or anything declared.

A reference of possible ClientIds can be found in the file:

\\build\base\ClientIdReference.txt

After creation in the world this object already has some default properties:

Basic:

  • Name: "" (Empty String)
  • Hue:"FFFFFF" (white)
  • Position: Loc(166.34,0.00,-135.43) - that's where I placed it
  • Rotation: Loc(0,0,0)
  • Scale: Loc(1,1,1)
  • template: "MostDumbTemplateEver" (That's how I named the template when I saved it)

Shared Object Properties

  • DefaultInteraction: "Use" (When we click it)
  • NoInteract: false (Default Interaction is on)
  • TooltipString: "" (Empty String)
  • Weight: -1 (Cannot be picked up normally)

Just for the fun of it and for better understanding I created another template:

<ObjectTemplate>
    <ClientId>1</ClientId>
</ObjectTemplate>

I saved it as MostDumbMaleEver.xml in my templates folder.
Inspecting it gave me the following properties, which are different from the NoDraw above, so we learn one thing:
The basic properties of a created object depend on the ClientId it is created from and are hardcoded in the engine.

Basic:

  • Name: "" (Empty String)
  • Hue:"FFFFFF" (white)
  • Position: Loc(166.12,0.00,-135.32) - that's where I placed it
  • Rotation: Loc(0,0,0)
  • Scale: Loc(1,1,1)
  • template: "MostDumbMaleEver" (That's how I named the template when I saved it)

Shared Object Properties

  • AudioIdentifierOverride: "" (Empty String)
  • BodyOffset: 0.8
  • CanEquipArmor: true
  • CanEquipWeapon: true
  • Capacity: 2000
  • CombatMode: false
  • CombatStance: Passive
  • DefaultInteraction: Interact (When we click it)
  • DisplayName: "" (Empty String)
  • Faction: None
  • FriendlyFactions: "" (Empty String)
  • IsDead: false
  • IsFlying: false
  • IsJumping: false
  • NoInteract: false (Default Interaction is on)
  • Pose: Standing
  • Title: "" (Empty String)
  • TooltipString: "" (Empty String)
  • Weight: -1 (Cannot be picked up normally)

A reference of which Shared Properties are available for which ClientId can be found in the non-moddable file (never ever edit it !!!)

\\build\base\ObjectTagDefinitions.xml

Properties you can define in templates

Data types are referenced by (type), e.g. (string), (number), (bool) or (XML tags)
They are NOT part of the final XML template.
Variable data you have to provide is written in italics
The pipe charcter "|" inside the curly brackets separates allowed values.

Property xml tag attributes content Parent Tag Reapeatable
within Parent Tag
Root Tag <ObjectTemplate> xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd =
"http://www.w3.org/2001/XMLSchema"
The entire template XML tree none -
Client Id <ClientId> none (number) 209 <ObjectTemplate> no
Name <Name> none (string) Orville the Mayor <ObjectTemplate> no
Hue <Hue> none (string) 0xFFFFFFFF or like FFFFFF <ObjectTemplate> no
Shared Object Property: see also
\\build\base\ObjectTagDefinitions.xml
<SharedStateEntry> name="Weight" type="int|bool|string" value="-1" none <ObjectTemplate> yes
Mobile Component <MobileComponent> none (XML tags)Mobile Component child tags <ObjectTemplate> no
Base Run Speed <BaseRunSpeed> none (number) 0.5 <MobileComponent> no
Mobile Type <MobileType> none (string)Friendly|Animal|Monster|Player <MobileComponent> no
Object Variable Component <ObjectVariableComponent> none (XML tags)Object Variable tags <ObjectTemplate> no
String Variable <StringVariable> Name="MyText" (string) Always look at the bright side of life <ObjectVariableComponent> yes
Number Variable <DoubleVariable> Name="MyValue" (number) 3.1415926535 <ObjectVariableComponent> yes
Boolean Variable <BoolVariable> Name="MyTruth" (Bool) true|false <ObjectVariableComponent> yes
Vector Variable <LocVariable> Name="MyLocation" (string) 1.5,0,23 <ObjectVariableComponent> yes
Script Engine Component <ScriptEngineComponent> none (XML tags) Lua script tags <ObjectTemplate> no
Attached Lua Script <LuaModule> Name="cel_mayor" (LuaTable) Optional Initializer Tag <ScriptEngineComponent> yes
Initializer Data <Initializer> none (LuaTable)
{ InitStr = "Shrubbery",
  InitVal = 42
}
<LuaModule> no