Everything "declarative" in a mod (anything that isn't code) goes in .txt files inside media/scripts/. Always with the same shape:
module MiModulo
{
imports { Base, }
item ... { ... }
model ... { ... }
craftRecipe ... { ... }
fixing ... { ... }
}You can split it across several files (items/, models/, recipes/) as long as they all use the same module.
Food
A real example: the vienesa (a Chilean-style hot dog sausage) from Completos Chilenos.
item Vienesa
{
DisplayCategory = Food,
ItemType = base:food,
Icon = Vienesa,
FoodType = Meat,
Weight = 0.1,
DaysFresh = 5,
DaysTotallyRotten = 9,
HungerChange = -8,
Calories = 150,
Carbohydrates = 2,
Lipids = 13,
Proteins = 6,
IsCookable = true,
GoodHot = true,
MinutesToCook = 10,
MinutesToBurn = 30,
CookingSound = FryingFood,
EvolvedRecipe = Pizza:8;Stew:8;Pie:8;Stir fry:8;Pasta:8;Rice:8,
}IsCookable,MinutesToCookandMinutesToBurnmake it cookable, and it burns if you leave it on too long.GoodHot = true: gives a bigger mood boost when eaten hot.EvolvedRecipelets it be used as an ingredient in the game's "evolved" recipes (pizza, stew...). The number is how much it contributes.
Drinks and "what's left over"
Melón con Vino (a Chilean drink of wine served in a hollowed-out melon) leaves the rind behind when you finish it:
item MelonConVino
{
ItemType = base:food,
Tags = base:alcoholicbeverage,
ThirstChange = -40,
Alcoholic = TRUE,
AlcoholPower = 0.3,
EatType = Candrink,
CustomContextMenu = Drink,
CustomEatSound = DrinkingFromCan,
ReplaceOnUse = Melvin42.MelonCascara,
...
}CustomContextMenu = Drinkswaps "Eat" for "Drink" in the menu.ReplaceOnUsegives you another item when it runs out: the rind.
Melee weapons
A summary of the Sable de Luz (lightsaber). The most important fields:
item SableLuz
{
ItemType = base:weapon,
DisplayCategory = Weapon,
Categories = LongBlade,
SubCategory = Swinging,
TwoHandWeapon = true,
MinDamage = 8,
MaxDamage = 14,
MaxRange = 2.0,
MaxHitCount = 10,
CriticalChance = 35.0,
ConditionMax = 30,
ConditionLowerChanceOneIn = 30,
SwingAnim = Bat,
SwingSound = SableLuzSwing,
HitSound = SableLuzHit,
...
}3D models (on the ground and in hand)
An item can have one model for when it's in hand (StaticModel) and another for when it's on the ground (WorldStaticModel). They're declared with model blocks:
model MelonConVinoGround
{
mesh = WorldItems/MelonConVino, <- models_X/WorldItems/MelonConVino.x
texture = MelonConVino, <- textures/MelonConVino.png
scale = 1.0,
}And in the item, with the module in front:
StaticModel = Melvin42.MelonConVino,
WorldStaticModel = Melvin42.MelonConVinoGround,Recipes (craftRecipe)
A real example: assembling a completo italiano (a Chilean hot dog topped with avocado, tomato and mayo).
craftRecipe MakeCompletoItaliano
{
timedAction = Making,
time = 60,
Tags = InHandCraft;Cooking,
category = Cooking,
xpAward = Cooking:3,
inputs
{
item 1 [CompleteItaliano.PanCompleto;Base.BunsHotdog_single] flags[InheritFoodAge;ItemCount],
item 1 [CompleteItaliano.Vienesa;Base.Hotdog_single] flags[InheritFoodAge;ItemCount],
item 1 [CompleteItaliano.Palta;Base.Avocado] flags[InheritFoodAge;ItemCount],
item 1 [Base.Tomato] flags[InheritFoodAge;ItemCount],
item 2 [Base.MayonnaiseFull],
}
outputs
{
item 1 CompleteItaliano.CompletoItaliano,
}
}[A;B]accepts either one: the mod's bun or the game's hot dog bun. That way the player doesn't get stuck hunting for one exact item.flags[InheritFoodAge]: the completo comes out as fresh (or as old) as its ingredients.Tags = InHandCraftlets you make it with the items in hand, no table needed.
And a recipe with a tool that doesn't get used up:
craftRecipe SLEnsamblarSable
{
timedAction = MakingElectrical,
time = 400,
Tags = AnySurfaceCraft,
category = Electrical,
SkillRequired = Electricity:3,
xpAward = Electricity:30,
inputs
{
item 1 tags[base:screwdriver] mode:keep,
item 1 [SL.EmpunaduraSable],
item 1 [SL.CristalKyber],
item 2 [Base.Battery] mode:destroy,
}
outputs
{
item 1 SL.SableLuz,
}
}tags[base:screwdriver]accepts any screwdriver. All the tags are in the tags reference, and the vanilla item IDs (Base.X) are in the items reference.mode:keepgives the tool back;mode:destroyconsumes the item.SkillRequiredrequires a skill level andxpAwardgrants experience.
The recipe's visible name goes in Translate/<LANGUAGE>/Recipes.json, with the key matching the recipe name ("SLEnsamblarSable": "Assemble Lightsaber" in EN, "SLEnsamblarSable": "Ensamblar sable de luz" in ES).
Repair (fixing)
fixing Fix Sable de Luz
{
Require : SableLuz,
Fixer : Battery; Electricity=2,
Fixer : ElectronicsScrap=2; Electricity=3,
}Each Fixer is an alternative way to repair: which material, how much, and which skill it requires.
Where to look for more
The most reliable source is the game's own scripts: in the install folder, media/scripts/. If you want to know how something is done, find a similar vanilla item. Old guides on the internet are usually for Build 41, and many of them no longer work.