Skip to content

Instantly share code, notes, and snippets.

@x4fx77x4f
x4fx77x4f / 1_wrap.md
Last active April 9, 2024 03:37
StarfallEx text soft wrapping

This is an implementation of soft text wrapping in Lua for StarfallEx. I wrote it in December of 2023 but haven't done anything with it and I figured it was better out there than left rotting on my hard drive. This release also doubles as a blog post. This code may be used by anyone in any way they see fit without restriction. Make something cool with it... because I don't think I can.

2_wrap.lua was my first attempt. I fell into the bad habit of using non-descriptive filenames. The code is really ugly.

3_wrap.lua is visually identical to 2_wrap.lua; the only difference is in the code. I cleaned up the code. It felt like night and day difference; I was quite pleased with how nice it looked afterward and was satisfied with myself. Some code has been moved into functions and the variable names are descriptive.

4_wrap.lua renders an HTML-like document. It caches the wrapped versions to increase performance. I would have loved to make it more complete.

@x4fx77x4f
x4fx77x4f / create_p64_rom.lua
Created March 27, 2024 18:13
Picotron .p64.rom extraction and creation
#!/usr/bin/env luajit
local argparse = require("argparse")(nil, [[Create a Picotron .p64.rom.
Dependencies:
sudo apt install liblz4-1 luajit luarocks
luarocks install luaposix --local]])
argparse:argument("input_path", "Directory to read files from.")
argparse:argument("output_path", "Path to save .p64.rom to.")
local arguments = argparse:parse()
local input_path = arguments.input_path
local output_path = arguments.output_path
@x4fx77x4f
x4fx77x4f / bit.lua
Created January 12, 2024 18:10
Pure Lua bitwise operations library compatible with Lua BitOp/LuaJIT
--[[
This file provides a library for bitwise operations. It is intended to
be compatible with Lua BitOp which itself is intended to be compatible
with the "bit" library bundled with LuaJIT. It is *not* compatible with
the "bit32" library bundled with Lua 5.2 and higher. For usage, consult
the Lua BitOp documentation:
https://bitop.luajit.org/api.html
https://bitop.luajit.org/semantics.html
]]
local string_format = string.format
@x4fx77x4f
x4fx77x4f / tdetool2.lua
Created November 16, 2023 22:45
Decrypt Teardown ".tde" files.
#!/usr/bin/env luajit
local argparse = require("argparse") -- https://github.com/mpeterv/argparse
local parser = argparse("./tdetool2.lua", "Decrypt and reencrypt Teardown's \".tde\" files.")
parser:argument("input", "Input file(s)."):args("+")
parser:option("-o --output", "Output file.")
parser:option("--working-directory"):hidden(true)
local args = parser:parse()
if #args.input > 1 and args.output ~= nil then
parser:error("cannot use output option with more than one input argument")
end
@x4fx77x4f
x4fx77x4f / hydra5-x64.c
Last active January 16, 2024 15:15
Analytics disabler for Teardown.
#define NULL ((void*) 0)
__declspec(dllexport) int hydra5_client_connect_developer(void* _1, void* _2) {
return 1;
}
__declspec(dllexport) int hydra5_client_connect_steam(void* _1, void* _2) {
return 1;
}
__declspec(dllexport) void* hydra5_client_create(void* _1) {
return NULL;
}
@x4fx77x4f
x4fx77x4f / unsubscribe_unavailable.js
Last active April 22, 2024 20:57
Unsubscribe unavailable Teardown mods
/*
# unsubscribe_unavailable.js
This script will go through your Steam Workshop mod subscriptions for
Teardown mods and unsubscribe from any that are unavailable (e.g. private).
## Usage:
1. Open a tab to any page on the steamcommunity.com domain
2. Open developer tools (Ctrl+Shift+I or F12)
3. Go to "Console" tab
4. Copy and paste the contents of this file into it
4.a.: Don't do this unless you trust me. Malicious code in the developer
@x4fx77x4f
x4fx77x4f / x_freecam.lua
Created May 28, 2023 22:54
Simple freecam script for Garry's Mod.
local identifier = "x_freecam"
local self = _G[identifier]
local function unload()
local hook_tbl = self.hook_tbl
if hook_tbl ~= nil then
for hook_name, hook_name_tbl in pairs(hook_tbl) do
for hook_id, func in pairs(hook_name_tbl) do
hook.Remove(hook_name, hook_id)
end
end
@x4fx77x4f
x4fx77x4f / hydra5-x64.c
Last active April 17, 2023 05:41
Disable analytics in Teardown
#define NULL ((void*) 0)
__declspec(dllexport) int hydra5_client_connect_developer(void* _1, void* _2) {
return 1;
}
__declspec(dllexport) int hydra5_client_connect_steam(void* _1, void* _2) {
return 1;
}
__declspec(dllexport) void* hydra5_client_create(void* _1) {
return NULL;
}
@x4fx77x4f
x4fx77x4f / tdpth.hexpat
Created March 28, 2023 21:29
TDPTH parser in ImHex Pattern Language
#pragma endian little
#include <std/io.pat>
#include <std/sys.pat>
struct vec_t {
float x;
float y;
float z;
} [[static, format("vec_str")]];
fn vec_str(vec_t vec) {
return std::format("Vec({:.3g}, {:.3g}, {:.3g})", vec.x, vec.y, vec.z);
@x4fx77x4f
x4fx77x4f / osk.lua
Created September 21, 2022 00:21
Work-in-progress on-screen keyboard for StarfallEx
--@client
local osk
do
osk = {}
local function enum(t_in)
local n = #t_in
local bits = 0
repeat
bits = bits+1