[0.8.9][NK] Archetypes

johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer
edited December 2015 in Modding Tutorials
Required: ModScriptClass

Archetypes

Archetypes are a way of defining groups of objects.
They are useful when setting up crafting recipes.

Example File

Archetypes
{
Cobblestone Clump
{
Cobblestone
Cobblestone Gray Clump
Cobblestone Blue Clump
Cobblestone Green Clump
}
}

Loading

To load a new file with archetypes you will need to call Eternus.CraftingSystem:ParseArchetypesFile with the filepath as 1st parameter. This should be done in your mod's Initialize function.

Example:
function MyMod:Initialize()
Eternus.CraftingSystem:ParseArchetypesFile( "Data/Archetypes/MyMod_Archetypes.txt" )
end

Usage

To check if object matches a specific archetype group you should call Eternus.CraftingSystem:IsMatchFor with 2 parameters:
name - archetype group or name of the object
target - either name of the target object or the target object (this can also be used with non-GameObject that exposes GetName or GetDisplayName function)

Example:
if Eternus.CraftingSystem:IsMatchFor("Cobblestone Clump", "Cobblestone Gray Clump") then
-- "Cobblestone Gray Clump" matches "Cobblestone Clump"
-- or it is in the "Cobblestone Clump" archetype group
end
Example:
 local cobblestoneGrayClump = CreateCobblestoneGrayClumpObject()
if Eternus.CraftingSystem:IsMatchFor("Cobblestone Clump", cobblestoneGrayClump) then
-- cobblestoneGrayClump:GetName() matches "Cobblestone Clump"
-- or it is in the "Cobblestone Clump" archetype group
end

Note (0.8.6)

The archetype system has changed in 0.8.7.

The new system is using txt files stored in /Data/Archetypes/* to define groups of archetypes.

The deprecated system used to work by assigning craftingArchetype to an object in it's txt file.
This system is no longer in use.
My Blog
jc.png
  yt.png  t.png  
Sign In or Register to comment.