Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
augitesoul

How could I get the current used RAM of the computer?

Question

2 answers to this question

Recommended Posts

  • 1
1 hour ago, augitesoul said:

Hello, I want to obtain the RAM currently used by the computer, by substracting the returned values of

computer.totalMemory and computer.freeMemory. Sadly, doing this returns an error message.

How should I do this?

So a few quick things.

First, when you get a problem, please send us a screenshot and logs if possible to make it easier for us to identify your problem.

Second, when you're looking at an API in the documentation, be sure to look at the examples that they give as they contain lots of hints!

For example, the first snippit.lua in the computer api shows why your program doesn't work.

I'll demonstrate a working solution here.

getRam.png.9acee50d7603ba2f95b86ec3eb53513b.png

Before you can call any methods, you have to assign the computer API to a variable.

What they usually do in the documentation is to call the variable 'computer' like so:

local computer = require("computer")

print(computer.totalMemory())

Because you didn't set the api to a variable first, your program tried to call a variable that doesn't exist and gave up.

Should be an easy problem to fix :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.