Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Script request - Simple simulated mining  (Read 2273 times)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Script request - Simple simulated mining
« on: March 25, 2015, 02:51:31 am »

Hey guys,

Could anyone come up with a script that does following thing: It removes unmined inorganic tiles. Best case with arguments for X,y and z axis, and the option to replace them with "open space", "downstairs", "upstairs" or "channel".

What I have in mind is a 1-tile workshop that has a reaction "dig a hide hole", which creates a downstairs next to is, and a 3x3x1 room underneath, with an upstairs under the downstairs tile.

If it only works on soil, even better. But it should NOT leave any mined objects. So if a person does this over a gold vein, he will essentially remove the gold, without ever getting the ore.

While this sounds completely crazy, I do have a good reason: I want kobolds be unable to dig, but it's a pain to build rooms for their furniture, which has to be 'inside'. It would be much easier if they can dig little holes into the soil.

I do have this old script by IndigoFenix, which digs a 3x3 hole straight into hell, I think it can be used as a good basis for this idea:

Code: [Select]
    local pos=position or copyall(df.global.cursor)
    if pos.x==-30000 then
        qerror("Select a location")
    end
local x = 0
local y = 0
for x=pos.x-3,pos.x+3,1 do
for y=pos.y-3,pos.y+3,1 do
z=pos.z
while true do
local block = dfhack.maps.getTileBlock(x,y,z)
if block then
--print(x..","..y)
block.tiletype[x%16][y%16]=32
z = z-1
else
z = z+1
block = dfhack.maps.getTileBlock(x,y,z)
block.tiletype[x%16][y%16]=42
break
end
end
end
end

Thank you!

PS: If that upstairs/downstairs thing is too hard, just use ramps. :D
« Last Edit: March 25, 2015, 02:53:06 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 :::

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Script request - Simple simulated mining
« Reply #1 on: March 27, 2015, 09:15:29 pm »

Nothing?
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: Script request - Simple simulated mining
« Reply #2 on: March 28, 2015, 04:12:53 am »

Stuff's complicated, heh. I basically don't understand it at all, myself.

It's fully possible that it could be just a simple fix. It might not be, but it's possible.

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Re: Script request - Simple simulated mining
« Reply #3 on: March 28, 2015, 06:18:38 am »

As I understand, it's all just about finding the block and changing tiletype to open space or to stars, or whatever else.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Script request - Simple simulated mining
« Reply #4 on: March 28, 2015, 06:49:52 am »

As I understand, it's all just about finding the block and changing tiletype to open space or to stars, or whatever else.
That's what I thought, but that script I posted was for 34.11, I dont know how it fares with 40.24.

It should be easy in theory, because I dont want actual mining, no ores or boulders created... just a hole in the ground is enough. :)
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 :::

BoredVirulence

  • Bay Watcher
    • View Profile
Re: Script request - Simple simulated mining
« Reply #5 on: March 28, 2015, 07:36:29 pm »

I'm not particularly familiar with scripting in dfhack, but I'm pretty sure I see what it does. If I can find the relevant documentation I should be able to get something, if someone doesn't beat me to it.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Script request - Simple simulated mining
« Reply #6 on: March 28, 2015, 09:55:19 pm »

Anything simple that works will be fine. Even if it only creates a 3x3x1 hole in the ground with nothing else. :D Players can still build up/downstairs as contruction, thats not a problem.
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 :::

BoredVirulence

  • Bay Watcher
    • View Profile
Re: Script request - Simple simulated mining
« Reply #7 on: March 31, 2015, 10:23:37 am »

Here's something.

Spoiler: DigRoom (click to show/hide)

It currently only mines out soil, but that can be toggled by ALL_MATS_ALLOWED.
I originally had it so that you could define your own "configuration" and pass it in with -c, but it didn't seem to work. For now, edit the default configuration, and it should be simple to define several, add an argument, and use the appropriate configuration based on that argument.

Do note that the "configuration" is defined oddly. By formatting it z,y,x rather than x,y,z it appears similar to diagrams people draw in ASCII. Also, it currently only supports stairs, floor, and wall. It may be able to do others, but I'd advise against it, and ramps won't work. Also, when defining your own configuration, for the love of god don't use nil to define an unchanged tile, use 'empty', because nil will mess with detecting the size, then you have to define the size rather than detect it automatically. And since the size can be detected, you should be able to define jagged arrays. I haven't tested that, but it should work.
Logged

Dirst

  • Bay Watcher
  • On hiatus
    • View Profile
Re: Script request - Simple simulated mining
« Reply #8 on: March 31, 2015, 10:31:20 am »

So, now the kobolds have a bunker bomb.
Logged
On hiatus. Feel free to adopt or update:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Dirst

  • Bay Watcher
  • On hiatus
    • View Profile
Re: Script request - Simple simulated mining
« Reply #9 on: March 31, 2015, 10:46:54 am »

This could be modified to enable really inefficient mining of arbitrary scope.  Make it choose a random adjacent tile that is designated for mining/channeling/ramping/etc. and change the tile the same way a miner would... except this process uses a building rather than a pick (perhaps an elaborate set of wooden wedges expanded by soaking them).  If there was a way to institute a delay, the rate of progress could vary with the material mined.  Otherwise just make the stone-digging version take more resources to build.
Logged
On hiatus. Feel free to adopt or update:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

BoredVirulence

  • Bay Watcher
    • View Profile
Re: Script request - Simple simulated mining
« Reply #10 on: March 31, 2015, 11:15:25 am »

This could be modified to enable really inefficient mining of arbitrary scope.  Make it choose a random adjacent tile that is designated for mining/channeling/ramping/etc. and change the tile the same way a miner would... except this process uses a building rather than a pick (perhaps an elaborate set of wooden wedges expanded by soaking them).  If there was a way to institute a delay, the rate of progress could vary with the material mined.  Otherwise just make the stone-digging version take more resources to build.
This can be used for arbitrary shapes, so maybe have a second script that has a timer mine out single layers.
In theory, you could make a drill type of building.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Script request - Simple simulated mining
« Reply #11 on: April 01, 2015, 08:19:37 am »

Awesome! Thank you a lot. I'll try to play around with it and let you know how it went. :)
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 :::