Implementation Structure Templates

Florian

Active Member
Contributor
Architecture
I pushed a new version that contains a new "Toolbox" item.

  • It can be obtained via the command "give toolbox"
  • It is intended to provide tools for structure template creation in future
  • For now however it already offers you a way to get blocks
  • Shapeless blocks can be obtained in any wished shape
  • It works in multiplayer (In my quick test at least)
  • It uses tree view component @rzats made in GSOC
 

Florian

Active Member
Contributor
Architecture
I pushed up a new version:
  • The toolbox contains now also a structure spawner for each type of structure template known.
  • The toolbox root node is now expanded by default.
 

Florian

Active Member
Contributor
Architecture
I pushed up a new version:
  • The toolbox offers now "Structure Template" items for each structure template.
  • Those new items can be used to place the blocks of structure template and obtain a structure template editor item that edits that structure.
  • The "Structure Spawner" items are still also in the toolbox and work as before.
 

Florian

Active Member
Contributor
Architecture
I finally pushed the new template editor work I was working in the last weeks to the master branch.

Since it is a big change with the chance to break existing stuff I increased the version number to 0.2.0-SNAPSHOT.

The following has changed:
  • The structure template editor gets no longer accessed via a item, but via a block that marks the origin of the structure template. It is the block with the T in the following screenshot:



  • When you use the structureTemplateGenerator item, the target block will be replaced by the structure template origin marking block.
  • The structure template origin block can be activated by pressing E to show the editor UI. It looks like this:

  • The region where from which blocks get copied does no longer need to be specified manually. Instead the origin block UI offers you a option to record any block placement.
    • When you place a block while that option is active any block you add with extend the tracked region by the position of the placed block.
    • When you remove a block while that option is active, the position of the removed block will be removed from the tracked region
    • That means that the tracked region can become any size
    • The option is called "Update region on block placement" and is currently at the bottom of the screen that shows up when you E click the origin.
    • The region of the template remains highlighted and the block tracking continous even if you close the UI. To stop tracking you need to open the UI again and uncheck the option.
    • One way to track air placement for now is to first add the blocks and then unckeck the option to track block addition. If you then remove the blocks the air will be copied that is there now.
    • Theoretically it will be possible in future for multiple players to work on the same structure
  • It is still possible to explicitly set a copy region of a specified size.
    • If you have already a non box-shaped region then the default of that region will the boundings of that region.
    • So if you want a box-shaped region, you can first activate the option to track block placements, place 2 blocks in the corner and then make the box-shaped region marked by that 2 blocks the tracked region.
    • The button for this option is called "Make edit region box-shaped"
  • The origin block UI also provides a button called "Selected -> Clipboard"
    • This button copies the complete JSON for the created structure template to the clipboard.
    • The basic template data (type and spawnChance) get also included. It can be adjusted via a "Edit STructure TEmplate Properties" button
    • The generated JSON also will include item additions to chests.
      • e.g. if you place items in a chest and then copy the JSON then the structure template that template describes will create a chest with the exact items you put in it.
      • It currently works for block items and for unmodified items based on prefabs.
    • Structure spawns will also be copied from the places structure placeholders (see next item for more info)
  • Structure template placeholders blocks can now be used to mark locations in the template where other structures should spawn.
    • The block with the s inthe following screenshot is a structure template placeholder
      • The screenshot shows a left turn corridor of gooey's quest.
      • The next room will appear with a rotation to the left as the structure template placeholder is rotated left.
      • The next corridor spawn origin will be at the block below the s marker.
    • The structure template placeholder block offers a minimalistic UI when you E click it that allows you to select the structure that should spawn.

    • The structure template place holders get automatically placed when you place a structure template (not structure spawner) from the toolbox item.
    • I suggest you have a look at existing templates to get a feel for them
    • The item can be obtained for now with the "give StructurePlaceholder" command but it will be added later on to the toolbox item UI.
  • The "Create Structure Spawner" button of the structure template orign block gives you now a structure spawner that includes the same features like the genreated JSON.
    • The generated structure spawner will place items in chets
    • The generated structure spawner will spawn additional structures if your template region included structure placeholders
  • There is now also a button for copying a "is underground" condition
    • It copies a JSON string to clipbard that represents for the structure template the condition that it is underground. You can then manually paste it in a template
    • The exact condition is that the regions the template + 1 block layer above are solid blocks
  • The structure template origin block can be replaced without loosing the marked regions or other data.
  • Structure templates get now also always copied with the correct relative rotation. The "front" and "position" field have been removed from the StructureTemplate component as this manual correction is no longer needed.
    • Existing templates with a "front" field value != FRONT need to be adjusted. This is however simple as you can just place the structure template and fix the rotation of the origin block. Then you just need to copy the new JSON over the old.
 
Last edited:

Florian

Active Member
Contributor
Architecture
I pushed some new changes to the repository:
  • The toolbox has now a "Structure Template Tools" node
  • The structure template generator has a new icon
 

Florian

Active Member
Contributor
Architecture
I puhsed a new version to the repository:
  • It is now possible to track block removal (new check box in screen that opens when you activate a structure template origin block)

  • Added a new "wall replacer" item that can be used to replace quickly complete walls with a different block type.
    • The item can be obtained from the toolbox item
    • While you hold the item, it shows in green a outline of the wall/region you are about to replace
    • Activating the item pops up a screen where you can select with which block you want replace the wall:
    • If you have the block addition tracking active of a structure template origin block then the blocks will be added to the template.
    • It is possible to replace a wall with air. Thus you can use the tool also to enlarge existing underground rooms by just adding air walls again and again.
    • It is possible to also replace the ground and ceiling.
Both changes together should speed up the creation of dungeon rooms a lot.
 

Florian

Active Member
Contributor
Architecture
I pushed a new version to the repository with improvements to the wall replacer tool:
  • It is now possible to replace walls with water and lava
  • It is now possible to replace walls under water or under lava
  • It is now possible to replace the air infront of a wall.
    • This makes it possible to use the wall replacement tool for building. Since it always replaces the wall towards the player it is possible to extend structures upwards.

    • This can also be used to make underground rooms smaller again
  • It is now possible to replace also a 1 block border around the wall. This is usefull when you are building a room and you want the wall also to be in the edges.
 

LazyJ

New Member
I'm trying to create an assortment of prefabs of hand-made trees and buildings in a singleplayer world dedicated to just making these sort of templates to later place in my creative-building singleplayer world, when and where I want them. I've been following examples and instructions found in StructureTemplates' GitHub, this thread, and a YouTube video ( Terasology - Module Guide - StructureTemplates ) but am having no luck in getting things to work.

The YouTube video is the most recent piece of information. It refers to a file path that does not exist in Terasology 74:

~/Terasology/modules/StructureTemplates/assets/prefabs/

According to the video, this is where I'm to save the structure's code as a plain text file, suffixed with ".prefab".

I'm currently using "Terasology 74 - alpha" installed from the launcher in LinuxMint 18.03. It's file path is:

~/Terasology/game_files/data/modules/

but the "modules" directory is completely empty.

I saved some test prefab files to this directory and then looked for them in the game through the Toolbox -- not there.

Then I tried a command: give structurespawnitem test1.prefab

and that didn't work.

Just "give structurespawnitem" alone will produce the page-like item in the hand but it doesn't place anything when right clicked.

I was able to get StructureTemplates to work by using the structuretemplateitem's menu and clicking on "Create Structure Template Item". However, as my singlplayer world grows, I'd have to keep a list of coordinates for every thing that I want to duplicate, teleport back to those spots, setup blocks in the cubical area of the structure, then click on the structruetemplateitem's menu's "Make edit reagion box-shaped" and then "Create Structure Template Item", teleport back to my build site, place the duplicate, and then remove the blocks I used to set the cubical area corners.

It would be nice if I could enter a command like: give structurespawnitem cherryblossomtree.prefab 3 to get three cherrry blossom trees to plunk down. To have the prefab's file name appear as part of the structurespawnitem would also be helpful when working with multiple structurespawnitems (i.e. three different heights of the same type of tree).

So is what I'm trying to do currently doable, if so, how?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
So I just ran a version of the launcher I had sitting around to get some more hard data on the first part of the question: where to module files end up with a game installed via launcher. During initial setup of the launcher it asks you to pick two directories, one of them the install dir where game files go. You can change it later in the settings (cog icon top right corner) - here's a screenie of how my setup looks with one of the installed game builds showing:

2018-05-20 22_48_54-modules.png


The data dir is the one you found. Yep the modules dir there is empty. I'm honestly not sure what it gets used for in the data dir. Modules don't generally write data, and the rare time they might (experiments during dev) you're usually in a source workspace with source module dirs. As you see in the above screenie all the modules are in jars making it a bit more trouble adding new prefab files to them.

In theory you should be able to extract one of those jar files into a directory named as per the module, like "AdditionalFruits" then move the jar file somewhere else. If you add prefabs to the extracted dir they should be available next time you launch the game. Might be easier to use a regular developer workspace though - we need to work on that :)

Would that help avoid having to make new STs constantly in-game? The toolbox can export an ST selection to the user's clipboard so you can paste it into a prefab.

The feature request about "give structurespawnitem cherryblossomtree.prefab 3" I'm not quite catching - you can currently give the ST prefabs themselves, and as "blueprint items" so to say they work repeatedly?

Might be something to catch up about on chat sometime so we can write it up as an issue request on GitHub :)
 

Florian

Active Member
Contributor
Architecture
My recommendation is not to spawn a structurespawnitem but instead get a toolbox item. Via toolbox it is possible to get a structure template spawner that is an item with 3 T on it that spawns a structure template origin block on each click and can be reused. The toolbox also contains other items that can be used to buidl structures quickly like the wall replacer item. The latter can be used to digg dungeon rooms or build walls of houses really fast.

From a template origin block you can create a structure spawner item that can be used multiple times to spawn the structure multiple times.

Once you have your templates stored in a module you can also use the toolbox item to get a spawner for on of your templates. Alternativly you can also get the template version of it which can be placed once and also places the origin block so that you can create a modified version of a structure template.
 
Top