Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 18 19 [20] 21 22 ... 32

Author Topic: Dwarf Foreman 0.7.2 - Tool to automatically dispatch jobs to your workers  (Read 114889 times)

wedrifid

  • Bay Watcher
    • View Profile

For those who may have grabbed it in the last 20 minutes I've edited the dfjobs. Made the item type detection a bit smarter.
Logged

wedrifid

  • Bay Watcher
    • View Profile

Nice script, now what about those of use who have their own set of mods to work with? Any chance of getting a compiled binary of that script for our personal use?

It's a ruby script. They can in principle be complied to standalone apps but my development VM runs linux and would compile a linux executable. Unfortunately 'compile to exe' isn't a feature of ruby and the tool that does it is about as much of an external cludgy hack/workaround as what we use to manage our dwarves!

ruby script
Code: [Select]
#!/usr/local/bin/ruby

class DFJOBSGenerator
  def initialize
    read_items
  end

  def print_reactions
    reactionfiles = Dir.glob("reaction_*")

    reactionfiles.each do |reactionfile|
      reactions = File.read(reactionfile).scan /REACTION:([^\]]+)[^(?:NAME)]*NAME:([^\]]+).*?BUILDING:(\w+).*?PRODUCT:[^:]*:[^:]*:([^:]*):([^:]+):([^:]+):([^:\]]+)/m

      reactions.each do |reaction|
        STDOUT.puts  <<EOF
    <dfjob name="#{reaction[1]}" category="#{reaction[2].downcase}" reaction="#{reaction[0]}">
        #{item_string(reaction)}
    </dfjob>
EOF
      end
    end

  end

  def item_string(reaction)
    if reaction[4] != "NO_SUBTYPE" && reaction[4] != "NONE"
      type = reaction[4]
    else
      type = reaction[3]
    end
    typestr= @items[type]
    typestr = type.downcase if typestr.nil?
    itemstr = "<item type=\"#{typestr}\" "

    if reaction[5] == "GET_MATERIAL_FROM_REAGENT"
      itemstr += "material=\"all\"/>"
    elsif reaction[5] == "METAL" || reaction[5] == "INORGANIC"
      itemstr += "material=\"#{reaction[6]}\"/>"
    else
      itemstr += "material=\"#{reaction[5]}\"/>"
    end

    return itemstr
  end

  def read_items
    itemfiles = Dir.glob("item*")
    @items = {}

    itemfiles.each do |itemfile|
      STDOUT.puts "Scanning file: #{itemfile}"
      items = File.read(itemfile).scan(/\[ITEM[^:]*:(?:([^\]]+))[^(?:NAME)]+?[^:]+:[^:]+:([^\]]+)/m)
      items.each do |item|
        @items[item[0]] = item[1]
      end
    end
  end
end

DFJOBSGenerator.new.print_reactions
« Last Edit: April 23, 2011, 01:46:43 am by wedrifid »
Logged

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile

Meaning it's possible, so long as someone with an interest has Ruby on their Windows computer and the desire to distribute that file.

Work on getting the code where you want it.  Dollars to doughnuts someone out there will come forward to compile it by the time you've got 1.0 polished up ;)
Logged
I like fortresses because they are still underground.

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile

Right now I have just cloned the foreman repository on google code and I can upload all the dfjobs.xml changes there and send a note that a pull is available.

Well, you're a contributor so you don't really need to bother with that. You can edit the project directly, which would be better IMHO. Whatever works though hehe.

My current dfjob.xml includes a few jobs that are only available in the genesis mod. I will split them out and create a vanilla DF only version so other folks can use it too. Come to think of it a feature request that allows selecting which dfjobs spec to use as well as which config would allow me to provide both versions and allow both groups to benefit!

It wouldn't be impossible to select which spec to use, but for now lets just make a dfjobs-genesis.xml file, and if people use genesis they can copy it over.
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile

Uh you might want to use a Code tag there.  Smilie faces aren't proper code ;)
Logged
I like fortresses because they are still underground.

wedrifid

  • Bay Watcher
    • View Profile

Meaning it's possible, so long as someone with an interest has Ruby on their Windows computer and the desire to distribute that file.

Work on getting the code where you want it.  Dollars to doughnuts someone out there will come forward to compile it by the time you've got 1.0 polished up ;)
I actually gave it a try myself. Running my code on windows went without a hitch but running the ruby2exe script failed. But that should be no problem. The ruby installer is 10mb and a single click away. A whole heap easier than fiddling around in XML! I'll throw the code into the repository and give a link to it here.

(And yes, if someone wants to fiddle and find a way to get the 2exe thing working then go for it!)
Logged

wedrifid

  • Bay Watcher
    • View Profile

Well, you're a contributor so you don't really need to bother with that. You can edit the project directly, which would be better IMHO. Whatever works though hehe.
Will do. Now that I can generate all the nonstandard stuff from the version I use myself I don't have to worry that I will accidentally include genesis stuff into the dfjobs.xml that i submit which would have messed with your repository.
Logged

wedrifid

  • Bay Watcher
    • View Profile

Uh you might want to use a Code tag there.  Smilie faces aren't proper code ;)
Ewww. Yes. Regex syntax dies a painful smiley death. Fixed.
Logged

wedrifid

  • Bay Watcher
    • View Profile

Work on getting the code where you want it.  Dollars to doughnuts someone out there will come forward to compile it by the time you've got 1.0 polished up ;)
Ok, 'ocra' works like a charm. Here is a compiled version http://dffd.wimbli.com/file.php?id=4257. Do let me know if it works.

Put it in the objects folder. Run. Copy and paste output into the bottom half of dfjobs.xml. Make sure you don't remove the entries at the top which all don't refer to 'reaction' in the tag. You'll probably want to keep those. (I should put a comment in there to make the distinction obvious.)
Logged

wedrifid

  • Bay Watcher
    • View Profile

Arhg!

I just noticed that version 0.7.1 is broken! It can't handle stone any more. It seems there were side effects to that last fix.

In version 0.7 the following code worked as expected:
Code: [Select]
    <dfjob name="stone throne" category="mason" type="72" materialType="other" other="INORGANIC">
        <item type="chair" material="all" />
    </dfjob>

But now it produces the 'new job per tick' problem. But wood, metals and glass are all fine.
Logged

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile

Hehe, the difference between > and >= made you >=O :)

Not going to push it out as an emergency or anything, but I have a release coming out today or tomorrow anyway.
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"

wedrifid

  • Bay Watcher
    • View Profile

Hehe, the difference between > and >= made you >=O :)

Not going to push it out as an emergency or anything, but I have a release coming out today or tomorrow anyway.

Oh, you mean line 134 of foremanthread.cpp? Yup, fixed that and it works a treat! ;)

Wait, no. It's formanthread.cpp. You must have corrected the spelling in the dwarfforeman main part but not bothered with changing the background detail. An easy mistake to make given that we are here playing Dwarf Fortress and you are free to spell stuff however you damn well please if it's your code. :P

I'm loving this editor you use, Qt Creator. It has built in Vim mode! If this was around back when I used to use c++ I might just have been able to drag myself away from the bash shell. :P

Your code is impressive too. All that messing around with pointers and hex strings. Glad it is you and not me.


« Last Edit: April 23, 2011, 10:57:07 am by wedrifid »
Logged

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile

See, Dwarf Foreman was already a project, but Dwarf Forman wasn't.. that's the joke sort of, it didn't go over well. I fail.

QTCreator however is awesome, even just for windows development it can't be beat because it "just works". The only flaw is the default gcc backend, and while it is better than msvc it still sucks donkey balls.

Besides xcode which is mac only, QTCreator will probably be the first IDE that has full clang/llvm support. The nokia guys are working pretty hard on it. I'm dying in anticipation.
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"

wedrifid

  • Bay Watcher
    • View Profile

See, Dwarf Foreman was already a project, but Dwarf Forman wasn't.. that's the joke sort of, it didn't go over well. I fail.
Ahh, gotcha. I'm afraid I was introduced to Dwarf Fortress just a week ago so the cultural reference swooshed straight over my head. :P

Playing around with the code I can see why you haven't put in support for subtypes apart from bolts. It gets messy!

Predictably enough I've been investigating the potential for pragmatically generating dfjobs entries for the hard coded jobs as well. ;)
« Last Edit: April 24, 2011, 12:00:27 am by wedrifid »
Logged

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile

Playing around with the code I can see why you haven't put in support for subtypes apart from bolts. It gets messy!

Meh, you just need to think it through to make sure it works with all possible modded versions of DF in any version that may be released in the future. My current codebase is printing this out hehe. RTTI + vectorscan = win.

Spoiler (click to show/hide)

Here is the rev if you wanna patch it into yours just for now http://code.google.com/p/dwarf-foreman/source/detail?r=5845d323f7c8e62bc3e55cfb3306a055c4c023c8
« Last Edit: April 24, 2011, 09:54:24 am by devek »
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"
Pages: 1 ... 18 19 [20] 21 22 ... 32