Crea
Ikke nok vurderinger
Introduction to Item Creation in Modding
Av Baxter900
A comprehensive guide on modding in (almost) all types of objects!
   
Utmerkelse
Favoritt
Favoritter
Fjern som favoritt
Introduction
Welcome!

This guide is a comprehensive overview of how to create almost any type of item in the game, no coding skills required!!!

Before you start, this guide is written with the assumption that you know how to create a mod at the basic level. If you don't you should read this guide first: http://gtm.you1.cn/sharedfiles/filedetails/?id=550024596
A Brief Warning
Before you start, a brief warning. This guide was created a while ago, and Crea changes very quickly, as such, stuff may be incomplete, wrong, or just flat out missing. If something looks one way in the code, and another way in this guide, trust the existing code.

Also, don't copy and paste from this guide, it screws everything up...
A basic item
Most items you're going to want to make by copying a similar item, that said, first we're going to go over the structure of items.

An item is declared like this:
Item()
However, just putting this doesn't work. For an example, here's the entire code for wood.
from core.template.item import Item Item(name="Wood", stack=99, buyPrice=10, sellPrice=0)
From now on, I'm not going to put the import function, make sure to import all functions used!!!

As you can see the item is being passed parameters, here's a list of all the parameters Item() can take:
  • name : The name of the object, this should be written with no spaces, first letter of each word capatalized: "IronArrow".
  • image : The image used for this item, defaults to an image of the same name, you should generally leave this alone.
  • icon : The icon used for this item, defaults to the image name with "_icon" at the end if that exists, and defaults to the image of the item if it doesn't. Again you usually shouldn't touch this.
  • stack : How many of that item can be in one stack.
  • cooldown : The cooldown of an item if it's usable
  • unique : I'm not 100% sure what this does, it seems to do a ton of separate stuff. As a general rule, if the item is something that you would only really want one of or expect to get rarely, set this to True.
  • discovered : Again, not quite sure what it does, what it appears to do in the code doesn't match up with in game. If you figure it out please tell me. Only place this is ever used is on bags, satchels, packs, and pouches.
  • useTime : How long it takes to use an item if it's usable.
  • buyPrice : The price you can buy this object at the merchant for.
  • sellPrice : The price you can sell this object to the merchant for.
  • price : The price you can buy, and 5 times the price you can sell, this object to the merchant for.
  • tags : Allows you to give an object a tag which can be checked elsewhere, only used by outfits.
  • useAnimation : Makes the player perform a certain animation when the object is used, only used in shears.
  • useVisual : Not 100% sure but all but in all but one occasion it's given immediately after useAnimation with a similar parameter to use animation, again the only item it's used in is shears.
Making the name display properly, adding a description, and flavor text
Crea displays names and descriptions of items using a single resource file. This resource file is found in the en.locale file. The en.locale file should be placed in a folder called locale in the root of your mod folder. To create a locale file, just open a blank file in a text editor. To give your item a proper display name you need to call the locale() method. This takes the name you gave your item in its .ce file, and the name to display, like this:
locale("ImbuingChamber", "Imbuing Chamber")
Now, instead of showing "ImbuingChamber", Crea shows "Imbuing Chamber". To add a description, again call the locale() method, but instead of just giving the itemname, add "Desc":
locale("ImbuingChamberDesc", "Used to upgrade materials")
Your item now has a description! Now, for the flavortext, do the same as the description, but instead of adding "Desc", add "Flavor":
locale("ImbuingChamberFlavor", "Capable of reinforcing some materials by concentrating the energy of Remna.")
There is also a method called associate(). This is used to name an upgrade from an item that's the same as another item, except for it's name. Let's look at an example:
locale("Broadsword", "Broadsword") locale("BroadswordFlavor", "A sturdy sword forged from iron. It shows much potential.") associate("BroadswordPlus", "Broadsword", "Broadsword +")
Here, the Broadsword is given a name and a flavor text. To give the same to the Broadsword +, save for the name, you can use associate(). You first give the name of the upgraded item, then the item it's upgraded from, and then the display name of the upgraded item. This can of course be done for items that aren't necessarily upgrades, but this is a good example of the principle.
Making an item craftable
Now I'm going to introduce something that will be used for almost everything. When we declare an item, we previously declared it as Item(parameters). However this isn't very useful beyond creating the item, the item exists, now we can't do anything with it. From now on, we're going to declare an item like this:
item_variable = Item(parameters)
What you name item_variable doesn't matter, as long as you keep it consistent. You can now add more to your item. The first thing we're going to do with it is make the item craftable. Here's the lines from lumber.ce that make lumber craftable:
Warning: Copying and pasting the below will not work!
lumber.craftable( category = "Basics", subcategory = "Essentials", level = 1, experience = 15, materials = ⟦ Material('wood'), ⟧, results = ⟦ CraftResult(quantity=4), CraftResult(quantity=5, quality=100) ⟧, )

You'll notice that it's declared as lumber.craftable(parameters), this is because the item was previously declared as lumber = Item(parameters). Here's a list of the parameters you can use:
  • upgradeFrom : The item that the item is upgraded from when crafting: upgradeFrom = "adventurers_mattock".
  • category : The category that the item is in, inside the crafting interface.
  • subcategory : The subcategory that this item is in.
  • level : The player level required to use this item.
  • experience : The crafting experience given by crafting this item.
  • isResearchable : If set to False, the recipe can't be discovered through research, it instead must be discovered by scrolls.
  • serviceRequired : What surfaces are required to craft this item, i.e. Workstation
  • onCraft : Not used except in painting.ce where it uses coding to pick one of 8 paintings to display randomly.<ADVANCED!>
Making an item placeable
Declared as item_name.placeable(parameters).
If you want collision, you'll also have to give the item physics.
  • dropped : This doesn't appear to do anything at the moment, if someone knows otherwise, please tell me.
  • allowCollection : Setting this to false prevents the object from being destroyed and picked up.
  • allowSupportRemoval : Allows you to destroy the floor or object below the item if set to True, object will then act as if you destoryed it as well, and you'll be able to pick it up.
  • destroyOnSupportRemoval : Doesn't seem to be implemented at the moment, but will theoretically do exactly what it says in the future.
  • floor_axis : Where you're able to place objects on it, most of the time you'll either give this the input Axis() which will allow you to place it anywhere on it, or Axis(support_top=Support(start=1, length=30)) where you'll want to set start equal to the pixel at which the collision starts and length equal to how many pixels it goes on.
Making an item imbuable
Declared as item_name.imbuable(parameters).
  • remnaType : I believe this makes it so that the item can only be imbued with this remna type. Inputs for remnaType are: Fire, Water, Wind, Earth, Light, All.
  • results : The results from imbuing the material, formatted as RemnaTier.One(works through Four): "refined_lumber". Each item in results needs to exist as an actual item (look at refined_lumber for an example).
Giving an item physics
Declared as item_name.hasPhysics(parameters).
  • active : Setting this to False makes the object spawn with it's physics turned off, don't used this unless you added code into your object to make the physics turn on when you interact with it or something.
  • collision : This is the direction you collide with an object. Direction.TOP for the top, Direction.ALL for everywhere, etc. Don't set it for no collision.
  • passthrough : Setting this to Direction.TOP will allow you to hold down and press space to fall through the object.
  • simulated : Whether gravity and other forces (like the player) are applied to an object, if immovable is set, then this is overwritten.
  • immovable : Makes an object immovable if set to True.
  • gravity : Takes a vector for the gravity. Most objects will have a gravity of Vector(0, 0) because they don't need to be influenced by gravity, however projectiles tend to have a gravity between Vector(0, 1.5) and Vector(0, 3).
  • friction : Slows down the object over time, again takes a vector, only used on projectiles.
  • groundFriction : Identical to friction but only slows down the object when touching the ground.
  • restitution : The "bounciness" of an object, similarly to friction it's only used on projectiles, usually with the value Vector(0.5, 0.5).
  • fallCap : Theoretically a max velocity, probably takes a vector but not used anywhere.
  • slope : No idea what this does, if anyone knows, please tell me.
  • hasGroundCollision : Setting this to False allows the object to fall through the ground.
Making a weapon
Weapons are a little bit different then most items, instead of declaring an item as Item(parameter), you're going to be declaring it as Sword(parameters), Spear(parameters), Bow(parameters), or Wand(parameters). You can use all of the parameters that you used before on Item() plus a few new ones.
  • power : The power of the weapon.
That isn't the only weapon stat, however it's the only one unique to weapons, attributes, which we're going to go over now, can also be used with equipable items.

All the attributes are contained within item\armor\attribute.py but when you import then you're actually going to import them from template\item.py. Since all the attributes are used in at least one item, I'm not going to list them, you should be able to figure them out between finding them in item.py and searching for an example of them.

  • attributes : These are attributes that will always be on the item, though the strength will be different each time if the attribute is set with a variable strength.
  • potentialRange : A number between the two numbers you give will be chosen, this number is how many potentials the item will have.
  • potentials : All of these have a chance of being on the weapon, the weight variable changes the probability of getting that stat on the item.

Since I've made this guide, the process for animating weapons has changed somewhat. The animations are now mostly handled by code, and thus weapons usually have only somewhere between 1-4 different frames in a single image. If you want to make a new weapon, I'd recommend importing one of the sprites already made onto the bottom layer in your photo editing program, adding a white layer behind it, adding another white layer in front of it and lowering the opacity somewhat, then making the layer you're going to draw on and making it slightly transparent so you can still see the original image. Then drawing your new weapon in the same poses over the original one.
Making a scroll
Making a scroll is really easy. It's declared as Scroll(parameters). It automatically will set the image to scroll.png unless you overide it. Next make an item that's craftable but set isResearchable to False. Scrolls have one special parameter:
  • recipes : This is the item_file_name of the object that you'll get the recipe for when you research it.
Making storage containers (like chests)
Storage containers are declared as StorageContainer(parameters).
The images for storage containers are always split directly in half with the left half being closed and the right half being open. The parameters unique to a storage container are:
  • capacity : How many items the container can hold.
  • keyRequired : Don't include this parameter unless you want a key to be required to use the object. The input is an item_file_name.
Making armor
Declared as a normal item with item_name.equippable(parameters) afterwards.
  • slot: In which of the equipment slot the item should go.
  • levelRequired: What level you need to at least be to be able to equip the item.
  • visuals: The item usually obscures another part of the body. This defines which part to replace.
  • attributes: What attributes this item definitely has.
  • potentialRange: This item has between the two given numbers amount of potential attributes.
  • potentials: What attributes this item might have.
The visuals parameter is written as visuals = [Substitute('bodypart')]. The bodyparts are:
shirt boot glove helmet leg
When creating a helmet, the visuals should hide hair. This is written as visuals = ⟦Substitute('helmet'), Hide('hair/top.png')⟧

Remember, no copying and pasting the above!
Making ammo
Ammo also uses item_name.equippable().
  • slot = 'ammo': Ammo must fit in the ammo slot. You'll always do this for ammo.
  • visuals = ⟦Substitute('arrow')⟧ : This way your character actually appears to be holding an arrow.*
Every other parameter is usable in the same way as armor. However, ammo needs a little extra.
item_name.usesAmmo('projectile')
This projectile.ce is that which is visibly thrown or shot. For more on this you can read the "making a projectile" section which deals with projectiles.

Example:
from core.template import Template from siege.util import Rect, Vector arrow = Template( name = "WoodArrowProjectile", image = 'wood_arrow.png', isPersistent=False ) arrow.hasPhysics( body = Rect(-2, -2, 4, 4), gravity = Vector(0, 0.15) ) arrow.isProjectile(power=1)

*Substitute() can also take an image as a parameter. This is used with, for example, a quiver. It would be weird if the character would appear to hold his quiver as an arrow. At this point, you might want to refer to an image of an actual arrow.
Making a crafting surface
To make a crafting surface add item_name.provideServices("ServiceName") to the item you want to be a crafting service.

To use this specific surface in another item, as has been mentioned before, one simply adds the 'serviceRequired' parameter in item_name.craftable().
item_name.craftable(serviceRequired="ServiceName")
Making a seed
Seeds are declared as normal items with item_name.usable(useSeed, 'plant_name', allowUnderground) after it.
  • plant_name: The name of the plant that is to be planted with this seed.
  • allowUnderground: True or False, it speaks for itself what this means.
Making an item usable using pre-made functions
To make an object usable, add item_name.usable(parameters) to your object.
The parameters here will behave a little differently than your used to, the first parameter will always be what the object is going to do when used, everything after that will change depending on what the object is going to do. Here's a list of all of the currently existing functions for an object:
  • useStatusPotion : Adds a status effect to the player upon using the potion.
  • status : The status effect induced by using the potion, found in core\effects\.
  • level : The level of the effect, some effects get stronger when a higher level is passed.
  • duration : How long the effect lasts, input as Seconds(x).
  • usePotion : Increases a stat on a player.
  • stat : The stat, written in shorthand as declared at the start of combat.py.
  • amount : The amount the stat is changed.


  • useOutfit : Use an outfit on a mannequin to create an NPC. Most definitely advanced.


  • throwItem : Throws a projectile and consumes item.
  • contentPath : The item_file_name.
  • lifetime : How long it exists in the world. Input as Seconds(x) or Minutes(x).
  • isSticky : If set to True, causes the projectile to stick to walls and monsters.


  • useExplosive : Consumes the item and throws a projectile which will explode. Note any damage done by the bomb will use the damage stats from the projectile used.
  • contentPath : The item_file_name.
  • fuseTime : How long the bomb waits after being thrown to explode. Input as Seconds(x) or Minutes(x).
    radius : Never used, so probably not necessary.
  • isSticky : If set to True, causes the bomb to stick to walls and monsters.
Note that any function can be used as long as you import it first, such as with way shards which trigger TravelSystem.useWayShard() on use.
Making a projectile
How your projectile is declared depends on how you want to set up your projectile delivery system. Some of the time with throwable objects, you'll want the object to be the same as the item you throw it from, in which case you'll just add item_name.isProjectile(parameters) to the item. However using the same item for the projectile and the item can cause problems and most of the time, you'll want to create a new object that's only the projectile. This object should be declared as Template(name(NameLikeThis), image(image_name.png), isPersistent=False). Note that unlike the other object declarations we've used previously, most things that work on Item() won't work on this. You then need to add item_name.isProjectile(parameters). It has these parameters:
  • power : How much damage it does on impact. Note that on arrows power is used as a multiplier for
  • other damage (i.e. stone arrows do 4 times the damage of wood arrows) and bombs do this damage, and all other stats upon exploding.
  • attackType : Input as AttackType.Type with Type being Divine, Melee, Magic, Ranged or All.
  • damageType : Input as DamageType.Type with Type being Physical, Fire, Earth, Wind, Water, or All.
  • knockback : The strength of the knockback upon damage being dealt.
  • interrupts : I'd guess whether it interrupts casting upon dealing damage but I'm not sure, it's never used, probably best to just not include this, it defaults to False.
  • critMultiplier : How much should the damage of a critical hit be multiplied?
  • statusEffect : The status effect applied upon dealing damage. Status effects are found in core\effect\
Adding light to an item
To add light to an object (projectiles included), first declare it normally, then add item_name.hasLightSource(parameters).

The parameters are:
  • enabled : Ignore this unless you want to set it to False for some reason, it would then have to be enabled by extra code for the light to have any effect.
  • center : Takes a Vector(x, y) as a way to shift the center of light source away from the center of the picture.
  • intensity : The strength of the light.
  • brightness : The brightness of the light.
  • decay : How quickly it get's dark when moving away from the light source.
  • size : The size of the light source, usually ignorable.
  • color : The color of the light, input as a Color(r, g, b) with r, g, and b being a value between 0 and 255.
Examples of advanced ideas
These items and ideas are to complex for this guide, that said, if you want to look into them yourself, here are some lists of good examples:

Animated Items
/item/basic/essential/torch.ce is a good example.

Interactable Items
/item/basic/surface/furnace.ce is a good example. As is item/way_crystal/way_crystal.ce.

Tiles
Anything in /tile/
I'd highly recommend that you just start with a tile that's similar to what you want and re-texture/re-color it unless you know what you're doing.
Conclusion
That's all that this guide has. There are a lot more items, and item types, but based off of what you've learned here, you can probably figure out the rest of them by looking at their files in mods/core. If you have any specific item type you want added to the guide, just ask!
7 kommentarer
Baxter900  [skaper] 29. juni 2018 kl. 17.40 
@David1271 I'd check your logs. They're super helpful to figure out what's wrong when something like that happens. If you wanna post them on the Crea discord in the #modding channel I'll take a look when I have time.
David1271 29. juni 2018 kl. 14.05 
@Bandersnatch Thanks! One more question, whenever I try to make a weapon, it crashes. I usually use another sword as a kind of “template” then I just change all the names, materials needed, etc. I then attach two photos with the name of the sword. After all this, I play and it crashes. Could you maybe do a quick step by step or tell me what I’m doing wrong? Thanks
Baxter900  [skaper] 29. juni 2018 kl. 12.25 
@Davind1271, that part's a tad out of date, for the most part weapons now have a single sprite which is moved via the code for the animation.
David1271 29. juni 2018 kl. 9.01 
To make a new item, like a sword, all i see is two photos. The icon, and the way it looks when holding. Where is the animation for them located?
Baxter900  [skaper] 12. juni 2016 kl. 11.43 
You're right, I've fixed it now. Thanks!
Vash 12. juni 2016 kl. 7.22 
In the "Making an item craftable" section. Looks like the parameters list is 2 copies of the 8 parameters o.O?
Lurch456 26. apr. 2016 kl. 17.10 
???