This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
awsmazinggenius's profile picture

awsmazinggenius's Programs*

Started by awsmazinggenius, 07 February 2014 - 04:49 PM
awsmazinggenius #1
Posted 07 February 2014 - 05:49 PM

Hello,
This is my programs thread. So far I have only one program that I admit probably belongs in APIs and Utilities, but I plan on releasing both Turtle and regular programs here too, and have just one thread, just as TheOriginalBIT does, so I would like to respectfully request to the moderators and admins that this thread not be moved.

Global Variable Checker - Are You Leaving Variables Behind?Description: This is a simple and incomplete program that simply iterates over the _G table to count how many variables there are of each type, and displays them in a list. There is some functionality for seeing what the variables are called, but due to a bug (which I will fix on my own when I have time) you can only see the first few currently. This program is useful to me as a developer tool to check that I don't leave my variables behind accidentally.

Screenshots






Download MethodsPastebin: http://pastebin.com/r81r3vvQ (I used an unlisted paste during testing, so if Pastebin is glitching and doesn't realize I changed it let me know.)
GitHub: https://github.com/a...iable-Check.lua

License
All of these programs are MIT licensed. You are encouraged to read through the whole license, but if you are impatient, it basically means give credit and include the permission notice if you use the whole thing or a large portion of it. The license can be found at the top of the code, or below.
MIT License

Copyright (c) 2014 awsmazinggenius

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Updates To ProgramsThe majority of programs here self-update. You can turn off this in their Options menu if you do not want this to happen.
Programs That Don't Self Update Due to Pointlessness
  • Global Variable Check
Edited on 08 February 2014 - 08:41 AM
wieselkatze #2
Posted 08 February 2014 - 01:26 PM
So, even if you declare your program as pointless, you could shrink your code a bit :)/>
As far as I have seen, you have structured your main part like this:

if term.isColor() then
-stuff-
else
-samestuff b/w-
end

Why not for example a scheme table or sth. like that?
so you could say:
term.setTextColor(scm.yourcolorforstring)
and just have one program part?

You would just need to put there an

if not term.isColor() then
scm.yourstringcolor = 1 – So it works on a normal computer
scm.yourbooleancolor = 1
-andsoon-
end

at the start of your code
Engineer #3
Posted 08 February 2014 - 05:52 PM
The first term.isColor statement is pointless.
If you want to check if the terminal is color, use this: if (term.isColor and term.isColor()) then … end

By the way, why would you need this program? You should never use global vars, at least, only use them in exceptional, rare cases. Would you use this to check if an API is loaded? If it's for that, the lua prompt is waaaaaaaaaaaaaaaaaaaay quicker!
awsmazinggenius #4
Posted 08 February 2014 - 10:57 PM
I use this to test that I don't leave anything behind. I use the term.isColor (no parenthesis) to tell them to upgrade to CC 1.45 as I am compatible with both kinds, but I need the term.setTextColor(colors.white/black) thing. If I do leave something, I can speed up the process of finding what it is through the type thing. I haven't had time to fix the major bug and shrink yet, but I do know that that is possible, I just wanted to get this out ASAP. I will minify when I have time.
surferpup #5
Posted 10 February 2014 - 03:20 PM
I like it. It already showed me a few variables I left dangling on some of my older code. Pointless – not entirely.
awsmazinggenius #6
Posted 10 February 2014 - 08:47 PM
Thanks. Haven't got time to fix the program yet as I am visiting someone and they have an old (vintage!) computer.