Skip to content

Instantly share code, notes, and snippets.

View Sleitnick's full-sized avatar

Stephen Leitnick Sleitnick

View GitHub Profile
-- MyService.lua
local MyService = {}
function MyService:DoSomething()
print("Do something")
end
return MyService
----------------------------
local MyService = {}
return MyService
-- Load all ModuleScripts within 'MyModules' that end with "Service" & call their OnStart methods.
Loader.SpawnAll(
Loader.LoadDescendants(MyModules, Loader.MatchName("Service$")),
"OnStart"
)
--[[
Copyright © 2022 Stephen Leitnick
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 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
@Sleitnick
Sleitnick / Log.lua
Created April 20, 2021 20:12
A logger for Lua based on Google's Flogger
-- Log
-- Stephen Leitnick
-- April 20, 2021
--[[
IMPORTANT: Only make one logger per script/module
Log.Level { Debug, Info, Warn, Severe }
@Sleitnick
Sleitnick / Platform.lua
Created November 7, 2018 15:47
Platform creator
-- Platform
-- Crazyman32
-- November 6, 2018
--[[
This should be a LocalScript within StarterCharacterScripts.
This creates platform parts as the player runs around. It does
not replicate the platforms to other players. So only the local
local mixedTbl = {
"test", "hello", "hi",
kills = 32,
deaths = 16
}
-- This table has both numeric indices and hashed indices.
-- e.g. 'mixedTbl[1]' and 'mixedTbl.kills'
-- Generic for loop:
Benchmark("Generic", 40, function()
for i,v in pairs(data) do
-- Foobar
end
end)
-- Numeric for loop:
Benchmark("Numeric", 40, function()
for i = 1,#data do
function Benchmark(title, iterations, func)
print("Running " .. title .. "...")
local start = tick() -- Start time
for i = 1,iterations do
func()
end
local duration = (tick() - start)
print(title .. " duration: " .. duration)
end
local data = {}
for i = 1,1000000 do
data[i] = 1
end