Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: custom reaction - burn wood objects into charcoal (tags: wooden, furniture)  (Read 844 times)

sheepish_gorilla

  • Bay Watcher
    • View Profile

Hey guys, credits to original posts are at the bottom of the post, but I thought people might be interested in ready to use code:

Ever wanted to burn all those non-masterpiece beds? Ever thought: I need more charcoal, but all these elves sell are useless wooden goods? worry no more!

The code below lets you burn furniture and other wooden objects at a wood furnace to obtain charcoal. Normally, a new ID is used for a new reaction. The downside of a new reaction is that a map regen is necessary. The example below shows how a reaction ID of a current game (making billon from raw ores) can be used to add a new reaction without having to start over a map.

In the code, for each piece of wood furniture, 0.25 charcoal is generated. This is just for balance, 1 on 1 recycle seems cheaty. Since custom reactions can't work in the same way as melting metal, 1 bar of charcoal is generated for 4 units of furniture. Since 4 different reagents are used, this does not necessarily need to be 4 beds, but can be 4 different wood objects. in the current code, each type of wooden object is elligible, so it is advisable to create an additional wood furnace and link specific stockpiles to this furnace. This allows you to burn low quality items, while preventing your masterpiece beds going up in flames.

the text below replaces the original 'billon making' reaction in data/save/'your save'/raw/objects/reaction_smelter.txt.

[REACTION:BILLON_MAKING]
[NAME:burn furniture]
[BUILDING:WOOD:CUSTOM_B]
[REAGENT:A:1:NONE:NONE:NONE:NONE][ANY_PLANT_MATERIAL][HARD_ITEM_MATERIAL][EMPTY]
[REAGENT:B:1:NONE:NONE:NONE:NONE][ANY_PLANT_MATERIAL][HARD_ITEM_MATERIAL][EMPTY]
[REAGENT:C:1:NONE:NONE:NONE:NONE][ANY_PLANT_MATERIAL][HARD_ITEM_MATERIAL][EMPTY]
[REAGENT:D:1:NONE:NONE:NONE:NONE][ANY_PLANT_MATERIAL][HARD_ITEM_MATERIAL][EMPTY]
[PRODUCT:100:1:BAR:NO_SUBTYPE:COAL:CHARCOAL][PRODUCT_DIMENSION:150]
[SKILL:WOOD_BURNING]

An important thing to note is that the code above works with all wood items. You don't want to turn every single wooden bolt into 0.25 charcoal. So keep that in mind while setting up the stockpiles.

Also, for wooden crafts 3 pieces are created for every piece of wood. So, if you have wooden crafts, you may want to add an additional reaction which uses 12 reagents instead of 4.



The original information comes from the following 2 posts:

turn wood items into charcoal
http://www.bay12forums.com/smf/index.php?topic=64706.0

[Reaction] Burn wooden object to ash
http://www.bay12forums.com/smf/index.php?topic=151874.msg6377142#msg6377142

especially the last one was useful. But somehow it did not turn up in my search queries, I only found it after 2 hours of experimentation based on the first post and only then using some reaction details in the search quer. Apparently, 'wood' and 'wooden' aren't interchangeable. That's why I've added the extra tags in the title. If I need to add other tags for future reference, please let me know! (although, is it possible to change the title on existing posts?)

Also, I just found there is an example custom reaction page on the wiki! http://dwarffortresswiki.org/index.php/DF2014:Reaction_examples
I've added the code above to it. I've also added a link to it from the main 'custom reaction' page, but I would encourage others to add their useful reactions to this page!
Logged

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution

Hmm that's for sure one easy way to make a generic burn 4 wooden items (including logs) to make charcoal, I always went the route of REACTION_CLASS on the WOOD_TEMPLATE. However I might be able to get away with that by using the same tags you just used/found
Code: [Select]
[ANY_PLANT_MATERIAL][HARD_ITEM_MATERIAL][EMPTY]

However I still feel a reaction per furniture item is still viable as maybe I just wanted to burn all my tables and chairs, not my buckets, and barrels.

and with the glory of CATEGORY for reactions we can now have a workshop have lots of reactions without cluttering it too too much.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile

Can't you make it so that the reaction takes only one wooden object as a reagent but only outputs charcoal with a 25% probability? Might be less unwieldy to use.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

sheepish_gorilla

  • Bay Watcher
    • View Profile

Can't you make it so that the reaction takes only one wooden object as a reagent but only outputs charcoal with a 25% probability? Might be less unwieldy to use.

That should also be possible, with 25 after PRODUCT. This should work:

Code: [Select]
[REACTION:BILLON_MAKING]
[NAME:burn furniture]
[BUILDING:WOOD:CUSTOM_B]
[REAGENT:A:1:NONE:NONE:NONE:NONE][ANY_PLANT_MATERIAL][HARD_ITEM_MATERIAL][EMPTY]
[PRODUCT:25:1:BAR:NO_SUBTYPE:COAL:CHARCOAL][PRODUCT_DIMENSION:150]
[SKILL:WOOD_BURNING]

Note that I haven't tested it. Also, with this reaction your wood burner needs to perform 4 reactions at the workshop to get the same amount of charcoal, so it takes 4x as much time to complete.
Logged

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution

Yeah that looks about right, however working 4 times as much might not be true, just means you only have a 1 in 4 chance of getting a result. If RNGeus smiles on you, you can be very lucky and get results many times in a row, or nothing for years.
Logged

TheDorf

  • Bay Watcher
    • View Profile

I tried to use this, with separate reactions for various items. However, it doesn't seem to work for me.



Code: [Select]
[REACTION:BURN_WOODEN_BED]
[CATEGORY:burn wooden items]
[NAME:burn bed]
[BUILDING:WOOD:CUSTOM_B]
[REAGENT:A:1:BED:NONE:NONE:NONE][ANY_PLANT_MATERIAL][HARD_ITEM_MATERIAL][EMPTY]
[PRODUCT:90:1:BAR:NO_SUBTYPE:COAL:CHARCOAL][PRODUCT_DIMENSION:150]
[SKILL:WOOD_BURNING]
Logged
I love this community. Somebody asks "hay guise how do i tame shark", and then everybody is like "why don't we fling sharks at things with complex mechanical devices?".

bloop_bleep

  • Bay Watcher
    • View Profile

I'm not sure, but perhaps the [EMPTY] tag on the bed reagent (which would be useless even if it didn't cause the problem) is the culprit?
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.