v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

User talk:Boo radley/cir.ahk

From Dwarf Fortress Wiki
Jump to navigation Jump to search
;
;  This script will designate a circular room for digging
;  invoke from the [d]esignate menu with the cursor in the upper left corner of the room's diameter.
;

Gui, Add, Text,, Radius
Gui, Add, Text,, Clobber Existing?
Gui, Add, Edit, vRadius ym 
Gui, Add, Checkbox, vClobber
Gui, Add, Button, Default, OK
Gui, Add, Button, Default, Cancel
Gui, Show,, Circular room digger
Return


ButtonOK:
	Gui, Submit  ; Save the input from the user to each control's associated variable.
	
	IfWinExist, Dwarf Fortress ; make sure df is running 
		WinActivate
		sleep, 3000
		;
		;  should we clobber existing dig commands?
		;
		if (Clobber = 1) {
		  outlier = x{enter}{enter}{right}
		} else {
			outlier = {right}  
		}
		nudge := Radius
		radiusSquare := Radius ** 2
		circ := Radius * 2
		y := -Radius + 1
		Loop 	{
			ySquare := y ** 2
			x := -Radius + 1
			Loop {
				if (((x ** 2 ) + (ySquare) + Radius) > (radiusSquare)) {			  
					send, %outlier%
				} else {
					send, d{enter}{enter}{right}
				}
				x++
				if (x > Radius) {
					break
				}
			}
			send {down}
			loop, %circ%{
				send {left}
			}
			y++
			if (y > Radius) {
				break
			}
		}	 
	ExitApp
	
	
Escape::
ButtonCancel:
ExitApp