[Tutorial] (Re)actions that produces multiple items

Post your mods and custom content here

[Tutorial] (Re)actions that produces multiple items

Postby smithforge » Mon Oct 01, 2012 10:32 am

Compound Product Items


This is a workaround for the fact that the actions simulating production can only produce one product at one time. It doesn't allow say Reagents A,B and C to be mixed and gives a Product X and 2 of Product Y.

This "trick" replies on these factors to work:

1) Instead of creating final product, create intermediate "compound product" (possibly with several versions prepresenting what product items are still left in the "stack". Will possibly need as many versions as the total number of products-1, depending on whether products are same type)

2) Uses automated queued tasks in the production menu that is set to a high number if the actions define a generated item type or a positive number representing the max total number of people who should do the breaking down jobs if the actions DO NOT define a generated item type (can set to a dummy item that never exist in game, so that the job will always try to spawn)

3) The control over the total number of products is somewhat possible by defining <generatedItem> in the action that produces the compound product.
However, if the products as different types (e.g. say producing a "butchered cattle" which will break down into 2 raw steaks and 1 bone), separate copies of the action each with a differen generated product item (in this example, "rawsteak" and "bone") will have to be created, each with a menu item of its own in the production menu, so that we can set the minimum for "rawsteak" and "bone" from cattle corpse separately (iow, as long as either rawsteak or bone does not meet the target, it will assign citizen to produce cattle corpse)

4) Due to the possible delay between production of the compound product to the actual "breaking up" into the final products by citizens, the control over the total number will not be exact. It will always produce a little surplus (e.g. before the last "butchered cattle" can be broken up which will create enough rawsteak specified in production menu, another "butcher cattle" action could have been assigned which will result in some extra rawsteak after everything is broken up.


The actual sequence is shown in the following image slides (with the sample action script further below)

Image

Basic steps in the image: (just in case image doesn't load)
1,2,3: Production of a wooden log into a stack of wooden boards (4 boards represented in a stack). The actual production can be controlled by production menu but I added a context action to rmwood itself so that I can right click on a wooden log and ordered it made into boards (for convenience, I added a command on carpentrydesk as well)

4,5: Other than using production menu, all the actions can be assessed via item context menu as well. These 2 images shows how the wooden board stacks can be broken up manually.

6. But the real intended usage is via automated production. There are 2 types of menu items: those that produce the compound item (which defines one of the final product item as the <generatedItem> NOT the compound item itself). The other menu items are those that are linked to actions that will break down the compound items into the product items (for each action, it will create one product item WITHOUT removing the compound item, but changes the compound item to the next stage to indicate that a product has been removed). Usually, all the breaking up actions will use the final product item type as <generatedItem> as well, which will tell it to continue to break up compound item as long as final items not enough.

7,8. To just ensure that there is minimum of a certain generated product item, just set the production control and the breaking control to the minimum number of final products that we want to maintain. The automation will take care of producing new items and break down existing compound items until there is enough. However, using this method, when we have enough of the product item as indicated, it will NOT break down existing compound items until there is a shortage again. Image 8 shows a typical result.

9,10. Though previous method of use is ok for wooden stack, for some stuff like "butchered cattle" we will probably want to decompose it fully. To do this, simply set the "breaking up" menu items in the production menu to a number much greater than the real target amount (controlled by the menu item for making the first compound item). This will fully break up all the compound items (original and intermediate) when there is enough manpower. (Image 10 shows the result for the wooden board experiment)



This is my mod in items.xml for my example using the wooden boards
Code: Select all
   <rmwoodboard>
      <name>Wood board</name>
      <type>rawmaterials.materials.woodboards</type>
         
      <stackable>false</stackable>
      <stackableSize>1</stackableSize>
      <value>6</value>
   </rmwoodboard>

   <rmwoodboard2>
      <name>Wood boards(2)</name>
      <type>rawmaterials.materials.woodboards</type>
         
      <stackable>false</stackable>
      <stackableSize>1</stackableSize>
      <value>12</value>

      <action>qSplitWoodBoard2</action>

   </rmwoodboard2>

   <rmwoodboard4>
      <name>Wood boards(4)</name>
      <type>rawmaterials.materials.woodboards</type>
         
      <stackable>false</stackable>
      <stackableSize>1</stackableSize>
      <value>24</value>

      <action>qSplitWoodBoard4</action>

   </rmwoodboard4>



This is my mod in actions.xml for my example using the wooden boards
Code: Select all
    <action>
      <id>qMakeWoodBoard4</id>
      <name>Make Wooden Boards</name>
      <priorityID>itemconstruction</priorityID>

      <generatedItem>rmwoodboard</generatedItem>

      <queue>
         <move useSource="true">rmwood</move>
         <pick>rmwood</pick>
         <move>carpentrybench</move>
         <wait>32</wait>
         <destroyItem />
         <createItem>rmwoodboard4</createItem>
         <unlock />
      </queue>
   </action>   



    <action>
      <id>qSplitWoodBoard4</id>
      <name>Separate Wooden Boards</name>
      <priorityID>itemconstruction</priorityID>

      <generatedItem>rmwoodboard</generatedItem>

      <queue>
         <move useSource="true">rmwoodboard4</move>
         <replaceCellItem>rmwoodboard2</replaceCellItem>
         <createItem>rmwoodboard2</createItem>
         <unlock />
      </queue>
   </action>   
   

    <action>
      <id>qSplitWoodBoard2</id>
      <name>Separate Wooden Boards</name>
      <priorityID>itemconstruction</priorityID>

      <generatedItem>rmwoodboard</generatedItem>

      <queue>
         <move useSource="true">rmwoodboard2</move>
         <replaceCellItem>rmwoodboard</replaceCellItem>
         <createItem>rmwoodboard</createItem>
         <unlock />
      </queue>
   </action>      




The following is my addition into the menu_production.xml
Code: Select all
      <item code="QUEUE" parameter="qMakeWoodBoard4" />
      <item code="QUEUE" parameter="qSplitWoodBoard4" />
      <item code="QUEUE" parameter="qSplitWoodBoard2" />


Finally, think of evi... *ahem* ... innovative ... ways to make use of this. (maybe now we can finally get both meat AND bone from butchering?)
smithforge
 
Posts: 222
Joined: Mon Sep 24, 2012 3:23 pm

Return to Modding

Who is online

Users browsing this forum: No registered users and 4 guests

cron