TUG Basic Modding Guidelines

NekochuNekochu REGISTERED Posts: 244 Developer
edited August 2014 in Mods
Welcome to TUG! If this is your first time in TUG or you have been involved with previous versions on the game, I hope you are enjoying your experience. If you've made it to this forum you probably are curious about what you can mod in the game. This thread should help you with the basics of making a mod for TUG.

Preparing for a Mod

Currently TUG supports modding based on the asset folders and files provided with your game. Before making changes to these files, make sure you set up a mod folder to work from so that you don’t cause problems with your current game files.

First, in the main folder, create your mod folder. After this, make a copy of any of the folders under assets that you will be modding in this new mod folder. This will be a copy of all of the files you will be changing or adding to and if you run into any problems, you can always refresh from the main assets folders. Now you must change your starting directory in your user_config.txt file, located under the Config directory.

User_config.txt
GameConfig
{
	soundVolume = 1
	gammaCorrection = 2.2
	ambientSoundVolume = 1
	viewDistance = 5
	objectDistance = 10
	particleLimit = 1
	textureFilter = 1
	theOneBiome = ""
	disableSound = 0
	mouseSensitivity = 0.0104937
	shadowQuality = 2
	useManifest = 0
	invertMouse = 0
	showGrass = 4
	workingDirectory = "./"
	fallbackDirectory = "MyMod"
	windowWidth = 1600
	windowHeight = 900
	fullscreen = 0
	autoSaveTime = 3
	vsync = 0
	fov = 60
	playerName = "Nekochu"
	lastIPAddress = ""
	renderClouds = 1
	gameMode = 1
	maxPlayers = 15
	minPlayers = 2
	devMode = 1
	tcpPort = 6602
	bloom = 1
}

Advanced Tips

While in the user_config.txt file, you'll notice some other fields that can help you out with modding as well.
theOneBiome = ""

Adding a biome name in this section will force the terrain to only generate that biome. This is great for testing if you are making adjustments to a biome or working on the settings for your own.

Creating a Terrain Texture

To create a new texture to be used as a terrain, create a tiling texture 512x512 and save this texture in the Materials/textures directory of your game files.

You will also need to create a bump map if you want this new terrain texture to have some depth when placed on the terrain. Save your new texture and bump as a 24 bit .bmp as well as a .tga. The engine uses the .bmp for spreading the new terrain texture and the .tga as a thumbnail shown in the menu icons.

Now that you have your new texture files, you can add this information to the materials.txt and create a game object file to begin placing blocks of your new texture all over the world. These two .txt files are located in the Data subfolder of your game files.

Below is an example of the script you will need to write in each file:

Data/materials.txt
My Material Name
{		
      name = "My Material Name"
      materialType = "Natural"
      minAngle = 0.60000
      maxAngle = 1.00000
      diffuseFile = "mymaterialname_diff.bmp"
      normalFile = "mymaterialname_bump.bmp"
      placementOctaves = 2.000000
      placementScale = <32.000000, 1.000000, 32.000000>
      textureScale = 6.0
}

After adjusting the materials file, create a new .txt file in the /GameObjects folder:

Data/GameObjects/PlaceableMaterials/MyMaterial/MaterialName.txt

MyMaterialName.txt
MyMaterialName
{
      material = "My Material Name"
      icon = "Materials/Textures/MyMaterialName.tga"
      gridSizeX = 1
      gridSizeY = 1
      placementSound = "GrassPlace"
      removalSound = "GrassDig"
      stepSound = "StepGrass"
      miningEmitter = "Strike GrassC Emitter"
			
      category = "Pick"
      tier = 1
}

At this point we have set up the new texture to be created as a place able block and assigned it an icon in the menu. So you can now run the game and see your new texture as a block that can be placed!

Advanced Tips

You will notice in the materials.txt there are some key variables that can affect the placement and size of your texture when it is placed.
minAngle = 
maxAngle =

These two variables will affect where the texture is generated if it is used as a texture on the terrain. These values can be overridden in the generation file but they are first set here. The range for these values is a float number that is between -1.0 and 1.0. The angle is a 90 degree angle of placement. So if you want your texture to generate closer to a flat surface set the the min and max between 0.9 and 1.0. If you would like for your texture to only generate along a right angle, say like a cliff wall, set the values to something more like -1.0 and 0.8. If you're ever unsure, check one of the other textures being generated and try to follow some of their settings.
textureScale =

This value adjust the scaling size of your texture when it is placed. You will want to adjust this value if you would like your texture to tile larger than the normal block size.

While looking through the materials.txt file you will notice some textures have references to billboard located inside their sections.
Grass with Oat
{		
      name = "Grass with Oat"
      materialType = "Natural"
      minAngle = 0.900000
      maxAngle = 1.000000
      diffuseFile = "mud_diff.bmp"
      normalFile = "mud_bump.bmp"
      placementOctaves = 2.000000
      placementScale = <32.000000, 1.000000, 32.000000>
      textureScale = 2.0
      Billboards
      {	
            Oat
            {
                  billboardMinAngle = 0.9
                  billboardMaxAngle = 1.0
                  billboardDensity = 0.8
                  billboardMinScale = 1.5
                  billboardMaxScale = 3.0
            }
      }
}

This is where grass and other textures are placed that occur on top of certain terrain textures. If you would like to add new billboards or adjust any of the existing, you can edit the Data/billboard.txt file. To add to the textures, edit the Materials/textures/billboards.tga.

Now if you want a new material to generate as a piece of terrain in a biome, you can edit the Data/Generation/generation.txt to make this happen. Find a section in the Biome structure of the file you want the new texture to generate in and add it to the Materials list.

Generation.txt
Biome
{
      name = "Piney Woods"
      depositSet = "Piney Woods Deposits"
      mainMaterialStrength = 0.5
      dayAmbiance = "MountainAmbientDay"
      nightAmbiance = "MountainAmbientNight"
      geome = "Rocky Foothills"

      ...

      Materials
     {
           "My Texture"

      ...

This will cause the new texture to tile in the Piney Woods biome at a consistent amount. In addition, placing the new texture at the top of the Materials list makes it the default texture, causing it to occur more frequently than any other texture in the biome.

Advanced Tips

As mentioned before, the generation file can override some of the settings for textures found in the materials.txt file. In order to do this, you will need to add your texture as a ModifiedMaterial:
ModifiedMaterial
{
      baseMaterial = "My Texture"
      minAngle = 0.9
      maxAngle = 1.0
      placementSize = <10.0, 1.0, 10.0>
}

The minAngle and maxAngle parameters are the exact same as described earlier. These values just replace any settings found in the materials.txt file. The placementSize allows you to try and control the patch size of the terrain as it is placed in the biome.

Smaller values in here tend to make the texture more frequent and in small patches while larger sizes will try and generate the texture over a larger area.

Adding an Object

Game models are read from .obj files and the textures associated with these .obj files are stored as .tga textures. Once you have created a correct .obj and found the order of the textures applied to the meshes stored in the .obj, you can add this model to a GameObjects file to make it available in game. If you want to have a thumbnail of this model, save out a quick render in a 128x128 .tga file saved in the UI/MenuIcons subfolder under your game folder.

For more info on creating art models for TUG, check out Rik's thread over here.

When creating a new .txt file for an object, try to follow one of the existing folder structures as this is good for consistency as well as how items will be organized in the inventory screen later. For this example, let's add a new tree.

The new file will fall into the following folder structure:

Data/GameObjects/PlaceableObjects/Trees

MyNewTree.txt
My New Tree
{
      name = "My New Tree"
      model = "Models/PlaceableObjects/Trees/myNewTree.obj"
      icon = "UI/MenuIcons/myNewTree.tga"
      minScale = 0.7
      maxScale = 1.5
      placementSound = "GrassPlace"
      removalSound = "GrassDig"
      miningEmitter = "Strike WoodHard Emitter"
      miningEmitterAlt = "Strike leavesBipinnateGreen Emitter"
      useAlphaShadows = 1.0

      category = "none"
      tier = 0
			
      activePhysics = 0
      mass = 10.0
      friction = 3.0
			
      Diffuse
      {
            0 = "Models/PlaceableObjects/Trees/myNewTree_diff.tga"
      }

      Normal
      {
            0 = "Models/PlaceableObjects/Trees/myNewTree_norm.tga"
      }
}

Now you have an object that can be placed in the world! If you to take the next step and start to have this object spawn in a biome, follow the below code snippet to set this up.

generation.txt
Biome
{
      depositSet = "Piney Woods Deposits"
      mainMaterialStrength = 0.5
      dayAmbiance = "MountainAmbientDay"
      nightAmbiance = "MountainAmbientNight"
      geome = "Rocky Foothills"
      skyState = "Normal"

      ...
			
      Materials
      {
            "My Texture"
      }

      ...

      PlacementRules
      {
            My New Trees
            {
                   object = "My New Tree"
                   weight = 0.1
            }

        ...

The weight value determines the density of the new object when it is placed in the biome. Now with these changes you will see your object spread all over the biome you just added it to!

Advanced Tips

Just like materials you will notice some values that are used to adjust the scale and settings for your models.
minScale =
maxScale =

This range controls the amount of scaling your model can be affected by within the game. When objects are placed during generation or through creative mode, this range controls the upper and lower limits at which items are scaled.

Just like materials, this range can be modified during generation time.
My New Trees
{
      object = "My New Tree"
      minScale = 2.5
      maxScale = 3.0
      weight = 0.1
}

Now our new tree will be larger than the standard size and will vary within this new range when it is generated throughout the biome.

These are just a few examples of modding and if you have noticed in some of this code there are ways to add sounds, control the scaling of your objects and textures and control FX! Try adjusting or adding to some of these other variables and see what you can come up with to mod TUG!
Twitter: @X_Nekochu_X
Tumblr: xnekochux

Comments

  • TestamentofTestamentof REGISTERED Posts: 1,234 Seed
    If/When I try to get into modding, and if this page is still relavent, I'll probably use this heaps. Thanks Nekochu!
    The Machine is on....

    6.jpg

    otViQlH.png
  • jjv360jjv360 REGISTERED Posts: 8 Podling
    When I create a new folder called "Mods" in the game folder, and then change workingDirectory in user_config.txt to workingDirectory="Mods", every time I load a map it says "[Parsing, Severe] Failed to successfully parse generation.txt!", and the world is just a flat rock. It still does that even if I copy everything in Assets into the Mods folder... If I put workingDirectory back to "./" then it doesn't show an error (but then mods don't work)

    Is there something I'm missing?
  • GyradosianGyradosian REGISTERED Posts: 3
    Hello! Sorry, but I'm rather confused. When in the files, it says to use .bmp files in the Data/materials.txt as the diff and normal files but in all the other ones it uses tga's. They also have _diff and _bump at the end, and you never really specify what these are and what they do, and if you should add them or change your files or add new files or etc. etc. It would be great if you could make a short video explaining/showing off how you did this, as this is very hard to understand at points.

    Thank you very much for making this tutorial, I just still don't know how modding works. :p
  • SkittlesSkittles REGISTERED, Developers Posts: 44 Developer
    @Gyradosian

    Hey Mate, There have been many changes in the engine since this thread got started, so some of it might be out of date. On textures, I think we might have finally gotten rid of the .bmp textures, will have to check tomorrow and get back to you. If we didn't, the .bmp files are only the materials for the voxels (like dirt, cobbled stone, sand) and I believe all these must be 512x512... can't remember if these can vary in size. All other textures in the game are .tga file formats. Something to note on these though, at the moment our engine does not support multiple texture map sizes on our models, which means if you model a tree and split the leaves and bark onto two different texture maps, both maps need to be the same size (two 512x512 maps, 1024x1024, 2048x2048, etc). Alphas can be applied to model texture maps, but we only have a 1bit alpha for them (this means your alpha needs to ether be white or black, no grays). World Materials cannot have alphas.

    well... I hope that explains it and doesn't further confuse you... cheers!
  • human1104human1104 REGISTERED Posts: 7 Podling
    Hello. I created a new material. Like obsidian. I used for sample obsidian. In the game work, in creative. But i would like, to i can craft, in urvival modes. I writed in crafting text new recipes, but in the game, before the crafting is complete, the game crashed. Anyone help pls. Thanks
  • NekochuNekochu REGISTERED Posts: 244 Developer
    It sounds like the game is crashing on creating the object from your craft. A lot of the engine has changed since this original post but I think for what you're trying to do, you will need to check on your voxel representation for the crafting result. You mentioned that you had used obsidian as your template for your new material so check in the blocks chunk file to copy how obsidian is represented by its voxel chunk.

    Assets\TUG\Game\Core\Data\GameObjects\PlaceableObjects\Z Blocks n Chunks\Clump Rock.txt

    After that make sure that your material file and the object chunk point back to each other so that the chunk will allow you to place blocks of your new material.
    Twitter: @X_Nekochu_X
    Tumblr: xnekochux
  • human1104human1104 REGISTERED Posts: 7 Podling
    This problem solved. Thanks the answer. i think cant work recipes, for material. I used for example , one for harvestable, Rock Loose Pebbles.

    i created new harvestable item,

    materialRep = "Cobblestone Gray"

    instead of cobbleston gray, i typed my new material name, its worked.

    (I use Tug 0.6.2, not have core, and zblocks n chunks folder).
  • nocarenocare REGISTERED, Tester Posts: 92 Seed
    Your version of tug is very very old there and I'm not sure anyone can effectively support your modding efforts unless you upgrade to a more current version.

    There are many new things for you to see (and mod ;)) in 0.8.5!
  • human1104human1104 REGISTERED Posts: 7 Podling
    Hello!
    I upgraded my Tug. 0.8.6. And realy, there are many new things. one more guestion, can create a book, or anything, in game, where are list of crafting recipes?
  • nocarenocare REGISTERED, Tester Posts: 92 Seed
    Well I'm not aware of any books yet, but take a look here for crafting recipes: http://tug.ovh/crafting/tug.html
    http://tug.ovh/crafting/tug-search.html

    Many many new things. Enjoy :)
  • human1104human1104 REGISTERED Posts: 7 Podling
    its ok, but i created new recipes, and i wanted to list them inside a game. but if cant.... cant :)
  • human1104human1104 REGISTERED Posts: 7 Podling
    Where can i found it the materials like large leaf?
  • RawrRawr REGISTERED, Tester Posts: 511 Seed
    Here's a wiki for you.
    contributions are welcome.
    Programmer, designer, artist.
  • human1104human1104 REGISTERED Posts: 7 Podling
    Thanks the answer, but i thing thing material files. like decor/bed.
  • human1104human1104 REGISTERED Posts: 7 Podling
    edited August 2015
    solved
Sign In or Register to comment.