#!/usr/bin/env python # -*- coding: utf-8 -*- # simple macro to assist wheat growing without completely # automating the process # this macro only keep pressing "w" and "h" key until it's killed or "q" is pressed # (but you have to switch to the console from which you launched the macro # and therefore run it directly from the console (python script.ltm), outside of # ltool :/) # keep moving the mouse over your wheat beds,, in regular movements. # my strategy : # - choose a place with plenty of room (i.e. sand area for akhet seeds) # and with water nearby to be able to refill jugs quickly. # - build many wheat beds togethers, in arrays like 4x4 or larger # (used with akhet seeds) # - keep moving the mouse over the beds. You can check that everything is ok by # sometimes clicking on beds menus and see that "water" option disappears # right after you move the mouse over the bed. # - patience, you may have to wait several (5 to 20) minutes until the first bed # is harvested. # - when a bed is harvested, build another one. import time import Image import LtMacroAPI import sys import Ltxtew import os import tty from select import select class NotTTYException(Exception): pass class TerminalFile: def __init__(self,infile): if not infile.isatty(): raise NotTTYException() self.file=infile #prepare for getch self.save_attr=tty.tcgetattr(self.file) newattr=self.save_attr[:] newattr[3] &= ~tty.ECHO & ~tty.ICANON tty.tcsetattr(self.file, tty.TCSANOW, newattr) def __del__(self): #restoring stdin import tty #required this import here tty.tcsetattr(self.file, tty.TCSADRAIN, self.save_attr) def getch(self): if select([self.file],[],[],0)[0]: c=self.file.read(1) else: c='' return c if __name__=="__main__": s=TerminalFile(sys.stdin) print "Press q to quit..." (target_hit, root_hit) = LtMacroAPI.getwindowclick() print root_hit[1],',',root_hit[2] key="a" while key!="q": Ltxtew.key("click", "w") Ltxtew.key("click", "h") print "key" time.sleep(0.1) key = s.getch() print "-- END --"