diff options
author | Aki <please@ignore.pl> | 2024-11-02 13:41:36 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-11-02 13:41:36 +0100 |
commit | 0b0e02875dbc4d7d795cafe6e5720aa66b32e1ac (patch) | |
tree | e42c905d5d1ddde4c1bb1cf58fbf7d697c17616e /reading.lua | |
parent | 1a2c8b663ed89b4d4a75463e28260a7c4955ecb1 (diff) | |
download | noita-eyes-0b0e02875dbc4d7d795cafe6e5720aa66b32e1ac.zip noita-eyes-0b0e02875dbc4d7d795cafe6e5720aa66b32e1ac.tar.gz noita-eyes-0b0e02875dbc4d7d795cafe6e5720aa66b32e1ac.tar.bz2 |
Naive approach to disk-based masking directly on the trigrams
Diffstat (limited to 'reading.lua')
-rw-r--r-- | reading.lua | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/reading.lua b/reading.lua index 2b74446..6c910e2 100644 --- a/reading.lua +++ b/reading.lua @@ -1,3 +1,8 @@ +local function trigram_to_value (a, b, c) + return a * 25 + b * 5 + c +end + + local function next_trigram (message, index) index = (index or 0) + 1 local offset = (index - 1) * 3 @@ -15,23 +20,33 @@ local function next_value (message, index) if not index then return nil end - return index, a * 25 + b * 5 + c + return index, trigram_to_value(a, b, c) end local reading = { + trigram_to_value = trigram_to_value, next_trigram = next_trigram, next_value = next_value, } function reading.trigrams (message, start) - return next_trigram, message, start + return next_trigram, message, start or 0 end function reading.values (message, start) - return next_value, message, start + return next_value, message, start or 0 +end + + +function reading.tvalues (message) + local values = {} + for _, value in reading.values(message) do + table.insert(values, value) + end + return values end |