Skip to content

Instantly share code, notes, and snippets.

View lolmanurfunny's full-sized avatar

lolmanurfunny

  • 10:32 (UTC -04:00)
View GitHub Profile
local function resume_with_error_check(thread: thread, ...: any): ()
local success, message = coroutine.resume(thread, ...)
if not success then
print(string.char(27) .. "[31m" .. message)
end
end
type Task<T...> = thread | (T...) -> ...any
@zeux
zeux / gctracker.lua
Last active July 15, 2024 21:32
GC tracker for Luau that provides more predicatable (compared to `__gc`...) destructor invocation for dead objects. Supports ~constant time update cost by limiting the iteration count such that update can be called every frame with a small n for negligible performance cost.
--!strict
--[[
BSD Zero Clause License
Copyright (c) 2022 Arseny Kapoulkine
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
@Rerumu
Rerumu / luau_in_luau.lua
Last active May 22, 2024 14:49
Luau translated to Luau, as a Studio compatible script
This file has been truncated, but you can view the full file.
-- Roblox's Luau as a Luau script
-- Translated using https://github.com/Rerumu/Wasynth
local luau_script = [[
print("Hello, World!")
]]
local Integer = (function()
local Numeric = {}
local NUM_ZERO, NUM_ONE, NUM_SIX_FOUR
@jovannic
jovannic / weld_truth.md
Last active July 5, 2024 21:19
The Truth About Welds

Since we don't have this documented anywhere, I'll explain real quick.

The Truth About Welds

Weld, Snap, WeldConstraint, Motor, and Motor6D joints all combine multiple parts into the same Assembly. An assembly is a rigid body if none of it's parts are anchored. No physical forces can ever separate the parts of an Assembly or move them relative to each other unless the joints are removed or updated. They're a single body.

Every Assembly has a root part, see BasePart:GetRootPart. When a weld is C0/C1 is modified the root part will stay where it was.

Welds do not have any directionality. Part0 or Part1, doesn't matter. You can imagine rigid joints forming a tree branching down from the root part. All the parts down the tree from root will move, and their welded "children" in this tree will move with them.

@evaera
evaera / Clean Code.md
Last active July 16, 2024 04:30
Best Practices for Clean Code
  1. Use descriptive and obvious names.
    • Don't use abbreviations, use full English words. player is better than plr.
    • Name things as directly as possible. wasCalled is better than hasBeenCalled. notify is better than doNotification.
    • Name booleans as if they are yes or no questions. isFirstRun is better than firstRun.
    • Name functions using verb forms: increment is better than plusOne. unzip is better than filesFromZip.
    • Name event handlers to express when they run. onClick is better than click.
    • Put statements and expressions in positive form.
      • isFlying instead of isNotFlying. late intead of notOnTime.
      • Lead with positive conditionals. Avoid if not something then ... else ... end.
  • If we only care about the inverse of a variable, turn it into a positive name. missingValue instead of not hasValue.