Skip to content

Instantly share code, notes, and snippets.

View MCJack123's full-sized avatar
๐Ÿ’š
Go Green!

JackMacWindows MCJack123

๐Ÿ’š
Go Green!
View GitHub Profile
@MCJack123
MCJack123 / aukit.lua
Last active January 27, 2022 01:08
AUKit: Audio decoding and processing framework for ComputerCraft
--- AUKit: Audio decoding and processing framework for ComputerCraft
--
-- AUKit is a framework designed to simplify the process of loading, modifying,
-- and playing audio files in various formats. It includes support for loading
-- audio from many sources, including PCM, DFPWM, and IMA ADPCM codecs, as well
-- as WAV, AIFF, AU, and FLAC files. It can also generate audio on-the-fly as
-- tones, noise, or silence.
--
-- AUKit uses a structure called Audio to store information about each audio
-- chunk. An audio object holds the sample rate of the audio, as well as the
@MCJack123
MCJack123 / imgquant.lua
Last active November 7, 2022 20:35
Basic image quantization library for ComputerCraft
-- MIT License
--
-- Copyright (c) 2021 JackMacWindows
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
@MCJack123
MCJack123 / string_pack.lua
Last active August 26, 2023 13:28
Backport of string.pack for Lua 5.2 [WIP]
-- MIT License
--
-- Copyright (c) 2021 JackMacWindows
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
@MCJack123
MCJack123 / jscc.mm
Created July 20, 2021 03:37
JavaScriptCore integration for CraftOS-PC (bad code)
#import <JavaScriptCore/JavaScriptCore.h>
#include <CraftOS-PC.hpp>
#include <math.h>
#include <float.h>
#include <stdarg.h>
static JSContext * ctx;
static JSValue * Function;
static int jsc_call(lua_State *L);
@MCJack123
MCJack123 / UTFString.lua
Last active January 25, 2025 15:11
UTF string type for Lua 5.3
local expect = require "cc.expect"
local UTFString = {}
local UTFString_mt = {__index = UTFString, __name = "UTFString"}
local function toUTF8(s)
-- convert from ANSI if the string is invalid in UTF-8
local ss = ""
local iter, invar, i = utf8.codes(s)
local ok, c
@MCJack123
MCJack123 / battleship.lua
Last active January 16, 2022 22:51
Battleship game for ComputerCraft
-- Battleship for ComputerCraft by JackMacWindows
-- GPL license
local mask = {
hasShip = 1,
hover = 2,
hit = 4,
miss = 8,
}
@MCJack123
MCJack123 / on-writing-an-os.md
Last active February 27, 2025 20:46
On Writing a ComputerCraft OS

On Writing a ComputerCraft OS

One of the most common projects I've seen for ComputerCraft is to write an operating system. People look at the limited command-line interface that CraftOS provides, and think, "I want this to work like my normal computer does!" Time and time again, a new post pops up on the ComputerCraft forums or Discord either announcing an OS, or asking for help with an OS, or releasing an OS. Usually, there are some very obvious flaws in these "OS"es, ranging from poor design choices, to overstating what they are and underdelivering. There are many common misunderstandings and undersights that newbie developers run into when writing an operating system, and these end up creating mediocre products at best.

A Critical Distinction

The term "OS" is thrown around a lot, and in my opinion it's very overused. According to [Wikipedia]: "An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs." However, m

@MCJack123
MCJack123 / lua5.1-ropes.patch
Last active February 13, 2025 02:18
Rope concatenation for Lua 5.1 inspired by SquidDev/Cobalt
diff -ruN lua-5.1.5-clean/src/Makefile lua-5.1.5-ropes/src/Makefile
--- lua-5.1.5-clean/src/Makefile 2012-02-13 15:41:22.000000000 -0500
+++ lua-5.1.5-ropes/src/Makefile 2021-06-19 08:03:46.000000000 -0400
@@ -135,7 +135,7 @@
ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \
ltable.h lundump.h lvm.h
-ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \
+ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h lstring.h ltm.h \
lzio.h lmem.h lundump.h
@MCJack123
MCJack123 / rawshell.lua
Last active March 22, 2025 01:35
Remote shell program for ComputerCraft featuring passwords, encryption, and background processing
-- MIT License
--
-- Copyright (c) 2021 JackMacWindows
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
@MCJack123
MCJack123 / rawterm.lua
Last active November 20, 2022 00:26
CraftOS-PC raw mode client/server API for ComputerCraft with test program
--- rawterm.lua - CraftOS-PC raw mode protocol client/server API
-- By JackMacWindows
--
-- @module rawterm
--
-- This API provides the ability to host terminals accessible from remote
-- systems, as well as to render those terminals on the screen. It uses the raw
-- mode protocol defined by CraftOS-PC to communicate between client and server.
-- This means that this API can be used to host and connect to a CraftOS-PC
-- instance running over a WebSocket connection (using an external server