summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-11-02 03:27:03 +0100
committerAki <please@ignore.pl>2024-11-02 03:27:03 +0100
commit1a2c8b663ed89b4d4a75463e28260a7c4955ecb1 (patch)
tree1197fd5279771e8aa8fa3f7b20f8d96be59fb8a8
parentf87fb2cb7b044a73284c75dfcd06f25e068df8e1 (diff)
downloadnoita-eyes-1a2c8b663ed89b4d4a75463e28260a7c4955ecb1.zip
noita-eyes-1a2c8b663ed89b4d4a75463e28260a7c4955ecb1.tar.gz
noita-eyes-1a2c8b663ed89b4d4a75463e28260a7c4955ecb1.tar.bz2
Cleaned up and added common reading scripts
-rwxr-xr-xascii+32.lua9
-rwxr-xr-xdecimal.lua11
-rw-r--r--eyes/init.lua22
-rw-r--r--reading.lua38
4 files changed, 80 insertions, 0 deletions
diff --git a/ascii+32.lua b/ascii+32.lua
new file mode 100755
index 0000000..c16eb6f
--- /dev/null
+++ b/ascii+32.lua
@@ -0,0 +1,9 @@
+#!/usr/bin/env lua
+local eyes = require "eyes"
+local reading = require "reading"
+for _, message in ipairs(eyes) do
+ for _, value in reading.values(message) do
+ io.write(string.char(value + 32))
+ end
+ print()
+end
diff --git a/decimal.lua b/decimal.lua
new file mode 100755
index 0000000..6f32e5d
--- /dev/null
+++ b/decimal.lua
@@ -0,0 +1,11 @@
+#!/usr/bin/env lua
+local eyes = require "eyes"
+local reading = require "reading"
+for _, message in ipairs(eyes) do
+ local start, value = reading.next_value(message)
+ io.write(value)
+ for _, value in reading.values(message, start) do
+ io.write(",", value)
+ end
+ print()
+end
diff --git a/eyes/init.lua b/eyes/init.lua
new file mode 100644
index 0000000..de63d08
--- /dev/null
+++ b/eyes/init.lua
@@ -0,0 +1,22 @@
+return {
+ require "eyes.east1",
+ require "eyes.east2",
+ require "eyes.east3",
+ require "eyes.east4",
+ require "eyes.east5",
+ require "eyes.west1",
+ require "eyes.west2",
+ require "eyes.west3",
+ require "eyes.west4",
+ east1 = require "eyes.east1",
+ east2 = require "eyes.east2",
+ east3 = require "eyes.east3",
+ east4 = require "eyes.east4",
+ east5 = require "eyes.east5",
+ west1 = require "eyes.west1",
+ west2 = require "eyes.west2",
+ west3 = require "eyes.west3",
+ west4 = require "eyes.west4",
+ permutations = require "eyes.permutations",
+ random = require "eyes.random",
+}
diff --git a/reading.lua b/reading.lua
new file mode 100644
index 0000000..2b74446
--- /dev/null
+++ b/reading.lua
@@ -0,0 +1,38 @@
+local function next_trigram (message, index)
+ index = (index or 0) + 1
+ local offset = (index - 1) * 3
+ local a = message[offset + 1]
+ if not a then
+ return nil
+ end
+ return index, a, message[offset + 2], message[offset + 3]
+end
+
+
+local function next_value (message, index)
+ local a, b, c
+ index, a, b, c = next_trigram(message, index)
+ if not index then
+ return nil
+ end
+ return index, a * 25 + b * 5 + c
+end
+
+
+local reading = {
+ next_trigram = next_trigram,
+ next_value = next_value,
+}
+
+
+function reading.trigrams (message, start)
+ return next_trigram, message, start
+end
+
+
+function reading.values (message, start)
+ return next_value, message, start
+end
+
+
+return reading