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

Get the bios.lua file from CC

Started by CCGrimHaxor, 13 January 2015 - 01:21 PM
CCGrimHaxor #1
Posted 13 January 2015 - 02:21 PM
Ok guys so I am creating a way better version of CCRoot and what I need to do is grab the actual bios.lua from within computercraft.
So can this be achived? How?
I was thinking of trying the top-level coroutine override but I don't know how to make it work to copy the bios itself.
Thanks.

Btw sorry for so much help I just never attempted anything this crazy.

EDIT: I don't have access to the jar file. I am trying to copy the bios.lua file from inside the jar file into the root directory.
Edited on 13 January 2015 - 01:45 PM
Lignum #2
Posted 13 January 2015 - 02:29 PM
You can't do it within ComputerCraft. You have to copy it from the mod's files. If that's not an option, then please tell us what you're trying to do, maybe there's a workaround.
CCGrimHaxor #3
Posted 13 January 2015 - 02:46 PM
You can't do it within ComputerCraft. You have to copy it from the mod's files. If that's not an option, then please tell us what you're trying to do, maybe there's a workaround.

I have edited the post if you need anymore information tell me
Lignum #4
Posted 13 January 2015 - 03:01 PM
The bios is outside the rom, you don't have any access to it at all (there is no way I can think of, at least). You're going to have to copy it using your actual computer. Regarding that, you said that you didn't have access to your jar? I'm a bit confused by what you mean by that, either way you can download one from the ComputerCraft website if needed. If you're on a server, just upload the bios to pastebin and download it to your computer.

If that doesn't help, please tell us what you're trying to do specifically. Are you trying to modify it or is it something else? Because you shouldn't need it for anything besides that, really.
KingofGamesYami #5
Posted 13 January 2015 - 03:14 PM
There is no way to modify it in game, however a copy of it is located here.
CCGrimHaxor #6
Posted 13 January 2015 - 04:05 PM
The bios is outside the rom, you don't have any access to it at all (there is no way I can think of, at least). You're going to have to copy it using your actual computer. Regarding that, you said that you didn't have access to your jar? I'm a bit confused by what you mean by that, either way you can download one from the ComputerCraft website if needed. If you're on a server, just upload the bios to pastebin and download it to your computer.

If that doesn't help, please tell us what you're trying to do specifically. Are you trying to modify it or is it something else? Because you shouldn't need it for anything besides that, really.

Ok thanks for the reply I am not trying to modify it I am trying to just copy it to another location. I was thinking of my program to pull the bios code to the root and then change the functions inside and run the copied bios causing the functions to overriten and continue from there. The reason I am trying this instead of pastebin is because I want to make the patch universal.

There is no way to modify it in game, however a copy of it is located here.
I am not attempting to modify it just copy it
Lignum #7
Posted 13 January 2015 - 04:19 PM
Since the bios functions are globals, you can easily substitute them for new functions.
Here's an example:

print = function()
   error("you may not use print")
end

print("Hello World!") --# This doesn't work anymore and will error.

You can also maintain the old functions' purpose while also executing your own code:

local oldPrint = print
print = function(...)
   oldPrint(...)
   error("you may kind of use print...")
end

print("Hello World!") --# Prints the text and errors.
CCGrimHaxor #8
Posted 13 January 2015 - 04:41 PM
Since the bios functions are globals, you can easily substitute them for new functions.
Here's an example:

print = function()
   error("you may not use print")
end

print("Hello World!") --# This doesn't work anymore and will error.

You can also maintain the old functions' purpose while also executing your own code:

local oldPrint = print
print = function(...)
   oldPrint(...)
   error("you may kind of use print...")
end

print("Hello World!") --# Prints the text and errors.

Nice but I need the users to see the function codes exectly as they are in the bios.
Lignum #9
Posted 13 January 2015 - 04:56 PM
Nice but I need the users to see the function codes exectly as they are in the bios.

You mean that other programs are affected by this as well? They are.
If you use the code above, all calls to print made on the computer will error until it's restarted. By all I mean all, even other programs, which is also the reason why you shouldn't use globals in your programs. They're reserved for stuff like this.

… or do you mean that you want to view the function's source?
Viewing a function's source is impossible without having the full file it's in. And even if you had the file, you'd have to write a piece of code to find and output the function's source, which is quite difficult to do considering the crazy things you can do with Lua. The closest you can get is string.dump(function), which returns the function's bytecode. However to humans it's just gibberish, so it's not of much use…
KingofGamesYami #10
Posted 13 January 2015 - 05:02 PM
..which is why he wants the file, which is impossible.
Lyqyd #11
Posted 13 January 2015 - 06:49 PM
Nice but I need the users to see the function codes exectly as they are in the bios.

You still haven't explained exactly what you're trying to do, or why this requirement is necessary. It is likely possible to achieve whatever functionality you're actually seeking without needing to copy the bios.lua file. What is it that you are wanting to do to the functions?
MKlegoman357 #12
Posted 13 January 2015 - 06:51 PM
Well from Lua bytecode it is possible to convert back to source but in this situation it shouldn't be used. Nor in any situation really. I'd suggest hosting a few versions of BIOS somewhere and then trying to detect which CC version it is running in to select the appropriate BIOS. The detection could be based on function and API changes in different CC versions. You can find the changelog in the CC wiki. For example, detecting if a program is running in CC 1.6+:


if type(term.native) == "function" then
  print("Running in CC 1.6 or higher")
else
  print("Running in CC 1.58 or lower")
end

EDIT: why is everyone asking why does he want the way he wants it? He sort of stated that in the OP:

Ok guys so I am creating a way better version of CCRoot and what I need to do is grab the actual bios.lua…

Here's the link to CCRoot if anyone is still wondering why is he asking for it :)/>. He's just making a copy of the bios and rom so users would be able to make changes to it.
Edited on 13 January 2015 - 05:57 PM
CCGrimHaxor #13
Posted 13 January 2015 - 08:58 PM
Well from Lua bytecode it is possible to convert back to source but in this situation it shouldn't be used. Nor in any situation really. I'd suggest hosting a few versions of BIOS somewhere and then trying to detect which CC version it is running in to select the appropriate BIOS. The detection could be based on function and API changes in different CC versions. You can find the changelog in the CC wiki. For example, detecting if a program is running in CC 1.6+:


if type(term.native) == "function" then
  print("Running in CC 1.6 or higher")
else
  print("Running in CC 1.58 or lower")
end

EDIT: why is everyone asking why does he want the way he wants it? He sort of stated that in the OP:

Ok guys so I am creating a way better version of CCRoot and what I need to do is grab the actual bios.lua…

Here's the link to CCRoot if anyone is still wondering why is he asking for it :)/>/>. He's just making a copy of the bios and rom so users would be able to make changes to it.
I guess I am gonna have to do it like that until someone finds a way to fully access the bios itself. I know it is kind of impossible but I was hoping with the top level coroutine you couls get the abillity to actually inject the code in a way to make it read itself and place the read file in the root.