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

Getting Computer Information

Started by AlphaGamer150, 07 October 2017 - 09:10 AM
AlphaGamer150 #1
Posted 07 October 2017 - 11:10 AM
Hello,
I am trying to make an 'About Computer' section, and I need to get some information like the ComputerCraft Version… here is a list:
- Minecraft Version
- ComputerCraft Version
- Computer Number
- Computer Label
- Computer Maximum Space
- Computer Space remaining

I have been looking around on the forums, and have been unable to find anything!
SquidDev #2
Posted 08 October 2017 - 10:03 AM
Minecraft and ComputerCraft version are stored in the _HOST variable (assuming you're on ComputerCraft 1.76 or greater). These can be extracted with Lua patterns:

local cc_version = _HOST:match("ComputerCraft (%S+)")
local mc_version = _HOST:match("Minecraft (%S+)")

Computer number (or id) and label can be accessed through the os API.

The space remaining can be accessed through fs.getFreeSpace("/"). There isn't a built in way to get the storage capacity of a computer, but you can find the size of each file on disk and add them to the free space to get the capacity.
Dave-ee Jones #3
Posted 08 October 2017 - 11:47 PM
Also keep in mind that if you are running an emulator you will instead get the emulator's version instead of Minecraft's.

I believe fs.getFreeSpace(…) returns a number in bytes?