Crea
Not enough ratings
Basics of Modding
By Baxter900
The definitive introduction to modding in Crea! Come here if you want to mod crea but don't know where to start.
   
Award
Favorite
Favorited
Unfavorite
Introduction
Welcome, this guide will walk you through everything you need to know about how mods are created for Crea.

Note that this guide makes the assumption that you know how to code in python. If you don't a good resource for learning python can be found here: http://www.codecademy.com/tracks/python
Finding your Crea files
  • First open steam and go to your library.
  • Then right click on Crea in the sidebar to the left of the screen.
  • Click "Properties".
  • Click the "Local Files" tab.
  • Click "Browse Local Files".

This should open up a folder with a bunch of files in it. For your purposes, there are two that you care about. 'crea.log' has the most recent log in it, this is what you'll be using to debug your mod if there's an error. Secondly, there's the 'mods' folder. This has all of the gameplay files in it, you'll spend most of your time here.

You'll probably want to create a shortcut to this folder, since it's hard to find without going through the above steps.

Now is a good time to mention that most of the gameplay for the core files is in the mods folder under mod/core. As such, if you ever need an example, you can look in there for actual code and objects in the game!
Get a good coding text editor
The first thing your going to want to do before starting to mod is get a good text editor, otherwise your coding experience will be miserable. If you already have one, skip this section. There are two options which are common in the modding community, Sublime Text, and Atom.

These two editors are almost identical, just with small differences.

Sublime Text
Sublime Text is technically a paid program, however, it has an infinite free demo.

Pros:
  • Much smaller memory footprint than Atom
  • Slightly more mature program
Cons:
  • Less addons and addons are harder to install
  • Asks you to buy it every 10 saves

Atom
An open source equivalent to Sublime Text which was launched by the Github community with a focus on addons.

Pros:
  • A ton of customizability and addons to change it how you want it
  • Open source, so it develops extremely quickly
  • No pestering to buy it (it's freeeeee!)
  • More control allows advanced users to customize the program easily.
Cons:
  • Bigger memory footprint (weaker computers can't handle it running alongside Crea and a web browser).
  • Addons sometimes break when updated (rarely though).
  • More control means that new users might have a harder time on some parts of it.

If you want Sublime Text, go to https://www.sublimetext.com/2 and download the newest version.

If you want Atom, go to htttps://www.Atom.io and download it there.

Crea Sublime Text Setup
After installing it, go to your crea folder, then \mods\core\body\ in your file browser and try to open player.ce. When your computer asks what to open it with, select Sublime Text.

Next in Sublime Text, click View-->Syntax-->Open all with current extension as..-->Python-->Python on the toolbar at the top. This will make it so Sublime Text handles .ce files correctly.

Lastly click Project-->Add folder to project... then find and select the 'mods' folder. This will allow you to open files from within Sublime Text and do some useful things like the ability to search for any mention of a phrase anywhere in a .ce or .py file in the mods folder

If you want Atom, go to https://www.sublimetext.com/2 and click the big download button.
Recommended Atom Packages
Pretty much the whole point of using Atom is that there are millions of addons to improve your experience. Here's a recommended list for Crea Modding. To install these, open Atom, then open the Preferences tab. Then click install. Then type these into the search bar.
  • auto-update-packages | This package will keep the rest of your packages updated without you having to click "update all".
  • file-icons | Adds little icons to the file selection on the left to make things easier.
  • file-types | We'll use this to teach Atom how to recognize .ce packages.
  • highlight-line | Makes our current line easier to find.
  • minimap | Adds one of the best Sublime Text features, you want this.
  • minimap-find-and-replace, minimap-highlight-selected, minimap-selection | Extend the functionality of minimap.
    Bonus:
  • linter | A base linter, working linter extensions are listed here: https://atomlinter.github.io/
  • script | Can be configured to run python within Atom
  • color-picker | Adds a color picker within atom
  • merge-conflicts | Lets you resolve git merge conflicts easier.

To configure the file-types package, click 'open your config', then in the file that opens, add this to the end:
"file-types": ce: "source.python"
Make sure that the first line is indented with one tab, and the second with two tabs.
Creating your mod
First of all, open up the folder that says "mods", this is your mods folder. Here you should find the core file.

Create a new folder, this will be the folder for your mod and should be named something that makes sense. The name of this folder should follow the convention of all lowercase, letters only, and underscores_instead_of_spaces.

Inside that folder you should create files called ' __init__.py', 'registration.py', and 'info. I recommend copying 'info' and 'registration.py' from the core.
The 'info' file
Now open up the 'info' file. Inside you'll find a couple of things.
  • version: This is the version number of your mod as a float. It's used by steam workshop to figure out if people have the newest mod version, always increment this on making changes. The number can be anything greater than 0. Usually 1.0 is your first release, then any subsequent small changes will increase the second digit (so 1.1, 1.2, etc.), and any feature additions will increment the primary digit (1.0, 2.0, etc.).

  • title: This is simply a string containing the title of your mod. It's how it will be displayed on steam workshop and with the integrated mod manager.

  • author: This is who wrote the mod, it should usually be your steam name.

  • description: Put a nice pretty description in this string. This will be the description for your mod in the steam workshop. Make sure to keep this all in one line or it will crash, if you want to add new lines to your description, type "\n" instead of pressing enter.

  • priority: Priority can be important. The engine loads all mods starting with the lowest priority first. Mods with the same priority are loaded in alphabetical order. Most of the time, you should leave your priority on 1. A priority of -1 is special in that it disables the mod from being loaded. Other negative values are converted to positive values, which means a priority of -2 will result in a priority of 4294967294 and so on.
  • tags: These are the tags your mod is uploaded with, you usually don't want to touch these manually, rather you should use the editor for the mod uploader. (This won't appear unless the mod has been uploaded before).
  • workshopid: This is the identity of a mod which has already been uploaded. Don't touch this!!!

Change these values to be something that better reflects your mod.
About 'registration.py'
So the first thing you need to do with registration.py is take a look at it and note which functions have something to do with what you want to do. The second thing to do is delete almost everything. If you need none of the original functions (which will often be the case for basic mods) it should look like this:
def register(): pass

If you ever need to use a register() function elsewhere in your code (like biomes.__init__.py which is used to add biomes into the game), put the corresponding lines of code back into the registration.py.

The register() function in registration.py is the only auto-run piece of code you have access to, so if you need something to run automatically at the very start of the game, you can put it here.

Even if you aren't using, registration.py for anything, the file needs to be there.

Registration.py will be discussed more in the "Behavior of .py files" section.
Behavior of .ce files
.ce files are a special file type that only exists in Crea. The files contain a class being called with parameters. These are used to create most things in the game, be it objects, or particles.

.ce files are loaded automatically upon starting the game, but should not contain code which actually does stuff, because they are called unpredictably at other times during the game.

The exception to this rule, is customizing functions:

A customization is declared like this: @object_name.originalFunction where object_name is the variable you're storing your object in (generally declared as object_name = Template(parameters) or something like that) and originalFunction is the function you imported which you want to customize.

This is used for various things, the most common example being to customize the onUse function, in order to run code when an object is used.

A customization can also be used to completely replace a class using @object_name.customize. A good example of which is shown in any of the monsters.
Behaviour of .py files
.py files are not run unless called except for a few exceptions.

Almost all of your code will be contained within .py files, then be called by .ce or special .py files.

There are a couple of special .py files which are always called:
  • There are ones that are called from the engine itself, these vary but unfortunately, aren't moddable without core overloading, which there is insufficient documentation of right now.
  • There's registration.py.

There are two things the registration.py does. It registers files, and events. The registration of files is where files which otherwise wouldn't be activated, but that the game needs to recognize, are called. A good example of this is the call of 'core.biome.register()'. This registers the biomes (which are just .py files) and allows the game to recognize them.

Events are more complicated. Events are a way for the game to call a ton of relevant functions at certain times. To make it so that a function is called when an event is activated, you call 'event.listen(function)`. To remove that link, call `event.remove(function)`. Lastly, events can be activated by calling 'event.invoke` (Don't do this on built in events!!!) You can create your own events, but this is a basic tutorial, so we won't cover that here, instead, you need to know about the built in events. Inside 'game' (which can be imported from siege), there's a dictionary called 'events'. This contains all built in events. An example is 'game.events['world_loaded']'. You can listen to these just like any other event, but unless you know exactly what you're doing, don't invoke them.
What are .pyc files?
.pyc files are semi-compiled versions of the .py files. They are more efficient for the computer to read from than .py files, but they still require the .py file they're based on to exist.

What does this mean to you? Well feel free to delete the .pyc files, they'll just get generated again the next time you run the game.
Sharing your mod
Alright, so you made a great mod, now what?

Well, before uploading it to Steam Workshop, there's a couple of steps you should take.

First, double check that everything in your 'info' file is correct. Consider revising the description. If you don't want to type out something super long in that one line, you can use this site to type out your description as you normally would, then put \n in the "replace new lines" box: http://www.free-online.tools/en/text/remove_line_breaks.aspx

Next you need your mod picture. This should be a square picture, but it can be any size. Add it into the root folder, next to your info file, and name it preview.png. This picture is the icon that will represent your mod in the workshop.

Open the game and click the wrench icon in the top right hand corner. You'll be shown a list of all mods you have installed. Click "publish/update mod" you'll be taken to a screen with all mods you can upload. Mod's you can upload are all recognized mods except ones made by people other than yourself, and ones without a preview.png. Click your mod and select the tags you want it to be listed under.

  • Item if it adds items.
  • Tweak if it's just a small change to the way the game works.
  • Creature if it adds creatures.
  • Utility if it's made to be useful, usually a tool for other modders or server control, etc.
  • Interface if it changes the basic UI.
  • Server only if the mod only needs to be run on the server, not the client. If you don't know, you shouldn't select this as it will effect things in the future.
  • Character if the mod adds new body types or abilities, or changes something about the character.
  • Worldgen if the mod affects the generation of worlds, like new biomes.
  • System if the mod changes or adds fundemental systems into the game. This could be anything from alchemy to PVP.
  • Language if your mod translates the game into another language.
  • Other if you do something not described here.

Click continue and you'll be taken to a page with two buttons. The first of which says "Read & Agree". Clicking this button will take you to a page where you can sign the Steam TOS for creating a workshop item. After you finish this, close the popup. (Note: You must click this button every time, even if you've already signed the TOS. If you already have, just close the window.) Clicking "publish" will then attempt to publish your mod, it will immediately become public.

Now you should probably uninstall the mod and subscribe to the version on Steam Workshop in order to test it. There should be nothing wrong with it, but there are occasional kinks in the system. If your mod doesn't work but works when installed manually, do your best to figure out why, and then notify Jasson via a bug report. Then go to the page of your workshop mod and on the right side under "owner controls" click change visibility, and set it to hidden until you can fix the problem. (Know that updating the mod will automatically set it to visible again.)

If everything works fine, then feel free to prettify the steam workshop page with screenshots, videos, contributors to the mod, and links to other pages about the mod. These can be added via the owner controls toolbar on the right.

That's all!
Learning More
First of all, if there's a function that you don't know what it does, search the file for it and look in the import line. If it's in the import line you can look in the file it's being imported from to learn more about it.

If it's in the import line and is imported from Siege or Siege.something then that means it's a function which originates in the engine. Go to http://playcrea.com/mod/index.html to see the documentation for these functions.

I'd recommend after this you go to https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=550099155 and read it. It's a comprehensive overview of almost everything you can do to create any sort of item. Weapons, seeds, armor, explosives, and almost all non-living objects in the game are contained within this guide.
That's all!
Hopefully this helped you!

If you have any feedback, just contact me with it!
12 Comments
riteclick 2 Jul, 2022 @ 8:26pm 
Hello from the distant future! Not sure yet whether I'm going to try modding this game, but hats off to the author. The world needs more people like you.
Sykotek 11 Jul, 2019 @ 6:27am 
Years later this thread helped me a lot. Still not too sure what I was doing but, got to the end result none the less. To publish for some reason I had to publish mod > accept > publish then subscribe to it then republish for it to finally publish. Not too sure why but it worked for me. So thank you for the guide
Tausret 2 Dec, 2016 @ 2:25am 
Done :albedothumbsup:
Baxter900  [author] 1 Dec, 2016 @ 7:51pm 
Can't see what the problem is from just that part. Copy your entire log to pastebin.com and post the link. Also this'll be easier if you make a post in the workshop subforum.
Tausret 1 Dec, 2016 @ 2:08pm 
OK, what will the log say to me:
12/01/16 21:57:39,730.498 [12940] mods\core\monster\__init__.py:348 WARN main � Monster no longer has realm: <Entity(id=9189, contentId=940, name='ParagonTorrend')>
12/01/16 21:57:39,730.498 [12940] mods\core\monster\__init__.py:348 WARN main � Monster no longer has realm: <Entity(id=9192, contentId=927, name='ParagonStegara')>

I have made a Translation, only the locale folder is in the mod, with the info, reg and *.py.....
Baxter900  [author] 1 Dec, 2016 @ 12:36pm 
@Tausret: If the game's crashing then that means that there's something wrong with your mod. Look in the crea.log file and see what error's there.
Tausret 1 Dec, 2016 @ 4:48am 
OK, i make a new german translation mod, but when i try to start the game with the mod in the mods folder, the game crash and i can't upload it to workshop, please help
:saltytears:
Baxter900  [author] 27 Mar, 2016 @ 9:10am 
Actually, on second thought, it's probably better to still having, but to have the 'empty' code detailed in the "about registration.py" section.
Baxter900  [author] 27 Mar, 2016 @ 9:08am 
It appears that registration.py is not required for language mods. I'll update the guide to reflect this.
Gh0st 26 Mar, 2016 @ 7:16pm 
In the registration.py i'm making a language mod what i should leave in the documment?