Reformat + add prefix selection for config
This commit is contained in:
parent
88f4173c8e
commit
262c0b5408
13 changed files with 1191 additions and 1141 deletions
87
readme.md
87
readme.md
|
|
@ -21,6 +21,52 @@
|
||||||
- Chatbox support for withdrawing and depositing items
|
- Chatbox support for withdrawing and depositing items
|
||||||
- Remote access via enderstorages
|
- Remote access via enderstorages
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
1. First, in your /config.lua file, add the following:
|
||||||
|
```lua
|
||||||
|
return {
|
||||||
|
["inventories"] = { -- REQUIRED!! Please set at least one inventory pattern.
|
||||||
|
".*barrel.*" -- Lua patterns to match all barrels
|
||||||
|
},
|
||||||
|
["import"] = { -- Not required, just don't set!
|
||||||
|
"ender_storage_156" -- A inventory I want to move all items from into our storage
|
||||||
|
},
|
||||||
|
["chatbox"] = { -- Not required, just don't set!
|
||||||
|
["prefix"] = "home",
|
||||||
|
["players"] = {
|
||||||
|
["hartbreix"] = "manipulator_42" -- Chatbox support
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["remote"] = { -- Access your items via modem, not required, just don't set!
|
||||||
|
["ender_storage"] = "ender_storage_493", -- Enderstorage that will be changed (set this to owner-only and computer-chanagable!)
|
||||||
|
["modem"] = "modem_1277", -- Modem to recieve messages
|
||||||
|
["remotes"] = { -- Remote access
|
||||||
|
["red/green/green"] = {
|
||||||
|
["port"] = 42420,
|
||||||
|
["password"] = "test123" -- Required!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
2. Run the following command:
|
||||||
|
```
|
||||||
|
wget run https://git.sad.ovh/sophie/storage-solution/raw/branch/main/src/.main-installer.lua
|
||||||
|
```
|
||||||
|
|
||||||
|
This will install storage-solution to /storage-solution.
|
||||||
|
To make it start every time you turn on the computer, add
|
||||||
|
|
||||||
|
```
|
||||||
|
shell.run("wget run https://git.sad.ovh/sophie/storage-solution/raw/branch/main/src/.main-installer.lua")
|
||||||
|
```
|
||||||
|
to startup.lua
|
||||||
|
|
||||||
|
### [EXTRA!]
|
||||||
|
|
||||||
|
You can also run `wget run https://files.sad.ovh/public/storage-solution/.beta-installer.lua`, which is quite unstable. You may experience issues while running the beta version, but also new juicy features :)
|
||||||
|
|
||||||
|
|
||||||
## RA
|
## RA
|
||||||
SiSS has a remote access system that allows you to access your items via modem.
|
SiSS has a remote access system that allows you to access your items via modem.
|
||||||
To use it, first set up your config.lua correctly. After that you need to implement the tiny_ra_library into your program.
|
To use it, first set up your config.lua correctly. After that you need to implement the tiny_ra_library into your program.
|
||||||
|
|
@ -57,44 +103,3 @@ sleep(2)
|
||||||
print("deposits 16 items from the first slot")
|
print("deposits 16 items from the first slot")
|
||||||
ra.depositBySlots({1}, 16)
|
ra.depositBySlots({1}, 16)
|
||||||
```
|
```
|
||||||
## How to use
|
|
||||||
1. First, in your /config.lua file, add the following:
|
|
||||||
```lua
|
|
||||||
return {
|
|
||||||
["inventories"] = { -- REQUIRED!! Please set at least one inventory pattern.
|
|
||||||
".*barrel.*" -- Lua patterns to match all barrels
|
|
||||||
},
|
|
||||||
["import"] = { -- Not required, just don't set!
|
|
||||||
"ender_storage_156" -- A inventory I want to move all items from into our storage
|
|
||||||
},
|
|
||||||
["chatbox"] = { -- Not required, just don't set!
|
|
||||||
["hartbreix"] = "manipulator_42" -- Chatbox support
|
|
||||||
},
|
|
||||||
["remote"] = { -- Access your items via modem, not required, just don't set!
|
|
||||||
["ender_storage"] = "ender_storage_493", -- Enderstorage that will be changed (set this to owner-only and computer-chanagable!)
|
|
||||||
["modem"] = "modem_1277", -- Modem to recieve messages
|
|
||||||
["remotes"] = { -- Remote access
|
|
||||||
["red/green/green"] = {
|
|
||||||
["port"] = 42420,
|
|
||||||
["password"] = "test123" -- Required!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
2. Run the following command:
|
|
||||||
```
|
|
||||||
wget run https://git.sad.ovh/sophie/storage-solution/raw/branch/main/src/.main-installer.lua
|
|
||||||
```
|
|
||||||
|
|
||||||
This will install storage-solution to /storage-solution.
|
|
||||||
To make it start every time you turn on the computer, add
|
|
||||||
|
|
||||||
```
|
|
||||||
shell.run("wget run https://git.sad.ovh/sophie/storage-solution/raw/branch/main/src/.main-installer.lua")
|
|
||||||
```
|
|
||||||
to startup.lua
|
|
||||||
|
|
||||||
### [EXTRA!]
|
|
||||||
|
|
||||||
You can also run `wget run https://files.sad.ovh/public/storage-solution/.beta-installer.lua`, which is quite unstable. You may experience issues while running the beta version, but also new juicy features :)
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ local function traverse_and_download(folder_data, prefix)
|
||||||
for _, dir in ipairs(folder_data.dirs or {}) do
|
for _, dir in ipairs(folder_data.dirs or {}) do
|
||||||
fs.makeDir(download_root .. "/" .. prefix .. dir.href)
|
fs.makeDir(download_root .. "/" .. prefix .. dir.href)
|
||||||
local new_prefix = (prefix ~= "" and (prefix .. "/") or "") .. dir.href
|
local new_prefix = (prefix ~= "" and (prefix .. "/") or "") .. dir.href
|
||||||
local subdir_url = base_url .. "/" .. new_prefix .. "?ls" local response = http.get(subdir_url)
|
local subdir_url = base_url .. "/" .. new_prefix .. "?ls"
|
||||||
|
local response = http.get(subdir_url)
|
||||||
if response then
|
if response then
|
||||||
local body = response.readAll()
|
local body = response.readAll()
|
||||||
if not body then return end
|
if not body then return end
|
||||||
|
|
@ -59,7 +60,8 @@ if fs.exists(download_root) then
|
||||||
local currentVersion = http.get(base_url .. "/version").readAll();
|
local currentVersion = http.get(base_url .. "/version").readAll();
|
||||||
|
|
||||||
if previousVersion == currentVersion then
|
if previousVersion == currentVersion then
|
||||||
print("Previous version " .. previousVersion .. " is already installed, we're on " .. currentVersion .. " aswell, so skipping installation.")
|
print("Previous version " ..
|
||||||
|
previousVersion .. " is already installed, we're on " .. currentVersion .. " aswell, so skipping installation.")
|
||||||
shell.run("storage-solution/main.lua")
|
shell.run("storage-solution/main.lua")
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
local g = string.gsub
|
local g = string.gsub
|
||||||
|
|
||||||
sha256 = loadstring(g(g(g(g(g(g(g(g('Sa=XbandSb=XbxWSc=XlshiftSd=unpackSe=2^32SYf(g,h)Si=g/2^hSj=i%1Ui-j+j*eVSYk(l,m)Sn=l/2^mUn-n%1VSo={0x6a09e667Tbb67ae85T3c6ef372Ta54ff53aT510e527fT9b05688cT1f83d9abT5be0cd19}Sp={0x428a2f98T71374491Tb5c0fbcfTe9b5dba5T3956c25bT59f111f1T923f82a4Tab1c5ed5Td807aa98T12835b01T243185beT550c7dc3T72be5d74T80deb1feT9bdc06a7Tc19bf174Te49b69c1Tefbe4786T0fc19dc6T240ca1ccT2de92c6fT4a7484aaT5cb0a9dcT76f988daT983e5152Ta831c66dTb00327c8Tbf597fc7Tc6e00bf3Td5a79147T06ca6351T14292967T27b70a85T2e1b2138T4d2c6dfcT53380d13T650a7354T766a0abbT81c2c92eT92722c85Ta2bfe8a1Ta81a664bTc24b8b70Tc76c51a3Td192e819Td6990624Tf40e3585T106aa070T19a4c116T1e376c08T2748774cT34b0bcb5T391c0cb3T4ed8aa4aT5b9cca4fT682e6ff3T748f82eeT78a5636fT84c87814T8cc70208T90befffaTa4506cebTbef9a3f7Tc67178f2}SYq(r,q)if e-1-r[1]<q then r[2]=r[2]+1;r[1]=q-(e-1-r[1])-1 else r[1]=r[1]+qVUrVSYs(t)Su=#t;t[#t+1]=0x80;while#t%64~=56Zt[#t+1]=0VSv=q({0,0},u*8)fWw=2,1,-1Zt[#t+1]=a(k(a(v[w]TFF000000),24)TFF)t[#t+1]=a(k(a(v[w]TFF0000),16)TFF)t[#t+1]=a(k(a(v[w]TFF00),8)TFF)t[#t+1]=a(v[w]TFF)VUtVSYx(y,w)Uc(y[w]W0,24)+c(y[w+1]W0,16)+c(y[w+2]W0,8)+(y[w+3]W0)VSYz(t,w,A)SB={}fWC=1,16ZB[C]=x(t,w+(C-1)*4)VfWC=17,64ZSD=B[C-15]SE=b(b(f(B[C-15],7),f(B[C-15],18)),k(B[C-15],3))SF=b(b(f(B[C-2],17),f(B[C-2],19)),k(B[C-2],10))B[C]=(B[C-16]+E+B[C-7]+F)%eVSG,h,H,I,J,j,K,L=d(A)fWC=1,64ZSM=b(b(f(J,6),f(J,11)),f(J,25))SN=b(a(J,j),a(Xbnot(J),K))SO=(L+M+N+p[C]+B[C])%eSP=b(b(f(G,2),f(G,13)),f(G,22))SQ=b(b(a(G,h),a(G,H)),a(h,H))SR=(P+Q)%e;L,K,j,J,I,H,h,G=K,j,J,(I+O)%e,H,h,G,(O+R)%eVA[1]=(A[1]+G)%e;A[2]=(A[2]+h)%e;A[3]=(A[3]+H)%e;A[4]=(A[4]+I)%e;A[5]=(A[5]+J)%e;A[6]=(A[6]+j)%e;A[7]=(A[7]+K)%e;A[8]=(A[8]+L)%eUAVUY(t)t=t W""t=type(t)=="string"and{t:byte(1,-1)}Wt;t=s(t)SA={d(o)}fWw=1,#t,64ZA=z(t,w,A)VU("%08x"):rep(8):format(d(A))V',"S"," local "),"T",",0x"),"U"," return "),"V"," end "),"W","or "),"X","bit32."),"Y","function "),"Z"," do "))()
|
sha256 = loadstring(g(
|
||||||
|
g(
|
||||||
|
g(
|
||||||
|
g(
|
||||||
|
g(
|
||||||
|
g(
|
||||||
|
g(
|
||||||
|
g(
|
||||||
|
'Sa=XbandSb=XbxWSc=XlshiftSd=unpackSe=2^32SYf(g,h)Si=g/2^hSj=i%1Ui-j+j*eVSYk(l,m)Sn=l/2^mUn-n%1VSo={0x6a09e667Tbb67ae85T3c6ef372Ta54ff53aT510e527fT9b05688cT1f83d9abT5be0cd19}Sp={0x428a2f98T71374491Tb5c0fbcfTe9b5dba5T3956c25bT59f111f1T923f82a4Tab1c5ed5Td807aa98T12835b01T243185beT550c7dc3T72be5d74T80deb1feT9bdc06a7Tc19bf174Te49b69c1Tefbe4786T0fc19dc6T240ca1ccT2de92c6fT4a7484aaT5cb0a9dcT76f988daT983e5152Ta831c66dTb00327c8Tbf597fc7Tc6e00bf3Td5a79147T06ca6351T14292967T27b70a85T2e1b2138T4d2c6dfcT53380d13T650a7354T766a0abbT81c2c92eT92722c85Ta2bfe8a1Ta81a664bTc24b8b70Tc76c51a3Td192e819Td6990624Tf40e3585T106aa070T19a4c116T1e376c08T2748774cT34b0bcb5T391c0cb3T4ed8aa4aT5b9cca4fT682e6ff3T748f82eeT78a5636fT84c87814T8cc70208T90befffaTa4506cebTbef9a3f7Tc67178f2}SYq(r,q)if e-1-r[1]<q then r[2]=r[2]+1;r[1]=q-(e-1-r[1])-1 else r[1]=r[1]+qVUrVSYs(t)Su=#t;t[#t+1]=0x80;while#t%64~=56Zt[#t+1]=0VSv=q({0,0},u*8)fWw=2,1,-1Zt[#t+1]=a(k(a(v[w]TFF000000),24)TFF)t[#t+1]=a(k(a(v[w]TFF0000),16)TFF)t[#t+1]=a(k(a(v[w]TFF00),8)TFF)t[#t+1]=a(v[w]TFF)VUtVSYx(y,w)Uc(y[w]W0,24)+c(y[w+1]W0,16)+c(y[w+2]W0,8)+(y[w+3]W0)VSYz(t,w,A)SB={}fWC=1,16ZB[C]=x(t,w+(C-1)*4)VfWC=17,64ZSD=B[C-15]SE=b(b(f(B[C-15],7),f(B[C-15],18)),k(B[C-15],3))SF=b(b(f(B[C-2],17),f(B[C-2],19)),k(B[C-2],10))B[C]=(B[C-16]+E+B[C-7]+F)%eVSG,h,H,I,J,j,K,L=d(A)fWC=1,64ZSM=b(b(f(J,6),f(J,11)),f(J,25))SN=b(a(J,j),a(Xbnot(J),K))SO=(L+M+N+p[C]+B[C])%eSP=b(b(f(G,2),f(G,13)),f(G,22))SQ=b(b(a(G,h),a(G,H)),a(h,H))SR=(P+Q)%e;L,K,j,J,I,H,h,G=K,j,J,(I+O)%e,H,h,G,(O+R)%eVA[1]=(A[1]+G)%e;A[2]=(A[2]+h)%e;A[3]=(A[3]+H)%e;A[4]=(A[4]+I)%e;A[5]=(A[5]+J)%e;A[6]=(A[6]+j)%e;A[7]=(A[7]+K)%e;A[8]=(A[8]+L)%eUAVUY(t)t=t W""t=type(t)=="string"and{t:byte(1,-1)}Wt;t=s(t)SA={d(o)}fWw=1,#t,64ZA=z(t,w,A)VU("%08x"):rep(8):format(d(A))V',
|
||||||
|
"S", " local "), "T", ",0x"), "U", " return "), "V", " end "), "W", "or "), "X", "bit32."), "Y", "function "), "Z",
|
||||||
|
" do "))()
|
||||||
|
|
||||||
local aead = require("lib.plc.aead_chacha_poly")
|
local aead = require("lib.plc.aead_chacha_poly")
|
||||||
|
|
||||||
|
|
@ -16,8 +26,10 @@ local function b64u_encode(bin)
|
||||||
local triple = a * 65536 + b * 256 + c
|
local triple = a * 65536 + b * 256 + c
|
||||||
out[#out + 1] = b64abc:sub(bit32.band(bit32.rshift(triple, 18), 63) + 1, bit32.band(bit32.rshift(triple, 18), 63) + 1)
|
out[#out + 1] = b64abc:sub(bit32.band(bit32.rshift(triple, 18), 63) + 1, bit32.band(bit32.rshift(triple, 18), 63) + 1)
|
||||||
out[#out + 1] = b64abc:sub(bit32.band(bit32.rshift(triple, 12), 63) + 1, bit32.band(bit32.rshift(triple, 12), 63) + 1)
|
out[#out + 1] = b64abc:sub(bit32.band(bit32.rshift(triple, 12), 63) + 1, bit32.band(bit32.rshift(triple, 12), 63) + 1)
|
||||||
out[#out+1]= i+1<=n and b64abc:sub(bit32.band(bit32.rshift(triple,6), 63)+1,bit32.band(bit32.rshift(triple,6), 63)+1) or ''
|
out[#out + 1] = i + 1 <= n and
|
||||||
out[#out+1]= i+2<=n and b64abc:sub(bit32.band(bit32.rshift(triple,0), 63)+1,bit32.band(bit32.rshift(triple,0), 63)+1) or ''
|
b64abc:sub(bit32.band(bit32.rshift(triple, 6), 63) + 1, bit32.band(bit32.rshift(triple, 6), 63) + 1) or ''
|
||||||
|
out[#out + 1] = i + 2 <= n and
|
||||||
|
b64abc:sub(bit32.band(bit32.rshift(triple, 0), 63) + 1, bit32.band(bit32.rshift(triple, 0), 63) + 1) or ''
|
||||||
i = i + 3
|
i = i + 3
|
||||||
end
|
end
|
||||||
return table.concat(out)
|
return table.concat(out)
|
||||||
|
|
@ -55,7 +67,8 @@ local function hmac_sha256(key, msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function int_be(n) -- 32-bit BE
|
local function int_be(n) -- 32-bit BE
|
||||||
return string.char(bit32.band(bit32.rshift(n,24), 255), bit32.band(bit32.rshift(n,16), 255), bit32.band(bit32.rshift(n,8), 255), bit32.band(n, 255))
|
return string.char(bit32.band(bit32.rshift(n, 24), 255), bit32.band(bit32.rshift(n, 16), 255),
|
||||||
|
bit32.band(bit32.rshift(n, 8), 255), bit32.band(n, 255))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function pbkdf2_sha256(password, salt, iterations, dkLen)
|
local function pbkdf2_sha256(password, salt, iterations, dkLen)
|
||||||
|
|
@ -138,7 +151,8 @@ local VERSION = "\1"
|
||||||
local KDF_ID = "\1"
|
local KDF_ID = "\1"
|
||||||
local AAD = "SiSS RA rev1|chacha20poly1305"
|
local AAD = "SiSS RA rev1|chacha20poly1305"
|
||||||
|
|
||||||
local function u32be(n) return string.char(bit32.band(bit32.rshift(n,24),255), bit32.band(bit32.rshift(n,16),255), bit32.band(bit32.rshift(n,8),255), bit32.band(n,255)) end
|
local function u32be(n) return string.char(bit32.band(bit32.rshift(n, 24), 255), bit32.band(bit32.rshift(n, 16), 255),
|
||||||
|
bit32.band(bit32.rshift(n, 8), 255), bit32.band(n, 255)) end
|
||||||
local function u16be(n) return string.char(bit32.band(bit32.rshift(n, 8), 255), bit32.band(n, 255)) end
|
local function u16be(n) return string.char(bit32.band(bit32.rshift(n, 8), 255), bit32.band(n, 255)) end
|
||||||
local function pack_params(iter)
|
local function pack_params(iter)
|
||||||
return u32be(iter) .. u16be(32)
|
return u32be(iter) .. u16be(32)
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,8 @@ end
|
||||||
---@param replacement string|nil A character to replace typed characters with
|
---@param replacement string|nil A character to replace typed characters with
|
||||||
---@param history string[]|nil A list of previous entries to provide
|
---@param history string[]|nil A list of previous entries to provide
|
||||||
---@param completion function|nil A function to call to provide completion
|
---@param completion function|nil A function to call to provide completion
|
||||||
function PrimeUI.inputBox(win, x, y, width, action, placeholder, fgColor, bgColor, placeholderFg, replacement, history, completion, default)
|
function PrimeUI.inputBox(win, x, y, width, action, placeholder, fgColor, bgColor, placeholderFg, replacement, history,
|
||||||
|
completion, default)
|
||||||
expect(1, win, "table")
|
expect(1, win, "table")
|
||||||
expect(2, x, "number")
|
expect(2, x, "number")
|
||||||
expect(3, y, "number")
|
expect(3, y, "number")
|
||||||
|
|
@ -273,8 +274,11 @@ function PrimeUI.scrollBox(win, x, y, width, height, innerHeight, allowArrowKeys
|
||||||
-- Check for scroll events and set direction.
|
-- Check for scroll events and set direction.
|
||||||
local dir
|
local dir
|
||||||
if ev[1] == "key" and allowArrowKeys then
|
if ev[1] == "key" and allowArrowKeys then
|
||||||
if ev[2] == keys.up then dir = -1
|
if ev[2] == keys.up then
|
||||||
elseif ev[2] == keys.down then dir = 1 end
|
dir = -1
|
||||||
|
elseif ev[2] == keys.down then
|
||||||
|
dir = 1
|
||||||
|
end
|
||||||
elseif ev[1] == "mouse_scroll" and ev[3] >= x and ev[3] < x + width and ev[4] >= y and ev[4] < y + height then
|
elseif ev[1] == "mouse_scroll" and ev[3] >= x and ev[3] < x + width and ev[4] >= y and ev[4] < y + height then
|
||||||
dir = ev[2]
|
dir = ev[2]
|
||||||
end
|
end
|
||||||
|
|
@ -315,7 +319,6 @@ function PrimeUI.scrollBox(win, x, y, width, height, innerHeight, allowArrowKeys
|
||||||
return inner, scroll
|
return inner, scroll
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Creates a list of entries that can each be selected.
|
--- Creates a list of entries that can each be selected.
|
||||||
---@param win window The window to draw on
|
---@param win window The window to draw on
|
||||||
---@param x number The X coordinate of the inside of the box
|
---@param x number The X coordinate of the inside of the box
|
||||||
|
|
@ -387,8 +390,11 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
selection = selection + 1
|
selection = selection + 1
|
||||||
if selection > scroll + height - 1 then scroll = scroll + 1 end
|
if selection > scroll + height - 1 then scroll = scroll + 1 end
|
||||||
-- Send action if necessary.
|
-- Send action if necessary.
|
||||||
if type(selectChangeAction) == "string" then PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
if type(selectChangeAction) == "string" then
|
||||||
elseif selectChangeAction then selectChangeAction(selection) end
|
PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
||||||
|
elseif selectChangeAction then
|
||||||
|
selectChangeAction(selection)
|
||||||
|
end
|
||||||
-- Redraw screen.
|
-- Redraw screen.
|
||||||
drawEntries()
|
drawEntries()
|
||||||
elseif key == keys.up and selection > 1 then
|
elseif key == keys.up and selection > 1 then
|
||||||
|
|
@ -396,14 +402,20 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
selection = selection - 1
|
selection = selection - 1
|
||||||
if selection < scroll then scroll = scroll - 1 end
|
if selection < scroll then scroll = scroll - 1 end
|
||||||
-- Send action if necessary.
|
-- Send action if necessary.
|
||||||
if type(selectChangeAction) == "string" then PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
if type(selectChangeAction) == "string" then
|
||||||
elseif selectChangeAction then selectChangeAction(selection) end
|
PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
||||||
|
elseif selectChangeAction then
|
||||||
|
selectChangeAction(selection)
|
||||||
|
end
|
||||||
-- Redraw screen.
|
-- Redraw screen.
|
||||||
drawEntries()
|
drawEntries()
|
||||||
elseif key == keys.enter then
|
elseif key == keys.enter then
|
||||||
-- Select the entry: send the action.
|
-- Select the entry: send the action.
|
||||||
if type(action) == "string" then PrimeUI.resolve("selectionBox", action, entries()[selection])
|
if type(action) == "string" then
|
||||||
else action(entries()[selection]) end
|
PrimeUI.resolve("selectionBox", action, entries()[selection])
|
||||||
|
else
|
||||||
|
action(entries()[selection])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif event == "mouse_click" and key == 1 then
|
elseif event == "mouse_click" and key == 1 then
|
||||||
-- Handle clicking the scroll arrows.
|
-- Handle clicking the scroll arrows.
|
||||||
|
|
@ -414,8 +426,11 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
selection = selection - 1
|
selection = selection - 1
|
||||||
if selection < scroll then scroll = scroll - 1 end
|
if selection < scroll then scroll = scroll - 1 end
|
||||||
-- Send action if necessary.
|
-- Send action if necessary.
|
||||||
if type(selectChangeAction) == "string" then PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
if type(selectChangeAction) == "string" then
|
||||||
elseif selectChangeAction then selectChangeAction(selection) end
|
PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
||||||
|
elseif selectChangeAction then
|
||||||
|
selectChangeAction(selection)
|
||||||
|
end
|
||||||
-- Redraw screen.
|
-- Redraw screen.
|
||||||
drawEntries()
|
drawEntries()
|
||||||
elseif cy == wy + height - 1 and selection < #entries() then
|
elseif cy == wy + height - 1 and selection < #entries() then
|
||||||
|
|
@ -423,8 +438,11 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
selection = selection + 1
|
selection = selection + 1
|
||||||
if selection > scroll + height - 1 then scroll = scroll + 1 end
|
if selection > scroll + height - 1 then scroll = scroll + 1 end
|
||||||
-- Send action if necessary.
|
-- Send action if necessary.
|
||||||
if type(selectChangeAction) == "string" then PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
if type(selectChangeAction) == "string" then
|
||||||
elseif selectChangeAction then selectChangeAction(selection) end
|
PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
||||||
|
elseif selectChangeAction then
|
||||||
|
selectChangeAction(selection)
|
||||||
|
end
|
||||||
-- Redraw screen.
|
-- Redraw screen.
|
||||||
drawEntries()
|
drawEntries()
|
||||||
end
|
end
|
||||||
|
|
@ -432,13 +450,19 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
local sel = scroll + (cy - wy)
|
local sel = scroll + (cy - wy)
|
||||||
if sel == selection then
|
if sel == selection then
|
||||||
-- Select the entry: send the action.
|
-- Select the entry: send the action.
|
||||||
if type(action) == "string" then PrimeUI.resolve("selectionBox", action, entries()[selection])
|
if type(action) == "string" then
|
||||||
else action(entries()[selection]) end
|
PrimeUI.resolve("selectionBox", action, entries()[selection])
|
||||||
|
else
|
||||||
|
action(entries()[selection])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
selection = sel
|
selection = sel
|
||||||
-- Send action if necessary.
|
-- Send action if necessary.
|
||||||
if type(selectChangeAction) == "string" then PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
if type(selectChangeAction) == "string" then
|
||||||
elseif selectChangeAction then selectChangeAction(selection) end
|
PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
||||||
|
elseif selectChangeAction then
|
||||||
|
selectChangeAction(selection)
|
||||||
|
end
|
||||||
-- Redraw screen.
|
-- Redraw screen.
|
||||||
drawEntries()
|
drawEntries()
|
||||||
end
|
end
|
||||||
|
|
@ -452,8 +476,11 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
selection = selection - 1
|
selection = selection - 1
|
||||||
if selection < scroll then scroll = scroll - 1 end
|
if selection < scroll then scroll = scroll - 1 end
|
||||||
-- Send action if necessary.
|
-- Send action if necessary.
|
||||||
if type(selectChangeAction) == "string" then PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
if type(selectChangeAction) == "string" then
|
||||||
elseif selectChangeAction then selectChangeAction(selection) end
|
PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
||||||
|
elseif selectChangeAction then
|
||||||
|
selectChangeAction(selection)
|
||||||
|
end
|
||||||
-- Redraw screen.
|
-- Redraw screen.
|
||||||
drawEntries()
|
drawEntries()
|
||||||
elseif key > 0 and selection < #entries() then
|
elseif key > 0 and selection < #entries() then
|
||||||
|
|
@ -461,8 +488,11 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
selection = selection + 1
|
selection = selection + 1
|
||||||
if selection > scroll + height - 1 then scroll = scroll + 1 end
|
if selection > scroll + height - 1 then scroll = scroll + 1 end
|
||||||
-- Send action if necessary.
|
-- Send action if necessary.
|
||||||
if type(selectChangeAction) == "string" then PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
if type(selectChangeAction) == "string" then
|
||||||
elseif selectChangeAction then selectChangeAction(selection) end
|
PrimeUI.resolve("selectionBox", selectChangeAction, selection)
|
||||||
|
elseif selectChangeAction then
|
||||||
|
selectChangeAction(selection)
|
||||||
|
end
|
||||||
-- Redraw screen.
|
-- Redraw screen.
|
||||||
drawEntries()
|
drawEntries()
|
||||||
end
|
end
|
||||||
|
|
@ -473,7 +503,6 @@ function PrimeUI.selectionBox(win, x, y, width, height, entries, action, selectC
|
||||||
return drawEntries
|
return drawEntries
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
PrimeUI = PrimeUI
|
PrimeUI = PrimeUI
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
---@class InnerRemote
|
---@class InnerRemote
|
||||||
---@field port number
|
---@field port number
|
||||||
---@field password string
|
---@field password string
|
||||||
|
|
@ -8,11 +7,15 @@
|
||||||
---@field ender_storage string
|
---@field ender_storage string
|
||||||
---@field modem string
|
---@field modem string
|
||||||
---@field remotes table<string, InnerRemote>
|
---@field remotes table<string, InnerRemote>
|
||||||
---
|
|
||||||
|
---@class Chatbox
|
||||||
|
---@field players table<string, string>
|
||||||
|
---@field prefix string|nil
|
||||||
|
|
||||||
---@class Config
|
---@class Config
|
||||||
---@field inventories string[]
|
---@field inventories string[]
|
||||||
---@field import string[]|nil
|
---@field import string[]|nil
|
||||||
---@field chatbox table<string, string>|nil
|
---@field chatbox Chatbox|nil
|
||||||
---@field remote Remote
|
---@field remote Remote
|
||||||
|
|
||||||
local inv = require("modules.inv")
|
local inv = require("modules.inv")
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ local function levDist(s, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function findBest(data, item)
|
local function findBest(data, item)
|
||||||
|
|
||||||
local sorted_data = {}
|
local sorted_data = {}
|
||||||
|
|
||||||
for _, z in ipairs(data) do
|
for _, z in ipairs(data) do
|
||||||
|
|
@ -84,7 +83,7 @@ end
|
||||||
local BOT_NAME = "&cS &eI&an&3c &5S&cI&6S"
|
local BOT_NAME = "&cS &eI&an&3c &5S&cI&6S"
|
||||||
|
|
||||||
function auth(user)
|
function auth(user)
|
||||||
local manip = config.chatbox[user]
|
local manip = config.chatbox.players[user]
|
||||||
if manip then
|
if manip then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
|
|
@ -99,9 +98,9 @@ function run()
|
||||||
while true do
|
while true do
|
||||||
local _, user, command, args = os.pullEvent("command")
|
local _, user, command, args = os.pullEvent("command")
|
||||||
|
|
||||||
if command == "sis" then
|
if command == (config.chatbox.prefix or "sis") then
|
||||||
if args[1] == "whoami" then
|
if args[1] == "whoami" then
|
||||||
local manip = config.chatbox[user]
|
local manip = config.chatbox.players[user]
|
||||||
if manip then
|
if manip then
|
||||||
chatbox.tell(user, "You are " .. user .. ", linked with `" .. manip .. "`.", BOT_NAME)
|
chatbox.tell(user, "You are " .. user .. ", linked with `" .. manip .. "`.", BOT_NAME)
|
||||||
else
|
else
|
||||||
|
|
@ -116,7 +115,7 @@ function run()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local perip = peripheral.wrap(config.chatbox[user])
|
local perip = peripheral.wrap(config.chatbox.players[user])
|
||||||
|
|
||||||
---@type ccTweaked.peripheral.Inventory
|
---@type ccTweaked.peripheral.Inventory
|
||||||
local peripInventory = perip.getInventory()
|
local peripInventory = perip.getInventory()
|
||||||
|
|
@ -172,7 +171,7 @@ function run()
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
local perip = peripheral.wrap(config.chatbox[user])
|
local perip = peripheral.wrap(config.chatbox.players[user])
|
||||||
|
|
||||||
---@type ccTweaked.peripheral.Inventory
|
---@type ccTweaked.peripheral.Inventory
|
||||||
local peripInventory = perip.getInventory()
|
local peripInventory = perip.getInventory()
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@ local function sendItemToSelf(itemName, perip, maxAmount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- sleep(0.1)
|
|
||||||
turtleMoveAllowed = true
|
turtleMoveAllowed = true
|
||||||
|
|
||||||
return total
|
return total
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ local function run()
|
||||||
|
|
||||||
for color, remote in pairs(config.remote.remotes) do
|
for color, remote in pairs(config.remote.remotes) do
|
||||||
if remote.port == channel then
|
if remote.port == channel then
|
||||||
|
|
||||||
local err, data = pcall(function()
|
local err, data = pcall(function()
|
||||||
return hmac.decrypt_with_password(remote.password, message)
|
return hmac.decrypt_with_password(remote.password, message)
|
||||||
end)
|
end)
|
||||||
|
|
@ -38,7 +37,6 @@ local function run()
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
if err == true then
|
if err == true then
|
||||||
|
|
||||||
---@type RemoteAccess
|
---@type RemoteAccess
|
||||||
local json, errj = textutils.unserialiseJSON(data)
|
local json, errj = textutils.unserialiseJSON(data)
|
||||||
if json or errj ~= nil then
|
if json or errj ~= nil then
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ local function run()
|
||||||
local refiltered = {}
|
local refiltered = {}
|
||||||
|
|
||||||
for i, filter in ipairs(filtered) do
|
for i, filter in ipairs(filtered) do
|
||||||
refiltered[i] = filter.name .. string.rep(" ", w-(2+#filter.name+#tostring(filter.count))) .. tostring(filter.count)
|
refiltered[i] = filter.name ..
|
||||||
|
string.rep(" ", w - (2 + #filter.name + #tostring(filter.count))) .. tostring(filter.count)
|
||||||
end
|
end
|
||||||
return refiltered
|
return refiltered
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue