Difference between revisions of "Ecopedia Modding"

From Eco - English Wiki
[checked revision][checked revision]
(Fixed information on custom files)
Tags: Visual edit Reverted
m (Reverted edits by Dennis (talk) to last revision by NomNom)
Tag: Rollback
Line 28: Line 28:
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 '''in a sub-folder''' (required!) under '''Mods/UserCode/Ecopedia'''. These files must follow the same XML file layout as the ones in '''Mods/__core__/Ecopedia.'''
It is possible to add your own custom pages to the Ecopedia by creating XML files under '''Mods/__core__/Ecopedia''', 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.






The example mod is comprised of three parts.
An example mod that is comprised of five parts.
* Rules.xml - The root page file for the Ecopedia chapter.
* Server.xml - The chapter name within the Ecopedia. ''(Folder name should also be the same.)''
* Rules;Server Rules.xml - The Server Rules sub page.
*Server Info.xml - '''Root page''' within within Ecopedia. ''(File name dictates its in game presentation.)''
* ServerInfo.xml - The root Ecopedia chapter that shows up in the left navigation.
* Server Info;Info.xml - Sub page. ''(File name dictates its in game presentation.)''
* Server Info;Mods.xml - Sub page. ''(File name dictates its in game presentation.)''
*Server Info;Rules.xml - Sub page. ''(File name dictates its in game presentation.)''




'''Example Chapter'''
'''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.<syntaxhighlight lang="xml">
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. ''(As of 09/01/2022 a priority of -10 will arrange the chapter at the top of the list)''<syntaxhighlight lang="xml">
<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. ''(A priority/location of -270 will make this the default page when the Ecopedia is opened as of 09/01/2022)''<syntaxhighlight lang="xml">
<ecopedia icon="PaperItem" chapter="ServerInfo">
<ecopedia chapter="Server" priority="0" icon="PaperItem">
   <summary>Summary of Server Rules</summary>
   <summary loc="0">Summary of Server Info</summary>
</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 priority="2" icon="PaperItem">
   <summary>Welcome to our Eco Server!</summary>
   <summary loc="1">Server Rules</summary>
   <section>
   <section>
1. Don't be an jerk.
1. Don't be an jerk.
Line 59: Line 61:
We hope you enjoy your stay!
We hope you enjoy your stay!
   </section>
   </section>
</ecopedia>
</syntaxhighlight>We can expand further upon the server rules example and add additional tabs, the priority field influences it's location when a tab system is created. (The below example will now be placed first in the list.)<syntaxhighlight lang="xml">
<ecopedia priority="1" icon="Prevent_LegalAction">
  <summary loc="1">Server Info</summary>
  <section loc="1">
Server Info:
Here we can talk about the server information, website/Discord Server/Specifics about what the playstyle are etc.
  </section>
</ecopedia>
</syntaxhighlight>We can further expand this with an additional tab that would be placed at the end of the tab list.<syntaxhighlight lang="xml">
<ecopedia priority="3" icon="Ecopedia_ChoosingProfession">
  <summary loc="1">Server Mods</summary>
  <section loc="1">
  Mods applied to the server list can go here!
  </section>
</ecopedia>
</ecopedia>
</syntaxhighlight>
</syntaxhighlight>

Revision as of 01:58, 13 January 2022

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, 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 mod that is comprised of five parts.

  • Server.xml - The chapter name within the Ecopedia. (Folder name should also be the same.)
  • Server Info.xml - Root page within within Ecopedia. (File name dictates its in game presentation.)
  • Server Info;Info.xml - Sub page. (File name dictates its in game presentation.)
  • Server Info;Mods.xml - Sub page. (File name dictates its in game presentation.)
  • Server Info;Rules.xml - Sub page. (File name dictates its in game presentation.)


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. (As of 09/01/2022 a priority of -10 will arrange the chapter at the top of 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. (A priority/location of -270 will make this the default page when the Ecopedia is opened as of 09/01/2022)

<ecopedia chapter="Server" priority="0" icon="PaperItem">
  <summary loc="0">Summary of Server Info</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 priority="2" icon="PaperItem">
  <summary loc="1">Server Rules</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>

We can expand further upon the server rules example and add additional tabs, the priority field influences it's location when a tab system is created. (The below example will now be placed first in the list.)

<ecopedia priority="1" icon="Prevent_LegalAction">
  <summary loc="1">Server Info</summary>
  <section loc="1">
Server Info:
Here we can talk about the server information, website/Discord Server/Specifics about what the playstyle are etc.
  </section>

</ecopedia>

We can further expand this with an additional tab that would be placed at the end of the tab list.

<ecopedia priority="3" icon="Ecopedia_ChoosingProfession">
  <summary loc="1">Server Mods</summary>
  <section loc="1">
   Mods applied to the server list can go here!
  </section>

</ecopedia>