0

I've been tiring to clear my console to make it neater, I've tried os.execute("clear") (which is similar to what I use in python) this is the whole program:

    while( true )
    do
        local opacity
        print("What do you want the opacity to be? (invisible is 1, solid is 0)")
        opacity = io.read()
        opacity = tonumber(opacity)
        if opacity >1 then
            print("Thats not correct, try again")
            os.execute("clear")
            elseif opacity <=1 then
            print(opacity)
        end
    end

SOLUTION HAS BEEN FOUND: require = os needed to be added for the os commands to work

erro50282069
  • 103
  • 4

1 Answers1

0

On Windows:

os.execute("cls")

On Unix:

os.execute("clear")
Mehrdad Moradi
  • 521
  • 1
  • 6
  • 21
  • The problem is I have no idea what OS I'm using, I'm on a website called replit and I know its Linux but not exactly what type – erro50282069 Sep 26 '22 at 20:35
  • You can use the technique mentioned [here](https://stackoverflow.com/questions/295052/how-can-i-determine-the-os-of-the-system-from-within-a-lua-script) to determine the operating system. – Mehrdad Moradi Sep 26 '22 at 20:37
  • i seem to be on a Unix however os.execute("clear") dosent seem to work, do i need to import os like in python? – erro50282069 Sep 26 '22 at 20:40
  • @erro50282069 probably neither one works on replit because it's a web browser – user253751 Sep 26 '22 at 20:45
  • 1
    ive found my problem, i didnt have `require = os` in there, the program now works – erro50282069 Sep 26 '22 at 20:52