Skip to content
Omar (gatoWololo) edited this page Jun 21, 2020 · 6 revisions

Adding a simple block.

First:

  • It should be solid
  • It should have a simple texture (how about an "information"-I?)
  • It should be hard to destroy as gaining new information may be tough ;)

To understand which file defines which aspect of a block and where to put all these files please have a look at the Block Definition page.

Using this information, the definition of our new block is straightforward. We add the following files to our assets/ folder under our TutorialAssetSystem/ folder.

  1. The block will be named information, as said before: use the same name for all files.
    For the texture, place the information.png inside the blockTiles folder:
    information.png: . Feel free to experiment with any other image you like.

  2. Now we define the actual block in a new file blocks/information.block with the following content:

    {
        "displayName": "Information",
        "categories" : ["information"],
        "hardness": 42    
    }
    

    The definition only requires non-default values, so we will be fine with this. For example our information.png-Texture will be picked automatically for us, based on the filename. Omit the category for now, this will define the material type which is required later in the tutorial.

Verify all files are where they should be

Your file hierarchy should look like:

modules/
  ...
  TutorialAssetSystem/
    ...
    assets/
      blocks/
        information.block
      blockTiles/
        information.png

You can also browse this repository's file tree https://github.com/Terasology/TutorialAssetSystem/tree/master/assets/ to verify yours matches. (Note: you will see extra files and folders that we have yet to add).

We omit the shape and prefab part here, so we are ready to test our block ingame.

Testing In Game

Launch the game, create a new game and don't forget to enable the module before starting :)

Once ingame, open the console (press F1) and execute the give information command. If other information blocks are present, the full command for exact this block is give TutorialAssetSystem:Information. You can use the command listBlocks to see all available blocks.

If everything works as expected, the block is ready to be used ingame.

If you want a tool for this block, you may continue with the next step: Add New Item