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

Resetable Scoreboard

Started by NumLox, 09 August 2016 - 11:39 AM
NumLox #1
Posted 09 August 2016 - 01:39 PM
Hi Everyone

I'm looking for a Scoreboard program to add to my community server and was wondering if anyone could help?

I'm going to be building a series of mini game and i would like to be able to keep track of everyones score from the mini games but i'm terrible at coding. Could anybody help me please.

Here are some features that i'm looking for:
  1. Simple clean interface
  2. Keep track of upto 20 people?
  3. Somewhere i can input the number of players.
  4. Can update players score manually by hitting a button.
  5. A reset button to reset the scores and number of players.
  6. Output to a monitor, maybe a 10 x 15?

Thanks in Advance.

Tomi
DannySMc #2
Posted 09 August 2016 - 02:34 PM
https://github.com/EDais/ComputerCraft/blob/master/programs/Scoreboard.lua
Found this upon quick Google, may be of some use, you should have a look at making your own, most likely that is the easiest way to learn, and be able to develop your own personalised version.
Lua References:
https://www.lua.org/manual/5.1/
ComputerCraft API List:
http://computercraft.info/wiki/Category:APIs
You will most likely need to know the following APIs:
Term, Peripheral, Painutils, Textutils, Colours/Colors, FS, and Table.
From what I have gathered about what you are trying to do, you will need to have a Table of users, and their scores. This can be saved to/loaded from file, I would suggest to do this because then if the computer restarts then it will keep the scores. You will need to use the peripheral API to attach the monitor and then write to the monitor with it.
Remember you can easily attach peripherals like so:
local monitor = peripheral.wrap("side OR name if using network cable")
It's also fairly easy to just redirect to the terminal, and then use all of the term API on it. This can be achieved like so:
term.redirect(monitor);
To actually display the scoreboard you can simply do a foreach loop over the table of users and scores and print them to screen, then when it changes, re-draw it.
Edited on 09 August 2016 - 12:35 PM