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 / betterPagedPrint.lua
Last active August 31, 2022 02:32
Better paged print for ComputerCraft using a less-style pager
-- CCPL license: https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.16.x/LICENSE
-- Note that this breaks help on vanilla CC (CC:T help still works)
textutils.pagedPrint = function(contents, freeLines)
freeLines = freeLines or 0
local foldLines = true
local lines = {}
@MCJack123
MCJack123 / classcompiler.lua
Last active November 28, 2020 18:28
Reinterpreter/compiler for my Lua class library
local classcompiler = {}
--[[
-- Example syntax:
class MyClass {
num = 0
function __init(num)
self.num = num
end
@MCJack123
MCJack123 / readBDFFont.lua
Last active March 17, 2024 10:41
BDF font loader for Lua 5.2+
-- MIT License
--
-- Copyright (c) 2019 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 / gfxterm.lua
Last active December 23, 2020 21:13
CraftOS-PC Graphics Mode terminal (requires readBDFFont)
-- WARNING: Render crashes are lethal and will 100% kill the computer
local loadBDF = require "readBDFFont" -- get from https://gist.github.com/MCJack123/3cbce89640923b3c42d4d0a0b8eaa7b2
if term.setGraphicsMode == nil then error("This requires CraftOS-PC v1.2 or later.") end
local font, oldterm, gfxMode
local nativeTerm = term.native()
local oldSetGfx, oldGetGfx = term.setGraphicsMode, term.getGraphicsMode
local nativeWidth, nativeHeight = term.getSize()
nativeWidth = nativeWidth * 6
@MCJack123
MCJack123 / mc_asset_extractor.py
Last active August 10, 2022 13:13
Quick script to extract/deobfuscate Minecraft assets folder
#!/usr/bin/env python3
import json, os, shutil, sys
if len(sys.argv) < 4 or sys.argv[1] == "--help" or sys.argv[1] == "-h":
print("Usage: " + sys.argv[0] + " <path to .minecraft/assets> <major.minor version, ex. 1.15> <output directory>")
sys.exit(1)
fp = open(sys.argv[1] + "/indexes/" + sys.argv[2] + ".json", "r")
if fp == None: raise FileNotFoundError("Could not find index file at " + sys.argv[1] + "/indexes/" + sys.argv[2] + ".json")
index = json.load(fp)
fp.close()
def recursive_mkdir(path):
@MCJack123
MCJack123 / unbios.lua
Last active March 15, 2025 17:36
UnBIOS: Load custom BIOSes in ComputerCraft without modifying ROM
-- UnBIOS by JackMacWindows
-- This will undo most of the changes/additions made in the BIOS, but some things may remain wrapped if `debug` is unavailable
-- To use, just place a `bios.lua` in the root of the drive, and run this program
-- Here's a list of things that are irreversibly changed:
-- * both `bit` and `bit32` are kept for compatibility
-- * string metatable blocking (on old versions of CC)
-- In addition, if `debug` is not available these things are also irreversibly changed:
-- * old Lua 5.1 `load` function (for loading from a function)
-- * `loadstring` prefixing (before CC:T 1.96.0)
-- * `http.request`
@MCJack123
MCJack123 / unbios.moon
Created April 1, 2020 02:19
UnBIOS ported to MoonScript (test)
-- UnBIOS (MoonScript) by JackMacWindows
return if _HOST\find "UnBIOS"
keptAPIs = bit32: true, bit: true, ccemux: true, config: true, coroutine: true, debug: true, fs: true, http: true, io: true, mounter: true, os: true, periphemu: true, peripheral: true, redstone: true, rs: true, term: true, _HOST: true, _CC_DEFAULT_SETTINGS: true, _CC_DISABLE_LUA51_FEATURES: true, _VERSION: true, assert: true, collectgarbage: true, error: true, gcinfo: true, getfenv: true, getmetatable: true, ipairs: true, loadstring: true, math: true, newproxy: true, next: true, pairs: true, pcall: true, rawequal: true, rawget: true, rawlen: true, rawset: true, select: true, setfenv: true, setmetatable: true, string: true, table: true, tonumber: true, tostring: true, type: true, unpack: true, xpcall: true, turtle: true, pocket: true, commands: true, _G: true
_G[v] = nil for _,v in ipairs [k for k in pairs _G when not keptAPIs[k]]
_G.term = _G.term.native!
_G.http.checkURL = _G.http.checkURLAsync
_G.http.websocket = _G.http.websocketAsync
d
@MCJack123
MCJack123 / minserialize.lua
Last active October 29, 2020 21:32
Table serializer/minimizer for ComputerCraft supporting recursive tables (also deduplicates table entries)
local deconstruct
deconstruct = function(t, values, tables)
local retval = { }
for k, v in pairs(t) do
local id
for i, w in ipairs(values) do
if v == w or (type(v) == "table" and type(w) == "table" and tables[w[1]] == v) then
id = i
break
end
@MCJack123
MCJack123 / modemshark.lua
Last active May 7, 2023 13:50
ModemShark: Modem packet sniffer for ComputerCraft
-- ModemShark: Modem packet sniffer for ComputerCraft
-- By JackMacWindows
-- Licensed under GPLv2+
local stackWindow, viewerWindow, lines, scrollPos
local w, h = term.getSize()
local selectedLine
local stack = {}
local file
@MCJack123
MCJack123 / client.lua
Last active May 2, 2025 18:09
Door lock program for ComputerCraft using secure remote servers, supporting optional key expiration & use limits
-- Save this as startup.lua on each client computer with a drive and modem attached. You can also optionally attach a speaker for audio feedback.
local secret = "" -- Set this to the same secret that was set in the server file.
local redstoneSide = "left" -- Set this to the side the redstone signal should be output on.
local openTime = 5 -- Set this to the number of seconds to keep the door open for.
local defaultOutput = false -- Set this to the default redstone state for the door. If set to true, this means power will be cut when unlocking.
-- This allows you to place a door sideways, and then have it stay closed even when power is applied externally.
if not secret or secret == "" then error("Please set some keys inside the script before running.") end
local ok, err = pcall(function()