Skip to content

Instantly share code, notes, and snippets.

View nightcycle's full-sized avatar

Nightcycle nightcycle

View GitHub Profile
@nightcycle
nightcycle / RTree.luau
Last active October 31, 2024 09:22
A basic R tree
--!strict
--!native
-- Services
-- Packages
-- Modules
-- Types
type RectangleImpl = {
__index: RectangleImpl,
__tostring: (self: Rectangle) -> string,
__eq: (self: Rectangle, other: Rectangle) -> boolean,
--!nocheck
export type Profiler = {
start: (label: string) -> (),
stop: (t: number?) -> (),
}
export type BenchFunction<Parameter> = (
profiler: Profiler,
parameter: Parameter
) -> ()
export type BenchModule<Parameter> = {
@nightcycle
nightcycle / pretty-lsp-analyze.sh
Created September 13, 2024 02:27
Create selene inspired more readable errors for whenever you use luau-lsp analyze
#!/bin/sh
# make a temp file
lsp_results=$(mktemp)
set +e
luau-lsp analyze "src" 2> "$lsp_results" #obvs swap this out to your actual lsp call
set -e
# iterate through the results
@nightcycle
nightcycle / DecalToSurfaceAppearance.luau
Last active September 2, 2024 15:58
Allows for mass porting of decals into surfaceAppearances under quads.
--!strict
-- NEEDS TO BE RUN IN PLUGIN OR COMMAND LINE
--!strict
local STEP = 0.005
local quadTemplate = game:GetService("ServerStorage"):WaitForChild("Quad") :: MeshPart
-- Function to get surface CFrame and Vector2 size
function getSurfaceCFrameAndSize(normalId: Enum.NormalId, cframe: CFrame, size: Vector3): (CFrame, Vector2)
-- moved to https://github.com/nightcycle/editable-clothing-util
return {}
@nightcycle
nightcycle / creatorlab-script.ahk
Last active April 30, 2024 19:33
Base CreatorLab AutoHotkey Script
; General Constants
SCREEN_CENTER_X_OFFSET := 950 ; x screen px coordinate for center of screen
SCREEN_CENTER_Y_OFFSET := 550 ; y screen px coordinate for center of screen
MIN_INPUT_DELAY_MS := 80 ; the number of milliseconds to wait after pressing enter to input a value into the menu
MIN_COMMAND_DELAY_MS := 250 ; the number of milliseconds to wait after copying / pasting / deleting / changing an in-world item
MENU_OPEN_DELAY_MS := 400 ; how long to wait for the menu to finish opening
MENU_CLOSE_DELAY_MS := 400 ; how long to wait for the menu to finish opening
@nightcycle
nightcycle / tag-array.sh
Last active May 31, 2024 19:51
Generate an array of tags for a muse project, just run in the vscodium integrated bash terminal (specifically bash, not powershell) "sh tag-array.sh MythNameHere" and it will generate a script called "TagArray.cs" in the appropriate myth.
#!/bin/bash
myth_name="$1"
codegen_path="Codegen/Tags.cs"
codegen_contents=$(<$codegen_path) # the contents of the codegen script
# Regular expression to match lines containing "public static readonly string".
codegen_regex="public const string[[:space:]]+[[:alnum:]_]+[[:space:]]*=[[:space:]]*\"([^\"]+)\";"
# Array to hold the extracted string values.
declare -a tags_array
@nightcycle
nightcycle / benchmark.d.lua
Last active February 5, 2024 18:50
benchmark.d.lua
--!nocheck
export type BenchmarkProfiler = {
Begin: (label: string) -> (),
End: () -> (),
}
@nightcycle
nightcycle / organize-imports.luau
Last active November 17, 2023 06:23
I wrote this because Synty Studios uses texture maps for their assets, but it's more convenient to recolor the mesh directly in Roblox Studio. This splits it into multiple OBJ based on the color the UV points to.
--!strict
-- Run this in command line after you import the meshes
-- Services
-- Packages
-- Modules
-- Types
-- Constants
local SEPARATION = 1
local MAX_X_OFFSET = 50
-- Variables
@nightcycle
nightcycle / ViewportModel.luau
Created September 1, 2023 13:20
A type safe version of EgoMoose's ViewportModel class
--!strict
--[[
MIT License
Copyright (c) 2021 EgoMoose + 2023 Nightcycle
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