From 05ee1a74845caebce361a734ab4bc43632414923 Mon Sep 17 00:00:00 2001 From: Burkino <24849979+Burkino@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:13:30 -0400 Subject: [PATCH] Add WHERE example --- .../template_programs/where_statement.sfml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/resources/assets/sfm/template_programs/where_statement.sfml diff --git a/src/main/resources/assets/sfm/template_programs/where_statement.sfml b/src/main/resources/assets/sfm/template_programs/where_statement.sfml new file mode 100644 index 00000000..8b5e4a77 --- /dev/null +++ b/src/main/resources/assets/sfm/template_programs/where_statement.sfml @@ -0,0 +1,43 @@ +NAME "WHERE Statements" + +-- WHERE statements allow you to filter blocks in +-- a label by the contents of the block +-- They support most of the same functionality as +-- IF statements though they can't compare 2 +-- inventories (or slots) against each other + +EVERY 20 TICKS DO + INPUT FROM source WHERE > 5 dirt AND < 5 stone + OUTPUT TO EACH dest WHERE (= 0 dirt) +END + +-- An issue with resource types +EVERY 20 TICKS DO + -- If you are moving resource type X + -- but WHERE is checking resource type Y + -- you need to specify that you want to move + -- 0 of resource type Y on the input or output + -- statement with the WHERE condition + -- This is only necessary if you are not planning + -- on moving resource type Y in this statement + + INPUT fluid:: FROM source + -- The following statement will not work + OUTPUT fluid:: TO dest WHERE > 0 dirt + + -- To fix this, do + OUTPUT 0 item::, fluid:: TO dest WHERE > 0 dirt +END + +-- Slots +EVERY 20 TICKS DO + -- WHERE statements will use the same slots as + -- the SLOTS statement. This can be useful for + -- machines with distinct groups of slots, such as + -- extended inscribers + INPUT FROM source + OUTPUT gold_ingot, silicon + TO EACH exinscriber SLOTS 0-3 WHERE > 0 universal_press + OUTPUT gold_ingot, silicon + TO EACH exinscriber SLOTS 4-7 WHERE > 0 universal_press +END \ No newline at end of file