Difference between revisions of "Ecopedia Modding"

From Eco - English Wiki
[checked revision][checked revision]
(Added custom pages example)
(Fixed wrong information)
Line 23: Line 23:
     }
     }
</syntaxhighlight>
</syntaxhighlight>
== Custom Ecopedia Pages ==
== Custom Ecopedia Pages ==
It is possible to add custom Ecopedia pages that are hand written using XML files in your Eco server mod directory. These files support all tags available in Eco such as '''<ecoicon>''' as well as some custom tags only used by the Ecopedia UI.
It is possible to add custom Ecopedia pages that are hand written using XML files in your Eco server mod directory. These files support all tags available in Eco such as '''<ecoicon>''' as well as some custom tags only used by the Ecopedia UI.
=== Modifying Existing Pages ===
=== Modifying Existing Pages ===
Starting with Eco 9.4 custom pages created by Strange Loop Games can be found in your server's mod directory under '''Mods/__core__/Ecopedia.''' Editing the XML files found in this directory will effect the pages found in the Ecopedia in game.
Starting with Eco 9.4 custom pages created by Strange Loop Games can be found in your server's mod directory under '''Mods/__core__/Ecopedia.''' Editing the XML files found in this directory will effect the pages found in the Ecopedia in game.
=== Adding Custom Ecopedia Pages ===
=== Adding Custom Ecopedia Pages ===
It is possible to add your own custom pages to the Ecopedia by creating XML files under '''Mods/UserCode/Ecopedia'''. These files must follow the same XML file layout as those found under '''Mods/__core__/Ecopedia.''' An example custom page can be found [https://github.com/StrangeLoopGames/EcoModKit/tree/master/Examples/EcopediaPage/Server/Ecopedia/Welcome here].
It is possible to add your own custom pages to the Ecopedia by creating XML files under '''Mods/__core__/Ecopedia''', preferably in a sub-folder. These files must follow the same XML file layout as the other ones in the Ecopedia folder'''.''' We plan to introduce support for putting Ecopedia files into Mods/UserCode/Ecopedia at a later date, it is currently not supported. An example custom page can be found [https://github.com/StrangeLoopGames/EcoModKit/tree/master/Examples/EcopediaPage/Server/Ecopedia/Welcome here].




The example mod is comprised of three parts.
The example mod is comprised of three parts.
* Rules.xml - The root page file for the Ecopedia chapter.
* Rules.xml - The root page file for the Ecopedia chapter.
* Rules;Server Rules.xml - The Server Rules sub page.
* Rules;Server Rules.xml - The Server Rules sub page.
Line 46: Line 42:
<ecopediachapter priority="0" />
<ecopediachapter priority="0" />
</syntaxhighlight>'''Example Root Page'''
</syntaxhighlight>'''Example Root Page'''
In the root page XML document we define our '''ecopedia''' tag which contains the Icon we would like to display and the chapter file that owns this page. The chapter field must match the name used in the chapter file minus the extension. Inside the '''ecopedia''' tag we define our summary text used in the Ecopedia page.<syntaxhighlight lang="xml">
In the root page XML document we define our '''ecopedia''' tag which contains the Icon we would like to display and the chapter file that owns this page. The chapter field must match the name used in the chapter file minus the extension. Inside the '''ecopedia''' tag we define our summary text used in the Ecopedia page.<syntaxhighlight lang="xml">
<ecopedia icon="PaperItem" chapter="ServerInfo">
<ecopedia icon="PaperItem" chapter="ServerInfo">
Line 52: Line 47:
</ecopedia>
</ecopedia>
</syntaxhighlight>'''Example Sub Page'''
</syntaxhighlight>'''Example Sub Page'''
In the sub example page we define another page using the '''ecopedia''' tag and icon however we do not define a parent field as this is defined by the file name which follows the rule of "OwningPage;SubPageName.xml". Inside this file we again define our summary text we would like to display as well as our custom content. In this case a section defining our server rules. All tags supported by Eco such as the '''ecoicon''' as well as some custom tags relating to sections are supported on in this file.<syntaxhighlight lang="xml">
In the sub example page we define another page using the '''ecopedia''' tag and icon however we do not define a parent field as this is defined by the file name which follows the rule of "OwningPage;SubPageName.xml". Inside this file we again define our summary text we would like to display as well as our custom content. In this case a section defining our server rules. All tags supported by Eco such as the '''ecoicon''' as well as some custom tags relating to sections are supported on in this file.<syntaxhighlight lang="xml">
<ecopedia icon="PaperItem">
<ecopedia icon="PaperItem">

Revision as of 10:21, 29 December 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[edit | edit source]

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)),
            });
        }
    }

Custom Ecopedia Pages[edit | edit source]

It is possible to add custom Ecopedia pages that are hand written using XML files in your Eco server mod directory. These files support all tags available in Eco such as <ecoicon> as well as some custom tags only used by the Ecopedia UI.

Modifying Existing Pages[edit | edit source]

Starting with Eco 9.4 custom pages created by Strange Loop Games can be found in your server's mod directory under Mods/__core__/Ecopedia. Editing the XML files found in this directory will effect the pages found in the Ecopedia in game.

Adding Custom Ecopedia Pages[edit | edit source]

It is possible to add your own custom pages to the Ecopedia by creating XML files under Mods/__core__/Ecopedia, preferably in a sub-folder. These files must follow the same XML file layout as the other ones in the Ecopedia folder. We plan to introduce support for putting Ecopedia files into Mods/UserCode/Ecopedia at a later date, it is currently not supported. An example custom page can be found here.


The example mod is comprised of three parts.

  • Rules.xml - The root page file for the Ecopedia chapter.
  • Rules;Server Rules.xml - The Server Rules sub page.
  • ServerInfo.xml - The root Ecopedia chapter that shows up in the left navigation.


Example Chapter

A chapter file contains only the ecopediachapter tag used to define the chapter on the left navigation bar. The priority is used to sort where it will be placed in the list.

<ecopediachapter priority="0" />

Example Root Page In the root page XML document we define our ecopedia tag which contains the Icon we would like to display and the chapter file that owns this page. The chapter field must match the name used in the chapter file minus the extension. Inside the ecopedia tag we define our summary text used in the Ecopedia page.

<ecopedia icon="PaperItem" chapter="ServerInfo">
  <summary>Summary of Server Rules</summary>
</ecopedia>

Example Sub Page In the sub example page we define another page using the ecopedia tag and icon however we do not define a parent field as this is defined by the file name which follows the rule of "OwningPage;SubPageName.xml". Inside this file we again define our summary text we would like to display as well as our custom content. In this case a section defining our server rules. All tags supported by Eco such as the ecoicon as well as some custom tags relating to sections are supported on in this file.

<ecopedia icon="PaperItem">
  <summary>Welcome to our Eco Server!</summary>
  <section>
1. Don't be an jerk.
2. Don't game the game, IE: Use waterwheels without a watersource.
3. All Structures must be supported, IE: no floating stockpile platforms.
3.1. Bridges can still float, but must have "support" columns for aesthetic purposes. 

We hope you enjoy your stay!
  </section>
</ecopedia>