Puman wrote:These are the rules you should follow when creating a sprites.png file if you want it to play better together with other mods:keep it as small as possibleuse sides that are 32, 64, 128, 256, 512, 1024 or 2048 pixels wide

Is there a particular reason to use powers of 2? I just checked the "Stock Sprite Fix" mod I downloaded on steam and they're using a sprites.png size of 896x896 which is a multiple of 32, but not a power of 2.

I'm sorry for that, I was never aware of this problem. Besides, it was my very first mod. The moment I read this I went and optimized the spritesheet though it's been quite a while since this was posted...Anyways it's down from 320x384 to 320x256, with only one (unavoidable) 64x64 empty space, hopefully it should work with a larger quantity of mods now.

As for the above question, I would say that keeping it as small as possible is more important than having sides that are powers of 2, for example if you're in a 256x256 box and your mod could fit in a 192x192 area, you could fit seven 64x64 spritesheets in the leftover space, but if you make it 256x256 you're wasting that space. Or in crappy ASCII graphics:xxxo > xxxxxxxo > xxxxxxxo > xxxxoooo > xxxx

Nice tutorial! It helped me expand the mods I use and want to use a lot.I cramped everything I wanted from something like 27 mods into two sprite images of 1024x1024 with only one tile of 32x32 space left free!And the best thing after a weekend of fiddling around with it is that everything works as intended. You just need to pay attention to the positioning of all the sprites.Think this sounds too good to be true? Have a look: http://i.imgur.com/cUWhanJ.jpg

Btw these two mods I made are for personal testing only. I see no need to release them to public, since I can't be bothered with tons of questions/bugreports/requests, nor asking for permission from more than 20 authors... And I don't use Steam so there is no way for me to upload it there anyway. It just shows that it is possible to combine lot's of stuff if you want to spend some time on it.

But one question arises, why can't the game engine itself fix what took me a weekend to puzzle together? :sFinally I can have a prison basketball, several different workshops, gardening stuff and much much more all together in one game.Something that was impossible before, even by trying to fit all separate mods in different order.... I dare you to try it yourself and load all the mods you recognize from the screenshot - you will fail miserably.

The game engine should strip every single sprite from its given canvas and throw them onto the big canvas before the game starts, instead of trying to match all the different canvases from the mods sprites.png files onto one big canvas. It makes the difference between lazy programming and proper programming.

Last edited by murgh on Thu Feb 25, 2016 9:43 pm, edited 4 times in total.

Puman wrote:All mods together must share a total space of 2048x2048 pixels (this is mentioned in the games debug log). The sprites.png of all mods are packed into this limited space, when the space runs out the next mods will get rather random graphics.

Playing around with large sprites.png files I noticed the maximum amount you can safely load is two images of 1024x1024 (which is also the maximum size allowed for a sprites.png as mentioned on page 1).If you add a third sprites file, it will start to overwrite the first one, starting in topleft corner. Examples:

Here is a snip from debug.txt when loading three sprites with sizes 1024x1024, 1024x1024, 512x512:

Notice the (x/y positions?) where WorldRenderer puts these together.When in game this will result in the Combi_3 sprites.png (512x512) overwriting the top left corner of the first sprites.png (Combi_1) canvas.

To have something to compare, here is a snip from debug.txt when loading three sprites with sizes 1024x1024, 1024x1024, 256x256:

And again, in this example the sprites canvas from Combi_3 will overwrite top left 256x256 part of the first sprites.png canvas (Combi_1).In the games mods menu these mods were sorted in this order:Combi_2Combi_1Combi_3(but not loaded that way by worldrenderer?)

I'm not sure if it was intended to have space for 'only' two 1024x1024px sprite for modding available. It seems a rather small area, and in fact is way smaller than the example drawing from ts. If the max size would be 2048x2048 then I should have been able to properly load 4 images of 1024x1024...yet a third one of a few pixels already starts to overwrite things

By coincidence I have just discovered that it's possible to define your custom sprites using the objects.png, people.png and special-entities.png files by using negative values for x / y positions.You can make a mod without using your own sprites.png file and still use any object on one of these images. And the good thing is, you can ALSO reach those objects if you DO have a custom sprites.png in your mod. A picture explains more than a wall of text here, so I'll just give you a wall of sprites with some x/y coordinate examples to play around with. Here you go, have fun modding!

This means for instance that the sprites.png canvas size from my booths mod can be reduced by quite a bit: currently it holds all standard sprites for workmen (4 rows of 4 sprites) and guards (4 rows of 4 sprites) as well the new ones (also 8 rows of 4 sprites). But now I just found out that the standard sprites could be reached just to the left of the canvas of our modsprite area, saving tons of space for other mods!

edit: hmm something in that picture is wrong, since I noticed before that the maximum space used for mods can only be 2x 1024x1024px and those two are side by side. But the grey field in the picture is 2048x2048px... So the grey field should be divided by half horizontally, and we have some mysterious emptiness below our modsprites all the sudden Also, where is tileset.png? It should be floating around somewhere as well, but some random x/y tests I did only showed up with empty black space or some vertical black lines.

I forgot to make a side note for the above example. The x/y coordinates work fine if you only use one mod, which will by default start at the top left corner. However, if several mods are loaded and the mod you made also contains a custom sprites.png, it seems that those x/y values start to change and you have to recalculate the exact positions...but not always. Weird stuff happening, pff. This should not be a problem when you have full control over your mods, but will be a problem in other situations. Bummer.

As a side effect of this I saw it should be possible to borrow sprites from your neighbour mod as well. So if you have two 1024x1024 mods then you should be able to define a sprite from the second mods sprites.png in the first mods materials.txt if you just find the exact x/y coordinate for it. To make that somewhat easier, define an object of width/height 8x8 or bigger and mess around with the x/y values. Soon you will recognize an area you just hit when you lay that sprite down on the open field, and when you look it up in the mentioned png files you can calculate the positions you want to use.