Jump to content

Need help with adding a custom equip slot, reading .xml and .tex and changing the voice lines


Recommended Posts

So i downloaded the Hollow Knight mod and already changed a couple things like:
The recipe of some itens
The the nail and it upgrades being able to work like a pickaxe

Now i want to change how the mod work in some ways, i want to:

Create a specific slot for the charms items, currently they are equiped in the head slot, it'l work like any other equip slot you start the game with it and you can only equip 1 charm at the time.
Make the character don't speak, currently he's using the wilson voice lines and i found the file responsible, should i just delet it?


Should i copy the backpack/amulet slot code and change the icon for the one i want? I don't know much about programing this is the first mod i try to change.

This is how it looks like when i open a .tex file

image.thumb.png.32c3d184faa23ce3f26608a78f8905b2.png 
 

The .xml file look like this, is it normal to be this short?
image.thumb.png.21187d56d8e948f8b9e0b7446e9fbe7f.png 

Link to comment
Share on other sites

XML files are just regular text files that you can open with any text editor. Though I don't recommend using Microsoft's Notepad because it's bad and it sucks and I'll bully anybody that uses it. One of the things that makes it suck is how it doesn't recognise the line feed character (LF) as a newline, and only recognises CR-LF. So if you open any file with Unix line endings, then all of the text will appear in one line, making it hard to read.

The game uses XML files alongside KTEX files to load image assets. The KTEX file is the image itself, and the XML file defines dimensions and names.

Here is an example of an XML file:

<Atlas>
	<Texture filename="atlasexample.tex" />
	<Elements>
		<Element name="firstimage" u1="0" u2="0.5" v1="0.5" v2="1" />
		<Element name="secondimage" u1="0.5" u2="1" v1="0.5" v2="1" />
		<Element name="thirdimage" u1="0" u2="0.5" v1="0" v2="0.5" />
	</Elements>
</Atlas>

The 'Texture' tag needs a value for its 'filename' attribute, which will be the path to the KTEX file relative to the XML file. In this example, we assume that we've got the XML file and atlasexample.tex in the same directory.

Inside 'Elements' is a list of images defined by the 'Element' tag that needs 5 attributes. These attributes are:

  • name - This is the name of the image
  • u1 - Starting x location (left to right)
  • u2 - Ending x location (left to right)
  • v1 - Starting y location (bottom to top)
  • v2 - Ending y location (bottom to top)

The attributes u1, u2, v1, and v2 will determine the proportions of the image and their value ranges from 0 to 1 (0% to 100%). If we assume that atlasexample.tex has a size of 128x128 pixels, then the resulting dimensions of 'firstimage' will be 50% of the width and 50% of the height of atlasexample.tex, which is 64x64 pixels.

femalesansissohotohmygodwhycantsheberealidontthinkicanhandlethisanymore.png.c9177b76b7bbf9fce60266a7b0452e0e.png

Usually mod icons only need one image, so mostly they'll have an XML file that looks like this:

<Atlas>
	<Texture filename="modicon.tex" />
	<Elements>
		<Element name="modicon.tex" u1="0" u2="1" v1="0" v2="1" />
	</Elements>
</Atlas>

 

As for KTEX files, they're non-text files that contain the actual image itself. So if you open them with a text editor, you'll just see a bunch of weird symbols, much like if you do the same with PNG files.

If you want to see what's in a KTEX file, it needs to be converted to PNG first. You can do this using ktech from simplex's ktools:

You can read more information about its usage on its README: https://github.com/nsimplex/ktools/blob/master/README.md

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...