PlotTwist - Plot debug values with ease

Introduction

Printing numbers in the output constantly can work in the short-term, however it has a lot of cons. One of the biggest being that it prevents you from seeing other information that isn’t being printed every frame. Another con is that it’s pretty hard to scroll up and see what happened a few frames ago since it’s scrolling so fast.
(related: Let us plot graphs for debugging)

To resolve this problem, I have decided to create PlotTwist.

Setup

Setting up PlotTwist is pretty easy. Get the plugin here, and get the module here.

How to use

Insert the module into your game, and require it in your script:

local plotUtil = require(PATH_TO_PLOT_UTIL)

Now we can use PlotUtil’s functions. Here’s an example script that should roughly show you how to use it:

local plotUtil = require(PATH_TO_PLOT_UTIL)
local graph = plotUtil:CreateGraph("EpicGraph") -- you can name your graph whatever you want

while true do
    local x = time()
    local y =  math.sin(time()) * 50
    plotUtil:NewPoint(graph, x, y) 
    wait(.1)
end

Let’s run it. If you go into play mode and turn on the plugin widget, you should see this:

image

Type the name of the graph you want to view. In this case, it’s “EpicGraph”:


Now we can see a sine wave! This means that everything is working as intended.

You can also do stuff like plotting character movement, mouse movement, etc. You can plot pretty much everything with this.

Documentation

Instance PlotUtil:CreateGraph(string graphName) -- create a graph that can be viewed on the plugin

PlotUtil:NewPoint(Instance graphFolder, float x, float y) -- create a point on a graph

Note that you should try firing NewPoint less than 10 times a second, any more gets very laggy very quickly.

Fin

Have fun programming with this plugin! Feedback is appreciated too.

(PlotUtil source pastebin because someone asked me to make it: PlotUtil - Pastebin.com)

37 Likes

New update

The plugin will now display points so that you know exactly where they are! (This is disabled when you create over 50 points)

When you hover over a point, it’ll now display its X and Y.

Feedback is appreciated and I hope you enjoy programming with this plugin!

3 Likes

Another update!

The plugin will now automatically adjust framerate according to how many points there are, so that your computer doesn’t fry :slightly_smiling_face:

It also reuses lines, so that it doesn’t create a new instance every time(creating a new instance every time causes a LOT of lag).


(smooth at the beginning, a bit less later since the number of points got higher)


There’s also a dropdown now, instead of a text box. Now you won’t need to type out the graph name every time.

Oh and if you didn’t notice, there’s a new color scheme! Looks pretty cool don’t you think?

I’m also open-sourcing the dropdown module I made:

And also an object cache module I made(works similarly to PartCache except you can use it for UIs & other objects):


Please contact me if you find any bugs/want to make a feature request. Have fun programming with this plugin!

TL;DR: huge performance improvements, dropdown instead of textbox, new color scheme

6 Likes

Awesome! Any chance we could get support for viewing multiple plots in parallel? It would be great to just have a button at the bottom to add a new plot, so you can make a stack as tall as you want.

2 Likes