Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 284 285 [286] 287 288 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1388589 times)

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.34.11 r3
« Reply #4275 on: July 22, 2013, 10:11:55 am »

df.global.world.world_data.region_map is a special structure - it's a 2-dimensional array which is sized according to the dimensions of your world (e.g. between 17x17 and 257x257), and DFHack/Lua doesn't properly know how to treat it as a 2D array, so you'll need to use _displace() to index into it (e.g. "df.global.world.world_data.region_map:_displace(x).value:_displace(y)").

Alternatively, you can let DFHack do the work for you and use the function "dfhack.maps.getRegionBiome(x,y)".
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

acetech09

  • Bay Watcher
  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4276 on: July 22, 2013, 12:17:03 pm »

Is stonesense operational on OSX? Every time I try to launch it, it crashes DF. I'm not sure if it's a known issue.
Logged
I challenge you to a game of 'Hide the Sausage', to the death.

vjek

  • Bay Watcher
  • If it didn't work, change the world so it does.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4277 on: July 22, 2013, 12:27:21 pm »

df.global.world.world_data.region_map is a special structure - it's a 2-dimensional array which is sized according to the dimensions of your world (e.g. between 17x17 and 257x257), and DFHack/Lua doesn't properly know how to treat it as a 2D array, so you'll need to use _displace() to index into it (e.g. "df.global.world.world_data.region_map:_displace(x).value:_displace(y)").

Alternatively, you can let DFHack do the work for you and use the function "dfhack.maps.getRegionBiome(x,y)".
Further to this, would it be possible to recursively prospect each region to get a worldwide list of stones, to make a holistic Finder?
« Last Edit: July 22, 2013, 12:33:59 pm by vjek »
Logged

fricy

  • Bay Watcher
  • [DFHACK:ZEALOT]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4278 on: July 22, 2013, 01:01:30 pm »

Is stonesense operational on OSX? Every time I try to launch it, it crashes DF. I'm not sure if it's a known issue.

Try this:

http://dffd.wimbli.com/file.php?id=7850

lastofthelight

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4279 on: July 23, 2013, 06:20:05 pm »



Query. I've been playing with it, but I can't seem to get it to work.

How do I use createitem to:

1. Create gold ore?

2. Create clear glass blocks?

I think if I could see how to do these, the function of it would become much clearer for me. I've had some partial successes, but they certainly have not worked out as I intended, heh.

Thanks!
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4280 on: July 24, 2013, 12:51:59 am »

Code: [Select]
BOULDER INORGANIC:GOLD
it works like reactions but you remove the ITEM. so if it's ITEMTOOLS then you use TOOLS in the code. also loads of spaces
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4281 on: July 24, 2013, 03:55:50 am »

Hey everyone, I stumbled upon a little problem. I am sure there is a simple solution for it, I just dont know it yet. I have this nice script that Urist da Vinci wrote, its actually two scripts. The first one shows the access of a civ to a specific material, this example show all wood types. The second one removes all items, crafts, barrels and so forth, of a specific wood.

wood.lua => Shows the tree_id of accessable wood.
Code: [Select]
local my_entity=df.historical_entity.find(df.global.ui.civ_id)

for k,v in pairs(my_entity.resources.organic.wood.mat_type) do
sText=dfhack.matinfo.decode(v,my_entity.resources.organic.wood.mat_index[k])
print(sText)

if (sText==nil) then
--print("nil")
else
--print("OK")
print(sText.plant.id)
end
end


nosporewood.lua => Removes access to sporewood from your civ. No more sporewood at embark or from traders.
Code: [Select]
removes all SPORE_TREE wood from all civs:

local my_entity=df.historical_entity.find(df.global.ui.civ_id)
local sText=" "
local k=0
local v=1

for x,y in pairs(df.global.world.entities.all) do
my_entity=y

k=0
while k < #my_entity.resources.organic.wood.mat_index do
v=my_entity.resources.organic.wood.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.organic.wood.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.crafts.mat_index do
v=my_entity.resources.misc_mat.crafts.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.crafts.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.barrels.mat_index do
v=my_entity.resources.misc_mat.barrels.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.barrels.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.wood2.mat_index do
v=my_entity.resources.misc_mat.wood2.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.wood2.mat_index[k])
if (sText==nil) then
--LIQUID wood2
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.cages.mat_index do
v=my_entity.resources.misc_mat.cages.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.cages.mat_index[k])
if (sText==nil) then
--LIQUID cages
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end
end

The problem that arises is that the user must run it manually. I can add "nosporewood" to the dfhack.init, but it does not work. The script, just like embark everywhere or startdwarf, has to be run at the embark screen, on the map before you press 'e' and get to your embark selection. The quesion I have is: Can this be automated? Are there any lines that can be added so that the script is run every time the embark screen is opened?

And if yes, would a small pop-up/ui be possible? It would be nice if a player would start DF, go to the embark selection, and a little pop-up shows with "With how many citizens would you like to embark? (min-7)" and the player could add a number, press enter, and thats it. Just to make the startdwarf script a bit more accessable.

Background info, for those who care: Evaporating wood can be done, and can affect woodcutter with syndromes. But you cant use it on the surface or in the caverns, because these wood types are stable in worldgen, so caravans will bring wagons, barrels and items made of those materials. They then instantly boil away, affecting the trader with the syndrome. If I remove these with a script from the traders, I can make syndrome-bearing trees... good with positive effects, evil with negative effects.. a firestarting-tree for deserts, poisonous gas-clouds from giant underground mushrooms, and so forth.

Which leads to question number 3: The script only removes it from your home-civ, if I am not wrong. Which means that allies, like elves, would still bring these evaporating wood types. I would need a variant of this script that targets all civs. I assume its just changing the my_entity. with something else, but I dont know lua. One for creatures/pets would be even more helpful. It would be a lot easier to assign specific domestic pets to specific races, which is a major point in MasterworkDF, because of the multiple playable races. It even leads to some bugs, because I have to remove and add several creatures, depending on which race you play.

I also found this script while reading through custom ones that have been posted:
Code: [Select]
MEDIC.RB. Mark unit as requiring a medic.

# Mark a unit as requiring a medic
selected = df.unit_find()

if selected == nil
   puts "You must select a dwarf first"
else
   puts "Marking '#{selected.name}' as needing a medic"
   selected.health.flags.rq_diagnosis = true
   selected.health.flags.needs_healthcare = true

   # This is normally set if dwarf can't walk,
   selected.health.flags.needs_recovery = true
end

As far as I understand it you look at a dwarf with 'k', then run the script, and the job-priority for diagnosis and rescue go up. So if an injured dwarf is lying, ignored, on a battlefield, or the chief medical dwarf is for some reason not diagnosing a patient in the hospital, then this script will help?

To sum it up:
#1: Can a script be automatically run once the embark screen/map opens?
#2: Can this script open a small pop-up that accepts a number as entry, for the startdwarf.rb script?
#3: Could someone please be so kind (if #1 has a yes as answer), to change the script to target all civs, instead of just the players civ?
#4: Can the above-shown scripts be altered to show/erase available creatures/pets?
#5: Does anyone have experience with the medic.rb script and could give a short readme for it?
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4282 on: July 24, 2013, 04:10:38 am »

1. Yes, with init.lua. For nosporewood, you have to remove the first line; then, the rest of the file goes into init.lua, which goes at the top folder of the raws folder.
2. Yes, but I (or someone else) will have to write that my/his/herself.
3. nosporewood already does. Also, Da Vinci: you could just have for k,my_entity in ipairs instead of for x,y and having y be set to my_entity.
4. Yeah
5. Medic.rb is so simple, I don't even KNOW ruby and I can read it.

Step 1: select dwarf with k or v menu (not related to for k,v in lua, btw).
Step 2: run "medic".
Step 3: that's it. You're done.

You could very easily just make it a hotkey.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4283 on: July 24, 2013, 04:18:15 am »

Thanks Putnam.

1. Where can I find the init.lua? I can frankenstein those together with what you told me, but I cant find an init.lua in my hack folders.
2. I will ask falconne about the pop-up, he seems to be the most experienced person when it comes to UIs, judging from workflow/dwarfmonitor.
3. Awesome.
4. Again, awesome. I'll ask DaVinci if he can do this.
5. Yes, I know how to use it. But does it work? I assume the flag is already set to true, so why should this script shorten the time a dwarf gets rescued/diagnosed?
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4284 on: July 24, 2013, 04:31:39 am »

For nosporewood, you have to remove the first line; then, the rest of the file goes into init.lua, which goes at the top folder of the raws folder.

You need to make it.

5. The flag is being set to true for creatures who have issues with being, say, legless but not being given a crutch due to bugs.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4285 on: July 24, 2013, 04:53:38 am »

Ah, ok. I thought that there should have been a init.lua that hooks into something. I will have a go at it, see if I can get it to work. At least the automated start.

Edit: Cant get it to work. Top folder of the raws folder? That would be the DwarfFortress folder, next to the .exe.

init.lua looks like this:
Code: [Select]
--local my_entity=df.historical_entity.find(df.global.ui.civ_id)
local sText=" "
local k=0
local v=1

for x,y in pairs(df.global.world.entities.all) do
my_entity=y

k=0
while k < #my_entity.resources.organic.wood.mat_index do
v=my_entity.resources.organic.wood.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.organic.wood.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.crafts.mat_index do
v=my_entity.resources.misc_mat.crafts.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.crafts.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.barrels.mat_index do
v=my_entity.resources.misc_mat.barrels.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.barrels.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.wood2.mat_index do
v=my_entity.resources.misc_mat.wood2.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.wood2.mat_index[k])
if (sText==nil) then
--LIQUID wood2
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.cages.mat_index do
v=my_entity.resources.misc_mat.cages.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.cages.mat_index[k])
if (sText==nil) then
--LIQUID cages
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end


end

Anything I have to add to the dfhack.init?
« Last Edit: July 24, 2013, 06:55:37 am by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4286 on: July 24, 2013, 06:48:08 pm »

#1 something like this can be run from dfhack.init and listen for the embark screen
Spoiler: embark_listener.lua (click to show/hide)
Listening for the embark profile select/modify screen might be useful for adjusting the embark points according to the number of extra dwarfs given by startdwarf (number of dwarfs over 7 might be easier to detect)


#2 a problem with the popup question for startdwarf is trying to run startdwarf (a ruby script) from a lua script, or translating startdwarf to lua.  Also, if you get to the embark profile screen, it is too late to ask about startdwarf. Running startdwarf at the site selector seems to be fine.

#3 I think that filtering the trade goods probably ought to happen at the site selector also. 

#5 I haven't noticed any improved response times for marking a unit for recovery/diagnosis as the dwarf in question usually has those flags already set to true.  I have thought about trying to force the unit to have a resting state/job but haven't tested that yet.
« Last Edit: July 24, 2013, 06:58:19 pm by Kurik Amudnil »
Logged

Somanarga

  • Escaped Lunatic
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4287 on: July 24, 2013, 07:53:40 pm »

hey guys, i have a bit of a situation and im hoping you guys can help me.

my map is permanently revealed. ive tried unrevealing, but it gives me error "there is nothing to revert!". i try revforget "there is nothing to forget!"

i can reveal/unreveal and it gives me the proper prompts, but nothing changes on the map, unless i do reveal hell, which shows hell, then i can unreveal and it blocks hell off again. doesnt change the already revealed spots though.

is there a way to fix this? or am i screwed?
Logged

kingubu

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4288 on: July 24, 2013, 08:13:42 pm »

Try 'revflood'
Logged

Somanarga

  • Escaped Lunatic
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4289 on: July 24, 2013, 08:16:58 pm »

Try 'revflood'

"point the cursor at some empty space you want unhidden"

everything is already unhidden so it wont hid it D:
Logged
Pages: 1 ... 284 285 [286] 287 288 ... 373