From 1ff3cea4d6d853f5df489e03189ff575ff0a8228 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Mon, 26 May 2025 02:36:15 +0200 Subject: [PATCH] mew --- computer/0/sfx | 17 + computer/1/recievfile.lua | 7 + computer/1/safetycopy | 962 +++++++++++++++++++++++++ computer/1/startup.lua | 28 + computer/1/test.lua | 3 + computer/1/tobuild | 884 +++++++++++++++++++++++ computer/13/fluid_state.lua | 32 +- computer/13/fluids.lua | 67 +- computer/13/machines.lua | 107 ++- computer/13/recipes.txt | 47 +- computer/13/work.lua | 2 +- computer/15/.settings | 4 + computer/15/logout.lua | 1 + computer/17/music | 704 ++++++++++++++++++ computer/20/startup.lua | 18 + computer/21/startup.lua | 6 + computer/3/startup | 84 +++ computer/4/disk/st | 84 +++ computer/4/disk/startup | 84 +++ computer/4/falseshell.lua | 1 + computer/4/recievefile.lua | 13 + computer/4/sendfile.lua | 9 + computer/4/test.lua | 6 + computer/5/complete.lua | 1 + computer/5/customlookup.lua | 35 + computer/5/rednetcopy | 61 ++ computer/5/turtlemanager | 2 + computer/5/turtlemanagercompletion.lua | 9 + computer/8/wood.lua | 7 + 29 files changed, 3206 insertions(+), 79 deletions(-) create mode 100644 computer/0/sfx create mode 100644 computer/1/recievfile.lua create mode 100644 computer/1/safetycopy create mode 100644 computer/1/startup.lua create mode 100644 computer/1/test.lua create mode 100644 computer/1/tobuild create mode 100644 computer/15/.settings create mode 100644 computer/15/logout.lua create mode 100644 computer/17/music create mode 100644 computer/20/startup.lua create mode 100644 computer/21/startup.lua create mode 100644 computer/3/startup create mode 100644 computer/4/disk/st create mode 100644 computer/4/disk/startup create mode 100644 computer/4/falseshell.lua create mode 100644 computer/4/recievefile.lua create mode 100644 computer/4/sendfile.lua create mode 100644 computer/4/test.lua create mode 100644 computer/5/complete.lua create mode 100644 computer/5/customlookup.lua create mode 100644 computer/5/rednetcopy create mode 100644 computer/5/turtlemanager create mode 100644 computer/5/turtlemanagercompletion.lua create mode 100644 computer/8/wood.lua diff --git a/computer/0/sfx b/computer/0/sfx new file mode 100644 index 0000000..f87f23d --- /dev/null +++ b/computer/0/sfx @@ -0,0 +1,17 @@ +speaker = peripheral.wrap("left") +volume = 2 + +return { + success = function () + speaker.playNote("pling",volume,4) + sleep(0.1) + speaker.playNote("pling",volume,8) + sleep(0.1) + speaker.playNote("pling",volume,16) + end, + fail = function () + speaker.playNote("didgeridoo", volume, 6) + sleep(0.2) + speaker.playNote("didgeridoo", volume, 3) + end +} diff --git a/computer/1/recievfile.lua b/computer/1/recievfile.lua new file mode 100644 index 0000000..1d2f21a --- /dev/null +++ b/computer/1/recievfile.lua @@ -0,0 +1,7 @@ +file = fs.open(arg[1],"w") +id,mess = rednet.receive() +while mess do + file.writeLine(mess) + id,mess = rednet.receive() +end +file.close() diff --git a/computer/1/safetycopy b/computer/1/safetycopy new file mode 100644 index 0000000..65157c0 --- /dev/null +++ b/computer/1/safetycopy @@ -0,0 +1,962 @@ +10,-48,-22 +10,-48,-14 +10,-48,-6 +10,-48,2 +10,-48,10 +10,-48,18 +10,-48,26 +10,-48,34 +10,-48,42 +10,-48,50 +10,-48,58 +10,-48,66 +10,-48,74 +10,-48,82 +10,-48,90 +10,-48,98 +10,-48,106 +10,-48,114 +10,-48,122 +10,-48,130 +10,-48,138 +10,-48,146 +18,-48,-150 +18,-48,-142 +18,-48,-134 +18,-48,-126 +18,-48,-118 +18,-48,-110 +18,-48,-102 +18,-48,-94 +18,-48,-86 +18,-48,-78 +18,-48,-70 +18,-48,-62 +18,-48,-54 +18,-48,-46 +18,-48,-38 +18,-48,-30 +18,-48,-22 +18,-48,-14 +18,-48,-6 +18,-48,2 +18,-48,10 +18,-48,18 +18,-48,26 +18,-48,34 +18,-48,42 +18,-48,50 +18,-48,58 +18,-48,66 +18,-48,74 +18,-48,82 +18,-48,90 +18,-48,98 +18,-48,106 +18,-48,114 +18,-48,122 +18,-48,130 +18,-48,138 +18,-48,146 +26,-48,-150 +26,-48,-142 +26,-48,-134 +26,-48,-126 +26,-48,-118 +26,-48,-110 +26,-48,-102 +26,-48,-94 +26,-48,-86 +26,-48,-78 +26,-48,-70 +26,-48,-62 +26,-48,-54 +26,-48,-46 +26,-48,-38 +26,-48,-30 +26,-48,-22 +26,-48,-14 +26,-48,-6 +26,-48,2 +26,-48,10 +26,-48,18 +26,-48,26 +26,-48,34 +26,-48,42 +26,-48,50 +26,-48,58 +26,-48,66 +26,-48,74 +26,-48,82 +26,-48,90 +26,-48,98 +26,-48,106 +26,-48,114 +26,-48,122 +26,-48,130 +26,-48,138 +26,-48,146 +34,-48,-150 +34,-48,-142 +34,-48,-134 +34,-48,-126 +34,-48,-118 +34,-48,-110 +34,-48,-102 +34,-48,-94 +34,-48,-86 +34,-48,-78 +34,-48,-70 +34,-48,-62 +34,-48,-54 +34,-48,-46 +34,-48,-38 +34,-48,-30 +34,-48,-22 +34,-48,-14 +34,-48,-6 +34,-48,2 +34,-48,10 +34,-48,18 +34,-48,26 +34,-48,34 +34,-48,42 +34,-48,50 +34,-48,58 +34,-48,66 +34,-48,74 +34,-48,82 +34,-48,90 +34,-48,98 +34,-48,106 +34,-48,114 +34,-48,122 +34,-48,130 +34,-48,138 +34,-48,146 +42,-48,-150 +42,-48,-142 +42,-48,-134 +42,-48,-126 +42,-48,-118 +42,-48,-110 +42,-48,-102 +42,-48,-94 +42,-48,-86 +42,-48,-78 +42,-48,-70 +42,-48,-62 +42,-48,-54 +42,-48,-46 +42,-48,-38 +42,-48,-30 +42,-48,-22 +42,-48,-14 +42,-48,-6 +42,-48,2 +42,-48,10 +42,-48,18 +42,-48,26 +42,-48,34 +42,-48,42 +42,-48,50 +42,-48,58 +42,-48,66 +42,-48,74 +42,-48,82 +42,-48,90 +42,-48,98 +42,-48,106 +42,-48,114 +42,-48,122 +42,-48,130 +42,-48,138 +42,-48,146 +50,-48,-150 +50,-48,-142 +50,-48,-134 +50,-48,-126 +50,-48,-118 +50,-48,-110 +50,-48,-102 +50,-48,-94 +50,-48,-86 +50,-48,-78 +50,-48,-70 +50,-48,-62 +50,-48,-54 +50,-48,-46 +50,-48,-38 +50,-48,-30 +50,-48,-22 +50,-48,-14 +50,-48,-6 +50,-48,2 +50,-48,10 +50,-48,18 +50,-48,26 +50,-48,34 +50,-48,42 +50,-48,50 +50,-48,58 +50,-48,66 +50,-48,74 +50,-48,82 +50,-48,90 +50,-48,98 +50,-48,106 +50,-48,114 +50,-48,122 +50,-48,130 +50,-48,138 +50,-48,146 +58,-48,-150 +58,-48,-142 +58,-48,-134 +58,-48,-126 +58,-48,-118 +58,-48,-110 +58,-48,-102 +58,-48,-94 +58,-48,-86 +58,-48,-78 +58,-48,-70 +58,-48,-62 +58,-48,-54 +58,-48,-46 +58,-48,-38 +58,-48,-30 +58,-48,-22 +58,-48,-14 +58,-48,-6 +58,-48,2 +58,-48,10 +58,-48,18 +58,-48,26 +58,-48,34 +58,-48,42 +58,-48,50 +58,-48,58 +58,-48,66 +58,-48,74 +58,-48,82 +58,-48,90 +58,-48,98 +58,-48,106 +58,-48,114 +58,-48,122 +58,-48,130 +58,-48,138 +58,-48,146 +66,-48,-150 +66,-48,-142 +66,-48,-134 +66,-48,-126 +66,-48,-118 +-22,-40,58 +50,-16,114 +50,-16,122 +50,-16,130 +50,-16,138 +50,-16,146 +58,-16,-150 +58,-16,-142 +58,-16,-134 +58,-16,-126 +58,-16,-118 +58,-16,-110 +58,-16,-102 +58,-16,-94 +58,-16,-86 +58,-16,-78 +58,-16,-70 +58,-16,-62 +58,-16,-54 +58,-16,-46 +58,-16,-38 +58,-16,-30 +58,-16,-22 +58,-16,-14 +58,-16,-6 +58,-16,2 +58,-16,10 +58,-16,18 +58,-16,26 +58,-16,34 +58,-16,42 +58,-16,50 +58,-16,58 +58,-16,66 +58,-16,74 +58,-16,82 +58,-16,90 +58,-16,98 +58,-16,106 +58,-16,114 +58,-16,122 +58,-16,130 +58,-16,138 +58,-16,146 +66,-16,-150 +66,-16,-142 +66,-16,-134 +66,-16,-126 +66,-16,-118 +66,-16,-110 +66,-16,-102 +66,-16,-94 +66,-16,-86 +66,-16,-78 +66,-16,-70 +66,-16,-62 +66,-16,-54 +66,-16,-46 +66,-16,-38 +66,-16,-30 +66,-16,-22 +66,-16,-14 +66,-16,-6 +66,-16,2 +66,-16,10 +66,-16,18 +66,-16,26 +66,-16,34 +66,-16,42 +66,-16,50 +66,-16,58 +66,-16,66 +66,-16,74 +66,-16,82 +66,-16,90 +66,-16,98 +66,-16,106 +66,-16,114 +66,-16,122 +66,-16,130 +66,-16,138 +66,-16,146 +74,-16,-150 +74,-16,-142 +74,-16,-134 +74,-16,-126 +74,-16,-118 +74,-16,-110 +74,-16,-102 +74,-16,-94 +74,-16,-86 +74,-16,-78 +74,-16,-70 +74,-16,-62 +74,-16,-54 +74,-16,-46 +74,-16,-38 +74,-16,-30 +74,-16,-22 +74,-16,-14 +74,-16,-6 +74,-16,2 +74,-16,10 +74,-16,18 +74,-16,26 +74,-16,34 +74,-16,42 +74,-16,50 +74,-16,58 +74,-16,66 +74,-16,74 +74,-16,82 +74,-16,90 +74,-16,98 +74,-16,106 +74,-16,114 +74,-16,122 +74,-16,130 +74,-16,138 +74,-16,146 +82,-16,-150 +82,-16,-142 +82,-16,-134 +82,-16,-126 +82,-16,-118 +82,-16,-110 +82,-16,-102 +82,-16,-94 +82,-16,-86 +82,-16,-78 +82,-16,-70 +82,-16,-62 +82,-16,-54 +82,-16,-46 +82,-16,-38 +82,-16,-30 +82,-16,-22 +82,-16,-14 +82,-16,-6 +82,-16,2 +82,-16,10 +82,-16,18 +82,-16,26 +82,-16,34 +82,-16,42 +82,-16,50 +82,-16,58 +82,-16,66 +82,-16,74 +82,-16,82 +82,-16,90 +82,-16,98 +82,-16,106 +82,-16,114 +82,-16,122 +82,-16,130 +82,-16,138 +82,-16,146 +90,-16,-150 +90,-16,-142 +90,-16,-134 +90,-16,-126 +90,-16,-118 +90,-16,-110 +90,-16,-102 +90,-16,-94 +90,-16,-86 +90,-16,-78 +90,-16,-70 +90,-16,-62 +90,-16,-54 +90,-16,-46 +90,-16,-38 +90,-16,-30 +90,-16,-22 +90,-16,-14 +90,-16,-6 +90,-16,2 +90,-16,10 +90,-16,18 +90,-16,26 +90,-16,34 +90,-16,42 +122,-8,-142 +122,-8,-134 +122,-8,-126 +122,-8,-118 +122,-8,-110 +122,-8,-102 +122,-8,-94 +122,-8,-86 +122,-8,-78 +122,-8,-70 +122,-8,-62 +122,-8,-54 +122,-8,-46 +122,-8,-38 +122,-8,-30 +122,-8,-22 +122,-8,-14 +122,-8,-6 +122,-8,2 +122,-8,10 +122,-8,18 +122,-8,26 +122,-8,34 +122,-8,42 +122,-8,50 +122,-8,58 +122,-8,66 +122,-8,74 +122,-8,82 +122,-8,90 +122,-8,98 +122,-8,106 +122,-8,114 +122,-8,122 +122,-8,130 +122,-8,138 +122,-8,146 +130,-8,-150 +130,-8,-142 +130,-8,-134 +130,-8,-126 +130,-8,-118 +130,-8,-110 +130,-8,-102 +130,-8,-94 +130,-8,-86 +130,-8,-78 +130,-8,-70 +130,-8,-62 +130,-8,-54 +130,-8,-46 +130,-8,-38 +130,-8,-30 +130,-8,-22 +130,-8,-14 +130,-8,-6 +130,-8,2 +130,-8,10 +130,-8,18 +130,-8,26 +130,-8,34 +130,-8,42 +130,-8,50 +130,-8,58 +130,-8,66 +130,-8,74 +130,-8,82 +130,-8,90 +130,-8,98 +130,-8,106 +130,-8,114 +130,-8,122 +130,-8,130 +130,-8,138 +-46,16,58 +-46,16,66 +-46,16,74 +-46,16,82 +-46,16,90 +-46,16,98 +-46,16,106 +-46,16,114 +-46,16,122 +-46,16,130 +-46,16,138 +-46,16,146 +-38,16,-150 +-38,16,-142 +-38,16,-134 +-38,16,-126 +-38,16,-118 +-38,16,-110 +-38,16,-102 +-38,16,-94 +-38,16,-86 +-38,16,-78 +-38,16,-70 +-38,16,-62 +-38,16,-54 +-38,16,-46 +-38,16,-38 +-38,16,-30 +-38,16,-22 +-38,16,-14 +-38,16,-6 +-38,16,2 +-70,24,82 +-70,24,90 +-70,24,98 +-70,24,106 +-70,24,114 +-70,24,122 +-70,24,130 +-70,24,138 +-70,24,146 +-62,24,-150 +-62,24,-142 +-62,24,-134 +-62,24,-126 +-62,24,-118 +-62,24,-110 +-62,24,-102 +-62,24,-94 +-62,24,-86 +-62,24,-78 +-62,24,-70 +-62,24,-62 +-62,24,-54 +-62,24,-46 +-62,24,-38 +-62,24,-30 +-62,24,-22 +-62,24,-14 +-62,24,-6 +-62,24,2 +-62,24,10 +-62,24,18 +-62,24,26 +-62,24,34 +-62,24,42 +-62,24,50 +-62,24,58 +-62,24,66 +-62,24,74 +-62,24,82 +-62,24,90 +-62,24,98 +-62,24,106 +-62,24,114 +-62,24,122 +-62,24,130 +-62,24,138 +-62,24,146 +-54,24,-150 +-54,24,-142 +-54,24,-134 +-54,24,-126 +-54,24,-118 +-54,24,-110 +-54,24,-102 +-54,24,-94 +-54,24,-86 +-54,24,-78 +-54,24,-70 +-54,24,-62 +-54,24,-54 +-54,24,-46 +-54,24,-38 +-54,24,-30 +-54,24,-22 +-54,24,-14 +-54,24,-6 +-54,24,2 +-54,24,10 +-54,24,18 +-54,24,26 +-54,24,34 +-54,24,42 +-54,24,50 +-54,24,58 +-54,24,66 +-54,24,74 +-54,24,82 +-54,24,90 +-54,24,98 +-54,24,106 +-54,24,114 +-54,24,122 +-54,24,130 +-54,24,138 +-54,24,146 +-46,24,-150 +-46,24,-142 +-46,24,-134 +-46,24,-126 +-46,24,-118 +-46,24,-110 +-46,24,-102 +-46,24,-94 +-46,24,-86 +-46,24,-78 +-46,24,-70 +-46,24,-62 +-46,24,-54 +-46,24,-46 +-46,24,-38 +-46,24,-30 +-46,24,-22 +-46,24,-14 +-46,24,-6 +-46,24,2 +-46,24,10 +-46,24,18 +-46,24,26 +-46,24,34 +-46,24,42 +-46,24,50 +-46,24,58 +-46,24,66 +-46,24,74 +-46,24,82 +-46,24,90 +-46,24,98 +-46,24,106 +-46,24,114 +-46,24,122 +-46,24,130 +-46,24,138 +-46,24,146 +-38,24,-150 +-38,24,-142 +-38,24,-134 +-38,24,-126 +-38,24,-118 +-38,24,-110 +-38,24,-102 +-38,24,-94 +-38,24,-86 +-38,24,-78 +-38,24,-70 +-38,24,-62 +-38,24,-54 +-38,24,-46 +-38,24,-38 +-38,24,-30 +-38,24,-22 +-38,24,-14 +-38,24,-6 +-38,24,2 +-38,24,10 +-38,24,18 +-38,24,26 +-38,24,34 +-38,24,42 +-38,24,50 +-38,24,58 +-38,24,66 +-38,24,74 +-38,24,82 +-38,24,90 +-38,24,98 +-38,24,106 +-38,24,114 +-38,24,122 +-38,24,130 +-38,24,138 +-38,24,146 +-30,24,-150 +-30,24,-142 +-30,24,-134 +-30,24,-126 +-30,24,-118 +-30,24,-110 +-30,24,-102 +-30,24,-94 +-30,24,-86 +-30,24,-78 +-30,24,-70 +-30,24,-62 +-30,24,-54 +-30,24,-46 +-30,24,-38 +-30,24,-30 +-30,24,-22 +-30,24,-14 +-30,24,-6 +-30,24,2 +-30,24,10 +-30,24,18 +-30,24,26 +-30,24,34 +-30,24,42 +-30,24,50 +-30,24,58 +-30,24,66 +-30,24,74 +-30,24,82 +-30,24,90 +-30,24,98 +-30,24,106 +-30,24,114 +-30,24,122 +-30,24,130 +-30,24,138 +-30,24,146 +-22,24,-150 +-22,24,-142 +-22,24,-134 +-22,24,-126 +-22,24,-118 +-22,24,-110 +-22,24,-102 +-22,24,-94 +-22,24,-86 +-22,24,-78 +-22,24,-70 +-22,24,-62 +-22,24,-54 +-22,24,-46 +-22,24,-38 +-22,24,-30 +-22,24,-22 +-22,24,-14 +-22,24,-6 +-22,24,2 +-22,24,10 +-22,24,18 +-22,24,26 +-22,24,34 +-22,24,42 +-102,80,66 +-102,80,74 +-102,80,82 +-102,80,90 +-102,80,98 +-102,80,106 +-102,80,114 +-102,80,122 +-102,80,130 +-102,80,138 +-102,80,146 +-94,80,-150 +-94,80,-142 +-94,80,-134 +-94,80,-126 +-94,80,-118 +-94,80,-110 +-94,80,-102 +-94,80,-94 +-94,80,-86 +-94,80,-78 +-94,80,-70 +-94,80,-62 +-94,80,-54 +-94,80,-46 +-94,80,-38 +-94,80,-30 +-94,80,-22 +-94,80,-14 +-94,80,-6 +-94,80,2 +-94,80,10 +-94,80,18 +-94,80,26 +-94,80,34 +-94,80,42 +-94,80,50 +-94,80,58 +-94,80,66 +-94,80,74 +-94,80,82 +-94,80,90 +-94,80,98 +-94,80,106 +-94,80,114 +-94,80,122 +-94,80,130 +-94,80,138 +-94,80,146 +-86,80,-150 +-86,80,-142 +-86,80,-134 +-86,80,-126 +-86,80,-118 +-86,80,-110 +-86,80,-102 +-86,80,-94 +-86,80,-86 +-86,80,-78 +-86,80,-70 +-86,80,-62 +-86,80,-54 +-86,80,-46 +-86,80,-38 +-86,80,-30 +-86,80,-22 +-86,80,-14 +-86,80,-6 +-86,80,2 +-86,80,10 +-86,80,18 +-86,80,26 +-86,80,34 +-86,80,42 +-86,80,50 +-86,80,58 +-86,80,66 +-86,80,74 +-86,80,82 +-86,80,90 +-86,80,98 +-86,80,106 +-86,80,114 +-86,80,122 +-86,80,130 +-86,80,138 +-86,80,146 +-78,80,-150 +-78,80,-142 +-78,80,-134 +-78,80,-126 +-78,80,-118 +-78,80,-110 +-78,80,-102 +-78,80,-94 +-78,80,-86 +-78,80,-78 +-78,80,-70 +-78,80,-62 +-78,80,-54 +-78,80,-46 +-78,80,-38 +-78,80,-30 +-78,80,-22 +-78,80,-14 +-78,80,-6 +-78,80,2 +-78,80,10 +-78,80,18 +-78,80,26 +-78,80,34 +-78,80,42 +-78,80,50 +-78,80,58 +-78,80,66 +-78,80,74 +-78,80,82 +-78,80,90 +-78,80,98 +-78,80,106 +-78,80,114 +-78,80,122 +-78,80,130 +-78,80,138 +-78,80,146 +-70,80,-150 +-70,80,-142 +-70,80,-134 +-70,80,-126 +-70,80,-118 +-70,80,-110 +-70,80,-102 +-70,80,-94 +-70,80,-86 +-70,80,-78 +-70,80,-70 +-70,80,-62 +-70,80,-54 +-70,80,-46 +-70,80,-38 +-70,80,-30 +-70,80,-22 +-70,80,-14 +-70,80,-6 +-70,80,2 +-70,80,10 +-70,80,18 +-70,80,26 +-70,80,34 +-70,80,42 +-70,80,50 +-70,80,58 +-70,80,66 +-70,80,74 +-70,80,82 +-70,80,90 +-70,80,98 +-70,80,106 +-70,80,114 +-70,80,122 +-70,80,130 +-70,80,138 +-70,80,146 +-62,80,-150 +-62,80,-142 +-62,80,-134 +-62,80,-126 +-62,80,-118 +-62,80,-110 +-62,80,-102 +-62,80,-94 +-62,80,-86 +-62,80,-78 +-62,80,-70 +-62,80,-62 +-62,80,-54 +-62,80,-46 +-62,80,-38 +-62,80,-30 +-62,80,-22 +-62,80,-14 +-62,80,-6 +-62,80,2 +-62,80,10 +-62,80,18 +-62,80,26 +-62,80,34 +-62,80,42 +-62,80,50 +-62,80,58 +-62,80,66 +-62,80,74 +-62,80,82 + diff --git a/computer/1/startup.lua b/computer/1/startup.lua new file mode 100644 index 0000000..785c882 --- /dev/null +++ b/computer/1/startup.lua @@ -0,0 +1,28 @@ +local filename = "tobuild" +rednet.open("left") +while true do + id, message, protocol = rednet.receive() + if protocol == "getnexttobuild" then + file = fs.open(filename,"r") + line = file.readLine() + restof = file.readAll() + file.close() + file = fs.open(filename,"w") + file.write(restof) + file.close() + print(line) + rednet.send(id,line,"nexttobuild") + elseif protocol == "failedtobuild" then + print(message.."failed") + file = fs.open(filename,"r") + restof = file.readAll() + file.close() + file = fs.open(filename,"w") + file.writeLine(message) + file.write(restof) + file.close() + end + --file = fs.open(filename,"r") + --print(file.readAll()) +end + diff --git a/computer/1/test.lua b/computer/1/test.lua new file mode 100644 index 0000000..fa9544a --- /dev/null +++ b/computer/1/test.lua @@ -0,0 +1,3 @@ +8,2,0 +9,3,4 +0,4,2 \ No newline at end of file diff --git a/computer/1/tobuild b/computer/1/tobuild new file mode 100644 index 0000000..f90af10 --- /dev/null +++ b/computer/1/tobuild @@ -0,0 +1,884 @@ +26,-48,-14 +26,-48,-6 +26,-48,2 +26,-48,10 +26,-48,18 +26,-48,26 +26,-48,34 +26,-48,42 +26,-48,50 +26,-48,58 +26,-48,66 +26,-48,74 +26,-48,82 +26,-48,90 +26,-48,98 +26,-48,106 +26,-48,114 +26,-48,122 +26,-48,130 +26,-48,138 +26,-48,146 +34,-48,-150 +34,-48,-142 +34,-48,-134 +34,-48,-126 +34,-48,-118 +34,-48,-110 +34,-48,-102 +34,-48,-94 +34,-48,-86 +34,-48,-78 +34,-48,-70 +34,-48,-62 +34,-48,-54 +34,-48,-46 +34,-48,-38 +34,-48,-30 +34,-48,-22 +34,-48,-14 +34,-48,-6 +34,-48,2 +34,-48,10 +34,-48,18 +34,-48,26 +34,-48,34 +34,-48,42 +34,-48,50 +34,-48,58 +34,-48,66 +34,-48,74 +34,-48,82 +34,-48,90 +34,-48,98 +34,-48,106 +34,-48,114 +34,-48,122 +34,-48,130 +34,-48,138 +34,-48,146 +42,-48,-150 +42,-48,-142 +42,-48,-134 +42,-48,-126 +42,-48,-118 +42,-48,-110 +42,-48,-102 +42,-48,-94 +42,-48,-86 +42,-48,-78 +42,-48,-70 +42,-48,-62 +42,-48,-54 +42,-48,-46 +42,-48,-38 +42,-48,-30 +42,-48,-22 +42,-48,-14 +42,-48,-6 +42,-48,2 +42,-48,10 +42,-48,18 +42,-48,26 +42,-48,34 +42,-48,42 +42,-48,50 +42,-48,58 +42,-48,66 +42,-48,74 +42,-48,82 +42,-48,90 +42,-48,98 +42,-48,106 +42,-48,114 +42,-48,122 +42,-48,130 +42,-48,138 +42,-48,146 +50,-48,-150 +50,-48,-142 +50,-48,-134 +50,-48,-126 +50,-48,-118 +50,-48,-110 +50,-48,-102 +50,-48,-94 +50,-48,-86 +50,-48,-78 +50,-48,-70 +50,-48,-62 +50,-48,-54 +50,-48,-46 +50,-48,-38 +50,-48,-30 +50,-48,-22 +50,-48,-14 +50,-48,-6 +50,-48,2 +50,-48,10 +50,-48,18 +50,-48,26 +50,-48,34 +50,-48,42 +50,-48,50 +50,-48,58 +50,-48,66 +50,-48,74 +50,-48,82 +50,-48,90 +50,-48,98 +50,-48,106 +50,-48,114 +50,-48,122 +50,-48,130 +50,-48,138 +50,-48,146 +58,-48,-150 +58,-48,-142 +58,-48,-134 +58,-48,-126 +58,-48,-118 +58,-48,-110 +58,-48,-102 +58,-48,-94 +58,-48,-86 +58,-48,-78 +58,-48,-70 +58,-48,-62 +58,-48,-54 +58,-48,-46 +58,-48,-38 +58,-48,-30 +58,-48,-22 +58,-48,-14 +58,-48,-6 +58,-48,2 +58,-48,10 +58,-48,18 +58,-48,26 +58,-48,34 +58,-48,42 +58,-48,50 +58,-48,58 +58,-48,66 +58,-48,74 +58,-48,82 +58,-48,90 +58,-48,98 +58,-48,106 +58,-48,114 +58,-48,122 +58,-48,130 +58,-48,138 +58,-48,146 +66,-48,-150 +66,-48,-142 +66,-48,-134 +66,-48,-126 +66,-48,-118 +-22,-40,58 +50,-16,114 +50,-16,122 +50,-16,130 +50,-16,138 +50,-16,146 +58,-16,-150 +58,-16,-142 +58,-16,-134 +58,-16,-126 +58,-16,-118 +58,-16,-110 +58,-16,-102 +58,-16,-94 +58,-16,-86 +58,-16,-78 +58,-16,-70 +58,-16,-62 +58,-16,-54 +58,-16,-46 +58,-16,-38 +58,-16,-30 +58,-16,-22 +58,-16,-14 +58,-16,-6 +58,-16,2 +58,-16,10 +58,-16,18 +58,-16,26 +58,-16,34 +58,-16,42 +58,-16,50 +58,-16,58 +58,-16,66 +58,-16,74 +58,-16,82 +58,-16,90 +58,-16,98 +58,-16,106 +58,-16,114 +58,-16,122 +58,-16,130 +58,-16,138 +58,-16,146 +66,-16,-150 +66,-16,-142 +66,-16,-134 +66,-16,-126 +66,-16,-118 +66,-16,-110 +66,-16,-102 +66,-16,-94 +66,-16,-86 +66,-16,-78 +66,-16,-70 +66,-16,-62 +66,-16,-54 +66,-16,-46 +66,-16,-38 +66,-16,-30 +66,-16,-22 +66,-16,-14 +66,-16,-6 +66,-16,2 +66,-16,10 +66,-16,18 +66,-16,26 +66,-16,34 +66,-16,42 +66,-16,50 +66,-16,58 +66,-16,66 +66,-16,74 +66,-16,82 +66,-16,90 +66,-16,98 +66,-16,106 +66,-16,114 +66,-16,122 +66,-16,130 +66,-16,138 +66,-16,146 +74,-16,-150 +74,-16,-142 +74,-16,-134 +74,-16,-126 +74,-16,-118 +74,-16,-110 +74,-16,-102 +74,-16,-94 +74,-16,-86 +74,-16,-78 +74,-16,-70 +74,-16,-62 +74,-16,-54 +74,-16,-46 +74,-16,-38 +74,-16,-30 +74,-16,-22 +74,-16,-14 +74,-16,-6 +74,-16,2 +74,-16,10 +74,-16,18 +74,-16,26 +74,-16,34 +74,-16,42 +74,-16,50 +74,-16,58 +74,-16,66 +74,-16,74 +74,-16,82 +74,-16,90 +74,-16,98 +74,-16,106 +74,-16,114 +74,-16,122 +74,-16,130 +74,-16,138 +74,-16,146 +82,-16,-150 +82,-16,-142 +82,-16,-134 +82,-16,-126 +82,-16,-118 +82,-16,-110 +82,-16,-102 +82,-16,-94 +82,-16,-86 +82,-16,-78 +82,-16,-70 +82,-16,-62 +82,-16,-54 +82,-16,-46 +82,-16,-38 +82,-16,-30 +82,-16,-22 +82,-16,-14 +82,-16,-6 +82,-16,2 +82,-16,10 +82,-16,18 +82,-16,26 +82,-16,34 +82,-16,42 +82,-16,50 +82,-16,58 +82,-16,66 +82,-16,74 +82,-16,82 +82,-16,90 +82,-16,98 +82,-16,106 +82,-16,114 +82,-16,122 +82,-16,130 +82,-16,138 +82,-16,146 +90,-16,-150 +90,-16,-142 +90,-16,-134 +90,-16,-126 +90,-16,-118 +90,-16,-110 +90,-16,-102 +90,-16,-94 +90,-16,-86 +90,-16,-78 +90,-16,-70 +90,-16,-62 +90,-16,-54 +90,-16,-46 +90,-16,-38 +90,-16,-30 +90,-16,-22 +90,-16,-14 +90,-16,-6 +90,-16,2 +90,-16,10 +90,-16,18 +90,-16,26 +90,-16,34 +90,-16,42 +122,-8,-142 +122,-8,-134 +122,-8,-126 +122,-8,-118 +122,-8,-110 +122,-8,-102 +122,-8,-94 +122,-8,-86 +122,-8,-78 +122,-8,-70 +122,-8,-62 +122,-8,-54 +122,-8,-46 +122,-8,-38 +122,-8,-30 +122,-8,-22 +122,-8,-14 +122,-8,-6 +122,-8,2 +122,-8,10 +122,-8,18 +122,-8,26 +122,-8,34 +122,-8,42 +122,-8,50 +122,-8,58 +122,-8,66 +122,-8,74 +122,-8,82 +122,-8,90 +122,-8,98 +122,-8,106 +122,-8,114 +122,-8,122 +122,-8,130 +122,-8,138 +122,-8,146 +130,-8,-150 +130,-8,-142 +130,-8,-134 +130,-8,-126 +130,-8,-118 +130,-8,-110 +130,-8,-102 +130,-8,-94 +130,-8,-86 +130,-8,-78 +130,-8,-70 +130,-8,-62 +130,-8,-54 +130,-8,-46 +130,-8,-38 +130,-8,-30 +130,-8,-22 +130,-8,-14 +130,-8,-6 +130,-8,2 +130,-8,10 +130,-8,18 +130,-8,26 +130,-8,34 +130,-8,42 +130,-8,50 +130,-8,58 +130,-8,66 +130,-8,74 +130,-8,82 +130,-8,90 +130,-8,98 +130,-8,106 +130,-8,114 +130,-8,122 +130,-8,130 +130,-8,138 +-46,16,58 +-46,16,66 +-46,16,74 +-46,16,82 +-46,16,90 +-46,16,98 +-46,16,106 +-46,16,114 +-46,16,122 +-46,16,130 +-46,16,138 +-46,16,146 +-38,16,-150 +-38,16,-142 +-38,16,-134 +-38,16,-126 +-38,16,-118 +-38,16,-110 +-38,16,-102 +-38,16,-94 +-38,16,-86 +-38,16,-78 +-38,16,-70 +-38,16,-62 +-38,16,-54 +-38,16,-46 +-38,16,-38 +-38,16,-30 +-38,16,-22 +-38,16,-14 +-38,16,-6 +-38,16,2 +-70,24,82 +-70,24,90 +-70,24,98 +-70,24,106 +-70,24,114 +-70,24,122 +-70,24,130 +-70,24,138 +-70,24,146 +-62,24,-150 +-62,24,-142 +-62,24,-134 +-62,24,-126 +-62,24,-118 +-62,24,-110 +-62,24,-102 +-62,24,-94 +-62,24,-86 +-62,24,-78 +-62,24,-70 +-62,24,-62 +-62,24,-54 +-62,24,-46 +-62,24,-38 +-62,24,-30 +-62,24,-22 +-62,24,-14 +-62,24,-6 +-62,24,2 +-62,24,10 +-62,24,18 +-62,24,26 +-62,24,34 +-62,24,42 +-62,24,50 +-62,24,58 +-62,24,66 +-62,24,74 +-62,24,82 +-62,24,90 +-62,24,98 +-62,24,106 +-62,24,114 +-62,24,122 +-62,24,130 +-62,24,138 +-62,24,146 +-54,24,-150 +-54,24,-142 +-54,24,-134 +-54,24,-126 +-54,24,-118 +-54,24,-110 +-54,24,-102 +-54,24,-94 +-54,24,-86 +-54,24,-78 +-54,24,-70 +-54,24,-62 +-54,24,-54 +-54,24,-46 +-54,24,-38 +-54,24,-30 +-54,24,-22 +-54,24,-14 +-54,24,-6 +-54,24,2 +-54,24,10 +-54,24,18 +-54,24,26 +-54,24,34 +-54,24,42 +-54,24,50 +-54,24,58 +-54,24,66 +-54,24,74 +-54,24,82 +-54,24,90 +-54,24,98 +-54,24,106 +-54,24,114 +-54,24,122 +-54,24,130 +-54,24,138 +-54,24,146 +-46,24,-150 +-46,24,-142 +-46,24,-134 +-46,24,-126 +-46,24,-118 +-46,24,-110 +-46,24,-102 +-46,24,-94 +-46,24,-86 +-46,24,-78 +-46,24,-70 +-46,24,-62 +-46,24,-54 +-46,24,-46 +-46,24,-38 +-46,24,-30 +-46,24,-22 +-46,24,-14 +-46,24,-6 +-46,24,2 +-46,24,10 +-46,24,18 +-46,24,26 +-46,24,34 +-46,24,42 +-46,24,50 +-46,24,58 +-46,24,66 +-46,24,74 +-46,24,82 +-46,24,90 +-46,24,98 +-46,24,106 +-46,24,114 +-46,24,122 +-46,24,130 +-46,24,138 +-46,24,146 +-38,24,-150 +-38,24,-142 +-38,24,-134 +-38,24,-126 +-38,24,-118 +-38,24,-110 +-38,24,-102 +-38,24,-94 +-38,24,-86 +-38,24,-78 +-38,24,-70 +-38,24,-62 +-38,24,-54 +-38,24,-46 +-38,24,-38 +-38,24,-30 +-38,24,-22 +-38,24,-14 +-38,24,-6 +-38,24,2 +-38,24,10 +-38,24,18 +-38,24,26 +-38,24,34 +-38,24,42 +-38,24,50 +-38,24,58 +-38,24,66 +-38,24,74 +-38,24,82 +-38,24,90 +-38,24,98 +-38,24,106 +-38,24,114 +-38,24,122 +-38,24,130 +-38,24,138 +-38,24,146 +-30,24,-150 +-30,24,-142 +-30,24,-134 +-30,24,-126 +-30,24,-118 +-30,24,-110 +-30,24,-102 +-30,24,-94 +-30,24,-86 +-30,24,-78 +-30,24,-70 +-30,24,-62 +-30,24,-54 +-30,24,-46 +-30,24,-38 +-30,24,-30 +-30,24,-22 +-30,24,-14 +-30,24,-6 +-30,24,2 +-30,24,10 +-30,24,18 +-30,24,26 +-30,24,34 +-30,24,42 +-30,24,50 +-30,24,58 +-30,24,66 +-30,24,74 +-30,24,82 +-30,24,90 +-30,24,98 +-30,24,106 +-30,24,114 +-30,24,122 +-30,24,130 +-30,24,138 +-30,24,146 +-22,24,-150 +-22,24,-142 +-22,24,-134 +-22,24,-126 +-22,24,-118 +-22,24,-110 +-22,24,-102 +-22,24,-94 +-22,24,-86 +-22,24,-78 +-22,24,-70 +-22,24,-62 +-22,24,-54 +-22,24,-46 +-22,24,-38 +-22,24,-30 +-22,24,-22 +-22,24,-14 +-22,24,-6 +-22,24,2 +-22,24,10 +-22,24,18 +-22,24,26 +-22,24,34 +-22,24,42 +-102,80,66 +-102,80,74 +-102,80,82 +-102,80,90 +-102,80,98 +-102,80,106 +-102,80,114 +-102,80,122 +-102,80,130 +-102,80,138 +-102,80,146 +-94,80,-150 +-94,80,-142 +-94,80,-134 +-94,80,-126 +-94,80,-118 +-94,80,-110 +-94,80,-102 +-94,80,-94 +-94,80,-86 +-94,80,-78 +-94,80,-70 +-94,80,-62 +-94,80,-54 +-94,80,-46 +-94,80,-38 +-94,80,-30 +-94,80,-22 +-94,80,-14 +-94,80,-6 +-94,80,2 +-94,80,10 +-94,80,18 +-94,80,26 +-94,80,34 +-94,80,42 +-94,80,50 +-94,80,58 +-94,80,66 +-94,80,74 +-94,80,82 +-94,80,90 +-94,80,98 +-94,80,106 +-94,80,114 +-94,80,122 +-94,80,130 +-94,80,138 +-94,80,146 +-86,80,-150 +-86,80,-142 +-86,80,-134 +-86,80,-126 +-86,80,-118 +-86,80,-110 +-86,80,-102 +-86,80,-94 +-86,80,-86 +-86,80,-78 +-86,80,-70 +-86,80,-62 +-86,80,-54 +-86,80,-46 +-86,80,-38 +-86,80,-30 +-86,80,-22 +-86,80,-14 +-86,80,-6 +-86,80,2 +-86,80,10 +-86,80,18 +-86,80,26 +-86,80,34 +-86,80,42 +-86,80,50 +-86,80,58 +-86,80,66 +-86,80,74 +-86,80,82 +-86,80,90 +-86,80,98 +-86,80,106 +-86,80,114 +-86,80,122 +-86,80,130 +-86,80,138 +-86,80,146 +-78,80,-150 +-78,80,-142 +-78,80,-134 +-78,80,-126 +-78,80,-118 +-78,80,-110 +-78,80,-102 +-78,80,-94 +-78,80,-86 +-78,80,-78 +-78,80,-70 +-78,80,-62 +-78,80,-54 +-78,80,-46 +-78,80,-38 +-78,80,-30 +-78,80,-22 +-78,80,-14 +-78,80,-6 +-78,80,2 +-78,80,10 +-78,80,18 +-78,80,26 +-78,80,34 +-78,80,42 +-78,80,50 +-78,80,58 +-78,80,66 +-78,80,74 +-78,80,82 +-78,80,90 +-78,80,98 +-78,80,106 +-78,80,114 +-78,80,122 +-78,80,130 +-78,80,138 +-78,80,146 +-70,80,-150 +-70,80,-142 +-70,80,-134 +-70,80,-126 +-70,80,-118 +-70,80,-110 +-70,80,-102 +-70,80,-94 +-70,80,-86 +-70,80,-78 +-70,80,-70 +-70,80,-62 +-70,80,-54 +-70,80,-46 +-70,80,-38 +-70,80,-30 +-70,80,-22 +-70,80,-14 +-70,80,-6 +-70,80,2 +-70,80,10 +-70,80,18 +-70,80,26 +-70,80,34 +-70,80,42 +-70,80,50 +-70,80,58 +-70,80,66 +-70,80,74 +-70,80,82 +-70,80,90 +-70,80,98 +-70,80,106 +-70,80,114 +-70,80,122 +-70,80,130 +-70,80,138 +-70,80,146 +-62,80,-150 +-62,80,-142 +-62,80,-134 +-62,80,-126 +-62,80,-118 +-62,80,-110 +-62,80,-102 +-62,80,-94 +-62,80,-86 +-62,80,-78 +-62,80,-70 +-62,80,-62 +-62,80,-54 +-62,80,-46 +-62,80,-38 +-62,80,-30 +-62,80,-22 +-62,80,-14 +-62,80,-6 +-62,80,2 +-62,80,10 +-62,80,18 +-62,80,26 +-62,80,34 +-62,80,42 +-62,80,50 +-62,80,58 +-62,80,66 +-62,80,74 +-62,80,82 \ No newline at end of file diff --git a/computer/13/fluid_state.lua b/computer/13/fluid_state.lua index 07a81e4..34759e8 100644 --- a/computer/13/fluid_state.lua +++ b/computer/13/fluid_state.lua @@ -1,40 +1,36 @@ return { { - connected = false, name = "water", amount = 13100, }, { - connected = false, name = "blood", amount = 100, }, { - connected = false, + name = "still_milk", + amount = 1000, + }, + { + name = "lava", + amount = 1325, + }, + { + name = "molten_copper", amount = 0, }, { - connected = false, + name = "molten_gold", amount = 0, }, { - connected = false, + name = "molten_rose_gold", + amount = 0.44444444444446, + }, + { amount = 0, }, { - connected = false, - amount = 0, - }, - { - connected = false, - amount = 0, - }, - { - connected = false, - amount = 0, - }, - { - connected = false, amount = 0, }, } \ No newline at end of file diff --git a/computer/13/fluids.lua b/computer/13/fluids.lua index 3d1a85a..ca13a87 100644 --- a/computer/13/fluids.lua +++ b/computer/13/fluids.lua @@ -1,11 +1,11 @@ require("pathfinding") pretty = require("cc.pretty") -pp = pretty.pretty_print() +pp = pretty.pretty_print isFluid = { water = true, lava = true, - milk = true, + still_milk = true, blood = true, molten_rose_gold = true, molten_copper = true, @@ -17,7 +17,7 @@ isFluid = { } fluidDevicePos = { - trash = vector.new(2, 0, -1), + trash = vector.new(1, 0, -1), water_source = vector.new(0, 0, -1), mixer = vector.new(-1, 0, -1), compactor = vector.new(-2, 0, -1), @@ -84,18 +84,10 @@ function resetAllFluidDevices() -- goTo(pos) -- setRedRouter(false) -- end - for x = 2, -4, -1 do - goTo(vector.new(x, 0, -1)) - setRedRouter(false) - end - for x = -4, 4 do - goTo(vector.new(x, 0, -3)) - setRedRouter(false) - end - _G.activeFluidDevice = nil - for i = 1, 9 do - _G.fluidTanks[i].connected = false - end + -- for x = 2, -4, -1 do + -- goTo(vector.new(x, 0, -1)) + -- setRedRouter(false) + -- end end function selectFluidDevice(name) @@ -103,14 +95,14 @@ function selectFluidDevice(name) error("selectFluidDevice(" .. name .. "); not a known fluid device", 2) end - if _G.activeFluidDevice ~= nil then - goTo(fluidDevicePos[_G.activeFluidDevice]) - _G.activeFluidDevice = nil - setRedRouter(false) + if _G.activeFluidDevice ~= name then + print("set active fluid device", name) + _G.activeFluidDevice = name + goTo(fluidDevicePos[name]) + redstone.setOutput("bottom", true) + sleep(0.1) + redstone.setOutput("bottom", false) end - goTo(fluidDevicePos[name]) - setRedRouter(true) - _G.activeFluidDevice = name end function connectTankOrAssign(fluid) @@ -135,27 +127,27 @@ function connectTankOrAssign(fluid) end end end - connectTanks({ fluid }) + connectTank(fluid) end -function connectTanks(fluid_list) - print("connecting tanks") - pp(fluid_list) +function connectTank(name) + -- TODO only single tank, otherwise pipes break for index, tank in pairs(_G.fluidTanks) do - should_be_connected = false - for _, fluid in pairs(fluid_list) do - if tank.name == fluid then - should_be_connected = true - break + if tank.name == name then + if index == _G.connectTank then + print("tank", name, index, "already connected") + return end - end - if should_be_connected ~= tank.connected then - print("setting", tank.name, index, "to", should_be_connected) goTo(tankPos[index]) - setRedRouter(should_be_connected) - _G.fluidTanks[index].connected = should_be_connected + redstone.setOutput("bottom", true) + sleep(0.1) + redstone.setOutput("bottom", false) + _G.connectedTank = index + print("tank", name, index, "already connected") + return end end + saveFluids() end function fluidInvAdd(name, amount) @@ -163,6 +155,9 @@ function fluidInvAdd(name, amount) for index, tank in pairs(_G.fluidTanks) do if tank.name == name then tank.amount = tank.amount + amount + if tank.amount < 1 then + tank.amount = 0 + end -- TODO limit capacity end end diff --git a/computer/13/machines.lua b/computer/13/machines.lua index 902d900..a8bbeb6 100644 --- a/computer/13/machines.lua +++ b/computer/13/machines.lua @@ -23,7 +23,7 @@ function spout(extra_items) goTo(spout_pos, "south") insertDepot(1) selectFluidDevice("spout") - connectTanks({fluid.name}) + connectTank(fluid.name) pumpToDevices(true) sleep(10) pumpToDevices(false) @@ -32,7 +32,9 @@ function spout(extra_items) fluidInvAdd(fluid.name, -fluid.count) pumpToTanks(true) goTo(spout_pos, "south") - while #pFront("tanks")[1].amount > 0 do + goUp() + goUp() + while pFront("tanks")[1].amount > 0 do sleep(0.5) end pumpToTanks(false) @@ -83,7 +85,7 @@ function deploy_tool(extra_items) insertDepot(1) goUp() goUp() - selectItem(extra_items[1].name) + selectItem(extra_items[1].name, true) turtle.dropUp(1) pFront("pullItem", "top") @@ -101,16 +103,19 @@ function furnace(extra_items) if turtle.getItemCount() ~= 0 then item_count = 1 end - insertForward(1, 1) + turtle.dropUp(1) + pFront("pullItems", "top", 1, 64, 1) for _,item in pairs(extra_items) do item_count = item_count + item.count selectItem(item.name) - insertForward(1, item.count) + turtle.dropUp(item.count) + pFront("pullItems", "top", 1, 64, 1) end wait_time = 10 * item_count -- TODO refuel sleep(wait_time) - takeForward(3) + pFront("pushItems", "top", 3) + turtle.suckUp() end function press(_) goTo(press_pos, "south") @@ -124,7 +129,7 @@ function compact(extra_items) end function make_water(_,_,yield) selectFluidDevice("water_source") - connectTanks({"water"}) + connectTank("water") pumpToTanks(true) print("waiting 30s for water tanks to fill") sleep(30) @@ -138,9 +143,36 @@ function alloy(parts, product) end end selectFluidDevice("mixer") - connectTanks(parts) - pumpToDevices(true) + for _, fluid in pairs(parts) do + connectTank(fluid.name) + pumpToDevices(true) + goTo(mixer_pos, "south") + -- TODO wait for 1B or tank content is in the mixer + sleep(5) + pumpToDevices(false) + end goTo(mixer_pos, "south") + -- TODO wait for alloy to be done + sleep(10) + created_amount = 0 + for _, fluid in pairs(pFront("tanks")) do + if fluid.amount > 0 then + connectTankOrAssign(stripModname(fluid.name)) + pumpToTanks(true) + sleep(10) + pumpToTanks(false) + if stripModname(fluid.name) == product then + fluidInvAdd(product, fluid.amount) + created_amount = fluid.amount + end + end + end + for _, fluid in pairs(parts) do + fluidInvAdd(fluid.name, -created_amount) + end + -- for _, fluid in pairs(parts) do + + -- end -- TODO --[[ wait until at least one input fluid is used up @@ -150,7 +182,6 @@ function alloy(parts, product) -- while true do -- end - pumpToDevices(false) end function melt(_, product, yield) goTo(melter_pos, "north") @@ -178,13 +209,14 @@ function mix(extra_items, product, yield) if #fluids > 0 then print("mixing with fluids", fluids[1]) selectFluidDevice("mixer") - connectTanks({fluids[1].name}) + connectTank(fluids[1].name) pumpToDevices(true) - sleep(10) + sleep(8) pumpToDevices(false) end - -- print("aaa") - -- read() + if isFluid[product] then + selectFluidDevice("mixer") + end -- mix goTo(mixer_pos, "south") insertForward(1, 1) @@ -192,14 +224,45 @@ function mix(extra_items, product, yield) selectItem(item.name) insertForward(nil, item.count) end - goUp() - goUp() - goDown() - goDown() - sleep(10) - -- todo wait until ingredients are gone - takeForward(10) - -- todo empty fluids + -- todo update the mixer somehow? + -- wait until ingredients are gone + repeat + sleep(1) + contents = pFront("list") + inputs_remaining = false + for i = 1,9 do + if contents[i] then + inputs_remaining = true + break + end + end + until not inputs_remaining + if product == "still_milk" then + repeat + is_done = false + for _,t in pairs(pFront("tanks")) do + if stripModname(t.name) == "still_milk" then + is_done = t.amount >= yield + break + end + end + until is_done + end + + for i = 10, 18 do + takeForward(i) + end + -- empty fluids + tanks = pFront("tanks") + for _,tank in pairs(tanks) do + if tank.amount > 0 then + connectTankOrAssign(stripModname(tank.name)) + pumpToTanks(true) + sleep(8) + pumpToTanks(false) + end + end + fluidInvAdd(product, yield) end function craft(extra_items) local slot = 0 diff --git a/computer/13/recipes.txt b/computer/13/recipes.txt index 983b92c..d6e1fb0 100644 --- a/computer/13/recipes.txt +++ b/computer/13/recipes.txt @@ -122,9 +122,9 @@ steps: deploy_tool flint_knife gravel -base cobblestone +yield 8 steps: -mill +mill cobblestone:8 fluid_valve steps: @@ -140,6 +140,11 @@ yield 8 steps: craft black_dye sand sand sand sand gravel gravel gravel gravel +red_concrete_powder +yield 64 +steps: +craft red_dye:8 sand:8 sand:8 sand:8 sand:8 gravel:8 gravel:8 gravel:8 gravel:8 + rose_quartz_lamp steps: craft polished_rose_quartz redstone zinc_ingot @@ -177,6 +182,15 @@ computer_normal steps: craft andesite_alloy andesite_alloy andesite_alloy andesite_alloy polished_rose_quartz andesite_alloy andesite_alloy glass_pane andesite_alloy +turtle_normal +steps: +craft iron_ingot iron_ingot iron_ingot iron_ingot computer_normal iron_ingot iron_ingot chest iron_ingot + +chest +yield 4 +steps: +craft birch_log birch_log birch_log birch_log nil birch_log birch_log birch_log birch_log + glass_pane yield 16 steps: @@ -271,3 +285,32 @@ water yield 20000 steps: make_water + +lava +yield 125 +steps: +mix andesite_dust cobblestone lava:50 + +andesite_dust +yield 2 +steps: +craft gravel + +still_milk +yield 1000 +steps: +mix cow_jar + +grout +yield 8 +steps: +mix andesite_alloy zinc_ingot gravel:8 + +cable +yield 6 +steps: +craft nil andesite_alloy nil andesite_alloy polished_rose_quartz andesite_alloy nil andesite_alloy + +spout +steps: +craft copper_casing nil nil dried_kelp diff --git a/computer/13/work.lua b/computer/13/work.lua index c278086..4b2e002 100644 --- a/computer/13/work.lua +++ b/computer/13/work.lua @@ -10,7 +10,7 @@ keep_stocked = { flint = 10 } -resetAllFluidDevices() +-- resetAllFluidDevices() goHome() print("known recipes:\n") diff --git a/computer/15/.settings b/computer/15/.settings new file mode 100644 index 0000000..4bc0f68 --- /dev/null +++ b/computer/15/.settings @@ -0,0 +1,4 @@ +{ + [ "motd.enable" ] = false, + [ "motd.path" ] = "/rom/motd.txt:/motd.txt:/rom/cccbridge_motd.txt", +} \ No newline at end of file diff --git a/computer/15/logout.lua b/computer/15/logout.lua new file mode 100644 index 0000000..f224edb --- /dev/null +++ b/computer/15/logout.lua @@ -0,0 +1 @@ +require("startup") diff --git a/computer/17/music b/computer/17/music new file mode 100644 index 0000000..ceb9180 --- /dev/null +++ b/computer/17/music @@ -0,0 +1,704 @@ +local api_base_url = "https://ipod-2to6magyna-uc.a.run.app/" +local version = "2.1" + +local width, height = term.getSize() +local tab = 1 + +local waiting_for_input = false +local last_search = nil +local last_search_url = nil +local search_results = nil +local search_error = false +local in_search_result = false +local clicked_result = nil + +local playing = false +local queue = {} +local now_playing = nil +local looping = 0 +local volume = 1.5 + +local playing_id = nil +local last_download_url = nil +local playing_status = 0 +local is_loading = false +local is_error = false; + +local player_handle = nil +local start = nil +local pcm = nil +local size = nil +local decoder = require "cc.audio.dfpwm".make_decoder() +local needs_next_chunk = 0 +local buffer + +local speakers = { peripheral.find("speaker") } +if #speakers == 0 then + error("No speakers attached. You need to connect a speaker to this computer. If this is an Advanced Noisy Pocket Computer, then this is a bug, and you should try restarting your Minecraft game.", 0) +end + +function redrawScreen() + if waiting_for_input then + return + end + + term.setCursorBlink(false) -- Make sure cursor is off when redrawing + -- Clear the screen + term.setBackgroundColor(colors.black) + term.clear() + + --Draw the three top tabs + term.setCursorPos(1,1) + term.setBackgroundColor(colors.gray) + term.clearLine() + + tabs = {" Now Playing ", " Search "} + + for i=1,#tabs,1 do + if tab == i then + term.setTextColor(colors.black) + term.setBackgroundColor(colors.white) + else + term.setTextColor(colors.white) + term.setBackgroundColor(colors.gray) + end + + term.setCursorPos((math.floor((width/#tabs)*(i-0.5)))-math.ceil(#tabs[i]/2)+1, 1) + term.write(tabs[i]) + end + + if tab == 1 then + drawNowPlaying() + elseif tab == 2 then + drawSearch() + end +end + +function drawNowPlaying() + if now_playing ~= nil then + term.setBackgroundColor(colors.black) + term.setTextColor(colors.white) + term.setCursorPos(2,3) + term.write(now_playing.name) + term.setTextColor(colors.lightGray) + term.setCursorPos(2,4) + term.write(now_playing.artist) + else + term.setBackgroundColor(colors.black) + term.setTextColor(colors.lightGray) + term.setCursorPos(2,3) + term.write("Not playing") + end + + if is_loading == true then + term.setTextColor(colors.gray) + term.setBackgroundColor(colors.black) + term.setCursorPos(2,5) + term.write("Loading...") + elseif is_error == true then + term.setTextColor(colors.red) + term.setBackgroundColor(colors.black) + term.setCursorPos(2,5) + term.write("Network error") + end + + term.setTextColor(colors.white) + term.setBackgroundColor(colors.gray) + + if playing then + term.setCursorPos(2, 6) + term.write(" Stop ") + else + if now_playing ~= nil or #queue > 0 then + term.setTextColor(colors.white) + term.setBackgroundColor(colors.gray) + else + term.setTextColor(colors.lightGray) + term.setBackgroundColor(colors.gray) + end + term.setCursorPos(2, 6) + term.write(" Play ") + end + + if now_playing ~= nil or #queue > 0 then + term.setTextColor(colors.white) + term.setBackgroundColor(colors.gray) + else + term.setTextColor(colors.lightGray) + term.setBackgroundColor(colors.gray) + end + term.setCursorPos(2 + 7, 6) + term.write(" Skip ") + + if looping ~= 0 then + term.setTextColor(colors.black) + term.setBackgroundColor(colors.white) + else + term.setTextColor(colors.white) + term.setBackgroundColor(colors.gray) + end + term.setCursorPos(2 + 7 + 7, 6) + if looping == 0 then + term.write(" Loop Off ") + elseif looping == 1 then + term.write(" Loop Queue ") + else + term.write(" Loop Song ") + end + + term.setCursorPos(2,8) + paintutils.drawBox(2,8,25,8,colors.gray) + local width = math.floor(24 * (volume / 3) + 0.5)-1 + if not (width == -1) then + paintutils.drawBox(2,8,2+width,8,colors.white) + end + if volume < 0.6 then + term.setCursorPos(2+width+2,8) + term.setBackgroundColor(colors.gray) + term.setTextColor(colors.white) + else + term.setCursorPos(2+width-3-(volume == 3 and 1 or 0),8) + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + end + term.write(math.floor(100 * (volume / 3) + 0.5) .. "%") + + if #queue > 0 then + term.setBackgroundColor(colors.black) + for i=1,#queue do + term.setTextColor(colors.white) + term.setCursorPos(2,10 + (i-1)*2) + term.write(queue[i].name) + term.setTextColor(colors.lightGray) + term.setCursorPos(2,11 + (i-1)*2) + term.write(queue[i].artist) + end + end +end + +function drawSearch() + -- Search bar + paintutils.drawFilledBox(2,3,width-1,5,colors.lightGray) + term.setBackgroundColor(colors.lightGray) + term.setCursorPos(3,4) + term.setTextColor(colors.black) + term.write(last_search or "Search...") + + --Search results + if search_results ~= nil then + term.setBackgroundColor(colors.black) + for i=1,#search_results do + term.setTextColor(colors.white) + term.setCursorPos(2,7 + (i-1)*2) + term.write(search_results[i].name) + term.setTextColor(colors.lightGray) + term.setCursorPos(2,8 + (i-1)*2) + term.write(search_results[i].artist) + end + else + term.setCursorPos(2,7) + term.setBackgroundColor(colors.black) + if search_error == true then + term.setTextColor(colors.red) + term.write("Network error") + elseif last_search_url ~= nil then + term.setTextColor(colors.lightGray) + term.write("Searching...") + else + term.setCursorPos(1,7) + term.setTextColor(colors.lightGray) + print("Tip: You can paste YouTube video or playlist links.") + end + end + + --fullscreen song options + if in_search_result == true then + term.setBackgroundColor(colors.black) + term.clear() + term.setCursorPos(2,2) + term.setTextColor(colors.white) + term.write(search_results[clicked_result].name) + term.setCursorPos(2,3) + term.setTextColor(colors.lightGray) + term.write(search_results[clicked_result].artist) + + term.setBackgroundColor(colors.gray) + term.setTextColor(colors.white) + + term.setCursorPos(2,6) + term.clearLine() + term.write("Play now") + + term.setCursorPos(2,8) + term.clearLine() + term.write("Play next") + + term.setCursorPos(2,10) + term.clearLine() + term.write("Add to queue") + + term.setCursorPos(2,13) + term.clearLine() + term.write("Cancel") + end +end + +function uiLoop() + redrawScreen() + + while true do + if waiting_for_input then + parallel.waitForAny( + function() + term.setCursorPos(3,4) + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + local input = read() + + if string.len(input) > 0 then + last_search = input + last_search_url = api_base_url .. "?v=" .. version .. "&search=" .. textutils.urlEncode(input) + http.request(last_search_url) + search_results = nil + search_error = false + else + last_search = nil + last_search_url = nil + search_results = nil + search_error = false + end + + waiting_for_input = false + os.queueEvent("redraw_screen") + end, + function() + while waiting_for_input do + local event, button, x, y = os.pullEvent("mouse_click") + if y < 3 or y > 5 or x < 2 or x > width-1 then + waiting_for_input = false + os.queueEvent("redraw_screen") + break + end + end + end + ) + else + parallel.waitForAny( + function() + local event, button, x, y = os.pullEvent("mouse_click") + + if button == 1 then + -- Tabs + if in_search_result == false then + if y == 1 then + if x < width/2 then + tab = 1 + else + tab = 2 + end + redrawScreen() + end + end + + if tab == 2 and in_search_result == false then + -- Search box click + if y >= 3 and y <= 5 and x >= 1 and x <= width-1 then + paintutils.drawFilledBox(2,3,width-1,5,colors.white) + term.setBackgroundColor(colors.white) + waiting_for_input = true + end + + -- Search result click + if search_results then + for i=1,#search_results do + if y == 7 + (i-1)*2 or y == 8 + (i-1)*2 then + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + term.setCursorPos(2,7 + (i-1)*2) + term.clearLine() + term.write(search_results[i].name) + term.setTextColor(colors.gray) + term.setCursorPos(2,8 + (i-1)*2) + term.clearLine() + term.write(search_results[i].artist) + sleep(0.2) + in_search_result = true + clicked_result = i + redrawScreen() + end + end + end + elseif tab == 2 and in_search_result == true then + -- Search result menu clicks + + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + + if y == 6 then + term.setCursorPos(2,6) + term.clearLine() + term.write("Play now") + sleep(0.2) + in_search_result = false + for _, speaker in ipairs(speakers) do + speaker.stop() + os.queueEvent("playback_stopped") + end + playing = true + is_error = false + playing_id = nil + if search_results[clicked_result].type == "playlist" then + now_playing = search_results[clicked_result].playlist_items[1] + queue = {} + if #search_results[clicked_result].playlist_items > 1 then + for i=2, #search_results[clicked_result].playlist_items do + table.insert(queue, search_results[clicked_result].playlist_items[i]) + end + end + else + now_playing = search_results[clicked_result] + end + os.queueEvent("audio_update") + end + + if y == 8 then + term.setCursorPos(2,8) + term.clearLine() + term.write("Play next") + sleep(0.2) + in_search_result = false + if search_results[clicked_result].type == "playlist" then + for i = #search_results[clicked_result].playlist_items, 1, -1 do + table.insert(queue, 1, search_results[clicked_result].playlist_items[i]) + end + else + table.insert(queue, 1, search_results[clicked_result]) + end + os.queueEvent("audio_update") + end + + if y == 10 then + term.setCursorPos(2,10) + term.clearLine() + term.write("Add to queue") + sleep(0.2) + in_search_result = false + if search_results[clicked_result].type == "playlist" then + for i = 1, #search_results[clicked_result].playlist_items do + table.insert(queue, search_results[clicked_result].playlist_items[i]) + end + else + table.insert(queue, search_results[clicked_result]) + end + os.queueEvent("audio_update") + end + + if y == 13 then + term.setCursorPos(2,13) + term.clearLine() + term.write("Cancel") + sleep(0.2) + in_search_result = false + end + + redrawScreen() + elseif tab == 1 and in_search_result == false then + -- Now playing tab clicks + + if y == 6 then + -- Play/stop button + if x >= 2 and x < 2 + 6 then + if playing or now_playing ~= nil or #queue > 0 then + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + term.setCursorPos(2, 6) + if playing then + term.write(" Stop ") + else + term.write(" Play ") + end + sleep(0.2) + end + if playing then + playing = false + for _, speaker in ipairs(speakers) do + speaker.stop() + os.queueEvent("playback_stopped") + end + playing_id = nil + is_loading = false + is_error = false + os.queueEvent("audio_update") + elseif now_playing ~= nil then + playing_id = nil + playing = true + is_error = false + os.queueEvent("audio_update") + elseif #queue > 0 then + now_playing = queue[1] + table.remove(queue, 1) + playing_id = nil + playing = true + is_error = false + os.queueEvent("audio_update") + end + end + + -- Skip button + if x >= 2 + 7 and x < 2 + 7 + 6 then + if now_playing ~= nil or #queue > 0 then + term.setBackgroundColor(colors.white) + term.setTextColor(colors.black) + term.setCursorPos(2 + 7, 6) + term.write(" Skip ") + sleep(0.2) + + is_error = false + if playing then + for _, speaker in ipairs(speakers) do + speaker.stop() + os.queueEvent("playback_stopped") + end + end + if #queue > 0 then + if looping == 1 then + table.insert(queue, now_playing) + end + now_playing = queue[1] + table.remove(queue, 1) + playing_id = nil + else + now_playing = nil + playing = false + is_loading = false + is_error = false + playing_id = nil + end + os.queueEvent("audio_update") + end + end + + -- Loop button + if x >= 2 + 7 + 7 and x < 2 + 7 + 7 + 12 then + if looping == 0 then + looping = 1 + elseif looping == 1 then + looping = 2 + else + looping = 0 + end + end + end + + if y == 8 then + -- Volume slider + if x >= 1 and x < 2 + 24 then + volume = (x - 1) / 24 * 3 + + -- for _, speaker in ipairs(speakers) do + -- speaker.stop() + -- os.queueEvent("playback_stopped") + -- end + -- playing_id = nil + -- os.queueEvent("audio_update") + end + end + + redrawScreen() + end + end + end, + function() + local event, button, x, y = os.pullEvent("mouse_drag") + + if button == 1 then + + if tab == 1 and in_search_result == false then + + if y >= 7 and y <= 9 then + -- Volume slider + if x >= 1 and x < 2 + 24 then + volume = (x - 1) / 24 * 3 + + -- for _, speaker in ipairs(speakers) do + -- speaker.stop() + -- os.queueEvent("playback_stopped") + -- end + -- playing_id = nil + -- os.queueEvent("audio_update") + end + end + + redrawScreen() + end + end + end, + function() + local event = os.pullEvent("redraw_screen") + + redrawScreen() + end + ) + end + end +end + +function audioLoop() + while true do + + -- AUDIO + if playing and now_playing then + local thisnowplayingid = now_playing.id + if playing_id ~= thisnowplayingid then + playing_id = thisnowplayingid + last_download_url = api_base_url .. "?v=" .. version .. "&id=" .. textutils.urlEncode(playing_id) + playing_status = 0 + needs_next_chunk = 1 + + http.request({url = last_download_url, binary = true}) + is_loading = true + + os.queueEvent("redraw_screen") + os.queueEvent("audio_update") + elseif playing_status == 1 and needs_next_chunk == 1 then + + while true do + local chunk = player_handle.read(size) + if not chunk then + if looping == 2 or (looping == 1 and #queue == 0) then + playing_id = nil + elseif looping == 1 and #queue > 0 then + table.insert(queue, now_playing) + now_playing = queue[1] + table.remove(queue, 1) + playing_id = nil + else + if #queue > 0 then + now_playing = queue[1] + table.remove(queue, 1) + playing_id = nil + else + now_playing = nil + playing = false + playing_id = nil + is_loading = false + is_error = false + end + end + + os.queueEvent("redraw_screen") + + player_handle.close() + needs_next_chunk = 0 + break + else + if start then + chunk, start = start .. chunk, nil + size = size + 4 + end + + buffer = decoder(chunk) + + local fn = {} + for i, speaker in ipairs(speakers) do + fn[i] = function() + local name = peripheral.getName(speaker) + if #speakers > 1 then + if speaker.playAudio(buffer, volume) then + parallel.waitForAny( + function() + repeat until select(2, os.pullEvent("speaker_audio_empty")) == name + end, + function() + local event = os.pullEvent("playback_stopped") + return + end + ) + if not playing or playing_id ~= thisnowplayingid then + return + end + end + else + while not speaker.playAudio(buffer, volume) do + parallel.waitForAny( + function() + repeat until select(2, os.pullEvent("speaker_audio_empty")) == name + end, + function() + local event = os.pullEvent("playback_stopped") + return + end + ) + if not playing or playing_id ~= thisnowplayingid then + return + end + end + end + if not playing or playing_id ~= thisnowplayingid then + return + end + end + end + + local ok, err = pcall(parallel.waitForAll, table.unpack(fn)) + if not ok then + needs_next_chunk = 2 + is_error = true + break + end + + -- If we're not playing anymore, exit the chunk processing loop + if not playing or playing_id ~= thisnowplayingid then + break + end + end + end + os.queueEvent("audio_update") + end + end + + os.pullEvent("audio_update") + end +end + +function httpLoop() + while true do + parallel.waitForAny( + function() + local event, url, handle = os.pullEvent("http_success") + + if url == last_search_url then + search_results = textutils.unserialiseJSON(handle.readAll()) + os.queueEvent("redraw_screen") + end + if url == last_download_url then + is_loading = false + player_handle = handle + start = handle.read(4) + size = 16 * 1024 - 4 + playing_status = 1 + os.queueEvent("redraw_screen") + os.queueEvent("audio_update") + end + end, + function() + local event, url = os.pullEvent("http_failure") + + if url == last_search_url then + search_error = true + os.queueEvent("redraw_screen") + end + if url == last_download_url then + is_loading = false + is_error = true + playing = false + playing_id = nil + os.queueEvent("redraw_screen") + os.queueEvent("audio_update") + end + end + ) + end +end + +parallel.waitForAny(uiLoop, audioLoop, httpLoop) \ No newline at end of file diff --git a/computer/20/startup.lua b/computer/20/startup.lua new file mode 100644 index 0000000..f279ab8 --- /dev/null +++ b/computer/20/startup.lua @@ -0,0 +1,18 @@ +screen = peripheral.wrap("bottom") + +message = { +"Menu coming soon!", +"Don't miss our opening day 50% off!", +"The best vegan* fast food available" +} +i= 1 +while true do +screen.clear() +screen.setCursorPos(1,1) +screen.write(message[i]) +i = i+1 +if i > #message then + i = 1 +end +sleep(4) +end diff --git a/computer/21/startup.lua b/computer/21/startup.lua new file mode 100644 index 0000000..4f61532 --- /dev/null +++ b/computer/21/startup.lua @@ -0,0 +1,6 @@ +tonk = peripheral.wrap("right") + +while true do + sleep(0.5) + tonk.pushFluid("left",math.abs(300-tonk.tanks()[1].amount)) +end diff --git a/computer/3/startup b/computer/3/startup new file mode 100644 index 0000000..d3a5f52 --- /dev/null +++ b/computer/3/startup @@ -0,0 +1,84 @@ +_G.position = vector.new(-250,96,106) +_G.facing = vector.new(-1,0,0) +rednet.open("left") +--old_print = _G.print +--[[new_print = function(...) + x = "" + for i,v in ipairs(arg) do + x = x..tostring(v).." " + end + old_print(x) + rednet.broadcast(x) +end]] +--_G.print = new_print +--rednet.host("tomfoolery",os.computerLabel()) +--while true do +function append(tbl,value) + table.insert(tbl,value) + return tbl +end +rednet.host("tomfoolery",os.getComputerLabel()) +queue = {} +history = {} +if true then + parallel.waitForAll( + function() + while true do + --print("reading") + while running do + coroutine.yield() + end + write( + shell.dir().."> " + ) + table.insert( + queue, + append( + history, + not running and read( + nil, + history, + shell.complete + ) + )[#history] + ) + sleep(0.05)--coroutine.yield() + end + end, + function() + while true do + --print("attempting to run shell on :"..(queue[1] or "")) + running = true + shell.run( + table.remove( + queue, + 1 + ) + ) + running = false + --term.clear() + for i,v in pairs(queue) do + --print(v) + end + sleep(0.05) + end + end, + function() + while true do + --print("recieving") + id,mess,kind = rednet.receive() + if kind == "complete" then + rednet.send(id,shell.complete(mess),"completed") + elseif kind == "run" then + print("recieved") + print(id, mess, kind) + table.insert(queue,mess) + sleep(0.05) + else + + end + end + end + ) +end +rednet.receive() diff --git a/computer/4/disk/st b/computer/4/disk/st new file mode 100644 index 0000000..d3a5f52 --- /dev/null +++ b/computer/4/disk/st @@ -0,0 +1,84 @@ +_G.position = vector.new(-250,96,106) +_G.facing = vector.new(-1,0,0) +rednet.open("left") +--old_print = _G.print +--[[new_print = function(...) + x = "" + for i,v in ipairs(arg) do + x = x..tostring(v).." " + end + old_print(x) + rednet.broadcast(x) +end]] +--_G.print = new_print +--rednet.host("tomfoolery",os.computerLabel()) +--while true do +function append(tbl,value) + table.insert(tbl,value) + return tbl +end +rednet.host("tomfoolery",os.getComputerLabel()) +queue = {} +history = {} +if true then + parallel.waitForAll( + function() + while true do + --print("reading") + while running do + coroutine.yield() + end + write( + shell.dir().."> " + ) + table.insert( + queue, + append( + history, + not running and read( + nil, + history, + shell.complete + ) + )[#history] + ) + sleep(0.05)--coroutine.yield() + end + end, + function() + while true do + --print("attempting to run shell on :"..(queue[1] or "")) + running = true + shell.run( + table.remove( + queue, + 1 + ) + ) + running = false + --term.clear() + for i,v in pairs(queue) do + --print(v) + end + sleep(0.05) + end + end, + function() + while true do + --print("recieving") + id,mess,kind = rednet.receive() + if kind == "complete" then + rednet.send(id,shell.complete(mess),"completed") + elseif kind == "run" then + print("recieved") + print(id, mess, kind) + table.insert(queue,mess) + sleep(0.05) + else + + end + end + end + ) +end +rednet.receive() diff --git a/computer/4/disk/startup b/computer/4/disk/startup new file mode 100644 index 0000000..d3a5f52 --- /dev/null +++ b/computer/4/disk/startup @@ -0,0 +1,84 @@ +_G.position = vector.new(-250,96,106) +_G.facing = vector.new(-1,0,0) +rednet.open("left") +--old_print = _G.print +--[[new_print = function(...) + x = "" + for i,v in ipairs(arg) do + x = x..tostring(v).." " + end + old_print(x) + rednet.broadcast(x) +end]] +--_G.print = new_print +--rednet.host("tomfoolery",os.computerLabel()) +--while true do +function append(tbl,value) + table.insert(tbl,value) + return tbl +end +rednet.host("tomfoolery",os.getComputerLabel()) +queue = {} +history = {} +if true then + parallel.waitForAll( + function() + while true do + --print("reading") + while running do + coroutine.yield() + end + write( + shell.dir().."> " + ) + table.insert( + queue, + append( + history, + not running and read( + nil, + history, + shell.complete + ) + )[#history] + ) + sleep(0.05)--coroutine.yield() + end + end, + function() + while true do + --print("attempting to run shell on :"..(queue[1] or "")) + running = true + shell.run( + table.remove( + queue, + 1 + ) + ) + running = false + --term.clear() + for i,v in pairs(queue) do + --print(v) + end + sleep(0.05) + end + end, + function() + while true do + --print("recieving") + id,mess,kind = rednet.receive() + if kind == "complete" then + rednet.send(id,shell.complete(mess),"completed") + elseif kind == "run" then + print("recieved") + print(id, mess, kind) + table.insert(queue,mess) + sleep(0.05) + else + + end + end + end + ) +end +rednet.receive() diff --git a/computer/4/falseshell.lua b/computer/4/falseshell.lua new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/computer/4/falseshell.lua @@ -0,0 +1 @@ + diff --git a/computer/4/recievefile.lua b/computer/4/recievefile.lua new file mode 100644 index 0000000..216705b --- /dev/null +++ b/computer/4/recievefile.lua @@ -0,0 +1,13 @@ +file = fs.open("tobuild","w") +while true do + id,message = rednet.receive() + if id == 3 then + if message=="done" then + file.close() + return + else + print(message) + file.writeLine(message) + end + end +end diff --git a/computer/4/sendfile.lua b/computer/4/sendfile.lua new file mode 100644 index 0000000..83055d8 --- /dev/null +++ b/computer/4/sendfile.lua @@ -0,0 +1,9 @@ +file = fs.open(arg[1],"r") +line = file.readLine() +while line do + print(line) + rednet.send(1,line) + line = file.readLine() +end +rednet.send(1,nil) +file.close() diff --git a/computer/4/test.lua b/computer/4/test.lua new file mode 100644 index 0000000..3055558 --- /dev/null +++ b/computer/4/test.lua @@ -0,0 +1,6 @@ +while true do + parallel.waitForAll( + os.run("shell"), + rednet.receive + ) +end diff --git a/computer/5/complete.lua b/computer/5/complete.lua new file mode 100644 index 0000000..aa01a77 --- /dev/null +++ b/computer/5/complete.lua @@ -0,0 +1 @@ +shell.setCompletionFunction("turtlemanager" diff --git a/computer/5/customlookup.lua b/computer/5/customlookup.lua new file mode 100644 index 0000000..81be9f5 --- /dev/null +++ b/computer/5/customlookup.lua @@ -0,0 +1,35 @@ + + +results = {} +rednet.broadcast({ +sType = "lookup", +sProtocol = "tomfoolery", +sHostname = "pocket" +}) +local timer = os.startTimer(1) +while true do + local event,p1,p2,p3 = os.pullEvent() + if event == "rednet_message" then + local sender, message, message_protocol = p1,p2,p3 + print(sender, message, message_protocol) + if + message_protocol == "dns" and + type(message) == "table" and + message.sType == "lookup response" + then + if message.sProtocol == "tomfoolery" then + if hostname == nil then + print(sender) + table.insert(results,{sender,message.sHostname}) + elseif message.sHostname == hostname then + os.cancelTimer(timer) + print(sender) + return sender + end + end + end + elseif event == "timer" and p1 == timer then + break + end +end +return results diff --git a/computer/5/rednetcopy b/computer/5/rednetcopy new file mode 100644 index 0000000..997835c --- /dev/null +++ b/computer/5/rednetcopy @@ -0,0 +1,61 @@ +require("rom/apis/rednet") +function lookup(protocol, hostname) +-- expect(1, protocol, "string") +-- expect(2, hostname, "string", "nil") + -- Build list of host IDs + local results = nil + if hostname == nil then + results = {} + end + + -- Check localhost first + if hostnames and hostnames[protocol] then + if hostname == nil then + table.insert(results, {os.getComputerID(),os.getComputerLabel()}) + elseif hostname == "localhost" or hostname == hostnames[protocol] then + return {os.getComputerID(),os.getComputerLabel()} + end + end + if not isOpen() then + if results then + return results + end + return {} + end + + -- Broadcast a lookup packet + broadcast({ + sType = "lookup", + sProtocol = protocol, + sHostname = hostname, + }, "dns") + + -- Start a timer + local timer = os.startTimer(0.05) + -- Wait for events + while true do + local event, p1, p2, p3 = os.pullEvent() + if event == "rednet_message" then + -- Got a rednet message, check if it's the response to our request + local sender_id, message, message_protocol = p1, p2, p3 + if message_protocol == "dns" and type(message) == "table" and message.sType == "lookup response" then + if message.sProtocol == protocol then + if hostname == nil then + table.insert(results, {sender_id,message.sHostname}) + elseif message.sHostname == hostname then + return {sender_id,message.sHostname} + end + end + end + elseif event == "timer" and p1 == timer then + -- Got a timer event, check it's the end of our timeout + break + end + end + + if results then + return results + end + return {} +end +return {lookup = lookup} diff --git a/computer/5/turtlemanager b/computer/5/turtlemanager new file mode 100644 index 0000000..89b2fbe --- /dev/null +++ b/computer/5/turtlemanager @@ -0,0 +1,2 @@ +local arg = ... +print(arg or 0) diff --git a/computer/5/turtlemanagercompletion.lua b/computer/5/turtlemanagercompletion.lua new file mode 100644 index 0000000..c3e3fa9 --- /dev/null +++ b/computer/5/turtlemanagercompletion.lua @@ -0,0 +1,9 @@ + +function() +return shell.setCompletionFunction( + "turtlemanager.lua", + function(...) + return {"meow"} + end +) +end diff --git a/computer/8/wood.lua b/computer/8/wood.lua new file mode 100644 index 0000000..002d1c5 --- /dev/null +++ b/computer/8/wood.lua @@ -0,0 +1,7 @@ +while true do + redstone.setOutput("left", false) + redstone.setOutput("right", not redstone.getOutput("right")) + os.sleep(20) + redstone.setOutput("left", true) + os.sleep(400) +end