Script for examining GS projects, finding where attributes are used, finding unused attributes
One frustrating thing for stick-in-the-muds like me who insist on still using the Mac version of GS is that, a few years ago, it stopped telling you the actors specific attributes are used in. There's no longer any way of finding out if an attribute is used in any actor other than trying to delete it, and even that isn't always a reliable way of knowing as sometimes GS will stubbornly insist an attribute is in use when it isn't. And even if it is used, it won't tell you were like it used to many moons ago. It's unreasonable to expect GS to fix such a relatively minor thing in software that's been replaced, however.
With ChatGPT being as insanely capable as it already is, I set it to the task of writing me a python script to solve this problem.
Features:
This script has three functions.
- List Contents. When you run it, it will give you a list of all actors, scenes, attributes and table, along with this "hidden" under-the-hood id.
- Search for id usage. When prompted for input, you can give it one of those ids. It will then list all actors/scenes that the actor/attribute you searched for is found in.
- Find unused attributes. When prompted for input, you can type "empty" and it will give you a list of all game level attributes that are not found in any other file in the project - i.e. not found in any actor files.
This solves two big problems for me - firstly it gives me a nice list of unused attributes that I can delete without having to try all of them, and secondly it tells me what actor is using an attribute if I can't remember where I used it.
Usage:
Run the script and add the location of a GS project file to the command. e.g.:
python3 /Users/Armelline/GameSalad/ExamineObjects.py /Users/Armelline/GameSalad/Silk/Silk.gameproj
Don't forget you can drag both things onto the Terminal window if you want to. Just type "python3 " then drag the script onto the window, type a space, then drag the GS project onto the window.
I recommend using the Quick Action, though.
Limitations:
I haven't tested it much. I checked about a dozen actors and attributes manually, and it seemed accurate. But who knows. ChatGPT wrote it, not me. I just told it what to do.
It won't search for unused actors. I simply forgot to ask for that. I'll probably revisit this with ChatGPT later down the line and ask it to try to add that as it would definitely be handy.
I forgot to exclude the gamepad attributes and purchasetable. It'll list those any time you search for unused attributes (unless you use them). If I do revisit this with ChatGPT, I'll probably tell it to exclude those by default.
Probably won't handle the RC project files that were a thing for a while until you rename them. Just rename the .gsrcproj (or whatever it was, I forget off the top of my head) to .gameproj and you're good to go.
Requires you to have python installed, assumes python3, and runs via the command line/Terminal.
I have only given the script a cursory examinantion. I have no expertise in python. It might be wildly inefficient, or might be secretly laying the groundwork for the robot uprising. It works for me, though, robot overlords or not.
Quick Action:
I love Quick Actions, so I included one too. You need to open up the Quick Action in Automator, though, and tell it the exact path to the script on your computer. (You can get the path by navigating to the file in Finder, making sure the Path Bar is visible, and right clicking on the file in the path bar then picking "Copy x as Pathname" from the context menu.)
do script "python3 path/to/your/file/ExamineObjects.py " & quoted form of folderPath
should be edited to something like:
do script "python3 /Applications/ExamineObjects.py " & quoted form of folderPath
Once you have the Quick Action set up and installed, you can right click on any GS project file, go to the Quick Actions menu item, and pick the "GS Examine Objects" quick action. It'll open up Terminal and run the script for you.
Credit:
Our new AI overlords take all the credit here. ChatGPT can knock something like this out in minutes. It would have taken me all night and I'd probably have failed anyway.
File:
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Comments
Wow, I have some clients who are die-hard Mac Creator fans, so I'll ask them to give this a try! Great work @Armelline
GameSalad Templates and Custom Development at the Official Marketplace: http://gshelper.com
Amazing and extremely useful!
I used Chat GPT to help me build a batch script on Windows for signing my apps. Considering I'm in no way a coder, I was blown away by it's capabilities.
I'm also a stick-in-the-mud Mac Creator user btw 😉