The Wiki for Tale 4 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.
If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.
Difference between revisions of "Users:Gemstar/Barley"
From A Tale in the Desert
Jump to navigationJump to search (New page: This was sent to me by Bellamoon. I have cleaned it up and posted here for general use with her permission. <pre> Constants // Insert constants here NumberOfLoops = 2 //This is the nu...) |
|||
| Line 1: | Line 1: | ||
| − | |||
<pre> | <pre> | ||
Constants | Constants | ||
Latest revision as of 00:05, 26 January 2009
Constants
// Insert constants here
NumberOfLoops = 2 //This is the number of loops, and with luck is the only thing you will
//have to change to suit your own needs. I personally use 8 with +2str
//(and dex from acro).
SleepTime = 200 //If you're having major problems with lag try moving this to a higher
//number (these are in milliseconds). This delay is used between most
//commands
MoveSleepTime = 1500 //This is the delay used for when the character is actually moving.
//Again this is in milliseconds, if lag is troubling you, try
//Upping this number.
LoopWaitTime = 1000 //This is used in the loop to check if it should feed or water the
//barley more. If you Change the times above up or down you may need
//to do the inverse with this in order to not waste fertilizer or
//worse, harvest the barley before it's done.
XCoordsOfPlantBarley = 973 //If you don't want the barley planting box in the upper right,
//can change this (and the Y value below this).
YCoordsOfPlantBarley = 47 //See above comment
NumToDo = 8 //This is actually equipped to handle doing anywhere between 1 and 8
//patches of barley at a time. Use this to set the number (recommended
//that you use 8, the others have not been extensively tested
varX = 0
varY = 0
Adding = 0
LoopNum = 0
NumberAdded = 0
varColourY = 0
varColourX = 0
varAddX = 0
varOriginalMouseX = 0
varOriginalMouseY = 0
MousePosX = 0
MousePosY = 0
varDelay = 0
End
MousePos 100, 20
Delay 250
LeftClick
call MakeBarley
//call GetPixelAtMouse
Procedure MakeBarley
SetActiveWindow eGenesis Client //On my computer I commented this line because it messes my computer
//up. Try that if you're having issues
loop $NumberOfLoops //How many times to run through the loop. I use 8 usually and have
//carry food going (+2 str, +3 or more dex will do for 8)
//SetConst NumToDo = 5 //Possible to do less than 8 at a time.
//<1 or >8 will break this
//SetConst sleeptime = 200 //How much time to wait
SetConst Adding = 1 //Tells it we're still adding, used in a later Function
SetConst LoopNum = 0 //Which Loop Number we're at. Used in the main loop
//****** 1 ******
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2 //plant barley spot
loop 1000 //This is a loop because the drag function misses sometimes.
//This keeps trying until it thinks it succeeds
Delay $sleeptime
SetConst MousePosX = 510
SetConst MousePosY = 425
SetConst varDelay = 1 //Delay is because the game is kinda slow in bringing
//up a window. See RightClick2 function
call RightClick2 // click on barley
Delay $sleeptime
Call GetMousePos
MousePos 610, 330
DragTo 103, 44 //Drag Barley to appropriate spot
Call SetMousePos
LoadRGB 105, 166 //Load the colours for a location
if {RGBBlue} > 240 //Check for heavy blue to make sure the window
//got where intended
break //If it did, exit this loop
else //otherwise click in a spot in the bottom right to clear the screen
delay $sleeptime
SetConst MousePosX = 743
SetConst MousePosY = 611
call RightClick2
end
end
Delay $sleeptime
SetConst MousePosX = 198
SetConst MousePosY = 47
call RightClick2 //This pins the window open
Delay $sleeptime
SetConst NumberAdded = 1
Call TestColourWhich //Go add the fertilizer and water
if $NumToDo > 1 //A statement like this that will be gone through for each number >1
//****** 2 ******
SetConst MousePosX = 760
SetConst MousePosY = 392
call LeftClick2 //This moves your character so you plant in a new spot
Delay 1500
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2
loop 1000
Delay $sleeptime
SetConst varDelay = 1
SetConst MousePosX = 510
SetConst MousePosY = 425
call RightClick2
Delay $sleeptime
Delay $sleeptime
call GetMousePos
MousePos 610, 330
DragTo 315, 44
Call SetMousePos
LoadRGB 314, 163
if {RGBBlue} > 240
break
else
Delay $sleeptime
SetConst MousePosX = 743
SetConst MousePosY = 611
call RightClick2
end
end
delay $sleeptime
SetConst MousePosX = 411
SetConst MousePosY = 48
call LeftClick2
Delay $sleeptime
SetConst NumberAdded = 2
Call TestColourWhich
end
if $NumToDo > 2
//****** 3 ******
SetConst MousePosX = 760
SetConst MousePosY = 392
call LeftClick2
Delay $MoveSleepTime
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2
loop 1000
SetConst varDelay = 1
Delay $sleeptime
SetConst MousePosX = 510
SetConst MousePosY = 425
call RightClick2
Delay $sleeptime
Call GetMousePos
MousePos 610, 330
DragTo 528, 44
Call SetMousePos
LoadRGB 521, 163
if {RGBBlue} > 240
break
else
Delay $sleeptime
SetConst MousePosX = 743
SetConst MousePosY = 611
call RightClick2
end
end
Delay $sleeptime
SetConst MousePosX = 621
SetConst MousePosY = 48
call RightClick2
Delay $sleeptime
SetConst NumberAdded = 3
Call TestColourWhich
end
if $NumToDo > 3
//****** 4 ******
SetConst MousePosX = 760
SetConst MousePosY = 392
call LeftClick2
Delay $MoveSleepTime
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2
loop 1000
SetConst varDelay = 1
Delay $sleeptime
SetConst MousePosX = 510
SetConst MousePosY = 425
call RightClick2
Delay $sleeptime
call GetMousePos
MousePos 610, 330
DragTo 740, 44
Call SetMousePos
LoadRGB 753, 163
if {RGBBlue} > 240
break
else
Delay $sleeptime
MousePos 743, 611
RightClick
end
end
Delay $sleeptime
SetConst MousePosX = 832
SetConst MousePosY = 48
call LeftClick2
Delay $sleeptime
SetConst NumberAdded = 4
Call TestColourWhich
end
if $NumToDo > 4
//****** 5 ******
SetConst MousePosX = 500
SetConst MousePosY = 620
call LeftClick2
Delay $MoveSleepTime
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2
loop 1000
SetConst varDelay = 1
Delay $sleeptime
SetConst MousePosX = 510
SetConst MousePosY = 425
call RightClick2
Delay $sleeptime
Call GetMousePos
MousePos 610, 330
DragTo 105, 265
Call SetMousePos
LoadRGB 135, 382
if {RGBBlue} > 240
break
else
Delay $sleeptime
SetConst MousePosX = 743
SetConst MousePosY = 611
call RightClick2
End
End
Delay $sleeptime
SetConst MousePosX = 197
SetConst MousePosY = 270
call RightClick2
Delay $sleeptime
SetConst NumberAdded = 5
Call TestColourWhich
end
if $NumToDo > 5
//****** 6 ******
SetConst MousePosX = 245
SetConst MousePosY = 393
call LeftClick2 //move to left
Delay $MoveSleepTime
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2 //Click on Plant Barley
loop 1000
SetConst varDelay = 1
Delay $sleeptime
SetConst MousePosX = 510
SetConst MousePosY = 425
call RightClick2 //Click on Barley
Delay $sleeptime
Call GetMousePos
MousePos 610, 330
Delay $sleeptime
DragTo 103, 530 //Drag Window
Call SetMousePos
LoadRGB 92, 665
if {RGBBlue} > 240
break
else
Delay $sleeptime
SetConst MousePosX = 743
SetConst MousePosY = 611
call RightClick2
End
end
Delay $sleeptime
SetConst MousePosX = 197
SetConst MousePosY = 526
call RightClick2
Delay $sleeptime
SetConst NumberAdded = 6
Call TestColourWhich
end
if $NumToDo > 6
//****** 7 ******
SetConst MousePosX = 245
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2
loop 1000
SetConst varDelay = 1
Delay $sleeptime
SetConst MousePosX = 510
SetConst MousePosY = 425
call RightClick2
Delay $sleeptime
Call GetMousePos
MousePos 610, 330
DragTo 316, 530
Call SetMousePos
LoadRGB 308, 665
if {RGBBlue} > 240
break
else
Delay $sleeptime
SetConst MousePosX = 743
SetConst MousePosY = 611
call RightClick2
end
end
Delay $sleeptime
SetConst MousePosX = 411
SetConst MousePosY = 526
call RightClick2
Delay $sleeptime
SetConst NumberAdded = 7
Call TestColourWhich
end
if $NumToDo > 7
//****** 8 ******
SetConst MousePosX = 245
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
SetConst MousePosX = $XCoordsOfPlantBarley
SetConst MousePosY = $YCoordsOfPlantBarley
call RightClick2
loop 1000
SetConst varDelay = 1
SetConst MousePosX = 510
SetConst MousePosY = 425
call RightClick2
Delay $sleeptime
Call GetMousePos
MousePos 610, 330
Delay $sleeptime
DragTo 529, 530
Call SetMousePos
LoadRGB 519, 665
if {RGBBlue} > 240
break
else
Delay $sleeptime
SetConst MousePosX = 743
SetConst MousePosY = 611
call RightClick2
end
end
Delay $sleeptime
SetConst MousePosX = 621
SetConst MousePosY = 526
call RightClick2
Delay $sleeptime
SetConst NumberAdded = 8
Call TestColourWhich
end
SetConst Adding = 0
loop 63 //This is the main loop
SetConst LoopNum = {LoopNo} //Need this variable below so we don't keep
//feeding the early ones
Delay $LoopWaitTime
Call TestColourWhich //Go to the functions to test the colour,
//see if we need to add
//ToolTip, %a_index%
//;send, {BS}
//;send, {BS}
//;send, %a_index%
end
delay $sleeptime
SetConst MousePosX = 110
SetConst MousePosY = 230
call RightClick2 // harvest
Delay $sleeptime
SetConst MousePosX = 190
SetConst MousePosY = 110
Call RightClick2 // close pinned window
Delay $sleeptime
if $NumToDo > 1
SetConst MousePosX = 325
SetConst MousePosY = 230
call RightClick2
Delay $sleeptime
SetConst MousePosX = 403
SetConst MousePosY = 108
call RightClick2
Delay $sleeptime
end
if $NumToDo > 2
SetConst MousePosX = 530
SetConst MousePosY = 230
call RightClick2
Delay $sleeptime
SetConst MousePosX = 617
SetConst MousePosY = 108
call RightClick2
Delay $sleeptime
end
if $NumToDo > 3
SetConst MousePosX = 746
SetConst MousePosY = 230
call RightClick2
Delay $sleeptime
SetConst MousePosX = 829
SetConst MousePosY = 108
call RightClick2
Delay $sleeptime
end
if $NumToDo > 4
SetConst MousePosX = 110
SetConst MousePosY = 448
call RightClick2
Delay $sleeptime
SetConst MousePosX = 191
SetConst MousePosY = 327
call RightClick2
Delay $sleeptime
end
if $NumToDo > 5
SetConst MousePosX = 110
SetConst MousePosY = 718
call RightClick2
Delay $sleeptime
SetConst MousePosX = 192
SetConst MousePosY = 600
call RightClick2
Delay $sleeptime
end
if $NumToDo > 6
SetConst MousePosX = 325
SetConst MousePosY = 718
call RightClick2
Delay $sleeptime
SetConst MousePosX = 403
SetConst MousePosY = 600
call RightClick2
Delay $sleeptime
end
if $NumToDo > 7
SetConst MousePosX = 530
SetConst MousePosY = 718
call RightClick2
Delay $sleeptime
SetConst MousePosX = 617
SetConst MousePosY = 600
call RightClick2
Delay $sleeptime
end
if $NumToDo > 4 //This means we need to go up 1 section as well
SetConst MousePosX = 500
SetConst MousePosY = 167
call LeftClick2
Delay $MoveSleepTime
if $NumToDo < 8 //Each of the below is to move back to the left 1 section
SetConst MousePosX = 240
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
end
if $NumToDo < 7
SetConst MousePosX = 240
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
end
if $NumToDo < 6
SetConst MousePosX = 240
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
end
else //4 or below
if $NumToDo > 1 //for each greater than 1, move to the left once
SetConst MousePosX = 240
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
end
if $NumToDo > 2
SetConst MousePosX = 240
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
end
if $NumToDo > 3
SetConst MousePosX = 240
SetConst MousePosY = 393
call LeftClick2
Delay $MoveSleepTime
end
end
end
End
//;***********************************************************
Procedure TestColourWhich //This function figures out which coordinates to call.
//No it is not terribly good code, but this was written first for AutoHotKey
loop $NumberAdded //This is for the water
if {LoopNo} < 5
SetConst varColourY = 164
if {LoopNo} = 1
SetConst varColourX = 179
SetConst varAddX = 197
end
if {LoopNo} = 2
SetConst varColourX = 391
SetConst varAddX = 408
end
if {LoopNo} = 3
SetConst varColourX = 606
SetConst varAddX = 621
end
if {LoopNo} = 4
SetConst varColourX = 815
SetConst varAddX = 833
end
end
if {LoopNo} = 5
SetConst varColourY = 384
SetConst varColourX = 179
SetConst varAddX = 197
end
if {LoopNo} > 5
SetConst varColourY = 652
if {LoopNo} = 6
SetConst varColourX = 170
SetConst varAddX = 197
end
if {LoopNo} = 7
SetConst varColourX = 391
SetConst varAddX = 408
end
if {LoopNo} = 8
SetConst varColourX = 606
SetConst varAddX = 621
end
end
if $adding = 1 //This little section is to click a 2nd time when first planting the barley
if {LoopNo} = $numberadded
Call TestColour
end
end
if {LoopNo} = 1
if $LoopNum < 46
Call TestColour
end
end
if {LoopNo} = 2
if $LoopNum < 49
Call TestColour
end
end
if {LoopNo} = 3
if $LoopNum < 52
Call TestColour
end
end
if {LoopNo} = 4
if $LoopNum < 55
Call TestColour
end
end
if {LoopNo} = 5
if $LoopNum < 58
Call TestColour
end
end
if {LoopNo} = 6
if $LoopNum < 61
Call TestColour
end
end
if {LoopNo} = 7
if $LoopNum < 64
Call TestColour
end
end
if {LoopNo} = 8
if $LoopNum < 67
Call TestColour
end
end
end
loop $NumberAdded //This is for the fertlizer
if {LoopNo} < 5
SetConst varColourY = 184
if {LoopNo} = 1
SetConst varColourX = 179
SetConst varAddX = 197
end
if {LoopNo} = 2
SetConst varColourX = 391
SetConst varAddX = 408
end
if {LoopNo} = 3
SetConst varColourX = 606
SetConst varAddX = 621
end
if {LoopNo} = 4
SetConst varColourX = 815
SetConst varAddX = 833
end
end
if {LoopNo} = 5
SetConst varColourY = 404
SetConst varColourX = 179
SetConst varAddX = 197
end
if {LoopNo} > 5
SetConst varColourY = 673
if {LoopNo} = 6
SetConst varColourX = 170
SetConst varAddX = 197
end
if {LoopNo} = 7
SetConst varColourX = 391
SetConst varAddX = 408
end
if {LoopNo} = 8
SetConst varColourX = 606
SetConst varAddX = 621
end
end
if $adding = 1 //This if block is to make it click a 2nd time when first planting
if {LoopNo} = $numberadded
Call TestColour
end
end
if {LoopNo} = 1
if $LoopNum < 43
call TestColour
end
end
if {LoopNo} = 2
if $LoopNum < 46
Call TestColour
end
end
if {LoopNo} = 3
if $LoopNum < 49
call TestColour
end
end
if {LoopNo} = 4
if $LoopNum < 52
Call TestColour
end
end
if {LoopNo} = 5
if $LoopNum < 55
Call TestColour
end
end
if {LoopNo} = 6
if $LoopNum < 58
Call TestColour
end
end
if {LoopNo} = 7
if $LoopNum < 61
Call TestColour
end
end
if {LoopNo} = 8
if $LoopNum < 64
Call TestColour
end
end
end
end
Procedure TestColour //This actually tests the colours based on the position set in TestColourWhich
LoadRGB $varColourX, $varColourY
if {RGBBlue} > 220 //If it's really high in blue content
else
Call GetMousePos
SetConst MousePosX = $varAddX
SetConst MousePosY = $varColourY
call RightClick2
Call SetMousePos
Delay 100
end
end
Procedure GetMousePos //find the original coords of the mouse
SetConst varOriginalMouseX = {MouseX}
SetConst varOriginalMouseY = {MouseY}
End
Procedure SetMousePos //set the mouse back where it came from
MousePos $varOriginalMouseX, $varOriginalMouseY
End
Procedure LeftClick2
call GetMousePos
MousePos $MousePosX, $MousePosY
if $varDelay = 1
delay 200
end
LeftClick
//delay 200
SetConst varDelay = 0
Call SetMousePos
End
Procedure RightClick2
Call GetMousePos
MousePos $MousePosX, $MousePosY
if $varDelay = 1
delay 200
end
RightClick
SetConst varDelay = 0
//delay 400
Call SetMousePos
End
Procedure GetPixelAtMouse //This was a test Procedure for finding coordinates and values, etc
//SetActiveWindow eGenesis Client
Loop 1
//SetConst testpixel = 0
//LoadRGB {MouseX}, {MouseY}
//keys {RGBBlue}
keys {MouseX}
keys :
keys {MouseY}
End
End