This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * sound.cpp plugin for CraftOS-PC | |
| * Adds a number of programmable sound channels (default 4) that play sound waves with the specified frequency, wave type, volume, and pan position. | |
| * Windows: cl /EHsc /Fesound.dll /LD /Icraftos2\api /Icraftos2\craftos2-lua\include plugin.cpp /link craftos2\craftos2-lua\src\lua51.lib SDL2.lib SDL2_mixer.lib | |
| * Linux: g++ -fPIC -shared -Icraftos2/api -Icraftos2/craftos2-lua/include -o sound.so sound.cpp craftos2/craftos2-lua/src/liblua.a -lSDL2 -lSDL2_mixer | |
| * Licensed under the MIT license. | |
| * | |
| * MIT License | |
| * | |
| * Copyright (c) 2021 JackMacWindows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Made by JackMacWindows, licensed under CC0 | |
| local expect = require "cc.expect".expect | |
| local activeRequests = {} | |
| local kPromiseSuccess, kPromiseFailure = {}, {} | |
| local openHandlers = 0 | |
| -- To use, call this function with each URL and optionally a table with options. | |
| -- Then call it with no arguments to process the requests in the queue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- YellowBox 1.0 | |
| -- By JackMacWindows | |
| -- | |
| -- @module yellowbox | |
| -- | |
| -- This module allows you to easily create and manage special ComputerCraft | |
| -- containers called "boxes". These boxes contain their own separate execution | |
| -- environment, completely sequestered from the caller's environment. This allows | |
| -- effective "virtual machines" running CraftOS. | |
| -- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local args = {...} | |
| if args[1] == nil then error("Usage: subleq <dawn.bin>") end | |
| if term.drawPixels == nil then error("This program requires CraftOS-PC v2.2 or later.") end | |
| local ok, err = pcall(function() | |
| if _G.dawn_chunks == nil then | |
| local file = fs.open(args[1], "rb") | |
| if file == nil then error("Could not open file at " .. args[1]) end | |
| _G.dawn_chunks = {} | |
| for i = 1, 640 do dawn_chunks[i] = file.read(1048576) end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <string.h> | |
| #include <sys/stat.h> | |
| #ifdef _WIN32 | |
| #include <windows.h> | |
| #include <io.h> | |
| #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR) | |
| #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- YahtCC by JackMacWindows | |
| -- GPL license | |
| local diceMaps = { | |
| [0] = {0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0}, | |
| {0x20, 0x10, 0x95, 0x8f, 0x8f, 0x85}, | |
| {0x08, 0x20, 0x95, 0x8f, 0x8d, 0x85}, | |
| {0x08, 0x10, 0x95, 0x8f, 0x8d, 0x85}, | |
| {0x08, 0x08, 0x95, 0x8d, 0x8d, 0x85}, | |
| {0x08, 0x18, 0x95, 0x8d, 0x8d, 0x85}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if config == nil then error("This must be run in CraftOS-PC v2.4 or later.") end | |
| local function runTests() | |
| local oldClockSpeed = config.get("clockSpeed") | |
| config.set("clockSpeed", 1000) | |
| -- Test characters | |
| term.redirect(term.native()) | |
| local benchmark = debug.getregistry().benchmark | |
| local w, h = term.getSize() | |
| local canBenchmark = benchmark ~= nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if fs.isUnlocked then | |
| local args = {...} | |
| if args[1] == "lock" or (args[1] == nil and fs.isUnlocked()) then | |
| fs.lock() | |
| print("The filesystem is now locked.") | |
| elseif args[1] == "unlock" or args[1] == nil then | |
| fs.unlock() | |
| print("The filesystem is now unlocked.") | |
| elseif args[1] == "encrypt" then | |
| if args[3] == nil then error("Usage: fsencrypt encrypt <infile> <outfile>") end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <setjmp.h> | |
| #include <errno.h> | |
| struct coroutine { | |
| int status; | |
| void* (*fn)(void*); | |
| void* arg; | |
| jmp_buf env_resume; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local w, h = term.getSize() | |
| local canBenchmark = term.benchmark ~= nil | |
| local count = 0 | |
| local start = os.epoch "utc" | |
| if canBenchmark then term.benchmark() end | |
| pcall(function() | |
| while true do | |
| term.setCursorPos(math.random(1, w), math.random(1, h)) | |
| term.setBackgroundColor(2^math.random(0, 15)) | |
| term.setTextColor(2^math.random(0, 15)) |