Explorer!

This is a second sidebar for Codea that shows all of the values, userdatas, tables, strings, etc… being used in the program.

Tap the arrow in the top right to open the explorer! The lower box shows all of the values in the current table or class instance you areviewing (_G at the start), and if you tap any table or class value in this list, you will then move on to viewing the values in that table or class. The boxes above that are the different tabs, tap them to change what types of variable are shown; the box above those one shows what table or class you are currently viewing, and tapping this box returns you to the last table or class, unless you are currently viewing _G. Long pressing that box will also return you to _G, no matter what depth you are currently at. Press the arrow again to close the explorer. Sorry im not too good at explaining.

To use it in a project just do: varname = Explorer() anywhere in your code (suggested setup) and then varname:remove() to get rid of it! If you would like to hide Codea default values then simply do varname = Explorer(true) when initiating the Explorer instead; useful for keeping track of your values in a game and not being cluttered by all of those Codea values.

Link: https://gist.github.com/monkeyman32123/374a4779bf394c3f55ce

Can’t be used with my FPS indicator, but if there’s enough interest in these projects ill make them compatible. Still a bit laggy, working to make it work faster, also still working on making the code efficient and pretty.

UPDATE: bug fixes and made it change with the orientation (oooooh)

So it draws a white background.

The draw and touched functions are empty. :-?

Nope! Rather it hijacks the draw function and adds its stuff to it. Has no effect on how things work except if you have another draw-hijacking thing (such as my FPS indicator). I like making my stuff that way so that it doesnt clutter draw. Just tap the arrow in the top right!

Just tap the arrow in the top right!

It would be nice if you said that in the first place, also what this program does, so people can decide if they want to try it out or not.

Youre right, sorry. Fixed in the original post.

@Monkeyman32123 This is something like I did back in Codea release 1.5, but not as nice. I’ll try to find where the original post is. If you’re making updates to this, here are some suggestions. When a table is selected, it would be nice if the selected areas background color would change. Also, when you return back to the _G table, the display would still be in the same position it was before, so you don’t have to rescroll back to where you were. It would be nice if this was sorted by variables, functions, and tables. I like what you’ve done with this.

I do plan to update this, and i very much like your suggestions! I think all of that will be easy, besides the sorting one (it’d make the live updating difficult, I suspect). And thank you!

@Monkeyman32123 I haven’t found the original post, but here’s the code. I sort the information, so maybe you could use what I did to sort yours. I show all the variables, tables, and functions in one group, then I show the individual variables, tables, and functions. When you see the word Done, exit the program and all the information is in a tab called func.


function setup()
    local all={}
    local stab={}
    local sfunc={}
    local svar={}
    local var={}  
    local svar1={}
    local str1=""
    for x,y in pairs(_G) do
        table.insert(all,x)
        if type(y)=="function" then
            table.insert(sfunc,x)
        elseif type(y)=="table" then
            table.insert(stab,x)
            if x~="_G" then
                for a,b in pairs(y) do
                    str =string.format("%s.%s",x,a)
                    if type(b)=="function" then
                        table.insert(sfunc,str)
                        table.insert(all,str)
                    else
                        table.insert(svar,str)
                        var[str]=b
                    end
                end
            end              
        else 
            var[x]=y      
            table.insert(svar,x)
        end        
    end
    
    table.sort(all)
    str1="all vars, tabs, and funcs\
----------\
"
    str1=str1..table.concat(all,"\
")
    
    table.sort(stab)
    str1=str1.."\
\
tables\
----------\
"
    str1=str1..table.concat(stab,"\
")
    
    table.sort(sfunc)   
    str1=str1.."\
\
functions\
----------\
" 
    str1=str1..table.concat(sfunc,"\
")
    
    table.sort(svar)
    str1=str1.."\
\
variables\
----------\
"
    for x,y in pairs (svar) do
        str=y.." "..tostring(var[y]).."\
"
        str1=str1..str
    end 
    str1="--[[\
"..str1..table.concat(svar1,"\
").."\
--]]"
    saveProjectTab("func",str1)
    print("Done")
end

Hmmm, ill brainstorm a way to make this efficient. Thatd be easy and not too costly if the tables didnt have to update every frame

EDIT: tabs, im thinking tabs could be the solution. So it sorts and only shows one type of variable at a time. Will do tomorrow, i think, i hope, probably.

UPDATE: Made all of the edits @dave1707 suggested

Now all needs done is to work on efficiency and cleanliness

@Monkeyman32123 There are things that aren’t working correctly. I was just viewing your table entries, and you list some items that aren’t Codea tables, but are part of your program. Those are Explorer, Tbox, and h. You should declare all of your variables as local to keep them from showing up in the list. Also, when I select a table entry, you’re not showing all of the entries for that table.

@dave1707 Ah, yes, thats so that you can use this in your other projects to keep an eye on variables without needing prints or parameter.watches; just wanted to make it work before advertising that feature. and if i may ask, what entries aren’t showing?

@Monkeyman32123 Is this for use in another program so that someone can see what functions, tables, userdata, and strings and their values that are being used in that program? If that’s the case, then you’re probably not missing entries.

That is the use, i just didnt advertise it that way because i didnt have it working too well at the time of posting; and with your suggestions and after bugfixes its now good for that purpose

@Monkeyman32123 If that’s the purpose of it, then when I run it all by itself, it shouldn’t be showing me anything. When I run it attached to another program, it should only show me the tables, userdata, variables, numbers, functions, and strings that are being used in that program and not all the other Codea things. If it’s going to show a lot of things I’m not using, then it’s not going to be that useful.

You’re absolutely correct, @dave1707. Thats why I’ve just now implemented a blocker for default Codea values (optional, of course, so you can either use it to explore codea things or for its main porpoise)