Skip to content

Instantly share code, notes, and snippets.

View jovannic's full-sized avatar

Jovanni jovannic

View GitHub Profile
@jovannic
jovannic / MockTree.lua
Last active November 26, 2020 02:44
MockTree: A module for handling Welds and Motor6Ds outside of Workspace
local MockTree = {}
local function addJointEdge(joints, joint, me, other)
local edgeList = joints[me]
if not edgeList then
edgeList = {}
joints[me] = edgeList
end
table.insert(edgeList, {joint, other})
end
@jovannic
jovannic / ApplyJointVelocities.md
Created May 1, 2020 20:30
Animator.ApplyJointVelocities
Animator.ApplyJointVelocities(motors : Array<Motor6D>) : void

Given the current set of AnimationTracks playing, and their current times and play speeds, compute relative velocities between the parts and apply them to Motor6D.Part1 (the part which Animator considers the "child" part).

This method will not apply velocities for a given joint if both of the joint's parts are currently part of the same assembly, e.g. if they are still connected directly or indirectly by Motors or Welds so that Part0:GetRootPart() == Part1:GetRootPart().

This method will not disable or remove the joints for you. You must disable or otherwise remove the rigid joints from the spanning tree before calling this method.

@jovannic
jovannic / Animate.lua
Last active September 29, 2020 01:43
AnimateV4
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local pose = "Standing"
local userNoUpdateOnLoopSuccess, userNoUpdateOnLoopValue = pcall(function() return UserSettings():IsUserFeatureEnabled("UserNoUpdateOnLoop") end)
local userNoUpdateOnLoop = userNoUpdateOnLoopSuccess and userNoUpdateOnLoopValue
local animateScriptEmoteHookFlagExists, animateScriptEmoteHookFlagEnabled = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserAnimateScriptEmoteHook")
end)
@jovannic
jovannic / CFrameEditor.lua
Last active September 29, 2020 01:43
Hacky C0/C1 CFrameEditor Plugin
local Selection = game:GetService("Selection")
local CoreGui = game:GetService("CoreGui")
local joints = {}
local attachments = {}
local conCFrame = {}
local conParent = {}
-- Event to deduplicate registered callbacks if plugins are reloaded.
local killmename = "CFrameEditor.Plugin.RefreshCleanupEvent"
@jovannic
jovannic / weld_truth.md
Last active November 8, 2022 05:27
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.

#include <stdio.h>
int main(int argc, const char* argv[])
{
const char* beep = "HONK";
[beep]()
{
printf(beep); getchar();
}();
@jovannic
jovannic / timesince.js
Created August 12, 2014 22:32
Consistent, Exact Aniversary Counter
var YEAR = 31536000000;
var DAY = 86400000;
var HOUR = 3600000;
var MINUTE = 60000;
var SECOND = 1000;
/**
* Takes two date objects and returns the time difference of the present date
* since the past date.
* @param {Date} past The past date
@jovannic
jovannic / gist:9239591
Last active June 7, 2021 03:59
sh2csh.sed
#!/bin/sed
# i can do 90% of the csh conversion work in batch, automagically!
# ...he said, 3 hours ago.
# ...but f*** all, it works! (does all my conversion, besides functions)
# change the shell to csh
1s|#!.*|#!/bin/csh -f|
# change if/while brackets
/^\s*\(if\|elif\|while\) / {
s/elif \[ /else if ( /