Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 276 277 [278] 279 280 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1456015 times)

cdombroski

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4155 on: June 24, 2013, 07:39:36 pm »

Is there a way to magically carry out designations?  I ask because I recently finished quickfort plans for the mines on Moria, and I'd love to have a look in Overseer and other visualisers, but there's no way my laptop could actually handle digging it out - designating while paused is one thing, but it's a 12x7 embark and fps death would arrive too fast.  It would also be useful in other situations, but that's not why I'm asking - one example that springs to mind is map alterations like an enormous canyon or a workaround for the channelling AI-fail.

I think tiletypes can do it as long as you're only talking about one action. There's a designated filter; pair that with painting floor shapes should give you what you want assuming you just want regular digging (disclaimer: I've never tried to use this filter). If you want additional actions, I guess you could separate the steps into different phases in quickfort and do them one at a time with the appropriate paint option in between each designation.
Logged

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4156 on: June 24, 2013, 08:39:28 pm »

Is there a way to magically carry out designations?  I ask because I recently finished quickfort plans for the mines on Moria, and I'd love to have a look in Overseer and other visualisers, but there's no way my laptop could actually handle digging it out - designating while paused is one thing, but it's a 12x7 embark and fps death would arrive too fast.  It would also be useful in other situations, but that's not why I'm asking - one example that springs to mind is map alterations like an enormous canyon or a workaround for the channelling AI-fail.

It took a bit longer than I thought, but you can try this (after a good backup of course)

Spoiler: magic-shovel.lua (click to show/hide)

It uses some trimmed and modified code ported from tiletypes.  It isn't perfect so there may be issues with continuing to play a game after using it.  Issues will most likely be related to reveal, light from being opened to the sky, and plants when their tile gets channeled.

EDIT:  Found out that it isn't working for simple dig ...
EDIT2: Fixed part of the problem ...
EDIT3: Ahh, found the last problem.  it should now dig.
EDIT4: performance improvement, only check each tile for designations if has block.flags.designated set .. and fix a refactoring bug I made when fixing the plain dig
« Last Edit: June 25, 2013, 01:47:48 am by Kurik Amudnil »
Logged

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4157 on: June 25, 2013, 05:43:16 am »

Hi, I could not find a complete doc on the ruby bindings so I have a couple of newbie questions.

a) As I am looking at tweak makeown, I see that it goes in a loop through the targeted unit's inventory to unforbid and manipulate values. Is there such a way to select an unit's inventory with Ruby?

b) Can raws be accessed? I want to select an creature raw, through an unit or its name ID, to know the natural skills that were defined.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4158 on: June 25, 2013, 03:52:27 pm »

1. Yeah, assigning a variable to unit.inventory should do the trick
2. Yeah, but I'm not entirely sure how it's done through Ruby.

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4159 on: June 25, 2013, 05:06:33 pm »

I think it would be something like this
Code: (ruby unit inventory) [Select]
unit.inventory.each do |invitem|
    invitem.item.flags.forbid = false
    puts invitem.item.id
end

hack/ruby/ruby-autogen.rb     contains type definitions.
hack/ruby/item.rb  unit.rb  building.rb  etc. contain some additional functions like unit_find or item_find which do about the same thing as dfhack.gui.getSelectedUnit and dfhack.gui.getSelectedItem in lua.  Many of the ruby definitions have a _tg function (for objects with an item id: .item_tg() ) which will search their id in their respective vectors (such as finding an item in items.all or a unit in units.all).  The only real difference in how to access fields in ruby vs lua is that lua usings df.global.etc and ruby uses df.etc

creatures/caste raws are at (lua): df.global.world.raws.creatures.all[ unit.race ].caste[ unit.caste ]

creatures/caste raws are at (ruby): df.world.raws.creatures.all[ unit.race ].caste[ unit.caste ]
    or unit.race_tg  and unit.race_tg.caste[unit.caste]

as a side note, I recently ported 'tweak makeown' to a  lua include for a minor mod to hire caravan guards.  I did change the item ownership claiming such that armor and weapons would remain forbidden so they wouldn't get dropped, but the rest of the own-able clothes would be claimed and owned.  I also changed the actual make_own function to call the function to add historical figure and nemesis data if the unit is of the same race as the fort.

Edit: if 'tweak makeown' gets changed to expose a lua api then my makeown include would probably go away or get moved to hack/lua/plugins/tweak.lua
« Last Edit: June 25, 2013, 05:09:10 pm by Kurik Amudnil »
Logged

meowmix

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4160 on: June 25, 2013, 09:12:07 pm »

does anyone know if there is a dfhack script that instantly ages baby and children dwarves into adult dwarves?
Logged

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4161 on: June 26, 2013, 01:03:15 am »

1. Yeah, assigning a variable to unit.inventory should do the trick
2. Yeah, but I'm not entirely sure how it's done through Ruby.

Thank you, that should be enough to finish a script or two.
« Last Edit: June 26, 2013, 01:19:42 am by Boltgun »
Logged

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4162 on: June 26, 2013, 02:51:23 am »

as a side note, I recently ported 'tweak makeown' to a lua include ...  I did change the item ownership claiming such that armor and weapons would remain forbidden so they wouldn't get dropped, but the rest of the own-able clothes would be claimed and owned.  I also changed the actual make_own function to call the function to add historical figure and nemesis data if the unit is of the same race as the fort.

Edit: if 'tweak makeown' gets changed to expose a lua api then my makeown include would probably go away or get moved to hack/lua/plugins/tweak.lua

I am wondering if I should go ahead and name this include file hack/lua/plugins/tweak.lua  and perhaps get hooked up on github to try to contribute a lua api update to the tweak plugin.  Is there anything specific to the dfhack project I ought to know if I do?  Is there a best practice that I should follow when writing stuff that ought to be used as an include instead of a stand alone script like this makeown.lua and fov.lua (field of view, 2d circular shadow cast)?

edit:  answered some of my own questions about writing contributions by re-reading the OP
« Last Edit: June 26, 2013, 04:35:14 am by Kurik Amudnil »
Logged

catvanbrian

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4163 on: June 26, 2013, 06:05:32 pm »

one question for dfhack tiletypes how do you make a floor out of grass and I mean like the grass outside and inside a cavern, how do you do that?
Logged

cdombroski

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4164 on: June 26, 2013, 06:32:23 pm »

one question for dfhack tiletypes how do you make a floor out of grass and I mean like the grass outside and inside a cavern, how do you do that?

Should be either grass_light or grass_dark material (dry and dead are also available)
Logged

catvanbrian

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4165 on: June 26, 2013, 06:47:45 pm »

one question. how do you make grass floors with tiletypes?
Logged

catvanbrian

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4166 on: June 26, 2013, 06:49:25 pm »

one question. how do you make grass floors with tiletypes?
h wait I all ready typed that sorry it's because my pc is slow
Logged

kingubu

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4167 on: June 26, 2013, 07:34:39 pm »

I has a problem.

Birds in df.global.world.units.active that are slaughtered stay in the list.  Which is the opposite of what I expected.  Seeing how they can't get any less active.

Do dead birds ever leave the list? 
Logged

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4168 on: June 26, 2013, 08:44:04 pm »

I has a problem.

Birds in df.global.world.units.active that are slaughtered stay in the list.  Which is the opposite of what I expected.  Seeing how they can't get any less active.

Do dead birds ever leave the list?

so far as I know all dead units, slaughtered or otherwise remain in active.  I posted a modifed version of hack/scripts/fix/dead-units.lua that would remove only slaughtered units here and posted another version to be more aggressive but save the unit ids so that those units could return the units.active later here.  I probably ought to upload the latter one to dffd.



one question for dfhack tiletypes how do you make a floor out of grass and I mean like the grass outside and inside a cavern, how do you do that?

Should be either grass_light or grass_dark material (dry and dead are also available)

paint shape floor     (floor)
paint material grass_dark     (for dark grass)
paint material grass_dead     (for dead greass)
paint material grass_dry      (for dry grass)
paint material grass_light     (for light grass)
paint variant var_1     (  right  '  )
paint variant var_2     (  ,  )
paint variant var_3     (  left  '  )
paint variant var_4     (  .  )
paint variant any      (or leave variant out and it should pick the first variant for you as needed)


note, this will only make the tile look like grass.  the block also needs an appropriate block_event that contains the amount of the specific grass type per tile in order to actually have grass.

Brilliand

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4169 on: June 26, 2013, 11:09:11 pm »

[edit] I've just written a new plugin (which will be called "cleanconst") which gets rid of construction materials and marks them to be recreated on disassembly.

I've ported this to lua.

Code: [Select]
local cleaned_total = 0

for _,item in ipairs(df.global.world.items.all) do
-- only process items marked as "in construction"
if item.flags.construction then
local pos = item.pos
local cons = df.construction.find(pos)
-- if the construction is already labeled as "no build item", then leave it alone
if not cons then
dfhack.printerr("Item at "..pos.x..","..pos.y..","..pos.z.." marked as construction but no construction is present!")
elseif not cons.flags.no_build_item then
-- only destroy the item if the construction claims to be made of the exact same thing
if item.getType(item) == cons.item_type and
item.getSubtype(item) == cons.item_subtype and
item.getMaterial(item) == cons.mat_type and
item.getMaterialIndex(item) == cons.mat_index then

item.flags.garbage_collect = 1
cons.flags.no_build_item = 1
cleaned_total = cleaned_total + 1
end
end
end
end

dfhack.println("Done. "..cleaned_total.." construction items cleaned up.\n");

Could someone confirm that mat_index in lua is the same as matgloss in C++?  It's the closest thing I could find, but since it doesn't have the same name, I'm not completely sure.

Installation instructions: Put the above code in a file named "cleanconst.lua" in your "hack/scripts" directory.  Type "cleanconst" in the dfhack window to run it.

Anyway, when I actually ran this, it didn't have any noticeable effect on my 6 FPS.  YMMV.
Logged
The blood of our enemies is but a symbol.  The true domain of Armok is magma - mountain's blood.
Pages: 1 ... 276 277 [278] 279 280 ... 373