Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Construct with Cloth [DFHack lua script]  (Read 9186 times)

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Construct with Cloth [DFHack lua script]
« on: July 26, 2017, 10:52:15 am »

Saw that NPC armies can make cloth camps, and player can't. Unfair! This script fixes that.

Spoiler: constructwithcloth.lua (click to show/hide)

Basically, it takes the native construction material list, grabs all unused cloth in the fortress, and gives back new material list that is both combined.
It may happen that some cloth in fortress is behind walls and you get things like dist -12500 for some pieces.
To fix that there's secondary function to remove such cloth in expanded view (contract to refresh).

Will do nothing if you're not in Construction menu or don't have any normal materials to build with, unless you call it with help/?/-help/-? (which gets usage instructions).

To use, you would save the above code as constructwithcloth.lua in hack/scripts,
then call constructwithcloth with dfhack as you're sizing the wall or picking it's materials (need to expand/contract to update).

Now, why use this?



Aesthetics. Cloth walls as inside separators look nice.

There's two one known issues:
1) Box select will, after using up automated material, return you to normal material menu. To fix, call it again and expand/contract to refresh the list.

2) Doesn't work with 43.03 (linux) dfhack (fails silently, unless you remove the safeties, in which case it crashes), as that version lacks the appropriate memory addresses. (But does work with 43.05 AND 42.06). Don't know how to fix this =( Fixed =)

« Last Edit: September 11, 2018, 03:19:31 am by Fleeting Frames »
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Construct with Cloth [DFHack lua script]
« Reply #1 on: July 26, 2017, 12:19:04 pm »

I don't think this is my cup of tea, but a couple of comments regardless:
- What about colored cloth? I can see a substantial aesthetic appeal in having different colors (although the DF dye range isn't exactly stellar).
- What about paper? I think paper walls were is use in Japan during the approximate DF timeline. It may be that you're just using what's already there but unavailable, while paper walls would be something new.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Construct with Cloth [DFHack lua script]
« Reply #2 on: July 26, 2017, 02:45:47 pm »

- Coloured cloth works, tested using sliver barb, gcs cloth became dark grey. Redroot dyed walls as marking of dangerous areas may hold particular appeal, as well as perhaps dimple dyed areas for sleeping quarters and bridges/underwater tunnels

- Not difficult change to make, but I tried leather and parchment sheet, as they're kind of similar to cloth (in my mind). However, upon tests it appeared that they take on the appearance of default (rock) walls, with parchment being white and leather brown. (I also considered cloth doors, and subsequently door walls/staircases. Alas, they behaved as if made from normal stone.)
« Last Edit: July 26, 2017, 02:48:48 pm by Fleeting Frames »
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Construct with Cloth [DFHack lua script]
« Reply #3 on: July 26, 2017, 03:40:01 pm »

Sad but not unexpected... Nice that colored cloth works, though.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Construct with Cloth [DFHack lua script]
« Reply #4 on: September 11, 2018, 03:17:19 am »

Small update: Seems it now works with 43.03-r1:

||

Just had to use :_displace(1,4) on the relevant memory structure to align it properly.

Also should be slightly more efficient now as instead of looking at all items and choosing cloth ones it chooses from cloth item list instead.

(Also works with at least 44.09, so it's aged well.)

lethosor

  • Bay Watcher
    • View Profile
Re: Construct with Cloth [DFHack lua script]
« Reply #5 on: September 13, 2018, 09:15:01 am »

Quote
Code: [Select]
local displacedRequirs = df.global.ui_build_selector.requirements [0]:_displace(1,dfhack.VERSION=="0.43.03-r1" and 4 or 0) --somehow 4 is appropriate size for moving it 2 ints south?
I'm guessing this displaces the start of ui_build_item_req, which has a job_item_filter at the beginning, which starts with two 16-bit integers. Those take up 2 bytes each (not all integers are the same size).
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Construct with Cloth [DFHack lua script]
« Reply #6 on: September 13, 2018, 12:01:20 pm »

Yup. When I saw looking at the deeper field in that struct crashed the game and when attempting to build 3 tiles of construction resulted in count_provided being 3, rather than count_required (i.e. 2 values after), with the preceding values having nonsense numbers, the problem was obvious. The solution, however, took me until now to find, after it occurred to me after going through lua docs and trying variety of different sizes such as 2^32, only arriving at 4 when those failed to work and I started to look at what incrementing it does.

zilpin

  • Bay Watcher
  • 437 forever!
    • View Profile
Re: Construct with Cloth [DFHack lua script]
« Reply #7 on: October 14, 2018, 09:36:13 am »


Very clever.
Logged