Author Topic: Frogger3140's AppleScript Stuff  (Read 1263 times)

Frogger3140's Pastebin: http://frogger3140.pastebin.com/archive_subdomain.php?p=1

Blockland CrashHelper
Use to restart dedicated servers on crash
Code: (AppleScript) [Select]
(*
PLEASE make sure your blockland folder is renamed to "Blockland" and it isn't named "Blockland v19"

Tested on Snow Leopard only.
*)
repeat
set kakez to ({"Blockland crash on ", (current date)} as string)
tell application "System Events" to (name of processes) contains "Blockland"
if the result is false then
do shell script "open /Applications/Blockland/dedicated.command"
beep 1 --Get attention
say kakez
end if
delay 1
end repeat
Maximum Exponent
Used to test the maximum square on Mac OS X
Code: (AppleScript) [Select]
set x to 0
repeat
try
log "Calculating 2^" & x & ": " & (2 ^ x)
set x to x + 1
on error number -2702
beep 1
display dialog "This computer can't handle the calculation 2^" & x with icon stop buttons {"End Test"} default button 1
exit repeat
end try
end repeat
BLName v3
Get a random blockland name(with the option for numbers for those dumb kids)
Code: (AppleScript) [Select]
-- Variables
set numbersInBLName to false -- boolean (set to true or false)
set digitsInBLName to 2 -- positive integer (set this to any number that is not decimal or negative)

-- The Script
set BLNamePart1 to {"Constant", "Crystallized", "Abstract", "Dynamic", "Firey", "Icy", "Cool", "Unique", "Blurred"}
set BLNamePart2 to {"Gamma", "Ice", "Fire", "Aspect", "Day", "Night", "Error", "Flight", "Failure", "Approach"}
set yourName to some item of BLNamePart1
set yourName to (yourName & some item of BLNamePart2)
if yourName is equal to "IcyGamma" then
say "It's not possible!"
display dialog (1 / 0)
end if
if numbersInBLName then
if (digitsInBLName ≤ 0 or digitsInBLName ≥ 9) then
beep 1
display dialog "Variable digitsInBLName has to be a positive integer between 1-8." buttons {"OK"} with icon 2 with title "Script Error" default button 1
return
end if
set yourName to (yourName & (round (random number (10 ^ digitsInBLName) to (10 ^ (digitsInBLName + 1) - 1)) rounding to nearest))
end if
tell application "TextEdit"
activate
make new document at the beginning of documents
set text of document 1 to yourName as text
end tell
tell application "System Events" to tell process "TextEdit"
if menu item "Make Plain Text" of menu 1 of menu bar item "Format" of menu bar 1 exists then
keystroke "t" using {shift down, command down}
keystroke return
end if
end tell
activate
display dialog "Your name has been randomized: " & yourName & ". You can copy and paste this into Blockland." buttons {"OK"} default button 1
tell application "TextEdit" to activate
Cake
You, sir, deserve 45 cakes!
Code: (AppleScript) [Select]
set cakes to (random number from 10 to 99)
say "You , sir, deserve " & cakes & " cakes!"
display dialog "You , sir, deserve " & cakes & " cakes!"
« Last Edit: February 24, 2011, 09:50:12 PM by frogger3140 »

I DON'T UNDERSTAND. D:


Make one that locates the Leopard Intro video and sound and copies it to the desktop.

Make one that locates the Leopard Intro video and sound and copies it to the desktop.
I'm trying to do that but it gives me errors.

Speaking of errors, setting digitsInBLName to 10 gave me this: FireyFailure-6.47030398E+8
« Last Edit: February 14, 2011, 12:06:26 PM by frogger3140 »

The FireyFailure-6.47030398E+8 bug is fixed, just had to put in number restrictions.

EDIT: Forgot to activate textedit after the dialog.

EDIT2: Who has found the division by 0?
« Last Edit: February 14, 2011, 12:36:38 PM by frogger3140 »

Olol, I miss messing around with Applescript. Fake virus error applications were my favorite to create. I would send them to friends who owned Macs, disguising them as "funny internet videos." Hilarity ensued.

Olol, I miss messing around with Applescript. Fake virus error applications were my favorite to create. I would send them to friends who owned Macs, disguising them as "funny internet videos." Hilarity ensued.
I made a trick Blockland CrashHelper(not on OP) for the lulz. It launched 5 applications, opened an ear rape, and opened kiprolled. If you launched Console or Activity Monitor, it would quit Console/Activity Monitor and open kiproll again.

I don't want to use it on my friends.
« Last Edit: February 17, 2011, 09:50:01 AM by frogger3140 »

Make an Windows Version of Blockland CrashHelper


Made a Python version of "Get a random blockland name":
Code: (Python) [Select]
#!/usr/bin/python
import random

numbers = raw_input("Put numbers at end of name? [y/n]: ")
if numbers is "y":
    numbers = True
    while True:
        digits = int(raw_input(" > How many digits should be appended to the name? [number 1-10]: "))
        if digits < 1 or digits > 10:
            print "    > Out of bounds (1-10)."
        else:
            break
else:
    numbers = False

part0 = ['Constant', 'Crystallized', 'Abstract', 'Dynamic', 'Firey', 'Icy', 'Cool', 'Unique', 'Blurred']
part1 = ['Gamma', 'Ice', 'Fire', 'Aspect', 'Day', 'Night', 'Error', 'Flight', 'Failure', 'Approach']

name = part0[int(random.random() * len(part0))] + part1[int(random.random() * len(part1))]
if numbers:
    for digit in xrange(digits):
        name = name + str(int(random.random() * 9))

print name
EDIT: Made version that can create multiple names at the same time cause I'm bored.
Code: (Python) [Select]
#!/usr/bin/python
import random

numbers = raw_input("Put numbers at end of name? [y/n]: ")
if numbers is "y":
    numbers = True
    while True:
        digits = int(raw_input(" > How many digits should be appended to the name? [number 1-10]: "))
        if digits < 1 or digits > 10:
            print "    > Out of bounds (1-10)."
        else:
            break
else:
    numbers = False

while True:
    count = int(raw_input("How many names should be generated? [number 1-inf]: "))
    if count < 1:
        print " > Out of bounds (1-inf)."
    else:
        break

part0 = ['Constant', 'Crystallized', 'Abstract', 'Dynamic', 'Firey', 'Icy', 'Cool', 'Unique', 'Blurred']
part1 = ['Gamma', 'Ice', 'Fire', 'Aspect', 'Day', 'Night', 'Error', 'Flight', 'Failure', 'Approach']

for i in xrange(count):
    name = part0[int(random.random() * len(part0))] + part1[int(random.random() * len(part1))]
    if numbers:
        for digit in xrange(digits):
            name = name + str(int(random.random() * 9))
   
    print name
« Last Edit: February 26, 2011, 01:23:46 PM by Bauklotz »

wow i'm bored.
Python version of cakes script:
Code: (Python) [Select]
#!/usr/bin/python
import random
print "You, sir, deserve", int((random.random() * 99) + 10), "cakes!"