Posted 30 April 2012 - 10:33 PM
I didn't want to copy all my programs onto the turtles in the tekkit server by hand, and there is no way to transfer them to my server other then copying them in. So I made a simple python utility that copies them in place. You just have to run it with the list of files to transfer as a parameters, then select your minecraft game already opened to a computercraft terminal, and it will start typing (after a 5 second delay) and write them all in. Just dont select anything else while it is running (I will have it target a specific window once I can figure out how to do this). It requires libxdo to be installed, just apt-get install libxdo.
#!/usr/bin/python
import time,sys
from ctypes import *
key_press_delay = 5000
editor_wait_delay = 0.2
xdo=cdll.LoadLibrary("libxdo.so.2")
xdo_context=xdo.xdo_new(None)
def typeout(string):
xdo.xdo_type(xdo_context, 0, string, key_press_delay)
def typekeys(keysyms):
for key in keysyms:
xdo.xdo_keysequence(xdo_context, 0, key, key_press_delay)
time.sleep(editor_wait_delay)
def copyfile(filename):
f = open(filename)
data = f.read()
typeout("rm "+filename+"\nedit "+filename+"\n")
time.sleep(editor_wait_delay)
typeout(data)
typekeys(["ctrl","Return","ctrl","Left","Return"])
if __name__ == "__main__":
print "Select minecraft window now!"
time.sleep(5)
for filename in sys.argv[1:]:
copyfile(filename)