Introducing MATHMODULE! My first community resource and my first completed module!
To get the math module, do require(where you put the math module)
.
All about it
The MathModule has functions and certain things corresponding to values. Now, I only managed to get 6 functions done because I couldn’t think of any. Please suggest in the replies if there are any functions I can add! Also, for almost every function, you need a table to return the results in so keep that in mind. Anyways, let’s see what each of these functions do.
Function 1(Coordinates)
Coordinates basically locates a part on another larger part, here’s an example of the basepart and the part:
What it does is get how far the part is from the basepart position x, basepart position y, basepart position -x and basepart position -y.
Arguments
basepart, part, result
basepart is the part that the part's position will be measured on
part is the part that is measured on
result must be a table and it basically gets returned the results
Example Code
local Math = require(script.Parent.MathModule)
local results = {}
Math.Coordinates(workspace.Basepart, workspace.part, results)
print(results[1] .. ", " .. results[2] .. ", " .. results[3] .. ", " .. results[4])
Example Output
14:24:33.164 80.804161071777, 159.91754150391, 141.74510192871, 76.054244995117 - Server - MathManager:7
Function 2(Square)
Square basically squares a number, for example, let’s get 4 and square it. That’s going to be doing 4x4
which is 16.
Arguments
number results
number is your number you want to square.
result must be a table and it basically gets returned the results
Example Code
local Math = require(script.Parent.MathModule)
local results = {}
Math.Square(4, results)
Example Output
14:32:15.229 16 - Server - MathManager:7
Function 3(Cube)
Now, let’s talk about cube. This basically cubes a number like 6. 6 x 6 x 6 is 216.
Arguments
number results
number is your number you want to square.
result must be a table and it basically gets returned the results
Example Code
local Math = require(script.Parent.MathModule)
local results = {}
Math.Cube(6, results)
print(results[1])
Example Output
16:36:10.293 216 - Server - MathManager:7
`
Function 4(Geometry)
DISCLIAMER, THIS FUNCTION MAY NOT WORK AS INTENDED AND MIGHT EITHER BE FIXED OR REPLACED IN THE FUTURE.
Geometry basically contains Area and Perimeter. This can help you find an area or perimeter on a part.
Arguments
shape geomtrytype results
shape is the part being measured on
geomtrytype contains "Area" or "Perimeter"
results get returned the results
Example Code
If you do choose area:
local Math = require(script.Parent.MathModule)
l
ocal results = {}
Math.Geomtry(workspace.pas, "Area", results)
print(results[1])
If you do choose perimeter:
local Math = require(script.Parent.MathModule)
local results = {}
Math.Geomtry(workspace.pas, "Perimeter", results)
print(results[1])
Example Output
If you chose area:
16:46:46.925 425.23455810547 - Server - MathManager:7
If you chose perimeter:
16:47:19.390 425.23455810547 - Server - MathManager:7
Function 5(Average Rate)
Average rate basically states an average rate of the value of a number. For example, you’re doing a daily reward system but you want it to have a small chance of less or more cash, well then, this system is for you.
Arguments
averagerate ,maxaveragerate,value,inchance ,chance ,results
averagerate - your average rate of cash(for example 30)
maxaveragerate - your max average rate of your cash(for example 100)
value - your value you're going to edit
inchance - the number m on the RNG(the chance it'll not be the average rate of cash)
chance - the number n on RNG(the chance it'll not be the average rate of cash)
results - will get returned the results
Example Code
local Math = require(script.Parent.MathModule)
local results = {}
local value = 0
Math.AverageRate(30, 50, value, 1, 6, results)
print(results[1])
Example Output
16:56:32.546 30 - Server - MathManager:7
`
Function 6(Proportion)
Last but not least, Proportion! Proportion can basically divides a value into 4 segments. Now this one doesn’t need results passed
Arguments
value, names
value - your value you're going to edit(has to be a string value)
names - has to be a table, the list of all the value names
Example code
local Math = require(script.Parent.MathModule)
local value = script.FarmedFood
local names = {
"Tomatoes",
"Potatoes",
"Broccoli",
"Orange"
}
Math.Proportion(value, names)
Example Images
Function 7(Ratio)
Ratio can basically determine the status of 2 values. It returns the percentage of the 2 values.
Arguments
value1, value2, results
value1 - the first value
value2 - the second value
results - gets returned the results
Example Code
For this, value1’s value is 4 and value2’s value is 2.
local Math = require(script.Parent.MathModule)
local value1 = script.Value1
local value2 = script.Value2
local results = {}
Math.Ratio(value1, value2, results)
print(results[1]
Example Output
Download the module here:
https://web.roblox.com/library/7162266387/MainModule
Hey! We’re done! I hope you found this module useful. Yes, I divided the functions into segments so this post won’t be too long and it would be organized. Anyways, peace!