Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Commandcracker committed Oct 14, 2023
1 parent b6ea5be commit a2a2bd7
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 8 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/sea.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CraftOS-PC Action
on:
workflow_dispatch:
push:
branches:
- main

jobs:
sea:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
submodules: true

- name: mkdir out
run: mkdir out

- name: CraftOS-PC >_
uses: Commandcracker/craftos-pc-action@v1
with:
options: --mount-rw /out=./out
--mount-ro /rom/autorun=./submodules/craftos-pc-tweaks/lua
--mount-ro /lib/busted=./submodules/busted/busted
--mount-ro /lib/system=./submodules/CC-LuaSystem/system
--mount-ro /lib/luassert=./submodules/luassert/src
--mount-ro /lib/lfs=./submodules/LuaFileSystem/lfs
--mount-ro /lib/pl=./submodules/Penlight/lua/pl
--mount-ro /lib/say=./submodules/say/src/say
--mount-ro /lib/cliargs=./submodules/lua_cliargs/src/cliargs

- name: upload artifact
uses: actions/upload-artifact@v3
with:
name: SEA
path: out/install.lua
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,23 @@ run:
--mount-ro /lib/say=./submodules/say/src/say \
--mount-ro /lib/cliargs=./submodules/lua_cliargs/src/cliargs \
--headless \
--exec "print('hi')" \
--script sstartup.lua \
--script startup.lua \
--args "" \
--single
bun:
$(CRAFTOS) \
--id 42 \
--mount-ro /=./ \
--mount-rw /out=./out \
--mount-ro /rom/autorun=./submodules/craftos-pc-tweaks/lua \
--mount-ro /lib/busted=./submodules/busted/busted \
--mount-ro /lib/system=./submodules/CC-LuaSystem/system \
--mount-ro /lib/luassert=./submodules/luassert/src \
--mount-ro /lib/lfs=./submodules/LuaFileSystem/lfs \
--mount-ro /lib/pl=./submodules/Penlight/lua/pl \
--mount-ro /lib/say=./submodules/say/src/say \
--mount-ro /lib/cliargs=./submodules/lua_cliargs/src/cliargs \
--headless \
--script ccsfx.lua \
--args "/lib /out/install.lua" \
--single
1 change: 1 addition & 0 deletions ansiec_to_cc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- easy use ani colors with CC
123 changes: 123 additions & 0 deletions ccsfx.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
-- based on: https://pastebin.com/rxnjypsW
local tArgs = { ... }

local function get_program_name()
if arg then
return arg[0]
end
return fs.getName(shell.getRunningProgram()):gsub("[\\.].*$", "")
end

local isColour = term.isColour()

if #tArgs ~= 2 then
print("Usage: " .. get_program_name() .. " <directory> <archivename>")
return
end

local sfxFiles = ""
local sfxDirs = ""

local root = tArgs[1]

if root:sub(-1) ~= "/" then
root = root .. "/"
end

local function serFile(fpath)
sleep() -- yield
print("file " .. root .. fpath)
if fs.getSize(root .. fpath) > 1000000 then
printError(root .. fpath .. " is too long, skipping")
return
end
local file = fs.open(root .. fpath, "r")
local text = file.readAll()
file.close()
sfxFiles = sfxFiles .. '"' .. fpath .. '",\n[=====[' .. text .. "]=====]" .. ",\n"
end

local function serDir(path)
if isColour then
term.setTextColour(colors.blue)
end
print("dir " .. root .. path)
if isColour then
term.setTextColour(colors.white)
end
local files = fs.list(root .. path)
for _, file in ipairs(files) do
local fpath = path .. file
if fs.isDir(root .. fpath) then
sfxDirs = sfxDirs .. '"' .. fpath .. '",\n'
serDir(fpath .. "/")
else
serFile(fpath)
end
end
end

serDir("")

local sfx = [[
local tArgs = { ... }
local function get_program_name()
if arg then
return arg[0]
end
return fs.getName(shell.getRunningProgram()):gsub("[\\.].*$", "")
end
local isColour = term.isColour()
if #tArgs ~= 1 then
print("Usage: " .. get_program_name() .. " <dir>")
return
end
local root = tArgs[1]
if root:sub(-1) ~= "/" then
root = root .. "/"
end
local files = {
]] .. sfxFiles .. [[
}
local dirs = {]] .. sfxDirs .. [[}
if not fs.isDir(tArgs[1]) then
fs.makeDir(tArgs[1])
end
for _,dir in ipairs(dirs) do
local fpath = root .. dir
if isColour then
term.setTextColour(colors.blue)
end
print("dir " .. fpath)
if isColour then
term.setTextColour(colors.white)
end
if not fs.isDir(fpath) then
fs.makeDir(fpath)
end
end
local i = 1
while i<#files do
sleep() -- yield
local fpath = root .. files[i]
local data = files[i+1]
print("file " .. fpath)
local file = fs.open(fpath, "w")
file.write(data)
file.close()
i = i+2
end]]

local file = fs.open(tArgs[2], "w")
file.write(sfx)
file.close()
2 changes: 2 additions & 0 deletions startup.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shell.run("ccsfx /lib /out/install.lua")
os.shutdown()
2 changes: 1 addition & 1 deletion submodules/Penlight
2 changes: 1 addition & 1 deletion submodules/busted
2 changes: 1 addition & 1 deletion submodules/craftos-pc-tweaks
2 changes: 1 addition & 1 deletion submodules/lua-term
Submodule lua-term updated 1 files
+4 −4 term/cursor.lua
2 changes: 1 addition & 1 deletion submodules/luassert
2 changes: 1 addition & 1 deletion submodules/say
Submodule say updated 1 files
+1 −1 README.md

0 comments on commit a2a2bd7

Please sign in to comment.