Add an item¶
You add an Orange Soda, a drink copied from the soda that ships, then register it, put it in a loot table, give it to yourself and check that it survives a save. The how-to page Add an item lists every item field.
Steps¶
1. Duplicate the soda¶
- In the Content Browser, open
Content/ZombieSurvival/DataAssets/Items/Childs/. - Right-click
DA_Item_Soda, Duplicate, and name the copyDA_Item_OrangeSoda.
The copy keeps the soda's floor mesh, icon, pickup sound and food definition. Start from a copy rather than a blank Data Asset: a blank one falls back on the class defaults without telling you.
2. Fill the fields¶
Open DA_Item_OrangeSoda and set:
| Field | Value | What it does |
|---|---|---|
DisplayName |
Orange Soda |
the name in the inventory row and in the tooltip |
Description |
A can of orange soda. Sweet, and it quenches thirst. |
the tooltip text under the name |
ItemSaveId |
OrangeSoda |
the id the save file stores, and the id you type after /give |
ThirstRestore |
30 |
what drinking it gives back |
Leave Category on Drink. Save the asset.
Change ItemSaveId
The copy still has the soda's id, Soda. The id is all the save file keeps of an item, so two
items with the same id cannot be told apart on load.
The copy also keeps FoodDef = DA_Food_Soda, so your drink ages like the soda. To give it its own
shelf life, add a food.
3. Register it¶
- Open
DA_ItemRegistry_Default, in the same folder. - Add
DA_Item_OrangeSodato theItemDefsarray. - Save.
An item that is not in this registry works in play but vanishes on save and load, and /give does not
find it.
4. Put it in a loot table¶
Pine Hollow fills each container from a loot table the first time the container loads.
- Open
Content/ZombieSurvival/DataAssets/Loot/Childs/DA_LootTable_Fridge. It already lists the soda. - In
Entries, add an element:ItemDef=DA_Item_OrangeSoda,MinCount=1,MaxCount=2, and the sameWeightas the soda's row. - Save.
A new table would also have to be listed in
DA_LootSettings_Default.
5. Try it¶
- Open
Content/ZombieSurvival/Maps/L_Worldand press Play. - Press T, type
/give OrangeSoda 3and press Enter. Three cans land in your bag. - Press Tab and hover the row: the tooltip shows your name and description.
- Left-click the row to drink one. The stack loses a can and your thirst gains 30.
6. Check that it survives a save¶
Play from the map does not save to a named world, so go through the menu.
- Open
Content/ZombieSurvival/Maps/L_Boot. Start it as a Standalone Game (the arrow next to Play): in the editor's own Play, Esc stops the game instead of opening the pause menu. - NEW GAME, START, create a character, PLAY.
- Type
/give OrangeSoda 2in the chat. - Esc, SAVE GAME, MAIN MENU, then CONTINUE. The two cans are still in the bag.
7. Find it on Pine Hollow¶
Start another NEW GAME and search the kitchen fridges. The table is a weighted draw, so you may open several before you find a can. A world already played keeps what its containers drew.
The fridges have not been checked in play: only the new row of the table was checked in the editor.
If it does not work¶
/giveanswers "No item by that id.": the id you typed is not theItemSaveId, or the item is not inItemDefs./giveanswers "Only the host can do that.": you are a client.- The cans are gone after CONTINUE: the item is not in
DA_ItemRegistry_Default. The Output Log says Item id '…' read from a save is not in the item registry. - No can on Pine Hollow: the world was created before your change, the row's
Weightis very low, or the item is listed inExcludedItemsofDA_LootSettings_Default.