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

The Re-Write Challenge

Started by Dlcruz129, 05 March 2013 - 12:36 PM
Dlcruz129 #1
Posted 05 March 2013 - 01:36 PM
I had a neat idea today. If you're REALLY, REALLY, BORED TO TEARS, try this. Its called the Re-Write Challenge.

How to Play:
  • Go to the ComputerCraft lua folder, and delete everything except for bios, startup, shell, and the lua program. DO NOT DELETE ANY API'S!
  • Launch Minecraft, and re-write every standard program in ComputerCraft however you want.

I'd love to see someone upload a YouTube video if they decide to do this. Also, you don't have to (and shouldn't) just recopy the standard programs. Improve on them a bit, make them your own, maybe add line numbers at the left side of edit, or a GUI for redset, the possibilities are endless!

Good Luck!
oeed #2
Posted 05 March 2013 - 11:31 PM
I see what you mean by "REALLY, REALLY, BORED TO TEARS", you'd be mad to do this :P/>
Exerro #3
Posted 06 March 2013 - 12:20 AM
How would it work? The files in the cc folder are the ones that manage what programs to run etc, like running the startup file, so it would be impossible as they are read only and i'm a noob and don't know how to edit them

edit: wow, reread and noticed "except the bios and startup". Nice idea then :D/> although you don't have to rewrite all of them, rewriting the term library would do most of that just fine
Dlcruz129 #4
Posted 06 March 2013 - 04:18 AM
How would it work? The files in the cc folder are the ones that manage what programs to run etc, like running the startup file, so it would be impossible as they are read only and i'm a noob and don't know how to edit them

edit: wow, reread and noticed "except the bios and startup". Nice idea then :D/>/> although you don't have to rewrite all of them, rewriting the term library would do most of that just fine

You get to keep all APIs. Without the term API, nothing would work.
immibis #5
Posted 07 March 2013 - 09:15 AM
You could delete all the Lua files, no problem. All the essential APIs are in Java.
Edit: To make computers usable at all, you'd need to rewrite at least the shell - probably as a Lua prompt or you wouldn't have any programs to run.
Dlcruz129 #6
Posted 07 March 2013 - 06:23 PM
You could delete all the Lua files, no problem. All the essential APIs are in Java.
Edit: To make computers usable at all, you'd need to rewrite at least the shell - probably as a Lua prompt or you wouldn't have any programs to run.

The instructions say to keep bios, startup, shell, and lua.
Lyqyd #7
Posted 08 March 2013 - 06:38 AM
Hard mode: strip everything down to the bare necessities to run the simplest Lua prompt possible. Re-build the system from there.
iownall555 #8
Posted 08 March 2013 - 08:27 AM
If you want more of a challenge, rewrite the bios and the shell.
Lyqyd #9
Posted 08 March 2013 - 08:49 AM
If you want more of a challenge, rewrite the bios and the shell.

That is precisely what I said above; only a Lua prompt, nothing more.
Bubba #10
Posted 08 March 2013 - 09:05 AM
I think I'm going to take this challenge. Video? Probably not - that would be boring for people because I can't talk and code at the same time. Maybe I'll post my progress on github.

I don't really see why you say you'd have to be really bored. It actually sounds like fun to me XD
Dlcruz129 #11
Posted 08 March 2013 - 06:17 PM
I think I'm going to take this challenge. Video? Probably not - that would be boring for people because I can't talk and code at the same time. Maybe I'll post my progress on github.

I don't really see why you say you'd have to be really bored. It actually sounds like fun to me XD

You'd have to be really bored because this would take AGES.
tesla1889 #12
Posted 08 March 2013 - 06:37 PM
it wouldnt take that long
the java-builtins are a significant chunk of it, so it shouldnt take long
writing an OS from just the BIOS of a real computer would

EDIT: btw, you can erase the APIs too, because the term API functions are stored in the natives table

2nd EDIT: im definitely going to try this :D/>
my only rom file will be one that holds this code:

dofile("/startup")

3rd EDIT: i just realized that im going to need a BIOS prompt, so im just using a while-true loadstring loop
immibis #13
Posted 08 March 2013 - 06:43 PM
writing an OS from just the BIOS of a real computer would

Writing an OS for a real computer is surprisingly easy. Writing one like Windows is hard, but that's only because Windows has so much stuff in it.
tesla1889 #14
Posted 08 March 2013 - 06:45 PM
writing an OS from just the BIOS of a real computer would

Writing an OS for a real computer is surprisingly easy. Writing one like Windows is hard, but that's only because Windows has so much stuff in it.

hand-typed from the BIOS terminal??? hell no. thats hard as fuck.
immibis #15
Posted 08 March 2013 - 06:46 PM
writing an OS from just the BIOS of a real computer would

Writing an OS for a real computer is surprisingly easy. Writing one like Windows is hard, but that's only because Windows has so much stuff in it.

hand-typed from the BIOS terminal??? hell no. thats hard as fuck.
No, I was thinking of writing it with an actual editor and compiler on a different computer. Wait, what's a BIOS terminal?
Bubba #16
Posted 08 March 2013 - 07:07 PM
No, I was thinking of writing it with an actual editor and compiler on a different computer. Wait, what's a BIOS terminal?

Think he means default shell. (?)
AndreWalia #17
Posted 08 March 2013 - 07:21 PM
This is my BIOS.lua

print("Lets do this.")
AndreWalia #18
Posted 08 March 2013 - 07:27 PM
This is my BIOS.lua

print("Lets do this.")
Nevermind…
tesla1889 #19
Posted 08 March 2013 - 08:16 PM
Think he means default shell. (?)

yeah, i thought "prompt" while i typed "terminal"



there seems to be some weird file requirements in CC

it doesnt seem tolerant of changes of any kind

any clues as to what the minimum requirements are?
immibis #20
Posted 08 March 2013 - 08:53 PM
Think he means default shell. (?)

yeah, i thought "prompt" while i typed "terminal"



there seems to be some weird file requirements in CC

it doesnt seem tolerant of changes of any kind

any clues as to what the minimum requirements are?

The BIOS on a PC doesn't have a prompt.

Have you tried these minimum requirements?
* Have a bios.lua
* Extract CC to a folder called ComputerCraft and then delete the zip file before you try editing any files.
tesla1889 #21
Posted 08 March 2013 - 10:51 PM
–snip–
Have you tried these minimum requirements?
* Have a bios.lua
* Extract CC to a folder called ComputerCraft and then delete the zip file before you try editing any files.

well, i discovered that my problem is that the /rom directory is required

it can be empty, but it still has to be present
Dlcruz129 #22
Posted 09 March 2013 - 04:10 AM
–snip–
Have you tried these minimum requirements?
* Have a bios.lua
* Extract CC to a folder called ComputerCraft and then delete the zip file before you try editing any files.

well, i discovered that my problem is that the /rom directory is required

it can be empty, but it still has to be present

With no rom folder, the computer would be a brick. Also, for people calling this easy, you have to re-write every standard program in CC. (Fine, you dont have to rewrite secret/alongtimeago) :P/>
tesla1889 #23
Posted 09 March 2013 - 04:42 AM
With no rom folder, the computer would be a brick. Also, for people calling this easy, you have to re-write every standard program in CC. (Fine, you dont have to rewrite secret/alongtimeago) :P/>

we are saying it's easy because it is easy.
as long as you have a prompt to edit files, you're golden

and the programs in /rom aren't all that spectacular, with the exception of edit and paint
Dlcruz129 #24
Posted 09 March 2013 - 12:49 PM
With no rom folder, the computer would be a brick. Also, for people calling this easy, you have to re-write every standard program in CC. (Fine, you dont have to rewrite secret/alongtimeago) :P/>/>

we are saying it's easy because it is easy.
as long as you have a prompt to edit files, you're golden

and the programs in /rom aren't all that spectacular, with the exception of edit and paint

Sorry, by easy I meant time-consuming. And like I said, try to change the programs; make them your own.
AndreWalia #25
Posted 09 March 2013 - 06:45 PM
why wont my bios.lua work? this is it

while true do
  loadstring(io.read())()
end
when i start a new computer its just a blank screen that has nothing and does nothing
Dlcruz129 #26
Posted 09 March 2013 - 06:47 PM
why wont my bios.lua work? this is it

while true do
  loadstring(io.read())()
end
when i start a new computer its just a blank screen that has nothing and does nothing

Have you deleted the APIs? io is an API, and read simply checks for key presses.
AndreWalia #27
Posted 09 March 2013 - 07:04 PM
why wont my bios.lua work? this is it

while true do
  loadstring(io.read())()
end
when i start a new computer its just a blank screen that has nothing and does nothing

Have you deleted the APIs? io is an API, and read simply checks for key presses.
but io is in java not the apis folder right?
Dlcruz129 #28
Posted 09 March 2013 - 07:06 PM
why wont my bios.lua work? this is it

while true do
  loadstring(io.read())()
end
when i start a new computer its just a blank screen that has nothing and does nothing

Have you deleted the APIs? io is an API, and read simply checks for key presses.
but io is in java not the apis folder right?

Nope! All of the file system functions in io are just wrappers of fs, and read() os.pullEvent's key presses.
AndreWalia #29
Posted 09 March 2013 - 07:20 PM
so would

while true do
  loadstring(read())()
end
work?
tesla1889 #30
Posted 09 March 2013 - 07:33 PM
so would

while true do
  loadstring(read())()
end
work?
yes, but it isnt nice looking at all
and there's no error handling
superaxander #31
Posted 09 March 2013 - 10:28 PM
I am gonna try this. I will record it and speed it up. How many times faster should I do?
oeed #32
Posted 09 March 2013 - 10:51 PM
Depends how long you take, I wouldn't want to watch for more than a few minutes, maybe 5 maximum.
theoriginalbit #33
Posted 09 March 2013 - 10:53 PM
so would

while true do
  loadstring(read())()
end
work?
No read() is defined in the CC bios.lua file :P/>
immibis #34
Posted 10 March 2013 - 12:15 AM
so would

while true do
  loadstring(read())()
end
work?
Nope, because read is in Lua.
Edit: I should scroll down before I reply.
1lann #35
Posted 10 March 2013 - 12:42 AM
You shouldn't delete the bios. It contains some really essential stuff, like os.shutdown management.
AfterLifeLochie #36
Posted 10 March 2013 - 12:50 AM
You shouldn't delete the bios. It contains some really essential stuff, like os.shutdown management.

It's fine if you replace them with equivalent functions. The worst you can do is introduce code that causes hangs, but CC has protection against this.

(Edit: To explain briefly, computers are terminated (forcefully, by thread death) if they don't yield back to the Java side of things. This is why infinite loops aren't infinite - as they get broken out of.)
superaxander #37
Posted 10 March 2013 - 01:35 AM
Ok i started this with a startup file with this but it doesn't work :(/>

--[[
Simple Bios(lua prompt)
]]
print("Simple Bios Loaded")
while true do
write(">")
command = read()
local ok, err = pcall(loadstring(command)())
if not ok then
  print("Error: "..err)
end
end

it attempts to call nil on line 5
superaxander #38
Posted 10 March 2013 - 01:36 AM
found error now nevermind
tesla1889 #39
Posted 10 March 2013 - 10:05 AM
You shouldn't delete the bios. It contains some really essential stuff, like os.shutdown management.

os.shutdown is java

bios.lua just replaces it with a wrapper that has a while true yield at the end just in case

the code is literally

local nativeshutdown = os.shutdown
function os.shutdown()
nativeshutdown()
while true do
coroutine.yield()
end
end

same for reboot

local nativereboot = os.reboot
function os.reboot()
nativereboot()
while true do
coroutine.yield()
end
end

there isnt a single bit of code in bios.lua or any programs or apis in /rom that is essential
dragonherald #40
Posted 11 March 2013 - 12:29 PM
If you want the hardest challenge delete your minecraft and rewrite minecraft from binary.
tesla1889 #41
Posted 11 March 2013 - 02:15 PM
If you want the hardest challenge delete your minecraft and rewrite minecraft from binary.

aaaaaaaaaand im out
Smiley43210 #42
Posted 11 March 2013 - 07:18 PM
If you want the hardest challenge delete your minecraft and rewrite minecraft from binary.
That kills it.
Even if you meant "from Java", …
tesla1889 #43
Posted 12 March 2013 - 06:25 AM
If you want the hardest challenge delete your minecraft and rewrite minecraft from binary.
That kills it.
Even if you meant "from Java", …

i think he was talking about JVM, which is the bytecode java is compiled to
1lann #44
Posted 13 March 2013 - 11:33 PM
Erm, well I suppose if anyone wants to do this challenge, here's a pretty barebones bios.lua (It launches to a lua prompt)

Spoiler

local function newLine()
local wid, hi = term.getSize()
local x, y = term.getCursorPos()
if y == hi then
  term.scroll(1)
  term.setCursorPos(1, y)
else
  term.setCursorPos(1, y+1)
end
end
local nativeShutdown = os.shutdown
function os.shutdown()
nativeShutdown()
while true do
  coroutine.yield()
end
end
local nativeReboot = os.reboot
function os.reboot()
nativeReboot()
while true do
  coroutine.yield()
end
end
local function reader()
local data = ""
local visibleData = ""
local startX, startY = term.getCursorPos()
local wid, hi = term.getSize()
while true do
  term.setCursorBlink(true)
  local e, p1 = coroutine.yield()
  if e == "key" and p1 == 14 then
   data = data:sub(1, -2)
  elseif e == "key" and p1 == 28 then
   newLine()
   return data
  elseif e == "char" then
   data = data .. p1
  end
  term.setCursorPos(startX, startY)
  if #data+startX+1 > wid then
   visibleData = data:sub(-1*(wid-startX-1))
  else
   visibleData = data
  end
  term.write(visibleData .. " ")
  local curX, curY = term.getCursorPos()
  term.setCursorPos(curX-1, curY)
end
end
while true do
term.setTextColor(1)
term.setBackgroundColor(32768)
term.write("lua> ")
local toRun, cError = loadstring(reader(), "error")
if toRun then
  setfenv(toRun, getfenv(1))
  local err, code = pcall(toRun)
  term.setBackgroundColor(32768)
  if not err then
   if term.isColor() then
    term.setTextColor(16384)
   end
   term.write(code)
  end
else
  if term.isColor() then
   term.setTextColor(16384)
  end
  term.write(cError)
end
newLine()
end
superaxander #45
Posted 13 March 2013 - 11:59 PM
I've started doing this I think I will upload episode 1 today.
I have done:
-Startup lua prompt with function and table and nil detection
-started work on edit program have problems with scrolling

Cheers
Smiley43210 #46
Posted 15 March 2013 - 09:02 PM
i think he was talking about JVM, which is the bytecode java is compiled to
I know, that's why I said "even". :P/>
InputUsername #47
Posted 17 March 2013 - 12:06 AM
If you want the hardest challenge delete your minecraft and rewrite minecraft from binary.

Yeah, great idea! Wait! Why don't we just wipe our hard drives and write a custom OS that is able to compete with Windows, Linux or OS X?

Wait!! Why don't we just create our own computer?
SpoilerExtra challenge: make it using only wood and duct tape!
tesla1889 #48
Posted 17 March 2013 - 12:02 PM
why dont we create our own materials to build the computer with?
remiX #49
Posted 17 March 2013 - 12:43 PM
I've started doing this I think I will upload episode 1 today.
I have done:
-Startup lua prompt with function and table and nil detection
-started work on edit program have problems with scrolling

Cheers

Can you upload video please? :P/>
Smiley43210 #50
Posted 17 March 2013 - 03:48 PM
How bout we create our own planet, with which we recreate and reinvent technology?
superaxander #51
Posted 17 March 2013 - 09:47 PM
I've started doing this I think I will upload episode 1 today.
I have done:
-Startup lua prompt with function and table and nil detection
-started work on edit program have problems with scrolling

Cheers

Can you upload video please? :P/>/>
Gonna do it I messed up with the timer cause I did bugfixes off camera
superaxander #52
Posted 17 March 2013 - 10:57 PM
Uploading done:
[media]http://www.youtube.com/watch?v=KsJeafcMnY0[/media]
Edited on 17 March 2013 - 11:31 PM
Smiley43210 #53
Posted 17 March 2013 - 11:09 PM
Uploading done:
Ok its cutting it out now will be done soon
Half an hour…

Edit: Shucks, still processing..
InputUsername #54
Posted 18 March 2013 - 03:03 AM
Uploading done:
Spoiler[media]http://www.youtube.com/watch?v=KsJeafcMnY0[/media]

Great job haha!

BTW are you Dutch? Lol.
superaxander #55
Posted 18 March 2013 - 04:32 AM
I am
Engineer #56
Posted 18 March 2013 - 12:43 PM
I am
Me either!:D/>
oeed #57
Posted 18 March 2013 - 01:13 PM

It's "Me too" :P/>
Smiley43210 #58
Posted 18 March 2013 - 02:31 PM
Oh, its only 5 minutes…I swear yesterday it said 37:something…perhaps it said that because it was processing.
superaxander #59
Posted 18 March 2013 - 07:38 PM
Oh, its only 5 minutes…I swear yesterday it said 37:something…perhaps it said that because it was processing.
That was indeed the case
Smiley43210 #60
Posted 18 March 2013 - 07:58 PM
Oh, its only 5 minutes…I swear yesterday it said 37:something…perhaps it said that because it was processing.
That was indeed the case
Almost thought I was imagining things :P/>