Skip to content

Commit

Permalink
Document global operators
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jan 23, 2024
1 parent 0da910e commit 17e30f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/resources/assets/integratedscripting/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@
"info_book.integratedscripting.writing.functions.text5": "For example, you can create a function with a single &8Item&0 argument that returns a &9Boolean&0 to use as filter &2Operator&0 for filtering a list of items that you read from a Chest.",
"info_book.integratedscripting.writing.functions.text6": "Below, you can find examples of different types of functions that could be created.",

"info_book.integratedscripting.writing.globals": "Global values",
"info_book.integratedscripting.writing.globals.text1": "TODO",
"info_book.integratedscripting.writing.globals.text2": "TODO",
"info_book.integratedscripting.writing.globals": "Global operators",
"info_book.integratedscripting.writing.globals.text1": "When writing JavaScript code, you can make use of the global &oidContext&r variable to access all Integrated Dynamics operators as functions through the &oops&r field. This allows you to make use of built-in operators when creating new ones.",
"info_book.integratedscripting.writing.globals.text2": "For example, you can write an &8Item&0 filter that checks if an item is stackable and if it has a stack size of at least 16, as shown below.",
"info_book.integratedscripting.writing.globals.text3": "To know what the name is of the operator you want to execute, you can look at their global name via the operator tooltips inside the &lLogic Programmer&r or in the list of operators in the Logic Programming section of this book.",
"info_book.integratedscripting.writing.globals.text4": "Since invoking operators via &oidContext&r can become quite verbose, you can choose to store operators in a custom constant variable, as shown in the second example. Alternatively, you can make use of &oobject methods&r, which are discussed in the next section.",

"info_book.integratedscripting.writing.methods": "Object value methods",
"info_book.integratedscripting.writing.methods": "Object methods",
"info_book.integratedscripting.writing.methods.text1": "TODO",
"info_book.integratedscripting.writing.methods.text2": "TODO"
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ const isOdd = (value) => value % 2 !== 0;</appendix>
<section name="info_book.integratedscripting.writing.globals">
<paragraph>info_book.integratedscripting.writing.globals.text1</paragraph>
<paragraph>info_book.integratedscripting.writing.globals.text2</paragraph>
<paragraph>info_book.integratedscripting.writing.globals.text3</paragraph>
<paragraph>info_book.integratedscripting.writing.globals.text4</paragraph>
<appendix type="textfield" scale="0.8">function filterItem(item) {
return idContext.ops.itemstackStackable(item) &amp;&amp; idContext.ops.itemstackStacksize(item) >= 16;
}</appendix>
<appendix type="textfield" scale="0.8">
const stackable = idContext.ops.itemstackStackable;
const stacksize = idContext.ops.itemstackStacksize;
function filterItemCompact(item) {
return stackable(item) &amp;&amp; stacksize(item) >= 16;
}</appendix>
</section>

<section name="info_book.integratedscripting.writing.methods">
Expand Down

0 comments on commit 17e30f0

Please sign in to comment.