forked from xomf/slabOS
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
e4015debbe | |||
17e3221fd9 | |||
186fa1b0bc | |||
f871625016 | |||
3074f9ec8d | |||
4c457e3118 | |||
560bfd7fa2 | |||
c20170a0a3 | |||
a1d2140017 | |||
674822e1ed | |||
55b4537e52 | |||
f9d241f7e5 | |||
48fdb784ce | |||
ba491b11bf | |||
df88bcf6f8 | |||
3ae183b105 | |||
9f9d728dd3 | |||
538bafae03 |
1
Terminal.lua
Normal file
1
Terminal.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
shell.run("sh")
|
|
@ -5,12 +5,11 @@
|
||||||
"url" : "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/Clicker.lua",
|
"url" : "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/Clicker.lua",
|
||||||
"path" : "apps/Clicker.lua"
|
"path" : "apps/Clicker.lua"
|
||||||
},
|
},
|
||||||
|
"Terminal" : {
|
||||||
"Tester" : {
|
|
||||||
"version" : 1,
|
"version" : 1,
|
||||||
"colour": "red",
|
"colour": "black",
|
||||||
"url" : "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/tester.lua",
|
"url" : "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/Terminal.lua",
|
||||||
"path" : "apps/Tester.lua"
|
"path" : "apps/Terminal.lua"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
17
eCash.lua
17
eCash.lua
|
@ -1,5 +1,5 @@
|
||||||
local basalt = require("../lib/basalt")
|
local basalt = require("/lib/basalt")
|
||||||
local libcredit = require("../lib/libcredit_mobile")
|
local libcredit = require("/lib/libcredit_mobile")
|
||||||
|
|
||||||
local username = ""
|
local username = ""
|
||||||
local main = basalt.getMainFrame()
|
local main = basalt.getMainFrame()
|
||||||
|
@ -243,21 +243,16 @@ local loginButton = login:addButton()
|
||||||
|
|
||||||
username = usernameInput:getText()
|
username = usernameInput:getText()
|
||||||
|
|
||||||
if not fs.exists("/.usrcache") then
|
|
||||||
local file = fs.open("/.usrcache","w")
|
|
||||||
file.write(username)
|
|
||||||
file.close()
|
|
||||||
end
|
|
||||||
|
|
||||||
login:setVisible(false)
|
login:setVisible(false)
|
||||||
appFrame:setVisible(true)
|
appFrame:setVisible(true)
|
||||||
refresh_ui()
|
refresh_ui()
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if fs.exists("/.usrcache") then
|
if fs.exists("/config.json") then
|
||||||
local file = fs.open("/.usrcache","r")
|
local file = fs.open("/config.json","r")
|
||||||
local username = file.readLine()
|
local file_content = file.readAll()
|
||||||
|
local username = textutils.unserialiseJSON(file_content).username
|
||||||
file.close()
|
file.close()
|
||||||
usernameInput:setText(username)
|
usernameInput:setText(username)
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,41 @@ local function sendRequestAndWaitForReply(messageTable, replyHandler, timeout)
|
||||||
return replyReceived
|
return replyReceived
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.createAccount(username, associatedDevice, callback)
|
||||||
|
if type(username) ~= "string" or #username == 0 then
|
||||||
|
error("Username must be a non-empty string.", 2)
|
||||||
|
end
|
||||||
|
if type(callback) ~= "function" then
|
||||||
|
error("Callback must be a function.", 2)
|
||||||
|
end
|
||||||
|
if associatedDevice and type(associatedDevice) ~= "number" then
|
||||||
|
error("Associated device must be a number if provided.", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local message = {
|
||||||
|
type = "createAccount",
|
||||||
|
user = username
|
||||||
|
}
|
||||||
|
if associatedDevice then
|
||||||
|
message.associatedDevice = associatedDevice
|
||||||
|
end
|
||||||
|
|
||||||
|
return sendRequestAndWaitForReply(message, function(reply)
|
||||||
|
if reply.type == "accountCreationConfirmation" and reply.user == username then
|
||||||
|
if reply.status == "success" then
|
||||||
|
print("Account '" .. username .. "' created successfully. New credit: " .. tostring(reply.newCredit))
|
||||||
|
callback(true, reply.newCredit)
|
||||||
|
else
|
||||||
|
print("Account creation failed for '" .. username .. "'. Reason: " .. tostring(reply.reason))
|
||||||
|
callback(false, reply.reason)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("Unexpected reply for createAccount request: " .. textutils.serialiseJSON(reply))
|
||||||
|
callback(false, "unexpected_reply")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function M.getCredit(username, callback)
|
function M.getCredit(username, callback)
|
||||||
local message = {
|
local message = {
|
||||||
type = "getCredit",
|
type = "getCredit",
|
||||||
|
|
246
oobe.lua
Normal file
246
oobe.lua
Normal file
|
@ -0,0 +1,246 @@
|
||||||
|
local basalt = require("/lib/basalt")
|
||||||
|
local libcredit = require("/lib/libcredit_mobile")
|
||||||
|
|
||||||
|
if fs.exists("/config.json") then
|
||||||
|
|
||||||
|
while true do
|
||||||
|
shell.run("/slabos.lua")
|
||||||
|
term.clear()
|
||||||
|
print("Starting...")
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local main = basalt.getMainFrame()
|
||||||
|
|
||||||
|
local contentFrame = main:addFrame()
|
||||||
|
:setPosition(1,1)
|
||||||
|
:setSize(26,20)
|
||||||
|
:setBackground(colours.white)
|
||||||
|
|
||||||
|
local colourSelectionFrame = main:addFrame()
|
||||||
|
:setPosition(1,1)
|
||||||
|
:setSize(26,20)
|
||||||
|
:setBackground(colours.white)
|
||||||
|
:setVisible(false)
|
||||||
|
|
||||||
|
local usernameSetupFrame = main:addFrame()
|
||||||
|
:setPosition(1,1)
|
||||||
|
:setSize(26,20)
|
||||||
|
:setBackground(colours.white)
|
||||||
|
:setVisible(false)
|
||||||
|
|
||||||
|
local passwordSetupFrame = main:addFrame()
|
||||||
|
:setPosition(1,1)
|
||||||
|
:setSize(26,20)
|
||||||
|
:setBackground(colours.white)
|
||||||
|
:setVisible(false)
|
||||||
|
|
||||||
|
local selectedColourButton = nil
|
||||||
|
local selectedWallpaperColourName = "white"
|
||||||
|
local selectedUsername = ""
|
||||||
|
local selectedPassword = ""
|
||||||
|
|
||||||
|
local welcomeBigFont = contentFrame:addBigFont()
|
||||||
|
:setText("Welcome!")
|
||||||
|
:setBackground(colours.white)
|
||||||
|
:setSize(40,5)
|
||||||
|
:setPosition(2, 2)
|
||||||
|
|
||||||
|
contentFrame:addButton()
|
||||||
|
:setText("Begin Setup")
|
||||||
|
:setBackground(colours.lime)
|
||||||
|
:setPosition(6, 8)
|
||||||
|
:setSize(15, 3)
|
||||||
|
:onClick(function(self)
|
||||||
|
contentFrame:setVisible(false)
|
||||||
|
colourSelectionFrame:setVisible(true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
contentFrame:addLabel()
|
||||||
|
:setText("Put me in your main hand and right click")
|
||||||
|
:setSize(26,2)
|
||||||
|
:setAutoSize(false)
|
||||||
|
:setPosition(2,15)
|
||||||
|
|
||||||
|
colourSelectionFrame:addLabel()
|
||||||
|
:setText("Choose your wallpaper")
|
||||||
|
:setPosition(3, 2)
|
||||||
|
:setSize(22, 1)
|
||||||
|
|
||||||
|
local wallpaperColours = {}
|
||||||
|
|
||||||
|
for name, colourValue in pairs(colours) do
|
||||||
|
if type(colourValue) == "number" then
|
||||||
|
local textColour = colours.black
|
||||||
|
if colourValue == colours.black or colourValue == colours.blue or colourValue == colours.red or
|
||||||
|
colourValue == colours.purple or colourValue == colours.brown or colourValue == colours.gray then
|
||||||
|
textColour = colours.white
|
||||||
|
end
|
||||||
|
table.insert(wallpaperColours, {name = name, colour = colourValue, textColour = textColour})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(wallpaperColours, function(a, b)
|
||||||
|
return a.name < b.name
|
||||||
|
end)
|
||||||
|
|
||||||
|
local startX = 2
|
||||||
|
local startY = 4
|
||||||
|
local buttonWidth = 5
|
||||||
|
local buttonHeight = 3
|
||||||
|
local paddingX = 1
|
||||||
|
local paddingY = 1
|
||||||
|
local coloursPerRow = 4
|
||||||
|
local maxRows = 3
|
||||||
|
local maxColoursToShow = coloursPerRow * maxRows
|
||||||
|
|
||||||
|
local navButtonHeight = 3
|
||||||
|
local buttonPaddingBottom = 1
|
||||||
|
local buttonPaddingSide = 2
|
||||||
|
|
||||||
|
for i = 1, math.min(#wallpaperColours, maxColoursToShow) do
|
||||||
|
local colourData = wallpaperColours[i]
|
||||||
|
local col = ((i - 1) % coloursPerRow)
|
||||||
|
local row = math.floor((i - 1) / coloursPerRow)
|
||||||
|
|
||||||
|
local x = startX + (buttonWidth + paddingX) * col
|
||||||
|
local y = startY + (buttonHeight + paddingY) * row
|
||||||
|
|
||||||
|
colourSelectionFrame:addButton()
|
||||||
|
:setText("")
|
||||||
|
:setBackground(colourData.colour)
|
||||||
|
:setForeground(colourData.textColour)
|
||||||
|
:setPosition(x, y)
|
||||||
|
:setSize(buttonWidth, buttonHeight)
|
||||||
|
:onClick(function(self)
|
||||||
|
if selectedColourButton then
|
||||||
|
selectedColourButton:setText("")
|
||||||
|
end
|
||||||
|
self:setText("X")
|
||||||
|
selectedColourButton = self
|
||||||
|
selectedWallpaperColourName = colourData.name
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
colourSelectionFrame:addButton()
|
||||||
|
:setText("Next >")
|
||||||
|
:setBackground(colours.green)
|
||||||
|
:setPosition(colourSelectionFrame:getWidth() - 7 - buttonPaddingSide, colourSelectionFrame:getHeight() - navButtonHeight - buttonPaddingBottom)
|
||||||
|
:setSize(8,navButtonHeight)
|
||||||
|
:onClick(function(self)
|
||||||
|
colourSelectionFrame:setVisible(false)
|
||||||
|
usernameSetupFrame:setVisible(true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
colourSelectionFrame:addButton()
|
||||||
|
:setText("< Back")
|
||||||
|
:setBackground(colours.red)
|
||||||
|
:setPosition(buttonPaddingSide, colourSelectionFrame:getHeight() - navButtonHeight - buttonPaddingBottom)
|
||||||
|
:setSize(8,navButtonHeight)
|
||||||
|
:onClick(function(self)
|
||||||
|
colourSelectionFrame:setVisible(false)
|
||||||
|
contentFrame:setVisible(true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
usernameSetupFrame:addLabel()
|
||||||
|
:setText("Set your Username")
|
||||||
|
:setPosition(4, 2)
|
||||||
|
:setSize(22, 1)
|
||||||
|
|
||||||
|
local usernameInput = usernameSetupFrame:addInput()
|
||||||
|
:setPosition(3, 4)
|
||||||
|
:setSize(20, 1)
|
||||||
|
:setText("")
|
||||||
|
|
||||||
|
usernameSetupFrame:addLabel()
|
||||||
|
:setText("WARNING: Use your In-Game Name (IGN) for eCash to ensure proper transactions and avoid issues!")
|
||||||
|
:setPosition(4, 6)
|
||||||
|
:setSize(20, 4)
|
||||||
|
:setAutoSize(false)
|
||||||
|
:setForeground(colours.red)
|
||||||
|
|
||||||
|
local confirmUsernameButton = usernameSetupFrame:addButton()
|
||||||
|
:setText("Next >")
|
||||||
|
:setBackground(colours.green)
|
||||||
|
:setPosition(usernameSetupFrame:getWidth() - 7 - buttonPaddingSide, usernameSetupFrame:getHeight() - navButtonHeight - buttonPaddingBottom)
|
||||||
|
:setSize(8,navButtonHeight)
|
||||||
|
:onClick(function(self)
|
||||||
|
local inputUsername = usernameInput:getText()
|
||||||
|
if inputUsername and inputUsername ~= "" and inputUsername ~= "Your IGN here" then
|
||||||
|
selectedUsername = inputUsername
|
||||||
|
usernameSetupFrame:setVisible(false)
|
||||||
|
passwordSetupFrame:setVisible(true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
usernameSetupFrame:addButton()
|
||||||
|
:setText("< Back")
|
||||||
|
:setBackground(colours.red)
|
||||||
|
:setPosition(buttonPaddingSide, usernameSetupFrame:getHeight() - navButtonHeight - buttonPaddingBottom)
|
||||||
|
:setSize(8,navButtonHeight)
|
||||||
|
:onClick(function(self)
|
||||||
|
usernameSetupFrame:setVisible(false)
|
||||||
|
colourSelectionFrame:setVisible(true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
passwordSetupFrame:addLabel()
|
||||||
|
:setText("Set your password (optional)")
|
||||||
|
:setAutoSize(false)
|
||||||
|
:setPosition(4, 2)
|
||||||
|
:setSize(22, 1)
|
||||||
|
|
||||||
|
local passwordInput = passwordSetupFrame:addInput()
|
||||||
|
:setPosition(3, 4)
|
||||||
|
:setSize(20, 1)
|
||||||
|
:setText("")
|
||||||
|
:setReplaceChar("*")
|
||||||
|
|
||||||
|
local confirmPasswordButton = passwordSetupFrame:addButton()
|
||||||
|
:setText("Done >")
|
||||||
|
:setBackground(colours.green)
|
||||||
|
:setPosition(passwordSetupFrame:getWidth() - 7 - buttonPaddingSide, passwordSetupFrame:getHeight() - navButtonHeight - buttonPaddingBottom)
|
||||||
|
:setSize(8,navButtonHeight)
|
||||||
|
:onClick(function(self)
|
||||||
|
local inputPassword = passwordInput:getText()
|
||||||
|
if inputPassword and inputPassword ~= "" then
|
||||||
|
selectedPassword = inputPassword
|
||||||
|
else
|
||||||
|
selectedPassword = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
libcredit.createAccount(selectedUsername,os.getComputerID(),function()
|
||||||
|
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
local configData = {
|
||||||
|
wallpaperColour = selectedWallpaperColourName,
|
||||||
|
username = selectedUsername,
|
||||||
|
password = selectedPassword,
|
||||||
|
}
|
||||||
|
|
||||||
|
local jsonString = textutils.serialiseJSON(configData)
|
||||||
|
|
||||||
|
local filePath = "config.json"
|
||||||
|
|
||||||
|
local file = fs.open(filePath, "w")
|
||||||
|
if file then
|
||||||
|
file.write(jsonString)
|
||||||
|
file.close()
|
||||||
|
end
|
||||||
|
os.reboot()
|
||||||
|
end)
|
||||||
|
|
||||||
|
passwordSetupFrame:addButton()
|
||||||
|
:setText("< Back")
|
||||||
|
:setBackground(colours.red)
|
||||||
|
:setPosition(buttonPaddingSide, passwordSetupFrame:getHeight() - navButtonHeight - buttonPaddingBottom)
|
||||||
|
:setSize(8,navButtonHeight)
|
||||||
|
:onClick(function(self)
|
||||||
|
passwordSetupFrame:setVisible(false)
|
||||||
|
usernameSetupFrame:setVisible(true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
basalt.run()
|
40
slabos.lua
40
slabos.lua
|
@ -1,4 +1,38 @@
|
||||||
local basalt = require("basalt")
|
local basalt = require("/lib/basalt")
|
||||||
|
|
||||||
|
config = {}
|
||||||
|
if fs.exists("config.json") then
|
||||||
|
|
||||||
|
local config_file = fs.open("/config.json","r")
|
||||||
|
local config_text = config_file.readAll()
|
||||||
|
config = textutils.unserialiseJSON(config_text)
|
||||||
|
config_file.close()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if config.password then
|
||||||
|
|
||||||
|
while true do
|
||||||
|
|
||||||
|
if config.password == "" then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
term.setCursorPos(1, 1)
|
||||||
|
term.clear()
|
||||||
|
print("This device requires a password to start.")
|
||||||
|
write("Password: ")
|
||||||
|
local msg = read()
|
||||||
|
|
||||||
|
if msg == config.password then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
print("Incorrect!")
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local main = basalt.getMainFrame()
|
local main = basalt.getMainFrame()
|
||||||
|
|
||||||
|
@ -12,6 +46,10 @@ local homescreen = main:addFrame()
|
||||||
:setBackground(colours.blue)
|
:setBackground(colours.blue)
|
||||||
:setVisible(true)
|
:setVisible(true)
|
||||||
|
|
||||||
|
if config.wallpaperColour then
|
||||||
|
homescreen:setBackground(colours[config.wallpaperColour])
|
||||||
|
end
|
||||||
|
|
||||||
local active_app_frames = {}
|
local active_app_frames = {}
|
||||||
local current_active_frame = homescreen
|
local current_active_frame = homescreen
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
print("Test")
|
|
|
@ -1,4 +1,4 @@
|
||||||
local CURRENT_CLIENT_VERSION = "1.0.0.2"
|
local CURRENT_CLIENT_VERSION = "1.1.0.1"
|
||||||
local INSTALL_PATH = "/"
|
local INSTALL_PATH = "/"
|
||||||
|
|
||||||
function http_get(url)
|
function http_get(url)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0.2",
|
"version": "1.1.0.1",
|
||||||
"sys_files": {
|
"sys_files": {
|
||||||
"startup.lua": "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/slabos.lua",
|
"slabos.lua": "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/slabos.lua",
|
||||||
"basalt.lua": "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt.lua",
|
"startup.lua": "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/oobe.lua",
|
||||||
"app_manifest.json": "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/app_manifest.json",
|
"app_manifest.json": "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/app_manifest.json",
|
||||||
"lib/libcredit_mobile": "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/libcredit_mobile.lua",
|
"lib/libcredit_mobile": "https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/libcredit_mobile.lua",
|
||||||
"lib/basalt.lua": "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt.lua",
|
"lib/basalt.lua": "https://raw.githubusercontent.com/Pyroxenium/Basalt2/refs/heads/main/release/basalt.lua",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user