aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@gmail.com>2019-03-05 19:26:59 -0500
committerAndrew Lee <alee14498@gmail.com>2019-03-05 19:26:59 -0500
commita18407bdb9c87ac970418cd625abe38f550ab45c (patch)
treecb40abeaef3b81dcd1cbf23304e80acf0445aed2 /system
parent84a82712e4e3bd6826e572e63accc0800992eb4b (diff)
downloadbits-UI-a18407bdb9c87ac970418cd625abe38f550ab45c.tar.gz
bits-UI-a18407bdb9c87ac970418cd625abe38f550ab45c.tar.bz2
bits-UI-a18407bdb9c87ac970418cd625abe38f550ab45c.zip
Added a bunch of stuff
Diffstat (limited to 'system')
-rw-r--r--system/apis/flib.lua124
-rw-r--r--system/boot.lua16
-rw-r--r--system/desktop.lua15
-rw-r--r--system/setup.lua14
-rw-r--r--system/skel/README.txt7
5 files changed, 174 insertions, 2 deletions
diff --git a/system/apis/flib.lua b/system/apis/flib.lua
new file mode 100644
index 0000000..c3b7150
--- /dev/null
+++ b/system/apis/flib.lua
@@ -0,0 +1,124 @@
+--[[
+ fLib by NDFJay
+]]--
+function exists(path)
+ local file = assert(io.open(path, "r"))
+ if file ~= nil then
+ file:close()
+ return true
+ end
+
+ return false
+end
+
+function getTable(path)
+ if exists(path) then
+ local file = io.open(path, "r")
+ local lines = {}
+ local i = 1
+ local line = file:read("*l")
+ while line ~= nil do
+ lines[i] = line
+ line = file:read("*l")
+ i = i + 1
+ end
+ file:close()
+ return lines
+ end
+ return {}
+end
+
+function getLine(path, n)
+ if exists(path) then
+ local lines = getTable(path)
+ return lines[n]
+ end
+ return ""
+end
+
+function getText(path)
+ if exists(path) then
+ local file = assert(io.open(path, "r"))
+ return file:read("*a")
+ end
+ return ""
+end
+
+function fappend(path, text)
+ local file = assert(io.open(path, "a"))
+ file:write(text.."\n")
+ file:close()
+end
+
+function fwrite(path, text)
+ local file = assert(io.open(path, "w"))
+ file:write(text)
+ file:close()
+end
+
+function fwriteAtStart(path, text)
+ local _text = getText(path)
+ fwrite(path, text.."\n".._text)
+end
+
+function fwriteFromTable(path, t)
+ local text = ""
+ for _, line in pairs(t) do
+ text = text..line.."\n"
+ end
+ fwrite(path, text)
+end
+
+function fappendFromTable(path, t)
+ local text = ""
+ for _, line in pairs(t) do
+ text = text..line.."\n"
+ end
+ fappend(path, text)
+end
+
+function fwriteAtStartFromTable(path, t)
+ local text = ""
+ for _, line in pairs(t) do
+ text = text..line.."\n"
+ end
+ fwriteAtStart(path, text)
+end
+
+function replaceLine(path, n, text)
+ local lines = getTable(path)
+ lines[n] = text
+ fwriteFromTable(path, lines)
+end
+
+function getName(path)
+ if exists(path) then
+ local lastSlashPos = 1
+ for i = 1, path:len() do
+ if path:sub(i, i) == "/" then
+ lastSlashPos = i
+ end
+ end
+
+ return path:sub(lastSlashPos + 1)
+ end
+ return ""
+end
+
+function getPath(path)
+ if exists(path) then
+ local lastSlashPos = 1
+ for i = 1, path:len() do
+ if path:sub(i, i) == "/" then
+ lastSlashPos = i
+ end
+ end
+
+ return path:sub(1, lastSlashPos)
+ end
+ return ""
+end
+
+function fremove(path)
+ os.remove(path)
+end \ No newline at end of file
diff --git a/system/boot.lua b/system/boot.lua
index 3061d57..c25fae2 100644
--- a/system/boot.lua
+++ b/system/boot.lua
@@ -1,5 +1,17 @@
+--[[
+ bits-UI Boot: A boot script for bits-UI.
+ Copyright (C) 2019 Alee14
--- bits-UI: An operating system for ComputerCraft. Licensed with GPL-3.0.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+]]--
local version = "1.0 Alpha 2"
local desktop = "/system/desktop.lua"
@@ -53,6 +65,8 @@ else
term.setTextColor(colors.blue)
print("[INFO] Config has not been found!")
print("[INFO] You will be sent to the OOBE setup...")
+ sleep(3)
+ shell.run("/system/setup.lua")
end
sleep(3)
diff --git a/system/desktop.lua b/system/desktop.lua
index 83abc6f..e0afe4f 100644
--- a/system/desktop.lua
+++ b/system/desktop.lua
@@ -1,4 +1,17 @@
--- bits-UI: An operating system for ComputerCraft. Licensed with GPL-3.0.
+--[[
+ bits-UI Desktop: A Desktop for bits-UI
+ Copyright (C) 2019 Alee14
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+]]--
function titleBar()
local time = os.time()
diff --git a/system/setup.lua b/system/setup.lua
new file mode 100644
index 0000000..644d0ed
--- /dev/null
+++ b/system/setup.lua
@@ -0,0 +1,14 @@
+term.clear()
+term.setCursorPos(1,1)
+term.setTextColor(colors.white)
+
+if fs.exists("/system/skel/README.txt") then
+ shell.run("copy", "/system/skel/README.txt", "/home")
+else
+ print("[ERROR] Unable to find README.txt...")
+end
+
+print("Welcome to the setup!")
+
+sleep(3)
+shell.run("/system/desktop.lua") \ No newline at end of file
diff --git a/system/skel/README.txt b/system/skel/README.txt
new file mode 100644
index 0000000..ef149d6
--- /dev/null
+++ b/system/skel/README.txt
@@ -0,0 +1,7 @@
+Thanks for downloading bits-UI!
+
+Please note that this project is in very early development and there might not be as much features as you'll expect but in future builds will be more!
+
+Oh yeah! Feel free to contribute to this project by the following link!
+
+Source Code: https://github.com/Alee14/bits-UI \ No newline at end of file