Scalar's Structurizer: A worldgen helper `library`

ScalarVector

Terrarian
icon.png

Scalar's Structurizer

StructureHelper/Scalar's Structurizer is a simple tool which allows mod creators to build world generation structures in-game and save them to external files, as opposed to manually encoding them into their source code, usually to the detriment of readability and organization. The nature of structures being saved to external files also allows for better organization, sharing, and editing/replacement of structures. The mod can also be used as a sort of world-editor allowing you to easily copy/paste sections of your world around.

The mod contains a number of features which give you a large amount of control over the structures you create and save, such as null tiles/walls and multistructures. These allow you to create complex generation with significantly less complex code.


How do I use this?
Instructions and documentation here


Download
Link




 
Last edited:
Pushing out a small update for this tool today, with a few useful features:

Test structure wands
TestWandCopy.png
TestWandPaste.png

These wands allow you to easily test how a structure will generate in-game, simply use the silver copy wand just as you would use the normal golden structure wand to save a structure to the test path, and use the copper placement wand to place it at your mouse. No more having to reboot the game to test a structure. Note that every time you save a new structure with the silver wand, it will overwrite the old one. Use the golden wand to save structures as unique files. Both wands can be crafted for 1 dirt

Null blocks
NullBlockItem.png

These special blocks can be added to your saved structure, when it generates these blocks will be ignored, leaving whatever already existed in the world behind. Perfect for generating anything that isn't rectangular. A stack of 9999 can be crafted for 1 dirt.

-----------------------------------


Other stuff:
-Fixed a bug that caused saving modded walls to turn your entire structure into... something strange. or just flat out crashing. yikes.
-You can now generate structures from outside of your own mod by providing a full path to the file and passing true to the fullPath param of GenerateStructure().



 
Last edited:
New update today, featuring a few new features, support for new things, and some major bug fixes.
This update includes a major fix for modded tile/wall saving, which is based on a new save format. This should still be backwards compatible with the old format, but if you have any structures in your mod with modded tiles I highly advise you to re-save them after updating.

Now, onto cool new stuff

Null block changes & Null walls:

NullBlockItem.png
NullWallItem.png

Null blocks no longer cause the generator to ignore walls, instead you must use null Walls for this. This change is to allow for walls and tiles to be ignored separately so that you can do things like smooth terrain without walls leaking through. In order to help with this change, null blocks now also have a window in them so you can see what wall is behind them.

NullBoth.png

Want to leave everything about a tile as-is and not have to worry about placing tiles and walls individually? Use the amazing new NULL TILE PLACE-O-MATIC to place a null tile and wall at the same time!

New data support:

New data about tiles is saved now! Your old structures are still compatible, but if you want any of the new data you will have to re-save your structures.
Saved structures now store, in addition to everything already stored:
- Half Slabs! this was an oversight originally
-Actuators! also an oversight originally
-Actuation state! no longer are you bound by the constraints of walls

and the big one:
TILE ENTITIES!
TileEntity.gif

Not only will you be able to save and generate Tile Entities with the mod, but any saved data on a modded tile entity will be saved and generated also!
At the moment, the mod is still unable to save vanilla TE data, so you'll still be unable to save the items in item frames or on mannequin unfortunately.

Misc. changes:

-Crafting recipes for wands and null blocks have been removed to prevent abuse in normal game-play. No more using the test wands to duplicate ore, you naughty people.
-Fixed a bug where all liquids would get saved as water. You'll need to re-save your structures for this to take effect.
-Null blocks now stack to 1 and are infinite. This extends to the new null walls also.
-Fixed a bug where the structure and test structure wand's preview would be placed incorrectly on UI scales > 100%
-Fixed a bug where structure and test structure wand's preview was visible while not holding the item

That's all for now folks. Happy building!

 
New update coming... soon! hopefully. Few things to iron out
Multistructure Wands
MultiWand.png
MultiWandCopy.png
MultiWandPaste.png

These new wands allow you to save a set of structures to a single file.


Simply click twice to select a structure like you would with the normal structure wand, then right click to add it to the structure cache. Repeat for all structures you want to include. When you're done, right click the wand in your inventory like a loot bag to save the file.


The green wand mirrors the gold structure wand, directly saving your structure to a file. The blue wand mirrors the silver structure wand, storing a temporary multistructure file to test generation, and the red wand mirrors the copper wand, allowing you to spawn a random structure from the saved test cache.

Saving.gif


Why use these?
Multistructures allow you to easily randomly generate a subset of structures, such as dungeon rooms, micro-structure variants, differently shaped clumps of ore, or anything else you can think of! they save all the same data as normal structures, so you can freely build with wires, paint, actuators, modded tiles, even tile entities!

Generating.gif



2 new methods exist in the main StructureHelper Class for multistructures:

GenerateMultistructureRandom(string path, Point16 pos, Mod mod, bool fullPath = false)
Same exact params as normal GenerateStructure, generates one structure from the multistructure file randomly.

GenerateMultistructureSpecific(string path, Point16 pos, Mod mod, int index, bool fullPath = false)
the index param is the index of the structure you want to generate from the multistructure (for example, 0 will give you the first structure you saved). The rest of the params are the same as normal GenerateStructure.

Misc. Changes

-Added a preview of where the points for all structure saving wands will be placed, so you dont have to guess where it will end up on the tile grid.
-The regular test placement wand now shows a preview of where the structure will show up. This does not apply to the new multistructure test wand, as structures can be different sizes within a single multistructure file.
-Fixed air generating as an actuated tile, causing any tiles placed in it to be actuated when placed. That was a strange one.
-Fixed an issue with saving modded walls. If your structure has modded walls (Including null walls) and generates strangely, re-save it after updating!
 
Itty bitty update but thought I would record it anyways:

- Fixed a bug where null tiles would generate as dirt with direct DLL refferences.
- Made the test structure placement wand not lag the game to hell and back.
 
Is this open source? Is there a way to pull tile structures from the world by way of API?
 
Last edited:
can you make a tool to generate mod biomes?

As what is considered a "biome" is a very loose term, there isnt exactly a "good" way to do this. A number of other library mods exist with worlgen utility features, and this mod could also be used to generate parts or even an entire biome.
 
sorry, but i'm still confused. i understand that you're supposed to add cross-compatibility between your mod and our own in order to use it, but that's what i'm stuck on. could you provide an example at all?
 
Can you make a clearer description of how to use this mod as a dependency? It sounds great, but It's not exactly clear how to build the structure in the WorldGen hook, if that is even where you intended it to go.
 
New major update! With this update comes a minor restructure of the mod, and a new save format. Legacy structure files can still be generated, though its reccomended that you convert your files by placing and re-saving them to reduce filesize. To assist with this, the test wand has been reworked, it now has it's own menu, allowing you to select any structure or multistructure in your SavedStructures folder for placement. Because of this, the now redundant test save/place wands have been removed.

This is not the update containing chest support, that will come at a later date.


Important (breaking!) change:

To generate structures, you should now call:

StructureHelper.Generator.GenerateStructure instead of StructureHelper.StructureHelper.GenerateStructure
StructureHelper.Generator.GenerateMultistructureRandom
instead of StructureHelper.StructureHelper.GenerateMultistructureRandom
StructureHelper.Generator.GenerateMultistructureSpecific
instead of StructureHelper.StructureHelper.GenerateMultistructureSpecific



Full changelog:


* New file format which contains the same information and is significantly smaller
* Structure data is now cached after they are first generated, preventing read issues and hopefully improving performance for generating the same structure multiple times
* Added a UI for the test structure wand which allows selection of any structure in the SavedStructures directory
* Removed the test structure saving wand, test multistructure saving wand, and test multistructure placer wand
* Test structure placer wand renamed to structure placer wand
* Resprited the multistructure wand and structure placer wand
* Moved generation methods out of the main mod class to a seperate Generator class
* Resprited icon



New documentation:

You can find new and up-to-date documentation on the mod on it's Github Wiki.
 
Last edited:
updated, and now GenerateMultistructureRandom seems to be giving an index out of bounds of array exception, all I had changed was re-make the structure files, GenerateStructure is fine however so im not sure whats causing it. It does the error with all GenerateMultistructureRandom lines, i didnt just try it once.
Code:
Generator.GenerateMultistructureRandom("WorldGeneration/AncientSPillarsM", origin, mod, false);

Edit: Interestingly i tried placing a multistructure using the structure placer wand and then it said it couldnt find LegacyGenerator.cs

Edit 2: I fixed the issue by removing LegacyGenerator and all mentions of it, for some reason GenerateMultistructureRandom was using that instead of the other one
 
Last edited:
updated, and now GenerateMultistructureRandom seems to be giving an index out of bounds of array exception, all I had changed was re-make the structure files, GenerateStructure is fine however so im not sure whats causing it. It does the error with all GenerateMultistructureRandom lines, i didnt just try it once.
Code:
Generator.GenerateMultistructureRandom("WorldGeneration/AncientSPillarsM", origin, mod, false);

Edit: Interestingly i tried placing a multistructure using the structure placer wand and then it said it couldnt find LegacyGenerator.cs

Edit 2: I fixed the issue by removing LegacyGenerator and all mentions of it, for some reason GenerateMultistructureRandom was using that instead of the other one
Thanks for the report, will look into a fix for this with the next update
 
Back
Top Bottom