Hi!
I'm having a hard time getting started with dfhack. Trying to get stacks to combine
( because my dorfs are filling every available container with "stacks of 2 meat" or "stacks of 2 [distillable plant]" while they're also slowly dying of dehydration because there are no containers left for the still even with my constantly growing super-stockpile-of-epic-lag and I'm sick of the constant barrel micromana... HEY DON'T PUT THOSE 100 STACKS OF ONE ARROW INTO THOSE BINS, THOSE ARE FOR THE CARAVAN!!!) *eeeerm-back-to-topic-sorrry*
... this is my first idea about how this could be achieved in a natural looking and possibly efficient manner, but I didn't get far - well, didn't really get started... -.-
pseydo-pseydocode:
while true do
c=get_random_container()
ia=get_random_item(c)
ib=get_random_item(c)
sleeponsuccess = 1000 + 10000 / amount_of_stackable_items_in_fortress_or_something
sleeponfail = 100 + 100 * $failed;
if stack_stacks(a, b) then
{ sleep $sleeponsuccess; failed=0 }
else
{ sleep $sleeponfail; failed++ }
done;
function stack_stacks(item1, item2)
{
if (item1 == item2 || item1.type != item2.type || item1.material != item2.material || item1.weight + item2.weight > 200) do return false
else do {
item1.stack_size += item2.stack_size;
item1.age = (item1.age + item2.age) / 2
item1.temperature = (item1.temperature + item2.temperature) /2
item1.therestofallthoseproperties = dostuff(item1.thoseproperties, item2thoseproperties)
item2.delete_dat_thing;
return "yay!"
}
So far so "good"... love pseydocode... could write or read it all day... well... and that's how far I actually got for real:
df.world.items.all.each do |c|
if c.flags.container then
c.general_refs.each do |id|
if id.respond_to?(:item_id=) then
i= df.world.items.all.binsearch(id.item_id)
puts "mat #{i.mat_type} #{i.mat_index}"
puts "stack #{i.stack_size}"
puts i
# bwahahaha i hate ruby
# new hash-thingy["#{i.pos.x}#{i.pos.y}#{i.pos.z}][
end
end
end
end
# puts df.world.items.inspect
I CAN'T FIND SH*T!( neither documentation about dfhack nor -out how ruby works T_T )
Uhm... HELP!!!!?