Please read: This is a module that was for fun and not to fit any use, if anyone finds an use, sure, I’ll update it to include new features, and fix glitches, but if not, I won’t. I’ll only fix glitches. I can’t find use specifically in this, but it’s cool to mess around with, and it’s also cool to code. I made this today and just liked it, so that’s really it, it’s completely fine if you can’t find use with it.
Link to download:
https://www.roblox.com/library/6480763439/ObjectTables
No github for now.
How does this work?
This is a module which will make and update, and mess with tables using values. These types of values:
All of the above are supported, plus SUB-TABLES. Meaning, you can have a table, inside a table… inside another table… inside yet another table. You get what I mean.
Because of the limitations of newproxy()
like not being able to list how many things are in a table, I included support for that and some other stuff.
How does one get an object-based table?
First, require the module, then, you can do objectTable.new()
to get a table object.
Now, you can set, get, anything from it.
objectBasedTable.Players = game:GetPlayers()
print(objectBasedTable.Players)
How slow is this compared to normal tables?
It is slower. It isn’t painfully slow. It’s fine slow. It’s not gonna break any of your systems.
I can’t really compare it, since I’m not good with math, and it uses that type of format: “6.54122340e-6” which I’m dumb and can’t calculate, but it is slower, that’s usually what you need to know. If you wanna do some bench marking, this can be useful:
Benchmarking script
local objectTable = require(game.ReplicatedStorage:WaitForChild("ObjectTables"))
wait(15)
local start = os.clock()
local End = os.clock()
local Table
print("ObjectTable: ")
Table = objectTable.new()
start = os.clock()
Table["cool"] = 100
End = os.clock()
local actionTimeWrite = End-start
print("Writing to: ", actionTimeWrite)
start = os.clock()
print(Table["cool"])
End = os.clock()
local actionTimeGet = End-start
print("Getting: ", actionTimeGet)
print("Is writing slower than getting: ", actionTimeWrite >= actionTimeGet)
local executionTime1 = actionTimeGet + actionTimeWrite
print("--------- \n Normal Table: ")
Table = {}
start = os.clock()
Table["cool"] = 100
End = os.clock()
actionTimeWrite = End-start
print("Writing to: ", actionTimeWrite)
start = os.clock()
print(Table["cool"])
End = os.clock()
actionTimeGet = End-start
print("Getting: ", actionTimeGet)
local executionTime2 = actionTimeGet + actionTimeWrite
print("Is writing slower than getting: ", actionTimeWrite >= actionTimeGet)
print("Winner: ")
if executionTime1 <= executionTime2 then
print("Object Table!")
else
print("Normal table!")
end
Why did you make this?
Mainly for fun, and that’s pretty much it, I didn’t have anything to do today, I was tired, and I felt like this could be a cool thing to do.
How safe is this, since it uses Instances/Objects?
I woudn’t recommend as of now, to use it on the client. And don’t keep sensitive data inside of that either.
Right now, I don’t have an option to not parent it to the storage folder inside the script.
Any uses?
Currently I can’t think of much, but I guess you can use it to limit yourself from using values that might be incompatible in some other system.
Documentation?
I can talk about is calling the table you made, as a function. Example: objectBasedTable()
, this will return you an actual table, a copy from the object version. This can be used in for loops, and such. If you do objectBasedTable(true)
, it will clean up the storage on which the table was made on. Don’t call anything from this table once you do that, you can also give it a table argument, objectBasedTable({coolright = 3})
, this will replace the current table with the new table you gave it.
Thanks for reading!