Skip to content

Instantly share code, notes, and snippets.

View ArvidSilverlock's full-sized avatar
🪱
i am a worm

Arvid ArvidSilverlock

🪱
i am a worm
View GitHub Profile
@ArvidSilverlock
ArvidSilverlock / AutoReactor.luau
Created July 24, 2025 07:53
A dynamically tickable, temperature controlling (utilising the game's back-end formulas), auto refueling & tamper resistant auto-reactor for the Roblox game Waste of Space.
local DESIRED_TEMPERATURE = 950
local FULL_BAR_COUNT = 4
local FUEL_EJECT_LEVEL = 0
local FUEL_WAIT_TIME = 1 / 10
local EPSILON = 0.01
for _, port: Port in Network:GetPorts() do
local subnet = Network:GetSubnet(port)
local reactor: Reactor? = subnet:GetPart("Reactor")
@ArvidSilverlock
ArvidSilverlock / guid-buffer.luau
Created January 28, 2025 10:48
Read/write GUIDs from/to buffers in Luau. Will throw errors for invalid GUIDs if you use the 'strict' version. Depending on the specifics of your use case, if you really love hyper-optimisation you could probably remove the support for allowing/allowing no braces. It does encode the UUID compliance characters (the `4` and the `[89ab]`), but that…
local GUID_FORMAT = "%08x-%04x-%04x-%04x-%04x%08x"
local GUID_BRACES_FORMAT = "{" .. GUID_FORMAT .. "}"
local GUID_PATTERN = "^{?(%x%x%x%x%x%x%x%x)-(%x%x%x%x)-(4%x%x%x)-([89AaBb]%x%x%x)-(%x%x%x%x)(%x%x%x%x%x%x%x%x)}?$"
local function writeGUID(buff: buffer, offset: number, guid: string)
if guid:sub(1, 1) == "{" then
buffer.writeu32(buff, offset, tonumber(guid:sub(2, 9), 16))
buffer.writeu32(buff, offset + 4, tonumber(guid:sub(11, 14), 16) * 2 ^ 16 + tonumber(guid:sub(16, 19), 16))
buffer.writeu32(buff, offset + 8, tonumber(guid:sub(21, 24), 16) * 2 ^ 16 + tonumber(guid:sub(26, 29), 16))
@ArvidSilverlock
ArvidSilverlock / Materials.json
Last active January 14, 2025 00:19
Waste of Space is ready...
{
"Jahojofium": {
"MalleabilityText": "Average",
"DurabilityText": "Incredible",
"Radioactive": false,
"Flammable": true,
"DefaultColor": "2154b9",
"Density": 2.67,
"Durability": 15,
"DefaultSize": [4, 2, 1]
@ArvidSilverlock
ArvidSilverlock / Reader.lua
Created March 22, 2024 08:30
Runtime Fast Bitbuffer
local Reader = {}
Reader.__index = Reader
local function nextChunk(reader, width)
local value
if width > 24 then
reader._chunk += buffer.readu32(reader._buffer, reader._byte) * 2^reader._bit
reader._byte += 4
reader._bit += 32
@ArvidSilverlock
ArvidSilverlock / calculateGroups.luau
Last active March 6, 2024 08:56
Buffer Bitpacking
local function calculateGroups(format)
local groups = {}
local currentIndex = 1
local excess = 0
repeat
local groupStart = currentIndex
local groupWidth = excess
local SIZE = Vector2.new(320, 320)
local SEED = math.random() * 256
local MASK_SCALE = 2^-4
local COLOUR_STEP = 1
local LAYER_STEP = 1
local FRAMES_PER_FRAME = 4
local FRAME_STEP = 1/60
@ArvidSilverlock
ArvidSilverlock / extendedbuffer.lua
Last active November 10, 2024 01:35
Possibly useful `read` and `write` functions for `buffer`s that aren't inluded in the normal API
--[[
Copyright 2024 Arvid
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR T
--!native
--!optimize 2
type Buffer = {
buffer: buffer,
offset: number,
}
export type GIF = {
width: number,
local PNG_IDENTIFIER = "\137PNG\13\10\26\10"
local BYTES_PER_PIXEL = { [0] = 1, [2] = 3, [3] = 1, [4] = 2, [6] = 4 }
-- https://github.com/jiwonz/zlib91.lua/blob/main/rbx/zlib91/compression.luau
local zlib = require(script.zlib).Zlib
local chunkParsers = {
IHDR = function(b, offset, output, length)
output.width = bit32.byteswap(buffer.readu32(b, offset))
output.height = bit32.byteswap(buffer.readu32(b, offset + 4))
[["AAAAAIAkyT8AAAAAAHA2wAAAAABIkgTAAAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAAAAAAAAAAAAAEAAAAAAAADwPwAAAAAAAOA/Y19iZmZm","Iron"],["AAAAAIAkyT8AAAAAAHA2wAAAAACA28Y/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPC/AAAAAAAAAAAAAAAAAADwPwAAAAAAAAAAAAAAAAAACEAAAAAAAADwPwAAAAAAAABALGUdZmZm","Microcontroller",{"Code":"https://gist.githubusercontent.com/EggnogPerson/66957a8ace079faf64f3358a99aab9b9/raw/694f58562b86dd6c95f59f9dff908c5e5ecd0005/UniverseMap.lua"}],["AAAAAMBt078AAAAAAHA2wAAAAACQJPm/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPC/AAAAAAAAAAAAAAAAAADwPwAAAAAAAAAAAAAAAAAA4D8AAAAAAADwPwAAAAAAAPA/Y19iZmZm","Port",{"PortID":"2"}],["AAAAAABuq78AAAAAAHA2wAAAAABw2/4/AAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAAAOA/zI5pZmZm","Polysilicon",{"Frequency":"1","PolysiliconMode":"2"}],["AAAAAABuq78AAAAAAHA2wAAAAAC4bQNAAAAAAAAA8L8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAADgPwAAAAAAAPA/2oVBZmZm","Button",{"TriggerMode":"0","KeyInput":""}],["AAAAAJAk+z8AAAAAAPA