Skip to content

Instantly share code, notes, and snippets.

View CheezusChrust's full-sized avatar

Matt CheezusChrust

  • Canada
  • 20:04 (UTC -05:00)
View GitHub Profile
--@name lib/controlsurface
--@author Cheezus
local deg, atan, sign = math.deg, math.atan, math.sign
local ControlSurface = class("ControlSurface")
local surfaces = {}
function ControlSurface:initialize(base, ent, axisEnt)
local worldEntAngle = ent:getAngles()
self.ent = ent
@CheezusChrust
CheezusChrust / nozzle.pl
Created September 17, 2023 22:37
Actuating nozzle for a jet engine, give it an A value of 0 to 1
@name Jet Nozzle
@inputs A
@outputs Value
@persist MoveRate Value Segments Distance MinAng MaxAng [MainScale Scale1 Scale2]:vector
@persist StartAngles:array LastValue First
@trigger none
@strict
if(first() | dupefinished()) {
MoveRate = 0.1 # Rate at which nozzle can move
@CheezusChrust
CheezusChrust / springexample.lua
Last active November 16, 2023 18:12
Example for spring library use
--@name Sim Spring Suspension
--@author Cheezus
--@server
--@include lib/spring.txt
-- Link front two wheels and then rear two wheels with adv e marker
-- Only update suspension when vehicle is frozen
local frontOffset = Vector(0, 0, 0) -- Position offset from wheel to place the end of the spring
local frontConstant = 10000 -- Newtons per meter of displacement
@CheezusChrust
CheezusChrust / spring.lua
Last active November 16, 2023 18:10
Starfall Spring Sim
--@name lib/spring
--@author Cheezus
local clamp, max = math.clamp, math.max
local Spring = class("Spring")
local springs = {}
local springID = 0
--- Create a new spring controller.
-- @param e1 The first entity to attach the spring to
@CheezusChrust
CheezusChrust / joystickcontroller.lua
Last active April 16, 2023 21:02
A Starfall script to make setting up joystick-like devices easier. Requires the joystick module, binaries can be found here: https://github.com/thegrb93/StarfallEx
--@name Joystick Controller
--@shared
--[[
INSTRUCTIONS/INFO:
1. Spawn this chip on a Starfall screen and move your input device around/press buttons on it
2. Fill the axes and buttons tables below using the formats described below
- Wire outputs will automatically be created based on table names
- DeviceID is displayed on the top of the screen
@CheezusChrust
CheezusChrust / joystickhelper.lua
Last active April 8, 2023 04:31
Helps you find what axis is what with the joystick module in Starfall, spawn on a Starfall screen
--@name Joystick Helper
--@author Cheezus
--@shared
if SERVER then
local ent = chip():isWeldedTo()
if isValid(ent) and ent:getClass() == "starfall_screen" then
ent:linkComponent(chip())
end
--@name Mesh Loader
--@author Cheezus
--@shared
local debugPrints = true -- Shows info about tri count and loading progress
if CLIENT then
local globalScale = Vector(0.1) -- Scale all meshes added by this amount, or add a scale vector to individual meshes
local offsetPos = Vector(0, 0, 0) -- Offsets are relative to chip/base
local offsetAngle = Angle(0, 0, 0)
@CheezusChrust
CheezusChrust / chipmonitor.lua
Created October 27, 2022 01:14
Simple CPU monitor for Starfalls and E2s, spawn on a Starfall screen component to use
--@name tools/CPU Tracker
--@author Cheezus
--@shared
-- To use this chip, spawn it on a Starfall screen component
if SERVER then
if chip():isWeldedTo() then
chip():isWeldedTo():linkComponent(chip())
end
@CheezusChrust
CheezusChrust / Car Steering v3.4.lua
Last active March 27, 2023 21:30
A Starfall-based SetAng steering chip with decent counter-steering abilities
--@name Car Steering v3.4
--@author Cheezus
--@shared
--@model models/sprops/rectangles_thin/size_2/rect_12x12x1_5.mdl
local showAxes = true
local frontWheelPos = Vector(50, 0, 0) -- Between your front wheels
local rightAxis = Vector(0, -1, 0) -- The RIGHT facing direction of your car
local upAxis = Vector(0, 0, 1) -- The UP facing direction of your car
@CheezusChrust
CheezusChrust / simulated_gearbox.lua
Last active February 15, 2023 02:01
A simple simulated gearbox
--@name Simulated Gearbox
--@author Cheezus
--@shared
local crankAxis = Vector(0, 0, 1) -- Rotation axis of the crankshaft
local flywheelAxis = Vector(0, 0, 1) -- Rotation axis of the flywheel
crankAxis:normalize()
flywheelAxis:normalize()
if SERVER then