#Better tprint()

1 messages · Page 1 of 1 (latest)

weak cloak
#

Do you want to print your table but you are tired of the tprint() function and how it is junky as hell?
I mean look at this: suppose you have this table

local POKEMON = {
    Types = {
        [1] = 'Grass',
        [2] = 'Poison'
    },
    Level = 5,
    HP = {
        Max = 15,
        Current = 15
    },
    EvolvesTo = {
        [1] = {
            Name = 'Ivysaur',
            LevelRequired = 16,
            TradeRequired = false,
            ItemRequired = false
        }
    },
}

and you want it printed on the console. If you use the vanilla tprint(POKEMON), the result is this

{
  EvolvesTo= table: 0x63c208e64860   {
     [1] = table: 0x63c208e648a0      {
        TradeRequired= "false",
        ItemRequired= "false",
        LevelRequired= 16,
        Name= "Ivysaur",
      },
   },
  Level= 5,
  Types= table: 0x63c208e64760   {
     [1] = "Grass",
     [2] = "Poison",
   },
  HP= table: 0x63c208e647e0   {
     Max= 15,
     Current= 15,
   },
}

but if you use the Better tprint function, the result looks like this:

{
  EvolvesTo = {
     [1] = {
        ItemRequired = false,
        LevelRequired = 16,
        Name = "Ivysaur",
        TradeRequired = false,
      },
   },
  Level = 5,
  Types = {
     [1] = "Grass",
     [2] = "Poison",
   },
  HP = {
     Current = 15,
     Max = 15,
   },
}

The Better tprint is designed to handle:

  • tables,
  • numbers,
  • strings,
  • booleans,
  • functions
    in a nice clean way so that you can tell them apart from each other.

How to use

Download this mod and put it into your Mods folder, then you can use tprint(element) like you did before and it will show the improved result.
You are not limited to passing a table inside the function, it can print all types of variable that lua supports.

#

I think this goes in the TOP 1 mods that no one asked for

bright grove
#

it really does

#

print(inspectDepth(table))

#

i guess this is cleaner?

#

but for debug purposes, inspectDepth does the job

weak cloak
#

I can't find that function?

bright grove
#

core/utils.lua of steamodded

weak cloak
#

ok found it

#

it's very good

#

i still prefer my version but thanks for that

storm cloud
#

I prefer when console shows object like valid code, so it can be copied and reused

#

So this mod is exactly what i want

rain oasis
#

I think it's a good programming practice to write simple debug utils for yourself 🦭

#

why do you need recursively created functions in functions tho balatrojoker

#

you should add fixed depth because some tables have reference to themselves so that would cause crash trying to print them

plush quiver
#

Does this just remove the table identifier?

weak cloak
weak cloak
pure ocean
empty tree
#

Especially ui elements + card objects

#

Yk what would be very nice

#

A function that takes a card object and prints only the necessary info, none of that weird stuff 😭

rain oasis
#

for now I just added this to my dump function for debugging

#

but necessary info kinda depends on what youre looking for