FINALLY THEY HAVE DONE IT (Function Documentation Lua)

the fact this post is still up proves a lot trust me i ain’t deleting it :joy: :joy:

3 Likes

Yes, I too get pissed of aswell but your comment was just borderline unnecessary.

Well, yeah. It was rude. You could’ve just removed the sarcasm. The sarcasm is what is rude. I legit thought I was reading a compliment until I saw the second part and was like “the hell is this dude on?”

2 Likes

So is this post…

Gee, I will remove the sarcasm next time boss! Wow! It’s not like I will remove it, if someone is being dumb then I might as well add some sarcasm. Also how did you even think it was a compliment?

1 Like

Well because you were like “Hey this is a really nice post, thank you for this good resource!” and then everything turns black after.

I’m gonna stop replying because I’m hungry now

3 Likes

That’s life for you then. There really isn’t much to compliment this post in the first place as it’s just a user expressing their love for something and providing bare minimum idea on a

All this arguing made me hungry too. Goodbye then.

I just had one singular reply but then some people decided to escalate the reply by calling me out which ended up in this entire hell.

I am gonna go now as well. I sure hope that no one else barges in just to call me out again because that would be a real shame.

1 Like

Hello everyone again, here’s how my MainModule for my module MoonValue looks with the function documentation (i this around 4-5 months ago, like a day after function documentation dropped, safe to say, it’s a great feature.)

Code
--[[

--//[AUTHOR] - @KingBlueDash

--//[TITLE] - MOONVALUE

--//[TAGLINE] - MAKING MOON ANIMATING A LITTLE EASIER

--//[DESCRIPTION] - A OPEN-SOURCE MODULE CRRATED WITH THE INTENT OF MAKING ANIMATING UNAVAILABLE PROPERTIES VIA THE
ADD ITEM DROPDOWN IN MOON ANIMATOR 2 EASIER BY UTILIZING VALUE INSTANCES TO EDIT SAID PROPERTIES IN MOON 2. READ THE
DEVFORUM POST FOR MORE INFORMATION: -- insert link here. --

--//[DEVELOPMENTAL_DATE] - 10/28/2024/6:37:09

]]--

--//VARIABLES

local main = require(script.Main)

local recording = require(script.Recording)

local animationPlayer = require(script.AnimationPlayer)

--//TYPES

type tab = {[any]: any}

--//MODULE CODE

local moonValue = {}

moonValue.__index = moonValue

--[[
	Creates ValueBase(s) inside the object(s) to set up property modifying.
	
	'object' must be a instance or a table of them.
	
	'property' must be a string or a table of them aswell.
]]
function moonValue.new(object: Instance | tab, property: string | tab): ()
	main:init(object, property)
end

--[[
	Begins recording the object(s) property changes either every frame, or when ever the object(s) property changes.
	
	'object' must be a instance or a table of them.
	
	'property' must be a string or table of them aswell.
	
	'timeout' can be a number, it's the duration the recording will last.
	
	'whenMoving' can either be true or false, if true, it'll only record when the object(s) property changes, and will stop
	when the amount of recorded frames reaches the timeout length, or when :EndRecording is called.
	
	Returns a 'frameDictionary' when complete
]]
function moonValue:StartRecording(
	object: Instance | tab,
	property: string | tab,
	timeout: number?,
	whenMoving: boolean?
): ()
	return recording:InitStart(object, property, timeout, whenMoving)
end

--[[
	Ends the recording immediately if 'timeout' wasn'tpassed into 'StartRecording.
	
	'object' must be a instance or a table of them.
	
	'save' can either be true or false, if true, saves the frameDicitonary to workspace in the form of a folder..

	Returns a 'frameDictionary' if successful.
]]
function moonValue:EndRecording(object: Instance | tab, save: boolean?): ()
	return recording:InitEnd(object, save)
end

--[[
	Plays back the contents of a recording, like a animation.
	
	'frameDictionary' must be a dictionary that has been retrieved from 'StartRecording'.
	
	'framerate' can be a number, plays the recording in the specified framerate.
	
	'timeout' can be a number, plays the recording for the specified amount of time before ending.
	
	'revert' can either be true or false, if true, will restore the object(s) properties once the recording finishes.
	
	'smooth' can either be true or false, if true, will smoothly revert the object(s) properties.
]]
function moonValue:PlayRecording(frameDictionary: tab, framerate: number?, timeout: number?, revert: boolean?, smooth: boolean?): ()
	recording:InitPlay(frameDictionary, framerate, timeout, revert, smooth)
end

--[[
	Disconnects any connections and cleans up any 'MV_Folder(s)'
	
	'object' must be a instance or a table of them.
]]
function moonValue:Destroy(object: Instance | tab): ()
	
	main:Disconnect(object)
	
	recording:Disconnect()
	
end

return moonValue

(sidenote: @mohamad_pro07, please listen and put this topic in #development-discussion, cause moderators will end up taking it down otherwise.)

1 Like

Looks nice although i use it this way

--[[
	@param length the length of the string default 8
	@param min minimum number def 0
	@param max maximum number def 255
	@param uniqueseed is a temporary seed added with the main seed default 0
	@returns a random string based on length and byte size constraints
]]
function public:NextString(length: number?, minbytes: number?, maxbytes: number?, uniqueseed: number?): string
	local self :PsuedoRandom = self
	uniqueseed = uniqueseed or 0
	minbytes = math.clamp(minbytes or 0, 0, 255)
	maxbytes = math.clamp(maxbytes or 0, minbytes, 255)
	length = length or 8
	local result = {}
	for i = 1, length do
		table.insert(result, self:NextInteger(minbytes, maxbytes, (i + uniqueseed)))
	end
	return table.concat(result)
end

--[[
	@param condition is number from 0-1 default 0.5
	@param uniqueseed is a temporary seed added with the main seed default 0
	@returns a random boolean based on a condition
]]
function public:NextBoolean(condition: number?, uniqueseed: number?): boolean
	local self :PsuedoRandom = self
	condition = condition or 0.5
	return self:NextNumber(0, 1, uniqueseed) > condition
end

--[[
	@param uniqueseed is a temporary seed added with the main seed default 0
	@returns a random item from a list
]]
function public:NextItem<A>(list: {A}, uniqueseed: number): A
	local self :PsuedoRandom = self
	print(self:NextInteger(1, #list, uniqueseed))
	return list[self:NextInteger(1, #list, uniqueseed)]
end

--[[
	@param uniqueseed is a temporary seed added with the main seed default 0
	@returns a random item based on weights and the choosen weight
]]
function public:NextWeightedItem<A>(items: {A}, weights: {number}, uniqueseed: number?): (A?, number?)
	local self :PsuedoRandom = self
	if (#items ~= #weights) then
		error("Items and weights must have the same length")
	end

	local totalWeight = 0
	for _, weight in ipairs(weights) do
		totalWeight = totalWeight + weight
	end

	local randomWeight = self:NextNumber(0, totalWeight, uniqueseed)
	local cumulative = 0

	for i, weight in ipairs(weights) do
		cumulative = cumulative + weight
		if (randomWeight > cumulative) then
			continue
		end
		return items[i], cumulative
	end
	return nil, nil
end

--[[
	@function Shuffles a list using a random seed
	@param uniqueseed is a temporary seed added with the main seed default 0
]]
function public:Shuffle<A>(list: {A}, uniqueseed: number?)
	local self :PsuedoRandom = self
	uniqueseed = uniqueseed or 0
	for i = #list, 2, -1 do
		
		local j = self:NextInteger(i, #list, i + uniqueseed)
		list[i], list[j] = list[j], list[i]
		j = nil
	end
end

local module = {}

--[[
	@constructor
	@param seed is a number when left blank it will use os.time()
	@returns a new random object.
]]
function module.new(seed: number?)

	local self = setmetatable({}, {__index = public, __metatable = "LOCKED"}) :: PsuedoRandom
	local seed = seed or os.time()
	seed = math.clamp(seed, LIMITATION.Min, LIMITATION.Max)
	
	if (seed == LIMITATION.Max or seed == LIMITATION.Min) then
		seed = math.random(LIMITATION.Min,LIMITATION.Max)
		warn("Seed exeeds "..LIMITATION.Min.."-"..LIMITATION.Max.." new seed: "..`{seed}`)
	end

	--The seed used for generating random numbers
	self.seed = seed
	--The base float generated for the seed
	self.BASE_FLOAT = 0
	--The base int generated for the seed
	self.BASE_INT = 0
	--The base boolean generated for the seed
	self.BASE_BOOL = false

	--[[
		@function UPDATES the base components
		**ONLY USE IF YOU HAVE CHANGED SEED**
	]]
	self.update = function()
		self.BASE_FLOAT = self:NextNumber()
		self.BASE_INT = round(self.BASE_FLOAT)
		self.BASE_BOOL = self.BASE_FLOAT > 0.5
	end
	
	--[[
		@function resets the seed to the default seed
	]]
	self.reset = function()
		self.seed = seed
		self.update()
	end

	self.update()

	return self
end
2 Likes

Finally someone who is intrested in this feature

3 Likes

That’s a nice way to do it, i only refrain from compacting it as it would make it hard for me to read in the future (or for others when i release the module,) it’s just personal preference though.


Also, i appreciate you wanting to let others know about great features like this, do remember to make topics in the right category, as some users could be even more agitated than Kat (which i feel was fairly calm about it) when seeing a topic in the wrong category.

1 Like

ah, yes i got many times that warning but it’s just hard to find the right catagory and if i even have perms to post in it.

1 Like

I think #development-discussion would be best, I’d assume they’d given you perms to post there, although maybe you have to get a certain devforum badge, I’m not sure as i only recently started visiting that category.

2 Likes