Skip to content

Instantly share code, notes, and snippets.

local mode = 0 -- 0 is ClassName, 1 is Name, 2 is parent, 3 is FullName
local printRate = 60 -- set to math.huge to disable
-- You can add a BindableEvent named PrintStats to this script and fire it to print stats
---
local changes = {}
local GetFullName = workspace.GetFullName
game.ItemChanged:connect(function(item, prop)
--[[
Version 4:
Fixed garbage collection detection.
Edit 3:
Clarified/fixed some terminology. (comments only)
Version 2:
Made it not prevent garbage collection by using ObjectValues
Version 1:
Initial
local instanceDestroyed = require(script.Parent.MainModule)
do
local a = Instance.new("Part")
instanceDestroyed(a, function()
print("Test 1 destroyed")
end)
a:Destroy()
end
local string_gmatch = string.gmatch
local function getWordDashSpaceTable(txt, tbl)
local tbl, numTbl = tbl or {}, 0
for word1, dash, word2, space in string_gmatch(txt, "([^%-%s]*)(%-)(%S*)(%s*)") do
tbl[numTbl + 1] = word1
tbl[numTbl + 2] = dash
tbl[numTbl + 3] = word2
tbl[numTbl + 4] = space
numTbl = numTbl + 4
end
@Corecii
Corecii / Yield.lua
Last active September 18, 2017 07:02
Coroutine-like scheduler-friendly interface for Roblox Lua
--[[ API Reference
Class Yield
METHODS
static Yield(f: function) --> yield: Yield
static :new(f: function) --> yield: Yield
Creates a new Yield that will run `f` when resumed
static :running() --> Yield currentYield
Returns the Yield that is currently running, or nil if none.
static :yield(... [1]) --> ... [2]
@Corecii
Corecii / UnityKeyCodes.txt
Created October 19, 2017 16:14
Unity KeyCode Names
None
Backspace
Delete
Tab
Clear
Return
Pause
Escape
Space
Keypad0
@Corecii
Corecii / tpcall.lua
Last active February 24, 2024 20:44
Pcall with traceback for Roblox
--[[
Use:
On success:
local success, return1, return2, ... = tpcall(func, arg1, arg2, ...)
On error:
local success, error, traceback = tpcall(func, arg1, arg2, ...)
--]]
--[[ runner.lua: belongs inside tpcall.lua
return setmetatable({}, {
@Corecii
Corecii / PlacePlugins.lua
Last active February 13, 2018 05:19
PlacePlugins Original Source Code
local placePlugins = game:GetService('ServerStorage'):WaitForChild('PlacePlugins', math.huge)
local loaded = {}
local function loadPlugin(name, pluginBase)
local newPlugin = PluginManager():CreatePlugin()
newPlugin.Name = name
if typeof(pluginBase) == "Instance" then
pluginBase.Parent = newPlugin
else
@Corecii
Corecii / luajit_lanes_reuse.lua
Last active May 17, 2018 19:02
Untested example code for reusing lanes in luajit to bypass thread creation time
local retired_lanes = {}
local function thread_func(controller)
while true do
local key, func_args = controller:receive(10, "func_args")
if key == lanes.cancel_error then
break
end
if func_args then
@Corecii
Corecii / TryCatchExample.lua
Created May 21, 2020 22:05
Roblox TS Try/Catch/Finally Example
-- Compiled with roblox-ts v0.4.0
local TS = require(game:GetService("ReplicatedStorage"):WaitForChild("rbxts_include"):WaitForChild("RuntimeLib"))
local function example()
while true do
local _0, _1 = TS.try(function()
return TS.TRY_RETURN, {}
end, function(err)
return TS.TRY_CONTINUE
end, function()
return TS.TRY_BREAK