Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

Rogue Legend 2

Run a farm, a shop, or dungeons with friends · By Kassoon

How to mod your own towns Sticky

A topic by Kassoon created Feb 06, 2019 Views: 54
Viewing posts 1 to 1

Make sure to back up any files you mod!

There's a secret mode you can access on the title screen now, which will allow you to mod your world.

In order to access the prefab editor you'll need to be at the title screen and enter a code. Once you enter the editor there's no way to leave besides alt-f4 or otherwise closing the game. The code is:
up, up, down, down, left, right, left, right, b, a, enter

After a pause you'll enter the editor. To get started click on LAN Host, then Client Ready, then hit Done on the appearance editor. You can now run around freely, you're not restricted to any bounds, and you can also move up/down with e/q or space/ctrl. If you open up the craft window you'll have access to everything (even uncraftable stuff) and can use the arrow buttons to paginate. You can build as normal and place items as normal, except you can remove blocks with an empty hand.

Image

If you click the new button everything will be deleted and give you a fresh scene. If you click save your current prefab will be saved and it will spit out a bunch of gobbledygook in the text field. That's your save data. If that gobbledygook is in the text field and you click load, your prefab will be loaded, so you can use that to save/load your prefabs. How to edit what shows up in the game? Go to your game's root directory, and open up the data folder then /StreamingAssets/prefab/ you should see some txt files. These are what's used in game.
To modify the basic town, open up town_basic_prefab.txt and you'll see a number of prefabs. How to read this file:
Empty lines and anything started with // is ignored, so you can use that for comments.
Anything using the code like TURLF_0_B is a prefab type, and the line immediately following is the gobbledygook of the save file.

The code defines how the prefab is to be used using the format NonTouchingSides_TouchingSides_Road (for town, others might have their own, usually stated at the top). Each of the letters is a code: T = Top, U = Under, R = Right, L = Left, F = Front, B = Back, 0 = Ignored. You may have noticed in the editor some colored walls with giant letters on them, that is which face it represents. The only ones missing are T (up) and U (down). Think of them like the edges of a puzzle piece, R pieces connect into L pieces, F pieces connect to B, and T connect to U.

To get a custom house or building or whatever to spawn in a town, you define what its edges are. Specifically which edges dont connect to others, which edges do, and which edges have road. So a code like TURB_0_LF means there's no connection T/U/R/B, it has no required connecting edges (the 0), and has a road along the R/F edges. So, a small standalone house with a road on the right and front sides. The road will connect to other roads on the L/B edges but otherwise it doesn't connect to any other piece.

Building connections (the middle _0_) can be used to make larger multi-part buildings. I recommend starting with _0_ though.

If you get your building in-game you may notice that it's been invaded by dirt, to prevent that you're going to want to fill the insides with Emptiness, which is a block you place in the editor. You should find it on one of the last pages. It's just like air, but it says "this space MUST be air, not any of that other stuff." If you take a look at my examples you'll see the insides of the building and the road all have forced air to ensure they're accessible. I usually place the air first so it's easier.

You can also place and edit grounditems, like if you want to make a shop. To do that you'll want to use the "Grounditem" item that should be right next to emptiness and place it like any item. Then if you check the "Item Edit" checkbox below the save/load you'll enter item edit mode. Click on the ground item you just placed and its values will be entered into the input fields. In order they're: Item ID, Amount, Data, Price%. If you hover over an item it'll have a number at the end of its tooltip, that's the ID. Amount is how many (dont set this higher than the actual max stack amount), data you can ignore, and price % is the individual mark-up vs the current market price. If you enter 100 it will always be 100% of the current market value, or 0 to make it just a regular ground item. Then click the set button. You can enter multiple numbers and ranges as well, like if you want a varied selection of shop items. Each number is comma delimited, or you can use a dash for a range. If you entered 12,14-29,45 for ItemIDs then it would be randomized between a bed, any of the seeds, or a yam. Or 1-3 for amount means it would contain 1,2, or 3 of the item.

That's it. Add or remove to the prefab files to modify your town. Feel free to share any towns you manage to cook up. If you'd like to contribute town buildings, enemy camps, or world ruins and landmarks then get in contact with me!

Getting your prefabs showing up

All the prefabs used for worldgen are stored in RogueLegend2_Data/StreamingAssets/prefab/
If you're using 64bit then that'll be /RogueLegend2_64bit_Data/ instead

To add a ruin to the world you'd open ruin_prefab.txt add another couple lines to the end of the file, then
:Ruin
SaveDataGoesHere

so something like
:Ruin
AAgAAB+LCAAAAAAABADsvQetc

The names after the : are important to determine where and how the prefab will be used. If you have multiple prefabs using the same name (like in the case of ruins) then one will be randomly chosen. You can look at the file to see examples of what valid names are, and copy+paste the save string into the prefab builder to see how it was built. If a name isn't used in the file, chances are good it won't do anything.