Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Autohotkey dump script  (Read 1424 times)

dukederek

  • Escaped Lunatic
    • View Profile
Autohotkey dump script
« on: January 21, 2008, 06:04:00 pm »

Hi all, i've been lurking here a while, just with nothing to say until now. Anyway time for a small bit of backstory: I had nothing to do at work today (oh the terrible life of a PhD student) except for drink coffee and wait until tomorrow. I chose to use this time in the most productive manner and learn how to use AutoHotKey properly, I've been using the dumping AHK scripts for a while and i felt like something a bit more ambitious.. So i present...

The block dumping script. Basically it allows you to designate (most of) the contents of a large block of tiles to be dumped. (a la the forbid and claim designation tools in the "d" menu)

The script is a little long for here but it's on my user page on the wiki. I would appreciate comments if anyone has anything constructive to say about it...

I hope something of this sort doesnt exist already, i assumed someone would have put it on the wiki if it did...

[ January 22, 2008: Message edited by: dukederek ]

[ January 22, 2008: Message edited by: dukederek ]

[ January 22, 2008: Message edited by: dukederek ]

[ January 23, 2008: Message edited by: dukederek ]

Logged

Pyro93735

  • Bay Watcher
    • View Profile
Re: Autohotkey dump script
« Reply #1 on: January 22, 2008, 01:02:00 am »

code:
^!d::
   FieldWidth = 1
   FieldHeight = 1
   LoopCount = 1
   Input, FieldWidth, C, {enter}
   if FieldWidth is integer
      {
      Input, FieldHeight, C, {enter}
      if FieldWidth is integer
         {
         LoopCount := FieldWidth
         Loop
            {
            Loop %FieldHeight%
            {
               Send, d{Numpad8}
               Sleep 25
               }
            LoopCount := --LoopCount
            If LoopCount = 0
               break
            Send, {Numpad6}{Numpad2}
            Sleep 25
            Loop %FieldHeight%
            {
               Send, d{Numpad2}
               Sleep 25
            }
            LoopCount := --LoopCount
            If LoopCount = 0
               break
            Send, {Numpad6}{Numpad8}
            Sleep 25
            }
         }
      }

   Return
 


That's the dumping script I've been using. It takes two inputs, width and height and just goes from there. I got it off this website but added in sleep delays so that it won't break on large chunks, like the original seemed to do.

EDIT: There's a text smiley in your url link. Click on the "Disable smilies in this post" box underneath Options, which is below the smilies bank.

[ January 22, 2008: Message edited by: Pyro93735 ]

[ January 22, 2008: Message edited by: Pyro93735 ]

Logged

dukederek

  • Escaped Lunatic
    • View Profile
Re: Autohotkey dump script
« Reply #2 on: January 22, 2008, 02:48:00 am »

changed. i cant believe i didnt notice that when i posted... damn

The advantage of my script over that one is that you mark out a large square of custom size (in game) and then it dumps the first two items from every square, you could run it when you start playing and never have to edit/close the script

EDIT: i just tried that one out, it's much more efficient in its dumping than mine, i'll have a go at changing mine for efficiency if today's workload is as light as yesterday's

[ January 22, 2008: Message edited by: dukederek ]

Logged

dukederek

  • Escaped Lunatic
    • View Profile
Re: Autohotkey dump script
« Reply #3 on: January 22, 2008, 12:03:00 pm »

sorry to be harping on about this but work's been slow today too. Anyway, taking a few things from the script Pyro93735 posted, I've changed the keys to start it, set it to be controlled with the arrow keys and return and made it much quicker. the new version has replaced the old one on my userpage on the wiki. Also, i post it below.

There are two ahk files here to get around certain issues with "input" not accepting non display keypresses (namely return and the arrow keys)

I call this one "blockdumpinit.ahk" it always sits open when i play DF

code:
 ^d::
RunWait, "blockdumpmain.ahk"
Return

This one is called "blockdumpmain.ahk" and is called when you press ctrl-d when the other one is running. It also closes when it's done. After pressing ctrl-d to start this, press shift directly after as it temporarily remaps some keys.

Consider ctrl-d selects the tool and shift confirms the start square (it is not possible to move the cursor between the two keypresses however

code:
 SetKeyDelay 25
return::
Send k
return
up::
Send w
return
left::
Send a
return
down::
Send s
return
right::
Send d
return
q::
ExitApp
return
shift::
x := 0
y := 1
Loop{
Input, keypress, B, {esc} , w,a,s,d,k,q
if keypress = w
{
y := --y
Send {up}
continue
}else if keypress = s
{
y := ++y
Send {down}
continue
}else if keypress = a
{
x := --x
Send {left}
continue
}else if keypress = d
{
x := ++x
Send {right}
continue
}else if keypress = k
{
break
}else if keypress = q
{
ExitApp
}
}
y := y / 2
z := y
z := Floor(z)
z := y/z
Send d{NumpadAdd}d
If z = 0
{   
If x = 0
ExitApp
Else{
Loop %x%{
Send {left}d
}ExitApp
}
}If z <> 1
{
Loop %y%{
Loop %x%{
Send {left}d{NumpadAdd}d
}Send {up}d
Loop %x%{
Send {right}d{NumpadAdd}d
}Send {up}d{NumpadAdd}d
}Loop %x%{
Send {left}d{NumpadAdd}d
}
}Else If z = 1
{
y := y + 0.5
Loop %y%{
Loop %x%{
Send {left}d{NumpadAdd}d
}Send {up}d
Loop %x%{
Send {right}d{NumpadAdd}d
}Send {up}d{NumpadAdd}d
}Send d{NumpadSub}d
}ExitApp

To exit the dump tool press q at any time (or close the relevant ahk icon in the system tray (obviously))

Because i'm at work I havent been able to check the keydelay doesnt mess up DF but it didnt in the last version of the tool, it may need a little tweak if it misses keystrokes or something...

I feel a bit like:

dukederek, physicist has been taken by a fey mood
dukederek has claimed a science workshop
dukederek has produced blockdumpmain.ahk, a niche designation tool

this tool menaces with spikes of wasted time

[ January 22, 2008: Message edited by: dukederek ]

Logged