smooth-landing

Jump to content

  • Log In with Google Log In with Steam      Sign In   
  • Create Account

Photo
- - - - -

Updating your mod for "Powers" release


  • Please log in to reply
38 replies to this topic

#1 Ipsquiggle

    Ipsquiggle
  • Entropy Wrangler


  • 457 posts

Posted 02 July 2013 - 12:35 PM

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:
               inst.components.container.widgetbgatlas = "path/to/atlas.xml"        inst.components.container.widgetbgimage = "image.tex" -- the image defined in the atlas
      Recipe and ingredient atlas code:
         local myingredient = GLOBAL.Ingredient( "mythingie", 1)  myingredient.atlas = "images/inventoryimages/mythingieatlas.xml" -- has 'mythingie.tex' specified inside it.  local myrecipe = GLOBAL.Recipe( "myprefab", { myingredient, Ingredient("slurtleslime", 10) }, RECIPETABS.TOWN, 2)  myrecipe.atlas = "images/inventoryimages/myprefabatlas.xml" -- has 'myprefab.tex' specified inside it.
      Inventory item code:
       inst:AddComponent("inventoryitem")inst.components.inventoryitem.atlasname = "images/inventoryimages/myitematlas.xml"
      Crafting tab code:
       GLOBAL.RECIPETABS['MYTAB'] = {str = STRINGS.TABS.MYTAB, sort=8, icon = "myicon.tex", icon_atlas = "mods/mymod/inventoryimages/myicon.xml"}
      Worldgen code sample:
       GLOBAL.require("map/levels")-- find an existing preset:local darknes = nilfor k,level in ipairs(GLOBAL.levels.sandbox_levels) do   if level.id == "COMPLETE_DARKNESS" then        darkness = level        break   endend-- do some kind of modification, like adding a new tasktable.insert(darkness.tasks, "Guarded For a nice walk")-- add a new preset:local my_preset = GLOBAL.Level({   id = "MY_PRESET",   name = "My lovely preset!",   tasks = {             "Make a pick",             "Easy Blocked Dig that rock",             "Great Plains",             "Guarded Speak to the king",   },   overrides = {},})table.insert(GLOBAL.levels.sandbox_levels, my_preset)
      There has also been lots of discussion in the testing forum so you may want to peek there as well.

      Edited by Ipsquiggle, 04 July 2013 - 07:35 AM.


#2 Ipsquiggle

    Ipsquiggle
  • Entropy Wrangler


  • 457 posts

Posted 02 July 2013 - 12:43 PM

[MENTION=15605]futaradragon[/MENTION] and others: The bit for crafting tab customization is included in the top post now. Let me know if that works for you!

#3 zeidrich

    zeidrich
  • Senior Member


  • 304 posts

Posted 02 July 2013 - 02:32 PM

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.

#4 tehMugwump

    tehMugwump
  • Handsome!



  • 1857 posts

Posted 02 July 2013 - 02:40 PM

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.



#5 futaradragon

    futaradragon
  • Senior Member



  • 178 posts

Posted 02 July 2013 - 08:09 PM

[MENTION=15605]futaradragon[/MENTION] and others: The bit for crafting tab customization is included in the top post now. Let me know if that works for you!

Oh Thankyou ><

#6 Heavenfall

    Heavenfall
  • Senior Member



  • 1065 posts

Posted 02 July 2013 - 10:34 PM

My mods will be updated as soon as I return home, hopefully this weekend.
Please quote my post or include @Heavenfall in your post if you are replying to me, it helps me see your reply.
 
My mods

#7 tehMugwump

    tehMugwump
  • Handsome!



  • 1857 posts

Posted 03 July 2013 - 08:50 AM

[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!

#8 zeidrich

    zeidrich
  • Senior Member


  • 304 posts

Posted 03 July 2013 - 10:50 AM

I'm making a set of utilities as interstitial assistance until the new asset definitions system comes in.Basically, it will work like:in modmain.lua:
 modimport("zutil.lua")RegisterPrefab("prefabname", "imagepath.tex", "atlaspath.xml")AddPrefabAnim("prefabname", "animpath.zip")AddRecipe("prefabname", ingredients, tab, tech)
Then in your prefabname.lua you'd have:
 local assets = GetPrefabAssets("prefabname")...inst.components.inventoryimage.atlasname = PrefabAssets["prefabname"].atlas...
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.

#9 tehMugwump

    tehMugwump
  • Handsome!



  • 1857 posts

Posted 03 July 2013 - 11:21 AM

Great idea, [MENTION=38597]zeidrich[/MENTION], except of course we know nothing will ever change again... :cower:

I'm making a set of utilities as interstitial assistance until the new asset definitions system comes in.Basically, it will work like:in modmain.lua:

 modimport("zutil.lua")RegisterPrefab("prefabname", "imagepath.tex", "atlaspath.xml")AddPrefabAnim("prefabname", "animpath.zip")AddRecipe("prefabname", ingredients, tab, tech)
Then in your prefabname.lua you'd have:
 local assets = GetPrefabAssets("prefabname")...inst.components.inventoryimage.atlasname = PrefabAssets["prefabname"].atlas...
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.



#10 ral365

    ral365
  • Senior Member

  • 217 posts

Posted 03 July 2013 - 03:58 PM

Aww, no powers for Wilson? :<

#11 zeidrich

    zeidrich
  • Senior Member


  • 304 posts

Posted 03 July 2013 - 10:05 PM

I'm releasing a version of my atlas tool that's barely functional for human consumption.

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.

Attached File  atlasgenerator-alpha.zip   98.41KB   23 downloads

Attached Files



#12 Siaynoq

    Siaynoq
  • Junior Member

  • 1 posts

Posted 04 July 2013 - 12:33 AM

Max Stacks crashes my game now. BOooooo!

#13 gamer.toukotsu

    gamer.toukotsu
  • Senior Member

  • 202 posts

Posted 04 July 2013 - 06:22 AM

I'm releasing a version of my atlas tool that's barely functional for human consumption.

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.

[ATTACH=CONFIG]10837[/ATTACH][ATTACH]10838[/ATTACH]

While it is very buggy it is extremely useful, thanks for the upload.

#14 tehMugwump

    tehMugwump
  • Handsome!



  • 1857 posts

Posted 04 July 2013 - 06:51 AM

[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?)

Edited by tehMugwump, 04 July 2013 - 07:03 AM.


#15 tehMugwump

    tehMugwump
  • Handsome!



  • 1857 posts

Posted 04 July 2013 - 06:52 AM

Max Stacks crashes my game now. BOooooo!

Read Please >>

#16 Ipsquiggle

    Ipsquiggle
  • Entropy Wrangler


  • 457 posts

Posted 04 July 2013 - 07:29 AM

@Ipsquiggle, 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?)

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.

#17 zeidrich

    zeidrich
  • Senior Member


  • 304 posts

Posted 04 July 2013 - 07:30 AM

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.

#18 Ipsquiggle

    Ipsquiggle
  • Entropy Wrangler


  • 457 posts

Posted 04 July 2013 - 07:33 AM

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?)

#19 Ipsquiggle

    Ipsquiggle
  • Entropy Wrangler


  • 457 posts

Posted 04 July 2013 - 07:52 AM

@Ipsquiggle, 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?)

And re: modsettings. Errf, I'll make that stop crashing.

#20 tehMugwump

    tehMugwump
  • Handsome!



  • 1857 posts

Posted 04 July 2013 - 08:09 AM

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.

Edited by tehMugwump, 04 July 2013 - 08:28 AM.