TUG
Not enough ratings
Beginners guide to modding [0.8.6]
By Rawr
An initial guide for those interested in modding TUG.
   
Award
Favorite
Favorited
Unfavorite
Welcome!
As of writing, TUG is in alpha. What does that mean for a modder? Well, as TUG progresses through the updates, more systems will become available to play with and some may even be revised. This is a normal part of any alpha development. Progress is our friend.

If your initial question is: what can I mod? The answer is everything and anything TUG.

Quick edit: There's now an official tutorial forum here[forum.nerdkingdom.com]. I highly recommend checking it out first. I will be moving my efforts towards that forum.

Initial Info & Setup.
Start small. After you get your feet wet, jump into the deep end. Yes it might be scary but I bet that's where you'll learn the most. If in doubt at any point, just have some fun.

First things first. Regardless of what you're intending on modding you should be aware that Eternus (the engine) loads different things at different times. When TUG starts up, the models, schematics, textures and sounds are loaded. Lua scripts are loaded when loading into a world. This means that if you're modding a texture you have to restart TUG to see any in-game changes however if you make changes to a script, reloading your current world will suffice.

Of course you can change everything in the Game/Core folder but having a single place to keep track of all the changes you've made is valuable. The Mods folder is for this purpose. Just be aware that if Eternus can't sort out something with your mod folder, it'll either use what's in Game/Core or throw you some error messages. More on that later.

Now, there are some things to bring to your attention straight away.

The Config
Eternus will need to know which mod folders to load at start up. Adding "Mods/YourModFolder" (with the quotation marks) to the list in Config/mods.txt . The hierarchy within this file is such that mods at the top take precedence.

There are other important variables in Config/user_config.txt and I'll be pointing out some of them as we go.

The Manifest
If you've browsed into some of the TUG folder already, you may have noticed that within the Game/Core and Mods/TestModScript that there is a schematic called manifest.txt . Your mod folder must have one and it must contain at least the following:
Manifest { Name = "YourModsName" }
Here's the list of things you can add. They must go between the Manifest's curly brackets.
# When you see the "#" in a line, this indicates that everything after it is just a comment. Description = "..." MajorVersion = 1.0 MinorVersion = 0.1 # These next two go hand in hand. ScriptFile = "..." ScriptClass = "..." Rules { FlyingEnabled = 1 ProcessHitPoints = 1 ProcessAIHitPoints = 1 ProcessPlayerHitPoints = 1 ProcessObjectHitPoints = 1 ShowObjectHitPoints = 1 ProcessToolHitPoints = 1 ProcessPlayerStamina = 1 ProcessPlayerEnergy = 1 ProcessStackSize = 1 ReactToPlayers = 1 }
And Structure
To begin with, say you've looked through Game/Core and found the thing you want to mod. Structuring your mod folder means whatever the "..." part of Game/Core/.../TheFileYouWant, you should make Mods/YourModFolder/.../TheFileYouWant. Furthermore, there's no need to copy all of the contents of the folders, just the file(s) you want to mod.

Of course you can create your own structure BUT do note that will entail various more configuration work on your part.

Regardless of whether you want to change the structure, schematics are one of the first things you should look into. These files will say exactly where all other related files are. There's an example further down of what one might look like.

The most general tip for modding is to simply copy how Nerd Kingdom has done something, after which point if you understand all the moving parts - do as you wish.

When modding there are a couple of in game commands that become really handy.
  • /spawn "Object Name" # -- Example: /spawn "Cooked Meat" 10
  • /time # -- Example: /time 2400
  • /timescale 0 -- Day time forever?
  • /debugging
I cannot guarantee how up-to-date this is but if you're looking for a slightly more complete list of built-in commands follow this link.[forum.nerdkingdom.com] Of course, you're more than welcome to mod in your own.

Schematics
known format: .txt (Custom format)
Folder(s):
  • Game/Core/Data
Visual example:
GameObjects { PlaceableObject { Example Object { Script { file = "Scripts/.../___.lua" class = "..." ... { StaticGraphics { model = ".../___.obj" Diffuse { 0 = ".../___.tga" } Normal { 0 = ".../___.tga" } } } } }
Textures & Sound
Pro tip: If you'd like to not see the .dds and .hkt files within the TUG folders, a good way to go about that is to hide them. To do so on a windows machine follow these steps:
go to the cmd prompt < change directory to the TUG folder < type "attrib +h *.dds /s" < type "attrib +h *.hkt /s" < then make sure your folder options are set to hide hidden files.

Textures
known usable file types: .tga, .png
Folder(s):
  • Game/Core/Materials/textures
  • Game/Core/models/PlaceableObjects
Sounds
known file types: .ogg
Folder(s):
  • Game/Core/Sound
Scripts
All TUG scripts are in lua. This guide will not be about teaching you how to program however here's a youtube video to get you started. Check out the comment section if you want to jump to a particular topic.

A Mod Script
If you'd like to have an entry script for your mod, make sure you've included ScriptFile & ScriptClass in your manifest. Below is an example of a mod script.
-- MyModExample ------------------------------------------------------------------------------- if MyModExample == nil then MyModExample = EternusEngine.ModScriptClass.Subclass("MyModExample") end ------------------------------------------------------------------------------- function MyModExample:Constructor() end ------------------------------------------------------------------------------- -- Called once from C++ at engine initialization time function MyModExample:Initialize() end ------------------------------------------------------------------------------- -- Called from C++ when the current game enters function MyModExample:Enter() end ------------------------------------------------------------------------------- -- Called from C++ when the game leaves it current mode function MyModExample:Leave() end ------------------------------------------------------------------------------- -- Called from C++ every update tick function MyModExample:Process(dt) end ------------------------------------------------------------------------------- EntityFramework:RegisterModScript(MyModExample)
It's not required for your mod to have such a script however you may want it in some cases. An example would be if you've made your own crafting recipe. Copying NK's entire recipe.txt schematic, then appending your recipe is one way BUT a better way is to use the following API call within the Initialize function of a mod script.
function MyModExample:Initialize() Eternus.CraftingSystem:ParseRecipeFile("Data/Crafting/your_crafting_file.txt") end

An Object Script
When making scripts for your objects, searching through TUG's scripts becomes even more important as it's a lot easier to include or copy than to make your own from scratch.
--include other scripts like this. include("Scripts/Objects/PlaceableObject.lua") include("Scripts/.../___.lua") ------------------------------------------------------------------------------- --Subclass your script. ExampleObjectScript = PlaceableObject.Subclass("ExampleObjectScript") --Make some static variables if you wish. ExampleObjectScript.m_MyStaticVar = 123 ------------------------------------------------------------------------------- function ExampleObjectScript:Constructor( args ) end ------------------------------------------------------------------------------- --Functions from other scripts, PlaceableObject.lua in this case, can have their --default function from PlaceableObject.lua script overridden function ExampleObjectScript:TryPickup( target ) end ------------------------------------------------------------------------------- --Of course making your own functionality is a thing. function ExampleObjectScript:MyOwnFunction() end ------------------------------------------------------------------------------- --Notice that it's a slightly different call from your mod script. EntityFramework:RegisterGameObject(ExampleObjectScript)

The Eternus API
The API[eternusapi.nerdkingdom.com] is a series of functions that can be used within your TUG scripts.

Is there a console for TUG? Yes, head into Config/user_config.txt and set ENABLECONSOLE = 1. To print to the console use the API call NKPrint()[eternusapi.nerdkingdom.com].

Most API functions are called the following way: Eternus.something:NKsomeFunction() . The exception are the globals [eternusapi.nerdkingdom.com] such as NKPrint() which can be called as is.

Errors & Debugging
Most times an NK pop-up error will tell you somethings not right. This is the next learning curve as you'll need to pay attention to what they say.

If you have the console enabled, you'll have noticed that the same text appears in red there too. If you'd prefer to just read the red text in the console, go to Config/user_config.txt and set SUPPRESS_ERRORS = 1

Debugging usually ain't that bad but when you haven't won the game of spot the bug for the past day or two it's probably a good idea to ask someone else to have a look into it.

Models & Animation
All TUG objects come in the form of .obj [en.wikipedia.org]files. Eternus loads these files when TUG starts up. There are the following naming requirements and order for the objects within .obj files:
  • pivot (required)
  • hand_atch
  • example_atch_rotx
  • example_atch_roty
  • example
  • example_coll (required)
Importing one of TUG's .obj files into your 3D modelling program is easy enough. To help you track down a vanilla object that you might like to edit, here's two folders to start your search: Game/Core/Models/PlaceableObjects and Game/Core/Character/(Armor, Weapons or Tools). Alternatively, finding and checking the schematic will tell you where to look.

Note: If your model doesn't have a hand_atch then pivot will be used.
Also, particle emitters originate from an objects pivot.

On fbx and blender, the importer is not perfect but workable. The xyz rotations of bones need to keep intact when recreated. A solution is to convert fbx to dae in ms visual studio 2015 using it's model editor then import dae into blender which will keep the model mostly intact. Let me know if anyone's found better solutions.

Final remarks.
I hope you've got a lot out of this guide. Please do comment below or get in contact with regards to how I could improve it as input from the community is appreciated.

If you're searching for or wanting to ask some detailed questions, either the NK forums[forum.nerdkingdom.com] or here on the steam forums is a good place to start.

If you'd like to have a look into what others have been up to check out this link[forum.nerdkingdom.com]

Appendix
Schematic variables
slot = "Chest", "Feet", "Arms", "Neck", "Legs", "Hands", "Shoulders", "Belt", "Helmet"

Tag = "Trees", "Plants", "System", "Gear", "Traps", "Refined", "Weapons", "CrudeAge", "Ruins", "BronzeAge", "Tools", "Harvestables", "Rocks", "Decor", "Mount"

placementSound = "AltarAmbient", "GrassPlacedPlace", "grassPlace", "SnowPlace", "GravelPlace", "SandPlace", "TorchPlace", "WoodDig", "MetalDig", "WoodPlace", "StonePlace", "GrassPlace"

removalSound = "grassDig", "MetalDig", "SnowDig", "GravelDig", "SandDig", "GrassDig", "WoodDig", "StoneDig"

equipSound = "GrassDig", "MetalDig", "WoodDig", "SandDig"

category = "Trap", "Magic", "Powder", Powder", "Potion", "Cloth", "Container", "Dye", "Coal", "Meat", "Edible", "None", "Fence", "Mount", "Door", "Chest", "Bed", "Decor", "Tilled Dirt", "Dirt", "Grass", "Weapon", "Vegetation", "Hoe", "Shovel", "Pick", "Metal", "Gear", "Wood", "Torch", "Rock", "Table", "Flesh", "Axe", "Hammer", "Knife"

craftingArchetype = "Veg Greens", "Crystal Shard", "Wood Log", "Light Green Clump", "Wood Handle", "Cobblestone Clump", "Seeds", "Club", "Sword Blade", "Tan Clump", "Spear", "Long Shaft", "Wood Shaft", "Stacked Wood", "Leaf", "Large Modular Tool", "Small Modular Weapon", "Bamboo Log", "Axe Head", "Hammer Head", "Small Modular Tool", "Sat Green Clump", "Knife Blade", "Cudgel Head", "Shovel Head", "Leather Wrap", "Leaf" , "Large Modular Weapon", "Dark Green Clump", "Hoe Head", "Spear Head", "Veg Roots", "Wood Plank", "Pick Head", "Clay Clump", "Crude Handle", "Thatch", "Crude Rock Head"

Affects
{"Wood", "Vegetation", "Edible", "Rock", "Ore", "Metal", "Flesh", "Dirt", "Grass"}