Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Dwarf Scripting  (Read 3039 times)

Martin

  • Bay Watcher
    • View Profile
Re: Dwarf Scripting
« Reply #15 on: February 09, 2009, 04:31:51 pm »

Ooh, fractal caverns... Hmm... I hadn't considered that possibility before...

Andy Korth

  • Bay Watcher
    • View Profile
Re: Dwarf Scripting
« Reply #16 on: February 09, 2009, 05:35:57 pm »

Even in 40d, I need to put a short delay between keystrokes:

Doh! I never put delays in my script! That would have done it. I just glossed over that part when I was reading other people's script.
Logged

winner

  • Bay Watcher
    • View Profile
Re: Dwarf Scripting
« Reply #17 on: February 09, 2009, 09:39:27 pm »

Logic gates like numberabbey has.

Or slightly divergent, a program that takes images and urns them into digging instructions

I actually tried this yesterday evening. Sadly AppleScript is a horrible language and i could not find anything readily available on a vanilla os x to read a pixel's color from an image file in "Image Event"s

I am currently thinking about simply creating a native os x app, where one could create templates on a grid or in a scripted fashion (probably python).

I think the most attractive templates are parametrized ones. The circle is a good example. I have created a small script for my default staircase design with alternating up and down stairs like this:

Code: [Select]
#####
#< >#
#< >#
#< >#
#####

<> - stairs
 - floor
# - wall

and am currently working on variations of that (like orientation) and the ability to input the number of levels you want the staircases to go (up and/or down).

Since i usually use relatively strict layout i will probably create simple layouts as well. What i am not so sure about is digging channels. In my experience i am quite careful with digging channels and do this in at least 2 stages.

For a bunker i could imagine a multi-phase template. First the digging, second some channeling and furniture placement, third some more channeling. I am not sure how to smartly tell df via actionscript which furniture or material (e.g. walls) to use. I would love an easy way to say "a wall of granite from here 10 tiles to the north".
if you could make your program read[ie match string] the materials from the list then it would have the same effect.
Logged
The great game of Warlocks!

monolar

  • Bay Watcher
    • View Profile
Re: Dwarf Scripting
« Reply #18 on: February 10, 2009, 05:55:16 am »

if you could make your program read[ie match string] the materials from the list then it would have the same effect.

The problem is that i cannot think of a way to read this with applescript, since DwarfFortress does not export any custom apple events that we can ask something. The best way to achieve this stuff would probably be to inject a program into the dwarf fortress main loop and hijack the thing, like the Ogre powered 3d client does. The thing is though i have no idea how to do this on os x 10.5
Logged

Rysith

  • Bay Watcher
    • View Profile
Re: Dwarf Scripting
« Reply #19 on: February 10, 2009, 10:18:23 am »

if you could make your program read[ie match string] the materials from the list then it would have the same effect.

So, at the point that we could get access to the materials list (short of injecting our own code in, which would be really ugly and would probably make DF unstable) it's actually just pixels, so there is no string to match. Getting the string would involve OCRing an area of the screen. While that's possible, that's well beyond what these scripts are able to do.
Logged
Lanternwebs: a community fort
Try my orc mod!
The OP deserves the violent Dwarven equivalent of the Nobel Peace Prize.

winner

  • Bay Watcher
    • View Profile
Re: Dwarf Scripting
« Reply #20 on: February 10, 2009, 10:19:16 pm »

you are right, I was just thinking of the way a minesweeper solver did it.
Logged
The great game of Warlocks!

Rysith

  • Bay Watcher
    • View Profile
Re: Dwarf Scripting
« Reply #21 on: February 11, 2009, 12:46:24 am »

you are right, I was just thinking of the way a minesweeper solver did it.

Is the solver open-source or something convenient like that? I could look into it if I had the code, but it would turn into a stand-alone program like Dwarf Companion or 3dwarf.
Logged
Lanternwebs: a community fort
Try my orc mod!
The OP deserves the violent Dwarven equivalent of the Nobel Peace Prize.

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: Dwarf Scripting
« Reply #22 on: February 11, 2009, 05:01:13 pm »

While screen-scraping is possible, you're forgetting two important things here - one, DF uses opengl; two, DF is tile-based.

You could trace the GL calls to figure out exactly which tiles are printed, where. It's fairly simple, and the source code is even available - see the git repository link in the 40d9 thread. :)

All the relevant code is in enabler_sdl.cpp
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?
Pages: 1 [2]