Skip to content

Instantly share code, notes, and snippets.

local DeltaTable ={
--[[
This module is for getting the difference between a table and then
being able to merge it back in.
-- Specifically great for networking as it allows us only to send what has changed
This is an independant Module because it has enough parts to it, that it should be
seperated from ADTs and or some sort of "Table" lib. This is abstractly a table differ.
--]]
_VERSION = 2.0
@MrChickenRocket
MrChickenRocket / astar.lua
Created July 31, 2022 04:25
Relatively well optimized Astar for luau (uses a kinda clever priority queue to avoid searching the open list for best f)
local module = {}
local INF = 1/0
function dist ( x1, y1, x2, y2 )
return math.sqrt ( math.pow ( x2 - x1, 2 ) + math.pow ( y2 - y1, 2 ) )
end
function heuristic_cost_estimate ( nodeA, nodeB )
return dist ( nodeA.x, nodeA.y, nodeB.x, nodeB.y ) * 2000
@MrChickenRocket
MrChickenRocket / ReplicatedFirst_KinematicObjectsClientScript.lua
Last active October 9, 2024 16:08
Kinematic animated objects for roblox. Tag anchored server objects with "Kinematic" and the motion and physics code is magic'd away.
if (script:IsDescendantOf(game.ReplicatedFirst) == false) then
error(script.Name .. "needs to be in ReplicatedFirst")
end
local CollectionService = game:GetService("CollectionService")
local kinematicObjects = {}
local function AddInstance(target)
--bresenham line walk
function MathUtils:BresLine(x0, y0, x1, y1, callback)
local sx,sy,dx,dy
if x0 < x1 then
sx = 1
dx = x1 - x0
else
@MrChickenRocket
MrChickenRocket / fileproxy.lua
Last active January 22, 2023 01:03
Roblox proxy server for writing files
local module = {}
local HttpService = game:GetService("HttpService")
function to_base64(data)
local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
local Frustum = {}
local function planeFromPoints(p0, p1, p2)
local normal = (p1 - p0):Cross(p2 - p1).Unit
return {
normal = normal,
d = -normal:Dot(p0),
}
end
@MrChickenRocket
MrChickenRocket / DeltaTable.lua
Created February 17, 2023 18:17
Knit styled replicated table service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Packages = ReplicatedStorage.Packages
local Shared = ReplicatedStorage.Shared
local TableUtil = require(Packages.TableUtil)
local DiffTable = {}
------------------------------------------------------------------------------------------------
@MrChickenRocket
MrChickenRocket / FileIOModule.lua
Created June 17, 2023 02:05
Very simple roblox file proxy. Read Write ListDirectory
local HttpService = game:GetService("HttpService")
local BASE_URL = "http://localhost:3090/"
local FileService = {}
function to_base64(data)
local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
return ((data:gsub('.', function(x)
local r,b='',x:byte()
local module = {}
local deltaTable = require(game.ReplicatedFirst.Modules.DeltaTable)
module.tables = {}
module.callbacks = {}
module.remoteEvent = nil
--Connect for a callback
-- function(currentTable, delta, oldTable)
function module:Connect(name, callback)