furbyq: a unicorn saying "yeah" in a cartoony speech bubble. (Default)
[personal profile] furbyq
(Warning: Super Image Heavy!)

Part 03: Recoloring Your Texture(s).
(Previous Parts)
Part 02: Exporting Your Packages!

Things That Are Needed for This Section.
  • Photoshop CS2 or higher; basically, a program that will run actions. If you want to forego the recoloring process, everything else can be done without Photoshop.
  • Sikuli IDE 1.0.1. 1.1.0 will not work for this.
  • Your favorite color actions. You can customize this method to use any number and any combination of them.
  • Pooklet's "SimPE Import Method" Action. Found in their Collector's Edition (Extraneous Actions).

So now we move on to the most fiddly part of this tutorial; the Photoshop recoloring. With enough patience and ingenuity, you can use Sikuli IDE to run a script that will open a retexture, run a color action, apply the alpha to the recolor, and save the new file under a new name. It's all about breaking it down into easy-to-understand sections.

First, you need your retexture, and you need it in Volatile OR whichever base color your actions run over. Sometimes this may be Time Bomb or something completely outside of Project Mayhem. Doesn't matter; you can still make it work. You will also need an alpha.

Open both of your files in Photoshop simultaneously.

With the retexture active, hit "Save As". Now you will need to create a directory for your hair files, preferably in Documents. I keep mine in something like Documents > Sims 2 Creations > Super Hair Retexturing. Do not subfolder this retexture or the alpha; you can sort them out when you're done with them.

Save your hair retexture file under a descriptive generic title like "basevolatile" and then the hair name. Hence "basevolatile-colorofwind". Save it as a png, not a bmp.

Now you can close your saved retexture and focus on the alpha.

Again, you need to save it under a really generic name. This time, do not put the hair name on the end of it. Keep it with the retexture so that you can tell which hair it's for.

Now the next part may be tricky if you have no prior experience with Photoshop actions, but it is necessary if you want to do the automating thing. You need to build a simple action that will open the alpha, select it, copy it, and paste it onto the active document. This is easier to do than it sounds.

Open the retexture you just saved. Locate your actions window. If you want to create a new folder to house the new action, hit the folder icon (circled in green) and give your new folder a name. Then hit the page-turning icon (circled in pink) to start a new action and give it a descriptive name like "copy to alpha". As soon as you create the action, it will start recording all of your commands in Photoshop, so take care with what you click on.

With the action recording and your retexture open, open your alpha file.

With the alpha as the active window, press ctrl + a. This will select the entire active document. With it selected, press ctrl + c to copy it. Click on the retexture and hit ctrl + v.

This will paste the alpha onto the retexture. The final thing you need to do before stopping the recording is click on the Background layer. Then hit the little stop button on the bottom of the action window.

You should end up with an action that looks like this; open alpha, select alpha, copy alpha, select retexture, paste alpha, select background layer. If it looks okay you can go ahead and close the retexture and alpha again. Do not save any changes to the retexture or alpha.

Now open Sikuli IDE. Go to File > New so that you get a new "untitled" tab.

Make sure that Photoshop isn't minimized. Under mouse actions, hit the "click" button.

When the screen dims, draw a rectangle around the "File" button on Photoshop using your mouse.

On Sikuli IDE, hit the click button again. This time, be really quick and hit the File button before the screen dims.

Draw a rectangle around the Open... option. If you aren't fast enough and the Open button doesn't show up, just double click on the screen. You'll end up with a "click" command on your Sikuli IDE script that has a little camera icon next to it. Just click the camera icon to redo your image capture.

Your Sikuli IDE script should look like this. If it doesn't, redo. If it does, go ahead and click File > Open... so that the file explorer pops up. If it doesn't open the folder that your retexture and alpha are in, you'll need to navigate to that folder.

Make sure you sort by "list" so that your files appear like this. This allows more of them to be visible on screen at a time.

Go to Sikuli IDE, hit doubleClick. Draw a rectangle around the "basevolatile" part of your retexture. You should end up with the retexture being the only document open in your Photoshop.

Now, before you continue with your script, you need to make sure that your actions window is setup in an accessible manner. You need all of the actions you plan to run visible at the same time. I tend to keep my colors actions at the top, sorted by naturals and unnaturals with grays at the bottom. Then, underneath your color actions, you should have your "copy to alpha" action and Pooklet's "SimPE import hair method" action (found in their "extraneous actions").

For the purposes of my tutorial I will be specifically using the colors that I currently use, but you can substitute the ones you use if you make sure they're named clearly. The full color name needs to be visible on your action window for the best results.

With your retexture still open, go to Sikuli IDE and hit click. Draw a rectangle around the name of your color action, which is Land Mine in this example. (Only draw it around the color name; not the "black1" or "(natural black)".

Note: Make sure that when you capture text from the action window, none of it is currently highlighted (like "Default Actions" is on the image above.)

Then go back to Sikuli IDE and hit click yet again, this time drawing a rectangle around the "play" button on the bottom of the actions window. After this, on the next line of your Sikuli IDE script, put the command "wait(4)".

Your script should look like this. Color action run time varies quite a bit, but putting the "wait(4)" command in seems to be enough for most of the longer color actions. Actions like Pooklet's Fluorophore and my Interstellar may take longer because they are really long actions.

Hit click on Sikuli IDE again and draw a rectangle around your "copy to alpha" action.

Copy line 5 to line 8. This should be the click(playbutton) command.

Afterwards, put in another click command and draw a rectangle around "SimPE import hair method".

Copy line 5 or 8 to line 10.

Your entire script should look like this.

On your Sikuli IDE script, copy line 1 to line 11 so that "click (File)" is on your script twice.

Now go back to Photoshop and select your recolored texture. Of course, whether or not you've actually recolored it doesn't really matter; you just have to have a placeholder for the script. For this next part, you're going to have to ninja click File right after you hit click again.

So that you can capture the "Save As..." command.

Right after this, go to your script and put the command "type("_01-landmine") at the end. You don't have to put exactly the same thing, of course. I typically number all of the hair colors I use so that when I sort by alphabetical, they're in the right order. You have to put the text inside quotations marks inside parentheses. Also, Sikuli IDE will sometimes skip the first character of your text unless you put an underscore before it, so don't forget that or you'll get "1-landmine" in your text box.

When you run the script, the script will automatically type whatever you put in the command above, assuming everything is right. But before you test your script, you need to finish saving your recolor.

Hit click and draw a rectangle around the "Save" Button. Sikuli IDE tends to not confuse the Save and Cancel buttons since the Save button is outlined in blue.

When you actually click save, this box will pop up, so you will have to tell Sikuli IDE to click the OK button. After this, put a wait(2) command on the next line.

After that, copy either line 1 or 11 again so that line 17 is another click(File) command.

Put in another click command and ninja click File again.

This time, draw a rectangle around "Close All".

When you actually click the "Close All" button, Photoshop will ask you if you want to save the changes to retexture and the document that is made when you use the "SimPE import hair method" action. Of course, you don't, so make a new click command and draw a rectangle around "No".

Then put in a wait(1) command on line 20 and copy line 19 to line 21.

The entirety of your script should look like this. Now you should take the time to test it. If you actually saved a file called 01-landmine or the equivalent to your folder, you need to delete that before you run this test.

Mild troubleshooting section for this section of the script:
  • Problem: The script hits Open As.../Save/Close instead of Open/Save As.../Close All.
  • Solution: Replace the images in those command lines with selections that include part of the choices above and below the one you're trying to hit. I don't know why but sometimes this script will work for a long time without needing to expand your capture, but sometimes it'll just break.
Basically select this area. Instead of this.

  • Problem: It stops after "SimPE import hair method" because of a dialogue box.
  • Solution: Before running your action, go to your actions window. On the left side of the SimPE import hair method action, there should be a check mark, and to the right of the check mark, there might be a little box with an ellipsis in it. Click on that box so that the ellipsis disappears and that dialogue box will not come up again. If it doesn't work with one click, try double clicking.
So if you've managed to make a script that will recolor your texture in landmine or whatever other color, then apply the alpha, then save and name the file, you've done most of the scripting work. The rest is a little tedious but a lot simpler.

What I typically do is put the name of the color action at the top now, so that you can tell which one this section of the script runs. Also, I put a line of hashtags/pound signs at the bottom to separate it from the part after it. Make sure to put at least one hashtag/pound sign before your color action name, otherwise Sikuli IDE will read it as a command.

Then copy the entirety of your script so far and paste it 1 time for each color action you plan to run. I'm in the process of revamping my spectrum, but at the current moment, I use 26 colors, so I will paste it 25 times. In my case, the script will expand to over 600 lines, but this shouldn't be a problem. If you're hesitant to run such a long script, you can separate the script into multiple scripts that can be run consecutively.

Back near the beginning of the script, I change the first copy's (not the original) header to read "FISSION", which is the second natural color I use.

Then highlight the part that says "click(landmine)".

Then hit the click button again.

This time, I draw a rectangle around "fission" in Photoshop's actions window.

So that the script looks like this.

Then I change type("_01-landmine") to say type("_02-fission") instead.

Change the rest of the script copies to do the rest of the colors you want to use. You only have to change the color action capture and the text it types when saving.

It may not seem that easy, but once you set the script up, barring Sikuli IDE hiccups, it should be able to replicate the recoloring process nearly flawlessly. All you have to do to change which hair texture it recolors is replace "basevolatile-hairname" with another texture called "basevolatile-differenthairname". However, because it relies on an action to do the alpha, the alpha file's name cannot be changed from hair to hair. I'd recommend only doing one hair at a time and putting the texture/alpha for the hairs you finish in a clearly named subfolder to keep track of which hair they go to.