I’d be happy to make an update if it fixes a critical bug. Can you be more specific?
That’s cool. I very like the idea but there’s already an easy way to print table
local table = {"hello",3,true} for _,v in pairs(table) do print(v) -- prints table's content end
but I think your way is quicker and will help me a lot
Have a nice day
This is really helpful! Now I don’t have to iterate through all indexes everytime I want to print! A quick suggestion, investigate on how this module allows the implementation of custom methods in Roblox interfaces. For example adding methods to the global math
library. This would allow you to add the table.print()
method. Cheers!
Really great module, it’s incredibly useful for me while I’m working on inventory systems
yes that’s fine for basic printing, but the main use of this module I would say is deep printing, and making prints more readable
example>
Your repr thingy returns:
local Table = {
Table2 = {
"House!"
},
[1] = "Haps"
}
I want it to return:
local Table = {
Table2 = {
"House!"
},
"Haps"
}```
So how would I go about doing that?
I have I have found this:
```lua
for _, kStr in pairs(keyOrder) do
if not first then
str = str .. (reprSettings.semicolons and ";" or ",") .. (reprSettings.pretty and ("\n" .. INDENT .. tabs) or " ")
end
str = str .. ("%s = %s"):format(kStr, keyValueStrings[kStr])
first = false
end
If I change it to:
for _, kStr in pairs(keyOrder) do
if not first then
str = str .. (reprSettings.semicolons and ";" or ",") .. (reprSettings.pretty and ("\n" .. INDENT .. tabs) or " ")
end
str = str .. ("%s%s"):format("", keyValueStrings[kStr])
first = false
end
I get
local Table = {
{
"House!"
},
"Haps"
}
But as you can see the Table2 is missing so how would I go about keeping the Table2
while removing “[1]”???
Sorry, there’s no option for this, and I don’t plan on adding one.
Only when a table is considered an array will its keys be excluded from the output. A table is considered not an array if the iterator returned by pairs
returns a non-numeric key.
The reason for this is because a goal of repr is to be as useful as possible during debugging. Excluding numeric keys would go against this principle: in your case, excluding the key might lead to confusion on the index of "Haps"
- is it 1 or 2? What if there’s potentially many non-numeric keys before it? repr can’t control that, so it’s better to err on the side of caution. Mixed key tables are uncommon, so I’m not really losing sleep over this looking weird.
If you’d like this to be a feature of repr as a non-default setting, you are more than welcome to add it yourself then submit a pull request on the GitHub repository.
I just get an error when requiring this:
Unable to find module for asset id 3148021300. Does the asset have a ModuleScript named “MainModule”?
It used to work fien for me, is something up with the module now?
At the upper left corner of roblox studio click the first button you see, then click beta features then in that window you should find a entry for the new output box tick it restart roblox studio and use print(table)
Sorry, apparently I didn’t set up repr v1.2 to work with require(assetId) - it should work now. There is a MainModule wrapper for it now.
This doesn’t fix the problem @Planet_Dad described - that’s just the new output window (ie it’s not repr)
It does. The new output menu has a integrated table printing system anyway not requiring to use Repr.
I’m aware of the new features of the output window – your suggestion is that of an alternative which is younger than repr, not a fix for repr itself, which is the topic of this thread. I’ve fixed his problem by updating the module directly anyway.
I have no problem that the built-in newer output window solves a similar use case than that of repr. By all means, if it works better for you, use it. repr is older, after all, so it makes sense. However, “X is broken” → “Don’t use X” is an anti-solution.
Hello, can I use this in my own experience? Albeit I do know the license says that you can do anything but I just want to confirm this, should I provide credits aswell?
edit: sorry for bumping, just realized the last reply was from December 2020
Yup, go ahead. The WTFPL allows you to do anything you want with it without credit.
repr will not serialize decimals correctly
elseif typeof(v) == "UDim2" then
return ("UDim2.new(%d, %d, %d, %d)"):format(v.X.Scale, v.X.Offset, v.Y.Scale, v.Y.Offset)
print(string.format(0.02, "%d"))
print(("%d"):format(0.02))
I made a PR to fix this by using %g
(although I think string.format is more optimize for Luau and encouraged by engineers)
(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)
This was created back when the expressive output window did not exist, what do you expect?
Love it, Thanks for making it!!