Tuesday, November 4, 2014

Building a better plugin

I've removed the older script files, and replaced it with this one:

TLX.py

It's going to be my dumping ground for all helpful scripts I write for kitbashing TLX stuff. It creates a top level TLX menu, under which there are currently three options:

Apply edges around hallway tiles
Apply edges around six inch tiles
Create anchors for hallway tiles
Create anchors for six inch tiles

It assumes you have layers like this:

 + Anchors
     . Annotated Tile Textures
 + 6" Tiles
     . Anchor Spots - 6" Tile
     . Template - 6" Tile
     . 6" Tile 1
     . 6" Tile 2
     . 6" Tile 3
     . ...
 + Hall Tiles
     + Anchor Spots - Hall Tile
     . Template - Hall Tile
     . Hall Tile 1
     . Hall Tile 2
     . Hall Tile 3
     . ...
 . Kitbash Base

The key is that there are groups that meet those names. If you don't, you won't be able to run the scripts that work on them. If you only have 6" tiles, you don't need Hall Tiles, but you should have Anchors. If you only have Hall Tiles, there's no need for Anchors or 6" Tiles. Make sense? The names of the layers is important, too. They look for layers that start with '6" Tile ' to identify those layers as ones to add edges to or make anchors from.

Update: I'm so close! I've got the 3" tile anchors and edges working themselves out, and I've got maybe 30% of the script for rotating and moving the tiles into position on the templates. I wrote some helper commands to make working with guides easier. I think the next step is to make some templates for the templates... That is, make a file that has all of the layers in place so that people would know where to put their graphics. What they won't have are the TLX lines on them.

It took a while for me to get my head around how to reload scripts (I seem to have to remove the .py file, restart GIMP, then re-add the .py file and restart GIMP for the new plugins to show up!), and how it behaves when I have errors in my script.

If you want to try this out, you copy the .py file into your plugins directory in GIMP. To figure out where this directory is, go into GIMP and select Edit > Preferences > Folders > Plug-Ins. For me, on Windows 7, I put it in c:\Users\Mike\.gimp-2.8\plug-ins

I have a lot to learn about python programming. I will continue to make the code cleaner and more reusable (it's not hard to see where refactoring could occur), and I'll continue to add features.

1 comment:

  1. Just used your scripts to
    - add edges around tiles
    - create the anchors
    - rotate the 3" tiles

    It's like magic !!

    ReplyDelete