Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Using Gems in Reactions  (Read 1316 times)

Keldane

  • Bay Watcher
    • View Profile
Using Gems in Reactions
« on: March 17, 2011, 03:35:52 pm »

So, I'm working on a mod which will include some fictitious metals forged by combining gems with existing metals. I'm having a little trouble figuring out how to do this, however. Specifically, I want to use any kind of uncut diamond for this reaction. The wiki provided me with the ROUGH item token for rough gems, and I'm not sure how to specify a specific type of gem from there. Am I right in thinking that I'm going to have to have one reaction per type of diamond, and would the line below work?

Code: [Select]
REAGENT:B:1:ROUGH:NO_SUBTYPE:INORGANIC:DIAMOND_CLEAR
Logged
WARNING:Side effects may include fatal badgerstorm and sudden appreciation for nobles.

Pickerel

  • Bay Watcher
    • View Profile
Re: Using Gems in Reactions
« Reply #1 on: March 17, 2011, 04:28:17 pm »

I don't know if this is going to answer your question, but I have been working with gems and glasses lately so here is what I have learned.

You will not have to have a reaction for every diamond necessarily.  If, for example, you do the following: 
Use this in the reaction:
[REAGENT:B:1:ROUGH:NONE:NONE:NONE] in other words, telling it to "use ANY rough gem..."
     [REACTION_CLASS:KELDANES_DIAMOND_MOD_YAY] "But ONLY those with this reaction class definition token"
Then put this by [REACTION_CLASS:KELDANES_DIAMOND_MOD_YAY] in the raw entry of every gem you want to be usable in the reaction.  If you put it by diamonds, only diamonds will be chosen.  If you put it by three specific gems, only they will be chosen.

The downfall of the single-reaction method is that, since there is one generic reaction that uses only any diamond, you won't be able to specify which diamond.  So if you want each diamond to make a different product, or want to control which type of diamond is used in any way (other than using stockpiles to control what is nearest), you are going to have to have a reaction for each diamond or for only several diamonds each.

There are, however, a variety of ways to mass produce reactions.  For example, lets say we have red diamond and green diamond, and you want red to make a Flameite, and green to make Poisonite.  You will need two separate reactions.  But there's two quick ways off the top of my head to make them.
1. Copy and paste, and then just change REACTION_CLASS listings.  For the red diamond, you could refer to it as such:
[REAGENT:B:1:ROUGH:NONE:NONE:NONE]
     [REACTION_CLASS:KELDANES_RED_DIAMONDS]
[PRODUCT:100:150:BAR:NONE:INORGANIC:FLAMEITE]
and in the red diamond's raw entry, put  [REACTION_CLASS:KELDANES_RED_DIAMONDS]
Then, copy and paste the reaction, and change a few words:
[REAGENT:B:1:ROUGH:NONE:NONE:NONE]
     [REACTION_CLASS:KELDANES_GREEN_DIAMONDS]
[PRODUCT:100:150:BAR:NONE:INORGANIC:POISONITE]
and put in the raw entry of the green diamond: [REACTION_CLASS:KELDANES_GREEN_DIAMONDS]
2. Have many specific reactions.  Copy and paste the reactions, and modify accordingly.  For example,
[REAGENT:B:1:ROUGH:NONE:INORGANIC:DIAMOND_RED] (I don't remember the diamond's actual raw)
[PRODUCT:100:150:BAR:NONE:INORGANIC:FLAMEITE]
copy and paste it and just modify to use be the following:
[REAGENT:B:1:ROUGH:NONE:INORGANIC:DIAMOND_GREEN] (I don't remember the diamond's actual raw)
[PRODUCT:100:150:BAR:NONE:INORGANIC:POISONITE]
3. (I JUST THOUGHT OF THIS ONE:) Have a SINGLE reaction again, but specify in the raws of each gem, a material reaction product.  In our example, you would put, in the raw of each gem, a material reaction product.  For example, you would put in the red diamond's entry [MATERIAL_REACTION_PRODUCT:MAGIC_MATERIAL:INORGANIC:FLAMEITE]
and in the green diamond's entry [MATERIAL_REACTION_PRODUCT:MAGIC_MATERIAL:INORGANIC:POISONITE]
THEN, in the reaction refer to it thusly:
[REAGENT:B:1:ROUGH:NONE:NONE:NONE] so any rough gem
     [HAS_MATERIAL_REACTION_PRODUCT:MAGIC_MATERIAL] but only those with one of the 'MAGIC_MATERIAL' reaction products specified.
[PRODUCT:100:150:BAR:NONE:GET_MATERIAL_FROM_REAGENT:B:MAGIC_MATERIAL] in other words, produce a unit of the material specified by the MAGIC_MATERIAL reaction product of whatever gem it happened to have used.  So if it happens to use a red gem, it will produce a bar of FLAMEITE, while if it used a green gem, it would be a bar of POISONITE

Way #1 is best if you may want to define more than one diamond for a particular reaction.  For example, if you wanted both red and yellow diamonds to make Flameite.  Just put the [REACTION_CLASS:KELDANES_RED_DIAMONDS] in the raw entries of both yellow and red diamonds.
Way#2 is faster, but less versatile, because one is limited by how well one can define things in a single reagent entry.  So you can be completely specific, 'choose a rough red diamond', but the next step down is just 'choose any inorganic rough', which is now quite broad.  However this way is better if you really will only want one diamond type per reaction - only red, for example, to make Flameite.
Way#3 has the least amount of duplication, and won't clutter your workshop with reactions to choose from, but also gives you no control on what gem, out of all the possible gems with the reaction product, are used.  Except, again,  by using stockpiled to determine what gem happens to be close to the workshop.

Something that was very enlightening to me was when someone said, in another post, and not to me, the following: You can technically make a reaction that takes ANYTHING, regardless of what it is, as a reagent, if you use [REAGENT:A:1:NONE:NONE:NONE:NONE]. 
That was a moment of epiphany, as I suddenly realized how items were referenced in reactions.  It showed me that any time one had a 'none' or a 'no subtype', it actually meant 'ANYTHING so long as it has the other defining features'.  So if you have, for example, [REAGENT:B:1:NONE:NONE:INORGANIC:GOLD], it will use ANY gold item, regardless of what it may be, including crafts and chairs if they happen to be laying about.
Another way to put it is...
When you specify [REAGENT:B:1:BOULDER:NONE:INORGANIC:BASALT], you can only use basalt boulders because what you are telling it is, in this order: Use a boulder, specifically one made of an inorganic material, specifically that of basalt.  This is very specific.  But you can have [REAGENT:B:1:BOULDER:NONE:INORGANIC:NONE], and it will use any boulder because this tells it: Use a boulder, specifically one of an inorganic material.  It won't, in this case, differentiate native gold boulders from basalt.  Likewise, if you become even less specific, you have [REAGENT:B:1:BOULDER:NONE:NONE:NONE], which says 'Use a boulder'.  In such a case, it could use rock boulders, pearl boulders, or if you happen to have any laying about, tree boulders or meat boulders.

NOTE: What I have said above about reactants does not hold for products.  If I put [PRODUCT:100:1:BOULDER:NONE:INORGANIC:NONE], I can't remember if it just crashes the game or if it produces some generic 'boulder' of a generic material with no real traits...  I think the former.  Products, if I am not mistaken, need to be specific.
« Last Edit: March 17, 2011, 06:20:54 pm by Pickerel »
Logged

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: Using Gems in Reactions
« Reply #2 on: March 17, 2011, 04:38:58 pm »

Can you not give something more than one reaction class?
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Pickerel

  • Bay Watcher
    • View Profile
Re: Using Gems in Reactions
« Reply #3 on: March 17, 2011, 04:49:23 pm »

Yes.  For example, It Nickel has both [REACTION_CLASS:GLASS_BLUE] and [REACTION_CLASS:GLASS_VIOLET], then it can be used for my blue glass, and my violet glass, reactions.

Likewise, one can give an item multiple MATERIAL_REACTION_PRODUCT tokens.  For example if I had two separate reactions that produced different things, they would each produce only the material in the MATERIAL_REACTION_PRODUCT they called for.
Logged

Keldane

  • Bay Watcher
    • View Profile
Re: Using Gems in Reactions
« Reply #4 on: March 17, 2011, 05:15:05 pm »

That is a fantastic amount of useful information, Pickerel! Thank you very much!

Just one question - in your third example, you used the tag [GET_MATERIAL_FROM_REACTANT]. Did you mean REAGENT, or is it different in this context?
Logged
WARNING:Side effects may include fatal badgerstorm and sudden appreciation for nobles.

Pickerel

  • Bay Watcher
    • View Profile
Re: Using Gems in Reactions
« Reply #5 on: March 17, 2011, 05:16:30 pm »

Oh, yeah.  You are right ^.^  Mistakes like that are why so much of my coding is trial and error.  For the longest time I couldn't figure out why it gave errors at every reference to ADAMANTIUM.

When in doubt, use the actual raws as a guide, for I am mistake prone...
Logged