Ecopedia Modding: Difference between revisions

From Eco - English Wiki
(Added example of EcopediaAttribute)
(No difference)

Revision as of 21:50, 1 August 2021

NOTE: The modding system is under heavy development. APIs are expected to change, which may break existing mods! Feel free to update any information on this wiki that is out of date.

Adding Custom Items to Ecopedia

Using the same tools used by items and blocks created by Strange Loop Games modded objects can be automatically added to the Ecopedia. Ecopedia automatically generates pages for items and blocks using the EcopediaAttribute class. More information about this class can be found here.

Example Usage

In the following example we add a Flag item to Eco. The Ecopedia attribute adds a new sub category called "Flags" under "House Objects" and places our new item inside it.

    [Serialized]
    [LocDisplayName("Test Flag")]
    [Ecopedia("Housing Objects", "Flags", createAsSubPage: true, display: InPageTooltip.DynamicTooltip)]
    [Weight(10)]
    public partial class FlagItem : WorldObjectItem<FlagObject>
    {
        public override LocString DisplayDescription { get { return Localizer.DoStr("A piece of fabric with something on it. can be used for decorating."); } }

        static FlagItem()
        {
            WorldObject.AddOccupancy<FlagObject>(new List<BlockOccupancy>(){
            new BlockOccupancy(new Vector3i(0, 0, 0)),
            new BlockOccupancy(new Vector3i(0, 1, 0)),
            });
        }
    }