User Tools

Site Tools


migration

This is an old revision of the document!


Migration Notes

Foundation 1.8.0.0

Resource bundles

Building part costs have been changed to allow for building in steps, with the builder bringing a bundle of resources for each step.

To allow this, BUILDING_PART_COST.RessourcesNeeded has been replaced with BUILDING_PART_COST.ResourceNeededList, a list of lists of RESOURCE_QUANTITY_PAIR. Each entry in the outer list corresponds to a bundle.

The number of construction steps built for each bundle is proportional to a bundle's quantity of resources. For example, if a part needs two resource bundles, one with 30 planks and the other with 10 planks, 75% of the construction steps will be done with the first bundle, and the rest with the second bundle.

Foundation 1.7.1

Texture loading

Some TEXTURE properties have been changed, depending on their use, to a new type: ATLAS_CELL.

Therefore, we added a way to explicitly choose the type of an asset to load, when calling registerAssetId. Specifying the type is optional, TEXTURE will be inferred for texture assets if absent.

This third parameter is currently only used for image assets.

mod:registerAssetId("test_img1.png", "TEST_IMAGE_1") -- without type specified, loads as a TEXTURE asset
mod:registerAssetId("test_img2.png", "TEST_IMAGE_2", "TEXTURE") -- loads as a TEXTURE asset
mod:registerAssetId("test_img3.png", "TEST_IMAGE_3", "ATLAS_CELL") -- loads as an ATLAS_CELL asset

Technical Info: Atlas Cells are images packed in a large unique texture (commonly called atlas). This is especially useful for the GUI engine, allowing to draw most of the interface without having to switch the active binded texture.

Foundation 1.6.0.0522

BUILDING and MONUMENT asset types

Monuments have been reworked, and the MONUMENT type has been merged into BUILDING. This means there are a few changes to the way buildings and monuments are created.

Buildings

A building's only building part should be specified with the property AssetCoreBuildingPart instead of BuildingPartSetList. For the game to not mistake a building for a monument, the property BuildingPartSetList shoud be left empty.

local myBuilding = 
{
    DataType = "BUILDING",
    ...
}
 
if (foundation.getGameVersion == nil or version.cmp(foundation.getGameVersion(), "1.6") < 0) then
    myBuilding.BuildingPartSetList = {
        {
            Name = "DEFAULT",
            BuildingPartList = { "CORE_BUILDING_PART" }
        }
    }
else
    myBuilding.AssetCoreBuildingPart = "CORE_BUILDING_PART"
end
 
mod:register(myBuilding)

Monuments

Monuments are now created around a single building part, placed before all the others. This part is the one selected just after selecting the monument in the building selection menu. This part has to be specified in the property AssetCoreBuildingPart. All other parts still are in BuildingPartSetList.

The core building part, if removed, will remove the whole monument. Like for the market, the core building part can be used for preview only, and be invisible once built by setting BUILDING_PART.IsVisibleWhenBuilt to false.

local myMonument = {
    ...
}
 
if (foundation.getGameVersion == nil or version.cmp(foundation.getGameVersion(), "1.6") < 0) then
    myMonument.DataType = "BUILDING"
    myMonument.BuildingPartSetList = {
    {
        Name = "DEFAULT",
        BuildingPartList = { "CORE_BUILDING_PART", "ADDITIONAL_PART_1", "ADDITIONAL_PART_2", "ADDITIONAL_PART_3" }
    }
else
    myMonument.DataType = "BUILDING"
    myMonument.AssetCoreBuildingPart = "CORE_BUILDING_PART"
    myMonument.BuildingPartSetList = {
    {
        Name = "DEFAULT",
        BuildingPartList = { "ADDITIONAL_PART_1", "ADDITIONAL_PART_2", "ADDITIONAL_PART_3" }
    }
end
 
mod:register(myMonument)

Bridge mover

The way bridges are placed has been modified, and requires a small mover change. A bridge mover (BUILDING_PART_MOVER_BRIDGE) was previously needed on a bridge's root part, and on the end part.

Now, to have a functional bridge, you need instead to place a bridge mover on the start part and end part, and remove the mover of the core part.

Before:

Now:

Slope constructor

Improvements have been made to the bridge, and you now have to setup bridge end parts (StartPart and EndPart) with a BUILDING_CONSTRUCTOR_SLOPE.

Building zone and basement

To improve the number of basement spawned, scalable building parts (with constructor BUILDING_CONSTRUCTOR_SCALER or BUILDING_CONSTRUCTOR_BASEMENT) now need a non-empty building zone that fits the size of your basement filler. If no building zone is set, basements will not be placed.

The BUILDING_ZONE type has also been reworked to allow zone polygons per building part.

Foundation 1.4.5.1009

Building Part Function

For assets from type BUILDING_PART, the attribute BuildingFunction is now replaced with AssetBuildingFunction. Thus, the building function must now be declared as an asset of type BUILDING_FUNCTION.

Migration example for the Example 02 mod:

building_parts.lua
mod:register({
    DataType = "BUILDING_PART",
    ...
 
--  OLD
--  BuildingFunction = { 
--      DataType = "BUILDING_FUNCTION_WORKPLACE",
--      WorkerCapacity = 4,
--      RelatedJob = { Job = "MITHRIL_MINER", Behavior = "WORK_BEHAVIOR" },
--      ResourceProduced = {
--          { Resource = "MITHRIL_ORE", Quantity = 5 }
--      }
--  },
 
--  NEW
    BuildingFunction = "MITHRIL_MINE_FUNCTION",
 
    ...
})
 
-- ALSO NEW
mod:register({
    DataType = "BUILDING_FUNCTION_WORKPLACE",
    Id = "MITHRIL_MINE_FUNCTION",
    WorkerCapacity = 4,
    RelatedJob = { Job = "MITHRIL_MINER", Behavior = "WORK_BEHAVIOR" },
    ResourceProduced = {
        { Resource = "MITHRIL_ORE", Quantity = 5 }
    }
})

Resource Type List

The enumeration RESOURCE_TYPE has been removed, and has been replaced by plain strings. This change means that modders can now define their own new types to work with their custom systems. The list of resource types has been moved to another page.

Another change is that resource, markets, granaries and warehouses can now have multiple resource types. This, combined with new customizable resource types, will be useful to customize where resources can be stocked and sold. This means that the property ResourceType from RESOURCE has been renamed to ResourceTypeList.

For example, before this change, the wine was a resource of type LUXURY_FOOD. Now, it has the types GRANARY and TAVERN. The granary is configured to only store resources of type GRANARY, and the tavern can only sell resources of type TAVERN. Thus, wine will only be stored in granaries, and sold in taverns. The luxury stall, with its types LUXURY and LUXURY_FOOD, will not be able to sell wine anymore.

The complete list of core resource types can be found: https://www.polymorph.games/foundation/modding/api/resource_type

Migration example:

mod:register({
    DataType = "RESOURCE",
    ...
 
--  OLD
--  ResourceType = "LUXURY_FOOD",
 
--  NEW
    ResourceTypeList = {
      "GRANARY",
      "TAVERN"
    }
 
    ...
})

Foundation 1.3.1.0802

Building Part Sets

In order to categorize the different parts of a building in the construction window, buildings and monuments now have building part sets.

For assets from type ASSET_BUILDING, the attribute BuildingPartList is now replaced with BuildingPartSetList (a list of BUILDING_PART_SET).

Migration example for the Example 02 mod:

monument.lua
mod:register({
    DataType = "MONUMENT",
    ...
 
--  Old
--  BuildingPartList = {
--      "MITHRIL_FACTORY_CORE_ROOT_PART",
--      "MITHRIL_FACTORY_EXTENSION_A_ROOT_PART",
--      "MITHRIL_FACTORY_EXTENSION_B_ROOT_PART",
--      "MITHRIL_FACTORY_DOOR_A_PART",
--      "MITHRIL_FACTORY_DOOR_B_PART",
--      "MITHRIL_FACTORY_DECORATION_A_PART",
--      "MITHRIL_FACTORY_DECORATION_B_PART"
--  },    
 
--  New
    BuildingPartSetList = {
        {
            Name = "PRODUCTION_CORE",
            BuildingPartList = {
                "MITHRIL_FACTORY_CORE_ROOT_PART"
            }
        },
        {
            Name = "PRODUCTION_EXTENSION",
            BuildingPartList = {
                "MITHRIL_FACTORY_EXTENSION_A_ROOT_PART",
                "MITHRIL_FACTORY_EXTENSION_B_ROOT_PART"
            }
        },
        {
            Name = "ENTRANCE",
            BuildingPartList = {
                "MITHRIL_FACTORY_DOOR_A_PART",
                "MITHRIL_FACTORY_DOOR_B_PART"
            }
        },
        {
            Name = "DECORATION",
            BuildingPartList = {
                "MITHRIL_FACTORY_DECORATION_A_PART",
                "MITHRIL_FACTORY_DECORATION_B_PART"
            }
        }
    },
 
    ...
})

Event Choices

The event assets have been reworked to give the possiblity to have multiple actions triggered when a choice is made. The class EVENT now has a new attribute ChoiceList (a list of EVENT_CHOICE), replacing the attribute ActionList.

Migration example for the Example 01 mod, where the action to give a quest has been replaced by a choice that gives two quests:

events.lua
myMod:register({
    DataType = "EVENT",
    ...
 
--  Old
--  ActionList = {
--      {
--          DataType = "EVENT_ACTION_GIVE_QUEST",
--          ShortName = "SUPER_EVENT_ACCEPT_QUEST",
--          Quest = "SUPER_QUEST"
--      },
--      {
--          DataType = "EVENT_ACTION_IGNORE",
--          ShortName = "KINGDOM_DECLINE",
--      }
--  },
 
--  New
    ChoiceList = {
        {
            ShortName = "EVENT_CHOICE_GIVE_TWO_QUESTS",
            EventActionList = {
                { DataType = "EVENT_ACTION_GIVE_QUEST", Quest = "SUPER_QUEST" },
                { DataType = "EVENT_ACTION_GIVE_QUEST", Quest = "GREAT_QUEST" }
            }
        },
        {
            ShortName = "KINGDOM_DECLINE",
            EventActionList = {
                { DataType = "EVENT_ACTION_IGNORE" }
            }
        },
    },
 
    ...
})

Foundation 1.2.2.3105

New mod.json

In order to only load mods when enabled, Foundation will now need a new description file for each mod. It will declare all the things Foundation would need to know about the mod without parsing the lua file.

mod.json
{
	"Name": "Simple Example Mod",
	"Author": "Leo",
	"Description": "A very simple mod example",
	"Version": "2.0.0",
 
	"AdditionalLanguageList": [
		{
			"Name": "Klingon",
			"Code": "tlh"
		}
	]
}

createMod() function is simplified

Since the new mod.json file already contains all basic information about the mod, the foundation.createMod() function does not take any parameter anymore.

mod.lua
local myMod = foundation.createMod()

GENERAL_DATA asset type has been removed

GENERAL_DATA asset type has been removed and all its properties has been moved to BALANCING.

However, modders can now partially override Foundation main balancing (DEFAULT_BALANCING), instead of being forced to replace all balancing properties. see Asset override for more information.

migration.1635344787.txt.gz · Last modified: 2021/10/27 10:26 by maxime

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki