Skip to content

Instantly share code, notes, and snippets.

View nightcycle's full-sized avatar

Nightcycle nightcycle

View GitHub Profile
@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)
@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
--!nocheck
export type BenchmarkProfiler = {
start: (label: string) -> (),
stop: (t: number?) -> (),
}
export type BenchFunction<Parameter> = (
profiler: BenchmarkProfiler,
parameter: Parameter
) -> ()
export type BenchModule<Parameter> = {
@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,
--!strict
--!native
-- Services
-- Packages
-- Modules
-- Types
export type Encoding = "i8" | "u8" | "i16" | "u16" | "i32" | "u32" | "f32" | "f64"
-- Constants
-- Variables
-- References