 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Bearclaw Guest
|
Posted: Sun Aug 23, 2009 12:38 pm Post subject: Hey |
|
|
I've been trying to optimize this script to follow a more efficient pattern (going right on the first row, then left, rinse and repeat, that way your little dude doesn't have to walk all the way back every time.)
Unfortunately I seem to be rubbish at this.
My problem seems to be that I can't figure out where in the script the input for row size is. If I have a row of 15, how do I tell it to go down and left after it's done 15 squares? After that it's just a matter of looping I guess.
Thanks in advance for any tips. |
|
| Back to top |
|
 |
Bearclaw Guest
|
Posted: Sun Aug 23, 2009 1:39 pm Post subject: bam |
|
|
Ok I figured it out, still can't manage to divide the Y variable by 2 by itself, so if you just enter half of it it'll work, as long as you have an even number of rows. Enjoy the more efficient macro that I made : D
| Code: | !^c::
GoSub GetFarmSq
GoSub Getfirstsq
i=1
Click %startx%,%starty%
newx=%startx%
newy=%starty%
Loop, %farmy%
{
Loop, %farmx%
{
Click %newx%,%newy%
newx+=25
newy-=12
Click %newx%,%newy%
sleep 200
i++
}
newx+=25
newy+=12
Click %newx%,%newy%
Loop, %farmx%
{
newx-=25
newy+=12
Click %newx%,%newy%
sleep 200
i++
}
newx+=25
newy+=12
startx+=25
starty+=12
sleep 200
}
return
GoSub Getfirstsq
GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row, ,100,150
Inputbox, farmy, Hey There, Enter half the number of squares in long, ,100,150
;msgbox, you said your farm was %farmx% x %farmy%
farmx--
return
Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return
!^x::reload
Return |
|
|
| Back to top |
|
 |
me Guest
|
Posted: Sun Aug 23, 2009 7:42 pm Post subject: |
|
|
| I cheat and just trap my little dude with bails of hay, been messing about with getting it in full screen a little, when it stays, works like a dream, but farmville seems to throw a paddy sometime going to full screen |
|
| Back to top |
|
 |
TUXHEDOHTOO Guest
|
Posted: Mon Aug 24, 2009 1:36 am Post subject: |
|
|
| me wrote: | | I cheat and just trap my little dude with bails of hay, been messing about with getting it in full screen a little, when it stays, works like a dream, but farmville seems to throw a paddy sometime going to full screen |
I did leave out some key points, you must zoom all the way out to use it... and I just figured out this trapping the farmer trick... I've got my farmer trapped in the bottom right corner by 3 hay bales.... he doesn't wander the farm to do anything now.
As far as going down and then left, I chose the pattern I did because it was easiest to code, not for efficiency. If you always go right left, than you need to do more math... not my strong point, and divide by two so you know whether to go left at the bottom or right at the bottom... in my head anyway.
the loop is nested, so the first loop handles the vertical.... and the inside loop is the horizontal... hopefully that helps. if you still can't figure it out, I might have time tomorrow to play some more. the hardest part was figuring out the size of the plots.
I want to work it out so that it checks the color of the plot and makes sure it's plant-able...
Here's the current code... added a default size to your plot size so that you only have to hit enter unless it changes, or you need to do something custom.
| Code: | !^c::
GoSub GetFarmSq
GoSub Getfirstsq
i=1
Loop, %farmy%
{
Click %startx%,%starty%
newx=%startx%
newy=%starty%
Loop, %farmx%
{
newx+=25
newy-=12
Click %newx%,%newy%
i++
}
startx+=25
starty+=12
}
return
GoSub Getfirstsq
GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row,,100,150,,,,,14
if ErrorLevel
GoSub Esc
Inputbox, farmy, Hey There, Enter the number of squares in long,,100,150,,,,,14
if ErrorLevel
GoSub Esc
;msgbox, you said your farm was %farmx% x %farmy%
farmx--
return
Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return
Esc:
!^x::reload
Return |
|
|
| Back to top |
|
 |
Tuxhedoh
Joined: 20 Apr 2006 Posts: 25 Location: Baltimore, MD
|
Posted: Mon Aug 24, 2009 1:42 am Post subject: |
|
|
You can see my little dude on the far right, and his status of plowing.
I just found this.... SetMouseDelay, 0
Add that to the top of the script, takes much less time.. I can't wait to use it on all 16 rows.  |
|
| Back to top |
|
 |
me Guest
|
Posted: Mon Aug 24, 2009 10:14 am Post subject: |
|
|
oh, I zoom out all the way, it's just that my plot is too big to all be seen, sorted now, I just have it click to go into full screen before going to the home square to start, 20x20 done in double quick time  |
|
| Back to top |
|
 |
corvardus
Joined: 24 Aug 2009 Posts: 1
|
Posted: Mon Aug 24, 2009 3:39 pm Post subject: Re: Hey |
|
|
| Bearclaw wrote: | | I've been trying to optimize this script to follow a more efficient pattern (going right on the first row, then left, rinse and repeat, that way your little dude doesn't have to walk all the way back every time.) |
Although I have annihilated this script for my own purposes to entertain a basic pattern I have learnt enough to help you with this. If you have an odd number of Y fields it will probably attempt to do an extra line. I am unsure how to stop that from happening, but this will do as you asked.
Left to right..... next line
Right to left.... next line
left to right... etc
| Code: |
!^c::
GoSub GetFarmSq
GoSub Getfirstsq
i=1
cycle := farmy/2
newx=%startx%
newy=%starty%
loop, %cycle%
{
Click %newx%,%newy%
Loop, %farmx%
{
newx+=25
newy-=12
Click %newx%,%newy%
}
newx+=25
newy+=12
Click %newx%,%newy%
Loop, %farmx%
{
newx-=25
newy+=12
Click %newx%,%newy%
}
newx+=25
newy+=12
}
return
GoSub Getfirstsq
GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row,,100,150,,,,,14
if ErrorLevel
GoSub Esc
Inputbox, farmy, Hey There, Enter the number of squares in long,,100,150,,,,,14
if ErrorLevel
GoSub Esc
;msgbox, you said your farm was %farmx% x %farmy%
farmx--
return
Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return
Esc:
!^x::reload
Return |
|
|
| Back to top |
|
 |
lordzer0 Guest
|
Posted: Mon Aug 24, 2009 3:42 pm Post subject: About fullscreen |
|
|
Just do this:
add this line to the script anywhere.
pause::Pause
now Run the script, when you now need to click on your first location, just press pause|break on the keyboard to pause the script. Go ahead and toggle fullscreen on farmville. zoom out twice, then press pause,break on keyboard and select your first location. |
|
| Back to top |
|
 |
me Guest
|
Posted: Mon Aug 24, 2009 9:57 pm Post subject: |
|
|
| nice idea lordzer0... all changing for me now the superberries have gone, none the less, a 20x20 takes a long time ahk or not, ready to change my farm a bit so that snippet will come in use... |
|
| Back to top |
|
 |
my_mistake Guest
|
Posted: Thu Aug 27, 2009 8:53 pm Post subject: Soybean-delete method? |
|
|
very nice script(s). thank you.
anyone tried to do one for the Soybean-delete method? |
|
| Back to top |
|
 |
szilveszter Guest
|
Posted: Mon Aug 31, 2009 4:32 pm Post subject: some really annoying things in fv |
|
|
first delete+big okay button:P
this script wait and klikk on okay its only an idea depends on pc where will it appear:P
| Code: |
!^Lbutton::
MouseGetPos, KezdoDestroyX, KezdoDestroyY
click KezdoDestroyX, KezdoDestroyY
;Msgbox, kérem a várakozási idot az okéig (nagyban függ a gépsebességtol, netkapcsolattól)
;inputbox, WT,WT,wait time (WT), ,50,150
;sleep %WT%
sleep 800
click 472,503
MouseMove KezdoDestroyX, KezdoDestroyY
|
;autoharvestklikk állatokon, fákon, használata: egy klikk és harvestol loopba rakva autoharvestálhat is:) 232,384 261,444
This script working, if u use this hotkey control+rightclick, dont need to click on harvest in pop-up menu working after 10th level (sell func). working on animals and trees.
| Code: |
^Rbutton::
MouseGetPos, HarvestLocX, HarvestLocY
click HarvestLocX, HarvestLocY
x1 := HarvestLocX + 48
y1 := HarvestLocY + 53
sleep 50
click %x1%,%y1%
sleep 10
MouseMove HarvestLocX, HarvestLocY
|
|
|
| Back to top |
|
 |
Viridis Guest
|
Posted: Tue Sep 01, 2009 8:31 pm Post subject: |
|
|
Or simply just zoom out.... and drag your farm around under your mouse.
Foolproof script based on the inital poster's one. Improved it to work for any farm, as long as you zoom out to the maximum.
(do note, when you trap your farmer with hay bales, you WILL click him or the haybales whenever you're harvesting. Whenever you have the plow tool or the plant tool selected, you will be able to just type in your entire farm ... 18x18 20x20 22x22 etc, you wont click your Farmerdude)
Script:
| Code: |
!^p::
GoSub GetFarmSq
GoSub Getfirstsq
looptimes := farmy // 2
checkmod := mod(farmy,2)
newx := startx + 25
newy := starty - 12
oldx := startx - 25
oldy := starty + 12
nextx := startx + 25
nexty := starty + 12
if (farmy = 1)
goto singleLine
else if (farmy > 1)
goto multiLine
multiLine:
Loop, %looptimes%
{
Click %startx%,%starty%
Loop, %farmx%
{
Click %newx%,%newy%
MouseClickDrag, L, newx, newy, startx, starty
sleep 200
}
Click %nextx%,%nexty%
MouseClickDrag, L, nextx, nexty, startx, starty
sleep 200
Loop, %farmx%
{
Click %oldx%,%oldy%
MouseClickDrag, L, oldx, oldy, startx, starty
sleep 200
}
Click %nextx% %nexty%
MouseClickDrag, L, nextx, nexty, startx, starty
sleep 200
}
if (checkmod = 0)
msgbox, Done
else if (checkmod = 1)
{
Loop, %farmx%
{
Click %newx%,%newy%
MouseClickDrag, L, newx, newy, startx, starty
sleep 200
}
msgbox, Done
}
return
singleLine:
Click %startx%,%starty%
Loop, %farmx%
{
Click %newx%,%newy%
MouseClickDrag, L, newx, newy, startx, starty
sleep 200
}
msgbox, Done
return
GoSub Getfirstsq
GetFarmsq:
Inputbox, farmx, Hey There, Enter the number of squares in your top row, ,100,150
Inputbox, farmy, Hey There, Enter the number of squares in long, ,100,150
msgbox, you said your farm was %farmx% x %farmy%
farmx--
return
Getfirstsq:
Msgbox, Click the middle of the top left square
KeyWait, LButton, D
KeyWait, LButton, D
MouseGetPos, startx, starty
return
!^x::reload
Return
|
start key got changed to CTRL ALT P (ctrl alt x to reload stayed)
Credits to Bearclaw for a nice base to start off. |
|
| Back to top |
|
 |
Viridis Guest
|
Posted: Tue Sep 01, 2009 8:46 pm Post subject: |
|
|
loldoublepost!!!
(the phailsquares were done by me, cause i'm pro like that =^___^= .. it has nothing to do with the script) |
|
| Back to top |
|
 |
eater44 Guest
|
Posted: Wed Sep 02, 2009 7:00 am Post subject: |
|
|
Just create a program that calculates all the mouseClicks and that generates the .ahk file for you, according to a set of parameters (like screen resolution, fullscreen button coordinates, window name, farm size, etc).
JavaScript would do.
Just a tip to get you all started  |
|
| Back to top |
|
 |
Tuxhedoh
Joined: 20 Apr 2006 Posts: 25 Location: Baltimore, MD
|
Posted: Wed Sep 02, 2009 2:17 pm Post subject: |
|
|
| eater44 wrote: | Just create a program that calculates all the mouseClicks and that generates the .ahk file for you, according to a set of parameters (like screen resolution, fullscreen button coordinates, window name, farm size, etc).
JavaScript would do.
Just a tip to get you all started  |
You add this like we haven't' developed a couple scripts that do what we need... now granted more ideas are always good, but at this time, we've got scripts that work, I'd be happy to see your solution though. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|