Skip to content

Instantly share code, notes, and snippets.

View Nimblz's full-sized avatar
🍳
Scrambling eggs

Austin Reuschle Nimblz

🍳
Scrambling eggs
View GitHub Profile
return function(model)
assert(model.PrimaryPart,
("%s has no primary part. Cannot create cache."):format(
model:GetFullName()
))
local root = model.PrimaryPart
local offsets = {}
UI
Menu
Splash*
CONTINUE -> Title
Title
TO_SAVESELECT -> SaveSelect
TO_OPTIONS -> Options
SaveSelect
SAVE_SELECTED -> Game
BACK -> Title
@Nimblz
Nimblz / output.txt
Last active November 3, 2019 01:25
LinkedList rotation solution
Running test: example1
Input: [7 -> 7 -> 3 -> 5]
Rotation: 2
Expected: [3 -> 5 -> 7 -> 7]
Got: [3 -> 5 -> 7 -> 7]
Success!
Running test: example2
Input: [1 -> 2 -> 3 -> 4 -> 5]
@Nimblz
Nimblz / withCursedScale.lua
Created October 31, 2019 17:52
Wierd component
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local common = ReplicatedStorage:WaitForChild("common")
local util = common:WaitForChild("util")
local lib = ReplicatedStorage:WaitForChild("lib")
local component = script:FindFirstAncestor("uiComponents")
local Dictionary = require(util:WaitForChild("Dictionary"))
local Roact = require(lib:WaitForChild("Roact"))
@Nimblz
Nimblz / lua-snippets.json
Created October 13, 2019 00:31
my vscode snippets
{
// Place your snippets for lua here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@Nimblz
Nimblz / directionToReachGoal.lua
Last active October 4, 2019 00:50
Uses dark magic (math) to calculate the unit velocity vector that will create a trajectory to your goal given a speed
function calcTrajectoryTheta(start,goal,speed,pickHighAngle)
local xzStart = start * Vector3.new(1,0,1)
local xzGoal = goal * Vector3.new(1,0,1)
local range = (xzGoal-xzStart).Magnitude
local yDiff = goal.Y - start.Y
local g = workspace.Gravity
if range == 0 then return nil end
if g == 0 then
return math.atan(yDiff/range) -- simply return angle to the goal
end
@Nimblz
Nimblz / interpolateSequence.lua
Last active October 2, 2019 18:31
Interpolation function for Roblox NumberSequence objects
local errors = {
incompatibleSequences = "Passed origin and goal NumberSequences do not have the same number of keypoints. Origin: $d Goal: $d",
}
-- double iter accepts two tables and the previous index and returns a new index and two values
local function doubleIter (tables, iterState)
iterState = iterState + 1
local valueOne = tables[1][iterState]
local valueTwo = tables[2][iterState]
@Nimblz
Nimblz / FSM.lua
Last active September 19, 2019 17:24
-- trying to make an ergonomic state machine
-- maybe im just making madness
local FSM = {}
function FSM.new(states,startState)
local self = setmetatable({},{__index=FSM})
self.states = states
self:transition(startState)
{
awake = {
enter = function()
return "idle"
end,
step = function()
end,
},
idle = {
enter = function()
return function()
return {
attack = {
inputs = {
{
type = Enum.UserInputType.MouseButton1,
keyCode = nil, -- respond to all inputs of the type
passThrough = true, -- dont block
state = Enum.UserInputState.Begin, -- trigger on this state
},