Skip to content

Commit

Permalink
Add filter chest tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jan 27, 2024
1 parent 2b4cb0b commit 2372336
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
15 changes: 13 additions & 2 deletions src/main/resources/assets/integratedscripting/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"advancement.integratedscripting.terminal_bind.desc": "Create a script, and bind it to a Variable Card.",
"advancement.integratedscripting.terminal_display": "The Unleashing of the Scripts",
"advancement.integratedscripting.terminal_display.desc": "Display a scripted value in a Display Panel",
"advancement.integratedscripting.filter_chest": "Overpowered item list filtering",
"advancement.integratedscripting.filter_chest.desc": "Filter a list of items read from a chest using a script-based function.",

"_comment": "Blocks",
"block.integratedscripting.mendesite": "Mendesite",
Expand Down Expand Up @@ -192,7 +194,16 @@
"info_book.integratedscripting.tutorials.terminal.text1": "In the previous step, we created and placed a &lScripting Disk&r and &lScripting Drive&r. In this tutorial, we will see how we can actually &owrite&r scripts and bind them to &lVariable Cards&r",
"info_book.integratedscripting.tutorials.terminal.text2": "First, let us craft a &lScripting Terminal&r, place it on a cable connected to the &lScripting Drive&r, and right-click on the &lScripting Terminal&r to open it.",
"info_book.integratedscripting.tutorials.terminal.text3": "You will see an editor in which you can access all script files stored in the different &lScripting Disk&r that are accessible to the network. You can toggle through the different &lScripting Disks&r by clicking on the arrows on the top-left of the screen.",
"info_book.integratedscripting.tutorials.terminal.text4": "At this stage, you will not have any script files in your network yet, so let's create a new file by clicking on the \"+\" button on the bottom-left of the screen. Now click on the new file to open it, and click on the text field at the right-hand side of the screen to edit the file.",
"info_book.integratedscripting.tutorials.terminal.text4": "At this stage, you will not have any script files in your network yet, so let's create a new file by clicking on the \"+\" button on the bottom-left of the screen. Now click on the new file to open it, and click on the text field at the right-hand side of the screen to edit the file and write &oJavaScript&r code.",
"info_book.integratedscripting.tutorials.terminal.text5": "To keep it simple for now, we will create a constant value. Let's write something like &oconst myVar = 123;&r",
"info_book.integratedscripting.tutorials.terminal.text6": "As a final step, let's bind this constant to a &lVariable Card&r by inserting an empty &lVariable Card&r into slot at the right-hand side of the screen, and select the variable by double-clicking it with your cursor. Your &lVariable Card&r will now be bound to the constant value. You can use this &lVariable Card&r now anywhere in your network. Let's try showing it in a &lDisplay Panel&r!"
"info_book.integratedscripting.tutorials.terminal.text6": "As a final step, let's bind this constant to a &lVariable Card&r by inserting an empty &lVariable Card&r into slot at the right-hand side of the screen, and select the variable by double-clicking it with your cursor. Your &lVariable Card&r will now be bound to the constant value. You can use this &lVariable Card&r now anywhere in your network. Let's try showing it in a &lDisplay Panel&r!",

"info_book.integratedscripting.tutorials.functions": "Scripting functions",
"info_book.integratedscripting.tutorials.functions.text1": "While creating constant values through JavaScript might be fun, the real power of these scripts become apparent when creating &ofunctions&r.",
"info_book.integratedscripting.tutorials.functions.text2": "Functions created through JavaScript can be bound to &lVariable Cards&r as &2Operator&0, which can then be used in Integrated Dynamics logic as usual. For example, you could use them for defining Integrated Tunnels exporter filters, or for calculating complex values such as the median stack size of items in a list.",
"info_book.integratedscripting.tutorials.functions.text3": "In this tutorial, we'll create a function that accepts a single &8Item&0 argument, and returns a &9Boolean&0 as output. This function will act as a filter operator, which we can use when for example filtering a list of items.",
"info_book.integratedscripting.tutorials.functions.text4": "Concretely, we will read the list of items using the &lInventory Reader&r, and &lFilter&r it using our newly created function. You can bind the function to a &lVariable Card&r by selecting it in the editor and inserting an empty &lVariable Card&r, which will store it as &2Operator&0.",
"info_book.integratedscripting.tutorials.functions.text5": "You are free to use any implementation of the filter function for this tutorial. Hereafter, you can find a valid example script which you are free to copy.",
"info_book.integratedscripting.tutorials.functions.text6": "To complete the tutorial, show the result of the filtered list in a &lDisplay Panel&r.",
"info_book.integratedscripting.tutorials.functions.text7": "In this example script, you will see that you can invoke built-in methods on items such as &oisStackable()&r and &ostacksize()&r. More details on which methods are available can be found later in the full manual."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"display": {
"icon": {
"item": "minecraft:chest"
},
"title": {
"translate": "advancement.integratedscripting.filter_chest"
},
"description": {
"translate": "advancement.integratedscripting.filter_chest.desc"
}
},
"parent": "integratedscripting:terminal/bind",
"criteria": {
"criteria_0": {
"trigger": "integrateddynamics:part_variable_driven",
"conditions": {
"parttype": "integrateddynamics:display_panel",
"variable": {
"type": "integrateddynamics:operator",
"operator": "integrateddynamics:operator_filter",
"input": {
"0": {
"type": "integratedscripting:script"
},
"1": {
"type": "integrateddynamics:aspect",
"aspect": "integrateddynamics:read_list_inventory_itemstacks"
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"display": {
"icon": {
"item": "integrateddynamics:variable",
"nbt": "{_type:\"integratedscripting:script\",disk:1,path:\"p\",member:\"m\",_id:1}"
"item": "integrateddynamics:part_display_panel"
},
"title": {
"translate": "advancement.integratedscripting.terminal_display"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<paragraph>info_book.integratedscripting.tutorials.terminal.text4</paragraph>
<paragraph>info_book.integratedscripting.tutorials.terminal.text5</paragraph>
<paragraph>info_book.integratedscripting.tutorials.terminal.text6</paragraph>
<appendix type="minecraft:crafting">integratedscripting:crafting/scripting_terminal</appendix>
<appendix type="minecraft:crafting">integratedscripting:crafting/part_terminal_scripting</appendix>
<appendix type="advancement_rewards" id="integratedscripting:terminal">
<advancements>
<advancement id="integratedscripting:terminal/open" />
Expand All @@ -44,4 +44,28 @@
</rewards>
</appendix>
</section>

<section name="info_book.integratedscripting.tutorials.functions">
<paragraph>info_book.integratedscripting.tutorials.functions.text1</paragraph>
<paragraph>info_book.integratedscripting.tutorials.functions.text2</paragraph>
<paragraph>info_book.integratedscripting.tutorials.functions.text3</paragraph>
<paragraph>info_book.integratedscripting.tutorials.functions.text4</paragraph>
<paragraph>info_book.integratedscripting.tutorials.functions.text5</paragraph>
<paragraph>info_book.integratedscripting.tutorials.functions.text6</paragraph>
<paragraph>info_book.integratedscripting.tutorials.functions.text7</paragraph>
<appendix type="integrateddynamics:operator">integrateddynamics:operator_filter</appendix>
<appendix type="integrateddynamics:aspect">integrateddynamics:read_list_inventory_itemstacks</appendix>
<appendix type="textfield" scale="0.8">function filterItemMethods(item) {
return item.isStackable() &amp;&amp; item.stacksize() >= 16;
}</appendix>
<appendix type="advancement_rewards" id="integratedscripting:functions">
<advancements>
<advancement id="integratedscripting:functions/filter_chest" />
</advancements>
<rewards>
<reward type="item" amount="4">integratedscripting:scripting_disk</reward>
<reward type="item" amount="16">integrateddynamics:variable</reward>
</rewards>
</appendix>
</section>
</section>

0 comments on commit 2372336

Please sign in to comment.