Posted 08 January 2013 - 04:25 PM
Requires that you have access to a PHP web server
This programs allow you to use a web interface to interact with you computer or turtle. This is just a very basic programe where the server sent the computer/turtle a program and the computer/turtle (if the program supports it) will send back status updates of what it is doing.
Download server code here: http://www.lozengia....mote_server.rar
Interface on Default web host: http://www.lozengia..../test/input.php
Note about Default host:(nothing will happen in the log unless at least one person out there is running the program as defult.)
Computer/turtal code
(change dir to the directory on the server you uploaded the server code too. (unless you want my public example controlling you stuff.)
To Do
-Fix log so it auto refreshes.
-Add server ip and computer/turtle id to the output it sends to the server.
-Add some form of arguments.
Considering but not sure about.
-Add all default turtle programs. (In Progress?)
old versions
V 0.2 server
V 0.1
The idea is that to sent command all you have to do is upload a file with the command
You have to change dir to a file on a server you have access to.
getOutput.php for the server.
Back up all 'input' files if you don't want to type it out aging.
*only tested on single-player, use caution early beta.
This programs allow you to use a web interface to interact with you computer or turtle. This is just a very basic programe where the server sent the computer/turtle a program and the computer/turtle (if the program supports it) will send back status updates of what it is doing.
Download server code here: http://www.lozengia....mote_server.rar
Interface on Default web host: http://www.lozengia..../test/input.php
Note about Default host:(nothing will happen in the log unless at least one person out there is running the program as defult.)
Computer/turtal code
(change dir to the directory on the server you uploaded the server code too. (unless you want my public example controlling you stuff.)
local function sendOutput( text )
local response = http.get(output .. "?output=" .. textutils.urlEncode(text))
print("Connecting to http for output.")
if response then
-- if page is reseved
if response then
print("Sending output.")
local sResponse = response.readAll()
response.close()
end
end
end
dir = "http://www.lozengia.com/tmas/Downloads/Minecraft/test/"
input = dir .. "input.txt"
output = dir .. "getOutput.php"
while true do
print("Connecting to http")
local response = http.get(input)
if response then
print("Page found attepting to download.")
-- if page is reseved
while response do
local sResponse = response.readAll()
response.close()
cache = shell.resolve( "temp" )
local file = fs.open( cache, "w" )
file.write( sResponse )
file.close()
response = nil
print("Running input from http.")
shell.run( "temp" )
end
text = "Finished Running Code."
sendOutput("Finished Running Code.")
else
print("Page not found.")
end
print("Yileding befor loop.")
os.sleep( 5 )
shell.run( "clear" )
end
To Do
Spoiler
-Add buttons for easier basic movement control (In Progress)-Fix log so it auto refreshes.
-Add server ip and computer/turtle id to the output it sends to the server.
-Add some form of arguments.
Considering but not sure about.
-Add all default turtle programs. (In Progress?)
old versions
V 0.2 server
V 0.1
Spoiler
As of right now the way it works is you set dir to the url of the directory you place the files in. The computer/turtle will check the directory for an file named 'input' and then download it and run it. It could be a full program or just shell.run( "program name here"). Then it sent a get string to getOutput.php witch then saves $_GET['output'] to a file with a time stamp and then delete the input file to prevent the program from just running it in a loop. This process starts over.The idea is that to sent command all you have to do is upload a file with the command
You have to change dir to a file on a server you have access to.
dir = "your url here"
input = dir .. "input"
output = dir .. "getOutput.php"
while true do
print("Connecting to http")
local response = http.get(input)
if response then
print("Page found attepting to download.")
-- if page is reseved
while response do
local sResponse = response.readAll()
response.close()
cache = shell.resolve( "temp" )
local file = fs.open( cache, "w" )
file.write( sResponse )
file.close()
response = nil
print("Running input from http.")
shell.run( "temp" )
end
local response = http.get(output .. "?output=" .. textutils.urlEncode("Finished Running Code."))
print("Connecting to http for output.")
if response then
-- if page is reseved
if response then
print("Sending output.")
local sResponse = response.readAll()
response.close()
end
end
else
print("Page not found.")
end
print("Yileding befor loop.")
os.sleep( 5 )
shell.run( "clear" )
end
getOutput.php for the server.
<?
$filename = "log.txt";
if (isset($_GET['output'])){
$theOutput = urlEncode(date("Y-m-d")) . ' ' . date("H:i:s", time()) . ' ' . $_GET['output'] . '
';
$handle = fopen($filename, 'a');
if(!$handle){
echo "Error, Could not open log file!!!";
} else if(!fwrite($handle,stripslashes($theOutput))) {
echo "Error, Could not save log to file!!!";
} else {
fclose($handle);
unlink('input.txt');
}
}
?>
Back up all 'input' files if you don't want to type it out aging.
*only tested on single-player, use caution early beta.