Jump to content

Mod assistance (how to code items)


Recommended Posts

Items 101:

An item is, like a rock, tree or creature, a "prefab" (pre-fabricated entity). To make one for yourself, you should start by copying a similiar one from "data/scripts/prefabs/" to "yourmod/scripts/prefabs/", where you can rename the lua file and then edit it.

When editing a prefab file, make sure to change the name at the very end of the file. Other than that, there's no general advice to give.

Load the file from "yourmod/modmain.lua" by adding it to the "Prefabs" list.

To make the item craftable, use "AddRecipe()". e.g.:
AddRecipe("youritem", {
  Ingredient("goldnugget",1),
  Ingredient("cutgrass",3),
},
GLOBAL.RECIPETABS.SCIENCE,
GLOBAL.TECH.SCIENCE_ONE,
nil, nil, nil, --a bunch of stuff you can leave blank
1, --number of crafted items
nil,
"images/inventoryimages/youritem.xml",
"youritem.tex",)

Edited by Mobbstar
extended
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...