commitblue
(commitblue)
December 3, 2022, 5:59pm
#1
Before you go click that “send reply” with your 9 cps of yours and say that table.getn and # exists for a solution, This is not what I mean.
Here is what i want to make:
i want to make some computer of terminal, that has limited ram and all that. But, # and table.getn would not fit this usecase.
Here is why:
Lets say I have my table
called ram
local ram = {}
now lets say i add a string and numbers.
local ram = {}
-- generate stuff on ram
table.insert(ram, "s")
table.insert(ram, 55)
print(#ram)
Two issues:
If i extend the stringor number, it would still count as one
of the values in the array.
Regardless it dosent get the size of the table either way.
So i want to get the size of ram
(in kbs), is that possible?
Btw sorry if i poorly explained it.
So if I’m reading this right, you’re trying to get the filesize of a table?
1 Like
After a quick google search. You could test this and see if this does what you’re looking for, but I’m not sure if it does as I haven’t tried it.
local HttpService = game:GetService("HttpService")
local data = 'okaaaaaaaaaaaahhhhhy'
print(#HttpService:JSONEncode(data))
-- > 22
local data2 = {'cat','dog','bird','tiger'}
print(#HttpService:JSONEncode(data2))
-- > 28
1 Like
commitblue
(commitblue)
December 3, 2022, 6:07pm
#5
Genius solution but i want it to be in vanilla lua too.
But thanks alot
astraIboy
(The Batman)
December 3, 2022, 6:20pm
#6
bro just use table.getn
, simple
Please read the post before replying. They are asking for how to get a table’s size in bytes .
2 Likes
astraIboy
(The Batman)
December 3, 2022, 6:23pm
#8
Oh, thats not possible in vanilla lua
2 Likes
A simple way to phrase this question would have been, “How much memory does a given table consume?”, but regardless, a search would have answered your question. Please refer to the following article:
I was wondering if it is possible to tell how much computer storage a variable takes. I was reading and I found some solutions that said you can use http service to json encode it, but this just seems to return a number that is two more then the amount of characters. And it also makes no sense that that would represent a data amount. So is this possible in roblox? Here is an example of what I want to do:
local table = {1,2,3,4,"5123wdsawdadwad",true,false,2e9}
--Then i would like to find ho…
commitblue
(commitblue)
December 5, 2022, 1:20pm
#10
Well “how to get the ACTUAL SIZE of the table” works too but some people misinterpret it, But thanks
system
(system)
Closed
December 19, 2022, 1:21pm
#11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.