Jump to content




Getting Computer Information

help computer

2 replies to this topic

#1 AlphaGamer150

  • Members
  • 3 posts
  • LocationUnited Kingdom

Posted 07 October 2017 - 10: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!

#2 SquidDev

    Frickin' laser beams

  • Members
  • 1,425 posts
  • LocationDoes anyone put something serious here?

Posted 08 October 2017 - 09: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.

#3 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 08 October 2017 - 10: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?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users