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

Making A Os?

Started by turtle5204, 20 September 2013 - 05:13 PM
turtle5204 #1
Posted 20 September 2013 - 07:13 PM
How would you make a OS? I just need a tutorial, and how to make an installer. I also need help making a directory that cannot be edited.





Progress Tree:

BIOS——————-|
|—————BootDrive
|
|—————BootAntivirus
|
Lyqyd #2
Posted 20 September 2013 - 08:08 PM
You cannot create with code a folder than cannot be edited. Installers are pretty simple, they usually just get some files from a website and save the contents.
immibis #3
Posted 21 September 2013 - 03:28 AM
An OS is a program that does certain things. Different people have different opinions of what "certain things" are, especially in ComputerCraft. What do you want it to do?

An installer is just a program that writes other programs to files.

You could override fs.open to disallow opening files in a certain directory.
turtle5204 #4
Posted 21 September 2013 - 06:38 AM
An OS is a program that does certain things. Different people have different opinions of what "certain things" are, especially in ComputerCraft. What do you want it to do?

An installer is just a program that writes other programs to files.

You could override fs.open to disallow opening files in a certain directory.
I want it to have a file browser, a great GUI, custom background, color, built-in programs…
Goof #5
Posted 21 September 2013 - 12:02 PM
Whoooops totally wrong post here…. Soorry :(/>
Edited on 21 September 2013 - 10:02 AM
Ristyo #6
Posted 21 September 2013 - 12:03 PM
I am still wondering how the console in the Turtle OS could block us from editing the program files.
BigTwisty #7
Posted 21 September 2013 - 03:46 PM
The so-called blocked folders you are talking about don't actually exist in the folder structure of that particular turtle. They are common folders shared between every computer or turtle in the game. The only way to edit them would be from outside the game. For SSP this is fairly easy, but you would need access to the server files for an SMP server.

It would probably be better for an OS to simply override any function with access to the file system and make your system folder artificially invisible.
H4X0RZ #8
Posted 21 September 2013 - 06:05 PM
Here, to stop peoples accessing your folders/files:

local fso = fs.open
local fsd = fs.delete
local fsiro =  fs.isReadOnly
local blocked = {
  ["somedir"] = true
}

function fs.open(dir,mode)
  if blocked[dir] then
    error("Can't access file!",2)
  end
  return fso(dir,mode)
end

function fs.delete(dir)
  if blocked[dir] then
    error("Can't access file!",2)
  end
  return fsd(dir)
end

function fs.isReadOnly(dir)
  if blocked[dir] then
    return true
  end
  return fsiro(dir)
end
I hope there aren't any typos :D/>
CraftedCart #9
Posted 22 September 2013 - 03:28 AM
A quick installer could be:

if http then
   file = http.get("URL PATH TO FILE HERE")
   if file then
      h = fs.open("PATH OF INSTALL HERE", w)
      h.write(file.readAll())
      h.close()
   else
      print("Seems like we couldn't find the file")
   end
else
   print("Looks like you can't access the internet")
end

Hopefully I didn't do anything wrong. It's not very advanced and could be improved on a lot
Engineer #10
Posted 22 September 2013 - 05:55 AM
Here, to stop peoples accessing your folders/files:

local fso = fs.open
local fsd = fs.delete
local fsiro =  fs.isReadOnly
local blocked = {
  ["somedir"] = true
}

function fs.open(dir,mode)
  if blocked[dir] then
    error("Can't access file!",2)
  end
  return fso(dir,mode)
end


function fs.delete(dir)
  if blocked[dir] then
    error("Can't access file!",2)
  end
  return fsd(dir)
end

function fs.isReadOnly(dir)
  if blocked[dir] then
    return true
  end
  return fsiro(dir)
end
I hope there aren't any typos :D/>/>
Since when can you open a directory?
immibis #11
Posted 25 September 2013 - 08:12 PM
I am still wondering how the console in the Turtle OS could block us from editing the program files.
It's built into ComputerCraft, in Java. You can simulate it with Lua. fs.isReadOnly returns true for read-only files, and some other functions throw errors.

I want it to have a file browser, a great GUI, custom background, color, built-in programs…
So your questions are these?
  • How do I make a file browser?
  • How do I make a great GUI?
  • How do I make a custom background?
  • How do I make colour?
  • How do I make built-in programs?

How do I make a file browser?
Up to you.

How do I make a great GUI?
Up to you. If there was a magic way everyone would be doing it.

How do I make a custom background?
You could use paintutils to display a picture. Or you could use the term API. Up to you.

How do I make colour?
Using term.setBackgroundColour and term.setColour (or use 'color' instead of 'colour', same thing).

How do I make built-in programs?
Well, you make it so that when you install the OS the programs are there. How do you do that? Depends on your OS and installer.


Notice that for all of these things, there isn't a specific way you do it. Eg. there is no function you can call to get a file browser. You have to program it to display files, folders, buttons, scrollbars, etc… on the screen in the right places. You have to program it to know what to do when the user clicks the mouse or presses a key. You have to program it so that when the user clicks a file it displays it, if that's what you want it to do (you have to decide what you want it to do).