Jump to content

Bream (Steam For Computercraft)

utility networking media

1 reply to this topic

Poll: New Name

Bream is not really a good name, what shall the name be?

You cannot see the results of the poll until you have voted. Please login and cast your vote to see the results of this poll.
Vote Guests cannot vote

#1 daantechcomputercraft

  • Members
  • 16 posts

Posted 14 September 2020 - 02:28 PM

Sort of Steam

Welcome to Bream! This is Steam for computercraft!

Install now: pastebin get wr2EyxxU Bream (BETA)

Upload your game: https://form.jotform...enkeldaan/Bream

For support please comment and i will be happy to assist you

Edited by daantechcomputercraft, 14 September 2020 - 04:14 PM.

#2 fatboychummy

  • Members
  • 25 posts

Posted 15 September 2020 - 04:49 AM

I hope I don't have to lay my eyes upon this program again... But for now, I'll give you a mini code review (aka me yelling at your insane code and praying that some day it might be a little less sickly looking)

Direct look at the program

1. Line 2: You use shell.run to run the clear program. This is horribly inefficient and the alternative is to write a simple function that takes up four lines.

local function clear()
  term.setCursorPos(1, 1)

2. Line 8: Localize your functions!

3. In function "UpdateBream": I can look past using shell.run for getting a pastebin file, as I've done it that way a few times for laziness (though if you want this to be an actually good, not-lazy program, make your own downloader), but seriously why are you using shell.run for all the other stuff there?

4. In function "RemoveGames": More shell.run madness, but it gets worse. You shell.run your own program. That is going to absolutely kill your server's (or your pc's if playing locally) memory!

5. In function "MyGames":
* Stop with shell.run-ing everything!
* If you install any other games, the way you have it set up you'll have to write an if statement for *every* game you add. Hardly any good if you plan on adding many games.

6. In function "InstallGame":
* Same problem as above, if you wish to install any other games, you now have to write an if-statement for every game you add to this.
* You call function menu with no inputs for an unknown reason directly after clearing the screen.

7. In function "menu":
* If you have more items in the list than space on the page, you won't be able to see the other items
* if e1 == 200 then In CC there exists a keys api, so you can do if e1 == keys.up then instead. It will look better, and you'll be able to remember what it does better later.
* you don't make use of e3, e4, e5 so you can remove them.
* you only are pulling 'key' events so you should include a filter for them instead of checking if e == "key" ( ie os.pullEvent("key") )
* Change the name of e1 to something like keyPressed or just key (ie local e, key = os.pullEvent("key") )

8. Line 142+: This code looks more 'proper', but it will only ever run once. However, due to the way you implemented the above functions which shell.run itself, it will run again BUT you will have to select "Exit" multiple times in order to actually exit the program.

General fixes and improvements

1. Your code needs better indentation. From line 105+ it gets better, but the rest is very poor.

2. You need to localize your functions. You seem to have this figured out for variables, but you should not pollute the global environment with non-localized functions.

3. shell.run should be used a lot less. Instead, implement your own versions of the program.

4. You rely on the program being named 'Bream' too much. There is a good chance that the person who downloads Bream does not name it Bream (or names it 'bream' which will also cause an error as the shell and fs apis are case-sensitive). Use function shell.getRunningProgram to get the name of your program.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users