Starbound

Starbound

Architect's Desk
This topic has been locked
JC  [developer] 18 Jan, 2020 @ 3:45am
Guide to making your own prefabs
I won't talk about the process to making the initial mod setup or how to make dungeons using tiled since there are already a lot of guides on that.

First of all make sure your mod requires Architect's Desk otherwise it won't work.

Now in the main folder of the mod create a dungeons folder, within that i have folders named after each tab of the desk to avoid confusion but its up to you what you name it.

In my example i will use prefabDemo. Now within that folder would normally be the different folders for prefabs that are associated with the race or misc but i will just go with demoDungeon. I don't think hierarchy matters much as long as your prefab is within the dungeons folder. I just like to be organized.

So now my directory looks like Demo Prefab/dungeons/prefabDemo/demoDungeon.

This mods structure looks like Architects Desk/dungeons/prefabApex/prefabApexCity.

In here we have two files demoDungeon.json which is your tiled dungeon file (make sure you have a misc World Gen Must Contain Air tile in the bottom left of your dungeon otherwise it will spawn from the top left) and demoDungeon.dungeon which looks something like this:
{ "metadata" : { "name" : "demoDungeon", #1 "species" : "generic", "rules" : [], "anchor" : [ "demoDungeon" ], #2 "gravity" : 80, "maxRadius" : 1000000, "maxParts" : 1, #3 "extendSurfaceFreeSpace" : 100, "protected" : false }, "parts" : [ { "name" : "demoDungeon", #4 "rules" : [ [ "ignorePartMaximumRule" ] ], "def" : [ "tmx", [ "demoDungeon.json" ] ] #5 } ] }

#1 The name of the dungeon.
#2 The name of the first part.
#3 You don't need to worry about this unless you have multipart prefabs.
#4 First part name.
#5 This points to your json file in the same folder.

You only really need to change the name so it's unique, the anchor to the name of your first part, the first part name and the name of the json file under the def section of the part.

Now go back to the root of the mod and create a folder called objects, within that another folder called prefab and finally another folder that i have called demoDungeon for consistency sake.

So Demo Prefab/objects/prefab/demoDungeon. In here we have three files, demoDungeon.frames, demoDungeon.object and demoDungeon.png.

The frames file looks like this:
{ "frameGrid" : { "size" : [288, 352], #1 "dimensions" : [1, 1], "names" : [ [ "default" ] ] } }

#1 [width, height] To get the size open your tiled json file and the map properties should be on the left, calculate the width by 8 and do the same with height.

The png is just an image of your dungeon so in tiled open your dungeon then go File then Export as image. Choose a location to save it to then the settings i have are
Only include visible layers ticked, Use current zoom level unticked, Draw tile grid ticked and Include background colour ticked. Then click ok.

Now for the object file:
{ "objectName" : "prefabDemoDungeon", #1 "colonyTags" : ["crafting"], "rarity" : "Common", "description" : "A blueprint.", #2 "shortdescription" : "Demo Dungeon", #3 "race" : "generic", "category" : "decorative", "price" : 3168, #4 "apexDescription" : "N/A", "avianDescription" : "N/A", "floranDescription" : "N/A", "glitchDescription" : "N/A", "humanDescription" : "N/A", "hylotlDescription" : "N/A", "novakidDescription" : "N/A", "inventoryIcon" : "/objects/prefab/prefabBlueprintIcon.png", "orientations" : [ { "image" : "/objects/prefab/demoDungeon/demoDungeon.png:<color>", #5 "imagePosition" : [0, 0], "frames" : 1, "animationCycle" : 1.0, "spaces" : [[0,0]], "anchors" : [ ] } ], "dungeon" : "demoDungeon", #6 "scripts" : ["/objects/prefab/prefabBlueprint.lua"], "scriptDelta" : 5 }

#1 unique name for the object.
#2 ingame description not really needed since you won't be looking at it. *Optional*
#3 ingame name for the blueprint.
#4 Ill talk about my price guide below.
#5 point this to your png in the same folder.
#6 the name of the prefab you are using.

You only need to change the five commented sections above. If you want the price to be the same as how i work it out then my guide is like this:

If you are adding a decorative prefab then i use 1 pixel per tile, for general sized prefabs so houses and such then 2 pixels per tile and for large prefabs like the hylotl castle or multipart prefabs i use 3 pixels per tile.

e.g. for this demo i used the large steam spring house so i would do 36 * 44 * 2 so the price would be 3168. 36 being the width and 44 the height of the prefab in tiles.

For multipart prefabs the pixel price per tile is the same but working it out is slightly different,
i work out the cost of the anchor part as above but for each extra part i find the average width and height between them then add that cost to the anchor part.

e.g. if the anchor was 128 * 200 * 3 = 76800. Then we had say 3 parts that connect to it being of the sizes [24,30], [28,20], [34,26] i would find the average then add that cost to the anchor so. 29 * 25 * 3 = 2175. 76800 + 2175 = 78975.

Rounding just follows normal rules.

Moving on the last thing you need is another folder in the root of the mod called recipes, in that a folder called architectsDesk and in that a folder called prefab*your prefab*.

So for me it is Demo Prefab/recipes/architectsDesk/prefabDemoDungeon.

Now in this folder we have prefabDemoDungeon.recipe which will add your hard work to the desk so you can actually buy it.
{ "input" : [ { "item" : "money", "count" : 3168 } #1 ], "output" : { "item" : "prefabDemoDungeon", #2 "count" : 1 }, "groups" : [ "architectsDesk", "apex", "all" ] #3 }

#1 The cost here is the same as the price of the object.
#2 This is the name of the object.
#3 The only thing to change here is "apex" this determines what tab your prefab will be under. It can be apex, avian, floran, glitch, human, hylotl, novakid or misc.

After saving that file your all done, now test that it works ingame and if everything is fine upload your mod to steam if that is your intention otherwise just enjoy.

If you have any problems then post a comment in the main section of this mod and i will try to help you as best i can.
Last edited by JC; 18 Jan, 2020 @ 3:57am