Applescript Loop App

Hey, currently, I’m helping programing a game, and having online support in the strangest ways, but it loads too slow, so I’m going to use a applescript app to make it go faster. So, I’m wondering, could anyone here help me make the app, or possibly make it themselves?

Here is how it will work:

When started, this AS app will run on a continuous loop every fraction of a second. What it will do is read a text file named “varname”. If the text file has anything but “Done” or “Shut off” in it, it will activate some code that I will personally put in. After it accesses that code, it will save a variable from that code into a text file named “vardata”. If the “varname” file says “Done” than it will continue the loop but do nothing. If it says “Shut off” than the applescript file will exit and shut off.

Anyone know how to make it or can help me make it?

Thanks,
-Gandolf

The problem with this is (unless there is a shell script to do this)
When you launch your game text edit will be opened as well which would be somewhat annoying :stuck_out_tongue:

EDIT I lied, you dont have to open text edit, ill work on this for you :smiley:

Something like this should get you started. Save it as a Stay Open application.

Cheers,

Craig


property varname : (path to desktop as Unicode text) & "test.txt"
property vardata : (path to desktop as Unicode text) & "data.txt"

on idle
	--read the file
	set what_to_do to do shell script "cat " & quoted form of POSIX path of varname
	
	--determine what to do
	if (what_to_do is "Done") or (what_to_do is "Shut off") then
		if (what_to_do is "Shut off") then
			quit
		end if
	else
		--put your code here
		--change variable_data
		set variable_data to "Whatever you want the data to be"
		do shell script "echo " & quoted form of variable_data & " > " & quoted form of POSIX path of vardata
	end if
	
	delay 0.1
end idle

on quit
	continue quit
end quit

nice one Craig!

edit: Why is GandolfMatt banned?:expressionless:

Thanks!