{"id":"pineappleblaster/spring-module","name":"spring-module","scope":"pineappleblaster","platform":"roblox","description":"Wally-packaged fork of bhristt's Spring Module","version":"0.1.0","latest":"0.1.0","versions":["0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"cae67f192a01cdf7dd2e17b6363aec326453e170f87dbb3783c612d423771ccb","likes":0,"downloads":0,"install":"forest install pineappleblaster/spring-module","url":"https://forest.dev/p/roblox/pineappleblaster/spring-module","files":"https://api.forest.dev/ai/package/roblox/pineappleblaster/spring-module/files","readme":"# Spring Module\r\n\r\nThe **Spring Module** is a module that allows you to create a realistic spring object that acts in one direction. This module creates a general solution to a second order differential equation given some inputs. It’s simple to use and is very useful in creating recoil systems, realistic spring systems, and anything else you can imagine a spring is useful for. This spring module is able to accurately replicate real springs.\r\n\r\n# API\r\n\r\n## Constructor\r\n\r\nTo create a new SpringObject, you can use the constructor\r\n\r\n> [SpringObject] **Spring.new([number] mass, [number] damping, [number] springConstant, [number?] initOffset, [number?] initVel, [number?] goal)**\r\n\r\nor, you can use this other constructor\r\n\r\n> [SpringObject] **Spring.fromFrequency([number] mass, [number] damping, [number] frequency, [number?] initOffset, [number?] initVel, [number?] goal)**\r\n\r\nConstructor use looks like:\r\n\r\n```lua\r\nlocal Spring = require(script:WaitForChild(\"Spring\"))\r\n--// only the first 3 parameters are required to make a\r\nlocal SpringObject = Spring.new(1, 0, 1)\r\n```\r\nDesmos Spring Graph: https://www.desmos.com/calculator/1lzjxyfjum\r\n\r\n## Properties\r\n\r\nThe Spring Object contains the following properties:\r\n\r\n> [number] **SpringObject.Mass**\r\n\r\nThe mass of the Spring Object\r\n\r\n> [number] **SpringObject.Damping**\r\n\r\nThe damping constant of the Spring Object\r\n\r\n> [number] **SpringObject.Constant**\r\n\r\nThe spring constant of the Spring Object (not to be confused with the damping constant)\r\n\r\n> [number] **SpringObject.InitialOffset**\r\n\r\nThe initial offset of the Spring Object\r\n\r\n> [number] **SpringObject.InitialVelocity**\r\n\r\nThe initial velocity of the Spring Object\r\n\r\n> [number] **SpringObject.ExternalForce**\r\n\r\nThe external force acting on the Spring Object\r\n\r\n> [number] **SpringObject.Goal**\r\n\r\nThe offset the spring is aiming to get to as time approaches infinity\r\n\r\n> [number] **SpringObject.Frequency**\r\n\r\nThe frequency of the oscillation of the Spring Object\r\n\r\n> [number] **SpringObject.Offset**\r\n\r\nThe current offset of the Spring Object (this constantly changes)\r\n\r\n> [number] **SpringObject.Velocity**\r\n\r\nThe current velocity of the Spring Object (this constantly changes)\r\n\r\n> [number] **SpringObject.Acceleration**\r\n\r\nThe current acceleration of the Spring Object (this constantly changes)\r\n\r\n> [number] **SpringObject.StartTick**\r\n\r\nThe point in time at which the Spring Object was created\r\n\r\n> [boolean] **SpringObject.AdvancedObjectStringEnabled**\r\n\r\nWhether to use the basic string or advanced string for the Spring Object when **tostring()** is called on the Spring Object\r\n\r\n## Functions\r\n\r\nThe Spring Object contains the following functions:\r\n\r\n---\r\n\r\n\r\n> [void] **SpringObject.Reset()**\r\n\r\nResets the Spring and creates a new **DifEqFunctionTable** for the Spring Object\r\n\r\n> [void] **SpringObject:SetExternalForce([number] force)**\r\n\r\nSets the external force of the Spring Object to the given force\r\n\r\n> [void] **SpringObject:SetGoal([number] goal)**\r\n\r\nSets the external force of the Spring Object such that the the limit of the spring as t approaches infinity is equal to the given number (same as `SpringObject:SetExternalForce(goal*SpringObject.Constant)`)\r\n\r\n> [void] **SpringObject:SetFrequency([number] frequency)**\r\n\r\nSets the frequency of the Spring Object to the given frequency. This overrides the spring constant of the object so that the frequency matches the given frequency\r\n\r\n> [void] **SpringObject:SnapToCriticalDamping()**\r\n\r\nSnaps the Spring Object to critical damping by changing the damping of the object.\r\n\r\n> [void] **SpringObject:SetOffset([number] offset, [boolean?] zeroVelocity)**\r\n\r\nSets the offset of the Spring Object to the given offset. Sets velocity to 0 if zeroVelocity = true. `zeroVelocity = false` by default\r\n\r\n> [void] **SpringObject:AddOffset([number] offset)**\r\n\r\nAdds the given offset to the Spring Object\r\n\r\n> [void] **SpringObject:SetVelocity([number] velocity)**\r\n\r\nSets the velocity of the Spring Object to the given velocity\r\n\r\n> [void] **SpringObject:AddVelocity([number] velocity)**\r\n\r\nAdds the given velocity to the Spring Object\r\n\r\n> [void] **SpringObject:Print()**\r\n\r\nPrints the Spring Object's properties (different print based on **AdvancedObjectStringEnabled**)\r\n\r\n## Internal functions\r\n\r\nThere are some cases where using the internal functions of the SpringObject is necessary. In these cases, it's necessary to use **SpringObject.F**\r\n\r\n> [table] **SpringObject.F**\r\n\r\n**SpringObject.F** is a table that consists of 3 functions:\r\n\r\n> [number] **SpringObject.F.Offset([number] t)**\r\n\r\nReturns an offset based on the given t value\r\n\r\n> [number] **SpringObject.F.Velocity([number] t)**\r\n\r\nReturns a velocity based on the given t value\r\n\r\n> [number] **Spring.F.Acceleration([number] t)**\r\n\r\nReturns an acceleration based on the given t value","readmeTruncated":false}