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

My First ComputerCraft Program

Started by Pyrif, 05 June 2015 - 08:37 PM
Pyrif #1
Posted 05 June 2015 - 10:37 PM
First off, let me start off by saying that this program is similar to one included in ComputerCraft already. It may not be uber-cool, but I've put a lot of work into it and am willing to try to make it even BETTER than the similar program. The program I've made is UPaint - a simple paint program that runs on all advanced ComputerCraft platforms, including Advanced Computers, Advanced Pocket Computers, Advanced Monitors (touch screen) and even Advanced Turtles! To get this program, use the shell program:

pastebin get yeyRsmsz upaint
Then simply type upaint and the program will start no matter what platform you're on! And of course, if you haven't already guessed, the U stands for Universal. :3
Controls:
Right-click a color in the bottom right pad to set that color.
Right-click anywhere else to paint with that color. Supports mouse right click and drag as well as monitor touch.
Press enter to bring a menu up.
Possible additional features:
Shapes
Touch-screen version of menu
Any suggestions given
Version History:
Ver1.2: Saving and loading is fixed and now creates the save/load directory.
Ver1.1: Now has support for saving and loading, slightly less touch-screen, but still works.
Ver1.0: Basic program, only has support for drawing and color selection, all platforms.
Edited on 08 June 2015 - 03:41 PM
KingofGamesYami #2
Posted 06 June 2015 - 04:00 AM
Pretty good for a first program, I'll give some constructive criticism:

1. Saving is a must. Not saving is weird (how would you use it for anything?)
2. The color pallet should be left-clickable (otherwise, how do you use it on a monitor?)
3. You may want to consider paintutils.drawPixel, it simplifies things somewhat.
4. Loading an image to edit would be nice
5. A control menu would be great (similar to the default edit program's menu) shameless self promotion

If you've got questions, or need help with anything, feel free to post in Ask a Pro. We like people in Ask a Pro.
Pyrif #3
Posted 06 June 2015 - 04:09 AM
Pretty good for a first program, I'll give some constructive criticism:

1. Saving is a must. Not saving is weird (how would you use it for anything?)
2. The color pallet should be left-clickable (otherwise, how do you use it on a monitor?)
3. You may want to consider paintutils.drawPixel, it simplifies things somewhat.
4. Loading an image to edit would be nice
5. A control menu would be great (similar to the default edit program's menu) shameless self promotion

If you've got questions, or need help with anything, feel free to post in Ask a Pro. We like people in Ask a Pro.
Thanks! Coding is my main profession, so I like to think that what I do is good. Also, thanks for the constructive criticism. All I'd need to do for save/load is figure out how to save a table to a file. I might need Ask a Pro for that. I'll have to look into the Paintutils API, I haven't toyed around with it yet. :3 The menu is a great idea, and while I had thought of it before, I didn't really have enough functionality in UPaint yet to have a menu for it. XD
Pyuu #4
Posted 06 June 2015 - 03:10 PM
-snip-
Thanks! Coding is my main profession, so I like to think that what I do is good. Also, thanks for the constructive criticism. All I'd need to do for save/load is figure out how to save a table to a file. I might need Ask a Pro for that. I'll have to look into the Paintutils API, I haven't toyed around with it yet. :3 The menu is a great idea, and while I had thought of it before, I didn't really have enough functionality in UPaint yet to have a menu for it. XD

textutils.serialize converts a table to a string (unless the table has a function inside it. Then I don't think it is compatible.)
textutils,unserialize converts the string back into a table.

Useful for save functions.
Also: Wonderful job on your first program!
Pyrif #5
Posted 06 June 2015 - 07:08 PM
-snip-
Thanks! Coding is my main profession, so I like to think that what I do is good. Also, thanks for the constructive criticism. All I'd need to do for save/load is figure out how to save a table to a file. I might need Ask a Pro for that. I'll have to look into the Paintutils API, I haven't toyed around with it yet. :3 The menu is a great idea, and while I had thought of it before, I didn't really have enough functionality in UPaint yet to have a menu for it. XD

textutils.serialize converts a table to a string (unless the table has a function inside it. Then I don't think it is compatible.)
textutils,unserialize converts the string back into a table.

Useful for save functions.
Also: Wonderful job on your first program!
Thanks! I also got the textutils info from Ask a Pro, and I'm glad that my first program is a good one. :)/> I'm currently working further on my UPaint program, and while the minimenu that Yami gave me makes it slightly less compatible with monitors, it's only when you need the menu. Then it's fine. :D/>
Pyrif #6
Posted 06 June 2015 - 07:48 PM
Update! Now has support for saving and loading files.
SGunner2014 #7
Posted 08 June 2015 - 02:34 PM
Nice! I like it :)/>

One thing, when I tried to save a file it errored with "f: attempt to index nil value" on line 88. That's because the folder it's trying to write the file to didn't exist. What I suggest is a system at the start that detects if the folder exists, and if not, creates it.

Other than that, nice work :P/>

- Sam
Pyrif #8
Posted 08 June 2015 - 05:32 PM
Nice! I like it :)/>

One thing, when I tried to save a file it errored with "f: attempt to index nil value" on line 88. That's because the folder it's trying to write the file to didn't exist. What I suggest is a system at the start that detects if the folder exists, and if not, creates it.

Other than that, nice work :P/>

- Sam
Thanks! I forgot to make it so that it makes the folder if it doesn't already exist, so thanks for reminding me! :D/>
Pyrif #9
Posted 08 June 2015 - 05:40 PM
Bug fix! The program now makes the directory /Pictures if it doesn't already exist at the beginning of the code, so now you can save and load pictures properly.