Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DF 40d## macros, new utility - php macroizer  (Read 1353 times)

Pearnamer

  • Bay Watcher
    • View Profile
DF 40d## macros, new utility - php macroizer
« on: September 06, 2009, 03:17:26 am »

Thanks to the new macro system, we can auto-designate and script grander things than ever before!

I saw snooptodd's macro work in the forum and was inspired.

But.. but.. it's sort-of a pain to type it in macro form, and there were all these Quickfort CSV layout files already laying around.

So, I whipped up a little PHP script that consumes CSV layout files, and spits out the 40d13-and-later macro forms that go into your interface.txt file for use in-game.

It actually started as an Applescript extension of Martin's excellent circle digger and barracks digger, but my approach wasn't very cross-platform, and thus, this PHP script was born.

Well, v1 of it, at least.  It effectively scratches an itch I had.  It was written pretty quickly, and is not an example of sterling code, but it gets the job done.

V1 supports dig macros, which includes the various stairs, ramps, etc.  It does not support building or placing macros (basically the build menu, and the stockpile menu), although someone who wants them is free to add the support.

It supports a subset of the community-generated CSV files for layouts- notably, it doesn't do space-delineated files (comma-separated only), or files which start layout data on the same line as a #dig.  Anyone objecting to this is free to change their files, or to make the parser smarter.

The script was specifically written in PHP to make it accessible to anyone who wanted to make it better, so that it can fit their needs as well.  Also, unlike my Applescript solution, it's cross-platform, running on Windows, OS X, and Linux- wherever you've got access to PHP to run it.

The v1 file can be found on the Dwarf Fortress File Depot: http://dffd.wimbli.com/file.php?id=1405

20090908 -
There's a web-hosted version with a relatively primitive and unforgiving wrapper at http://nullship.net/dwarf/submit.php.  You should be able to copy-and-paste your CSV layout into the text field, and copy out the results.
« Last Edit: September 08, 2009, 10:40:34 pm by Pearnamer »
Logged

Pearnamer

  • Bay Watcher
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #1 on: September 06, 2009, 03:17:58 am »

This space intentionally left blank, in the unlikely event that I need it.
Logged

jaked122

  • Bay Watcher
  • [PREFSTRING:Lurker tendancies]
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #2 on: September 06, 2009, 02:17:01 pm »

would you mind changing it from a PHP to something that people who don't have web servers can run(perl/java/something-not-PHP)

Danarca

  • Bay Watcher
  • [MILL_CHILD:ONLY_IF_GOOD_REASON]
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #3 on: September 06, 2009, 03:08:28 pm »

I can upload the script to the server provided for me at the school tomorrow :)
Alternatively, if you can't wait, download Xampp, it's made for easy setup (install program, click start PHP in popup box), that will set up a server up on your own computer ;)
Logged
Clutter god the god of godly gods.
Om Nom nom nom nom
Ah yes the god of stone stockpiles, long randomly generated names, and gods.

Pearnamer

  • Bay Watcher
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #4 on: September 06, 2009, 06:02:08 pm »

would you mind changing it from a PHP to something that people who don't have web servers can run(perl/java/something-not-PHP)

Actually, the web-server aspect isn't as important as you think.  As written, it won't do ANYTHING useful on a webserver, except complain that you didn't give it a command-line name of a file to convert.

It's written to be run as a shell-level script, as if it were a command-line Perl or Java program... (except, of course, it's in PHP)

That's not a bad idea though- I could throw together a wrapper for it, and host it on a web server somewhere for folks who don't want to run it on their local command-lines.
Logged

Danarca

  • Bay Watcher
  • [MILL_CHILD:ONLY_IF_GOOD_REASON]
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #5 on: September 07, 2009, 01:26:24 am »

Actually, the web-server aspect isn't as important as you think.  As written, it won't do ANYTHING useful on a webserver, except complain that you didn't give it a command-line name of a file to convert.
Yeah I just found that out :p
No good to host it >.>
Logged
Clutter god the god of godly gods.
Om Nom nom nom nom
Ah yes the god of stone stockpiles, long randomly generated names, and gods.

Pearnamer

  • Bay Watcher
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #6 on: September 08, 2009, 10:37:57 pm »

There's a web wrapper (extremely unpolished) up at http://nullship.net/dwarf/submit.php for use.

Paste in the contents of your CSV file, and copy out the resulting macro definition for your interface.txt file.

No local PHP necessary, although you could still run it that way from the copy on the Dwarf Fortress File Depot on your own.  On the down-side, you can't really poke at the internal workings if you're using the web version.
Logged

Andy Korth

  • Bay Watcher
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #7 on: September 08, 2009, 10:48:53 pm »

would you mind changing it from a PHP to something that people who don't have web servers can run(perl/java/something-not-PHP)

Php comes preinstalled on Macs, I assume it's similar for other operating systems. Instead of typing "perl scriptname" or "java classfile", just type "php script" and it'll run.
Logged

rdwulfe

  • Bay Watcher
  • Rion Wulfe
    • View Profile
Re: DF 40d## macros, new utility - php macroizer
« Reply #8 on: September 09, 2009, 10:00:19 am »

Too bad that doesn't work on Windows. :D
Logged
"   So the gods discussed it and created elves. The Elves were beautiful, Mistral Thrax admitted, in and elvish way, but it was his belief that the gods grew disappointed after a time because the elves -- being elves -- were essentially decorative but not particularly functional. They were content simply to live long lives and to exist. They did not nothing of any real value, in the opinion of Mistral Thrax."
   -- The Covenant of the Forge by Dan Parkinson, a Dragon Lance Novel