Introducing XSamy's Better Variables module!

What is Better Variables module?

Better Variables module Is a module which is helping developers seeing changes of variables.

How can I get Better Variables module in my scripts?

If you are using a script, you can simply use

local Better_Variables_Module = require(5030236950).new()_

if you are using a local Script, then simply use

local Better_Variables_Module = require(Module_Location).new()

Also, do not forget to put this module:

Where Module_Location is.

How can I use Better Variables module in my scripts?

You can use it very simply, like any Instance using

Better_Variables_Module.Thing = AnotherThing

What is the best thing from Better Variables module?

The best thing that you can do is using the function :GetPropietyChangedSinal() which is returning a RBXScriptSignal.

This is an example of it:

Better_Variables_Module:GetPropietyChangedSignal(Name):Connect(function(OldValue,NewValue)
        ...
end)

If you want anything more from this module Reply, if you found a bug please send me an DM. Any bugs resolved/updates will be listed here.

1 Like

Example:

Script:

local VariablessModule = require(script.MainModule).new()

VariablessModule.Thingy = 343

VariablessModule:GetPropietyChangedSignal("Thingy"):Connect(function(OldVal,NewVal)
	print(OldVal,NewVal)
end)

VariablessModule.Thingy = "ThingyVal"

Output: 343 ThingyVal

If I wanted to use GetPropertyChangedSignal on a variable I would most likely just stored it as a value instance (which i’m assuming is what you are currently doing however if your not, do say.) I feel this is a very limited functionality. However I feel this could be interesting if you added some functionalities I cannot just access by using a value instance.

2 Likes

He’s doing it with metatables.

Also, it’s Property, not Propiety @TheTurtleMaster_2

:slight_smile:

2 Likes

Thanks for pointing that out! Our team is working to 2 new functions that will be released today!

I’m going to guess these are functions to End the events and also Set without firing an event? I can’t help but notice you made this module that looks very similar to mine, pretty close to after I released mine :wink:

You released a module? Lol, I did not check very much the Resurces.

I’m ending only one event.

I don’t really see this useful, as the developer can only say

rawset(Better_Variables_Module,Name,Value) without firing it. This is a useful error with the code.

I’d say :Set(Property, Value) is easier to use than rawset.

Not quite sure what this means.

1 Like

By that I mean it was not indeed to happen, that is just a side-effect of the __newindex function.

1 Like

First update!

Added a new function: RawSet(Name,Value)

RawSet is setting VariablessModule[Name] = Value without firing the Event.

Exaple Use:

VariablessModule:RawSet("Thingy","AnotherThingy")

The output with it:
343 ThingyVal

The output without it:

ThingyVal AnotherThingy

Changed the script’s speed. The new script:

local Remotes = {}
local Ret = {}
local module = {}

local function GetPropietyChangedSignal(self,Name)
	if Name then
	if rawget(self.Variables,Name) then
		if rawget(Remotes,Name) and typeof(rawget(Remotes,Name)) == "table" and rawget(Remotes,Name)[1] and rawget(Remotes,Name)[1]:IsA("BindableEvent") then
			return rawget(Remotes,Name)[1].Event
		end
	end
	end
end

local function RawSet(self,Name,Value)
	rawset(self.Variables,Name,Value)
end

module.__newindex = function(Table,index,NewValue)
	if not Table["Variables"][index] then
	rawset(Table.Variables,index,NewValue)
	Remotes[index] = {Instance.new("BindableEvent"),NewValue}
	else
		rawset(Table.Variables,index,NewValue)
		rawget(Remotes,index)[1]:Fire(rawget(Remotes,index)[2],NewValue)
		rawset(rawget(Remotes,index),2,NewValue)
	end
end

module.__index = function(self,Name)
	if Name == "RawSet" or Name == "GetPropietyChangedSignal" then
		if Name == "RawSet" then
			return RawSet
		elseif Name == "GetPropietyChangedSignal" then
			return GetPropietyChangedSignal
		end
	else
		return rawget(self["Variables"],Name)
	end
end



Ret.new = function()
	local data = setmetatable({},module)
	rawset(data,"Variables",{})
	return data
end


return Ret