seattlewil
Well-known member
- Joined
- Dec 27, 2010
- Messages
- 616
- Thread Author
- #1
Yesterday I decided to refresh myself on the little Python I actually knew, and while doing so, I happened upon Applescript for the first time.
For those of you who don't know, Applescript is a programing language created by Apple for the purpose of automating tasks. While I was messing around with the basic functions I thought of a feature that I thought would be useful to have on my computer for Minecraft.
To any of you guys with any basic background in Applescript, it may sound like a very simple project. But, rest assured, it took me a great deal of time (mostly because the little java I know managed to screw me over multiple times). My goal was to create a program that would allow me to have two .jar files (one saved in the bin of the minecraft folder and one saved in a "storage" folder), and to let me switch between them seamlessly with one simple click. In other words, easy switching during rollbacks/modded jar files.
Fast foward to 12:30 in the morning, and here's what I'd come up with...
For any of those of you on Macs (sorry everyone else), feel free to pop this into your Applescript Editor program and give it a try (keep in mind, you will have to change the pathways to your minecraft folder and you'll have to create the other folders I reference in the script).
Ultimately, this was less of a "I want to be able to switch jars with one button" (because really, switching jars is fairly easy), I just wanted to learn some Applescript and this was my excuse.
If you stuck with me this whole post, thanks, and I hope you found this either useful or entertaining (everyone loves watching people struggle right?)!
For those of you who don't know, Applescript is a programing language created by Apple for the purpose of automating tasks. While I was messing around with the basic functions I thought of a feature that I thought would be useful to have on my computer for Minecraft.
To any of you guys with any basic background in Applescript, it may sound like a very simple project. But, rest assured, it took me a great deal of time (mostly because the little java I know managed to screw me over multiple times). My goal was to create a program that would allow me to have two .jar files (one saved in the bin of the minecraft folder and one saved in a "storage" folder), and to let me switch between them seamlessly with one simple click. In other words, easy switching during rollbacks/modded jar files.
Fast foward to 12:30 in the morning, and here's what I'd come up with...
Code:
tell application "Finder"
activate
set jarOLD to file "minecraft.jar" of folder "bin" of folder "minecraft" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
set jar2 to file "minecraft.jar" of folder "jar2" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
set tempbin to file "minecraft.jar" of folder "tempbin" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
set jarOLDf to folder "bin" of folder "minecraft" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
set jar2f to folder "jar2" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
set tempbinf to folder "tempbin" of folder "jar switching script folder" of folder "Application Support" of folder "Library" of folder "username" of folder "Users" of startup disk
duplicate jarOLD to tempbinf with replacing
duplicate jar2 to jarOLDf with replacing
duplicate tempbin to jar2f with replacing
end tell
tell application "Finder"
display dialog "Jar files have been switched." buttons "OK" default button "OK"
end tell
For any of those of you on Macs (sorry everyone else), feel free to pop this into your Applescript Editor program and give it a try (keep in mind, you will have to change the pathways to your minecraft folder and you'll have to create the other folders I reference in the script).
Ultimately, this was less of a "I want to be able to switch jars with one button" (because really, switching jars is fairly easy), I just wanted to learn some Applescript and this was my excuse.
If you stuck with me this whole post, thanks, and I hope you found this either useful or entertaining (everyone loves watching people struggle right?)!