Updating your mod for "Powers" release

In case you didn't participate in the excitement in the testing branch, here's what you missed:

Lots of breaking changes for modders, take note! If you run into any problems upgrading your mods, please discuss it here.

[*]In-game mod management and mod info! Now all mods require a modinfo.lua which has lots of cool/important information in it. This will be shown to everyone who installs the mod, and also helps the game know if the mod is out-of-date or has been updated. See one of the sample mods for an example.[*]Atlases! Due to engine changes, all .tex files need to have an accompanying atlas definition in the form of an .xml. This will primarily affect inventory images as well. In many cases, where just a texture was specified the atlas must now also be specified. (See the updated sampleprefab to see how inventory images are handled.)

[*]UI elements need to have their atlases specified as well. (See sample below)[*]Recipes need to have their atlases specified as well. (See sample below)[*]Inventory items need to have their atlases specified. (See sample below)[*]Custom crafting tabs also. (Sample below)[/list][*]inventoryimages path has changed to images/inventoryimages, so all mods with resources and recipes will need to shuffle their assets around.[*]Changed the way modmain is loaded during worldgen, so that it's easier to "inject" presets and other tweaks to the gen process. (See sample below)[*]Priority system for mod loading. In modinfo.lua, specify priority=X where X is how "early" the mod must load. Mods default to 0, higher priorities will load sooner, lower priorities will load later. Use this for 'library' mods which must load early, or mods that depend on other mods which must load late.[/list]UI element atlas code:

Kind of a lazy question, because I could just wait and figure out the answer later, but I'll ask it anyways:When you are declaring assets, do you have to declare them in the prefab or can you just declare them in modmain? I'm not certain because I know the environment of a prefab is different from that in modmain, and the Assets of a prefab is a local table.I'm assuming that you do have to.

I've had them in both and tried pulling them only out of the prefab and things don't work, so they at least have to be in the prefab.

Kind of a lazy question, because I could just wait and figure out the answer later, but I'll ask it anyways:When you are declaring assets, do you have to declare them in the prefab or can you just declare them in modmain? I'm not certain because I know the environment of a prefab is different from that in modmain, and the Assets of a prefab is a local table.I'm assuming that you do have to.

[MENTION=24606]chromiumboy[/MENTION] got me over the hump getting the prefab screen to load on Test Tools. I've re-written a crap-ton of the rest of the mod to get it working and loading backgrounds. Man O man I'm worn out!

Some of this seems maybe as much work as just updating the paths by hand. The purpose though is that so that next time things change, I can just change the behavior in zutil.lua and not have to touch multiple locations in multiple prefab files. I'll post it when it's operational.My atlas composer is functional and this weekend I'll probably tidy it up enough for public consumption and post it. (Along with the source so that I can be ridiculed) If I get really ambitious, I can make it so that any prefab textures or anims that aren't registered show a placeholder or warning image instead of just being blank or crashing.

Some of this seems maybe as much work as just updating the paths by hand. The purpose though is that so that next time things change, I can just change the behavior in zutil.lua and not have to touch multiple locations in multiple prefab files. I'll post it when it's operational.My atlas composer is functional and this weekend I'll probably tidy it up enough for public consumption and post it. (Along with the source so that I can be ridiculed) If I get really ambitious, I can make it so that any prefab textures or anims that aren't registered show a placeholder or warning image instead of just being blank or crashing.

I'm just doing it in this thread because it's still pretty rough around the edges, but I figure maybe if someone else plays with it they can help me find some bugs. I'll probably tidy it up further this weekend and make the source available then.

Features:

Open either a valid .png file, .tex file, or .xml file.

On opening a .png file, the tool will search for a corresponding atlas and tex file when you load and create them if they don't exist. IE: you open a file called bomb.png, it will create a file called bomb.xml which is your atlas, and bomb.tex which is your DS texture.

On opening a .tex file, the tool will search for a corresponding png file and atlas. If the png file doesn't exist, it will create it from the texture. If the atlas doesn't exist, it will create a simple one.

On opening a .xml file, the tool will read the xml file and load the .tex file texture filename indicated in the atlas. If that file doesn't exist it should create a 64x64 bitmap in its place. It will try to load the corresponding .png file, if that doesn't exist, it will create it from the .tex file loaded.

Launch image editor from the program.

You should be able to launch an image editor from the .png pane. It will try to open with whatever program is assigned to the "Edit" option when you right click a .png file.

Save your edited textures back as .tex

When you hit save it will convert the currently loaded png file to tex and save it back.

Edit multiple items in atlas
Add additional lines in the spreadsheet view on the right to define additional texture regions in the atlas. Left click on the image in the .tex pane to set the u1,v1 point. Right click on the image in the .tex pane to set the u2,v2 point. Use the width and height fields to set the size of the regions in pixels. (Ignore the coordinate spinners for now, they're not up to date, I will probably replace them with pixel-based nudging)

Ultimately it can help speed things up a fair bit. For instance, you can open the tool, click save with no data loaded, it will prompt for a name to save under, it will create a new atlas, tex and png file. You can then open the png file draw your image, save it, reload the data, and save the new .tex file. Likewise, you could already have a .png file, you can just open it up, and it will generate corresponding tex and atlas files for it. Or you could have a big atlas with multiple elements.

Big thanks to Handsome Matt for the Klei Studio which I've used for the saving/loading of tex files, also, this is still pretty rough like I said so if you do use it, let it be at your own risk. I don't expect anything horrible could go wrong, but it's still not fully tested.

If anyone does use this and have questions, please PM me rather than muddy up this thread.

I'm just doing it in this thread because it's still pretty rough around the edges, but I figure maybe if someone else plays with it they can help me find some bugs. I'll probably tidy it up further this weekend and make the source available then.

Features:

Open either a valid .png file, .tex file, or .xml file.

On opening a .png file, the tool will search for a corresponding atlas and tex file when you load and create them if they don't exist. IE: you open a file called bomb.png, it will create a file called bomb.xml which is your atlas, and bomb.tex which is your DS texture.

On opening a .tex file, the tool will search for a corresponding png file and atlas. If the png file doesn't exist, it will create it from the texture. If the atlas doesn't exist, it will create a simple one.

On opening a .xml file, the tool will read the xml file and load the .tex file texture filename indicated in the atlas. If that file doesn't exist it should create a 64x64 bitmap in its place. It will try to load the corresponding .png file, if that doesn't exist, it will create it from the .tex file loaded.

Launch image editor from the program.

You should be able to launch an image editor from the .png pane. It will try to open with whatever program is assigned to the "Edit" option when you right click a .png file.

Save your edited textures back as .tex

When you hit save it will convert the currently loaded png file to tex and save it back.

Edit multiple items in atlas
Add additional lines in the spreadsheet view on the right to define additional texture regions in the atlas. Left click on the image in the .tex pane to set the u1,v1 point. Right click on the image in the .tex pane to set the u2,v2 point. Use the width and height fields to set the size of the regions in pixels. (Ignore the coordinate spinners for now, they're not up to date, I will probably replace them with pixel-based nudging)

Ultimately it can help speed things up a fair bit. For instance, you can open the tool, click save with no data loaded, it will prompt for a name to save under, it will create a new atlas, tex and png file. You can then open the png file draw your image, save it, reload the data, and save the new .tex file. Likewise, you could already have a .png file, you can just open it up, and it will generate corresponding tex and atlas files for it. Or you could have a big atlas with multiple elements.

Big thanks to Handsome Matt for the Klei Studio which I've used for the saving/loading of tex files, also, this is still pretty rough like I said so if you do use it, let it be at your own risk. I don't expect anything horrible could go wrong, but it's still not fully tested.

If anyone does use this and have questions, please PM me rather than muddy up this thread.

[MENTION=55]Ipsquiggle[/MENTION], two things:It just occurred to me that we can't order mods now. I was about to suggest to someone to load a particular mod first, but then realized, there's no way to do so. I know there was some mention of this, but is anything in the works?The other thing is we're now telling folks to comment out anything that's in their modsettings.lua file or it will crash the game, but they still need to keep the empty modsettings file. Will this be addressed? (i.e. will modsettings even be needed?)

It just occurred to me that we can't order mods now. I was about to suggest to someone to load a particular mod first, but then realized, there's no way to do so. I know there was some mention of this, but is anything in the works?

The other thing is we're now telling folks to comment out anything that's in their modsettings.lua file or it will crash the game, but they still need to keep the empty modsettings file. Will this be addressed? (i.e. will modsettings even be needed?)

Whoops, forgot to add to the top-post. There is an optional parameter in modinfo.lua, "priority". The higher the priority, the sooner the mod will load. Mods default to 0, so a library mod could choose, say, 10, and if your mod depends on other mods, set it to, say, -10. This isn't a perfect system, but it does let the modder control when their mod loads relative to other mods.

Removed ruminations on priority system based on Ipsquiggles ninja post. [MENTION=53767]gamer.toukotsu[/MENTION] if you do notice bugs, please PM me. I probably know of some of them, it was a bit of a rush-job but I hope to get them mostly out of the way by the weekend.

Also, I forgot to mention in yesterday's hotfix notes!You can now specify atlases for inventory items; see the top post for details.(cc [MENTION=15605]futaradragon[/MENTION], [MENTION=24606]chromiumboy[/MENTION], [MENTION=7686]ArcticFox789[/MENTION]... There were a few others but I can't find the threads, if anyone sees them want to point them here?)

It just occurred to me that we can't order mods now. I was about to suggest to someone to load a particular mod first, but then realized, there's no way to do so. I know there was some mention of this, but is anything in the works?

The other thing is we're now telling folks to comment out anything that's in their modsettings.lua file or it will crash the game, but they still need to keep the empty modsettings file. Will this be addressed? (i.e. will modsettings even be needed?)

Whoops, forgot to add to the top-post. There is an optional parameter in modinfo.lua, "priority". The higher the priority, the sooner the mod will load. Mods default to 0, so a library mod could choose, say, 10, and if your mod depends on other mods, set it to, say, -10. This isn't a perfect system, but it does let the modder control when their mod loads relative to other mods.

[MENTION=55]Ipsquiggle[/MENTION], could this setting possibly re-sort the mods on the mod screen accordingly? There's no way for the user to know what's loading in what order. He may want "CampRes" to load after "RPG HUD", but has no way to check. That would be a good visual for both users and modders to reference.

Users will also need to set their own load order via [priority = 1, 2, 3, etc.] in each modinfo file, if they're seeing conflicts.

Interesting: I've also noticed that 'priority = 1' does not mean the mod loads first. It means it loads last, thus taking priority over the others.