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

Get local string from bios

Started by CCGrimHaxor, 16 February 2015 - 01:08 PM
CCGrimHaxor #1
Posted 16 February 2015 - 02:08 PM
Let me change this a little bit

Basicly this is in the bios.lua:

if true then
local data1 = "ok"
local data2 = true
local data3 = "done"
local data4 = "k"
function getData()
if data2 then
return data4
else
return data3
end
end
function getDataX()
return data1
end
end

What I wanna get is data3 but as you can see it is hardcoded in
The only way would be to override the functions!

So because this is in bios.lua I have found a working TLCO by Geforce Fan. Now there is a problem
his TLCO overrides the function printError wich is not even close to getData.
Let me show you:
When I override the printError it looks like this:

if true then
--You know what is in here
-- We want to be here
end
-- But we are here:
function printError(txt)
--Our location
end

Now how would I make it go to the place I want and get data3?
And I don't know how overriding works so that might also be a problem

Hope you can help

Thanks
Edited on 27 February 2015 - 10:15 AM
InDieTasten #2
Posted 16 February 2015 - 02:21 PM
Either I'm stupid or your code just says nothing about your intention. I mean, you can override txt in your –Code here section, but this seems too obvious to me than it being the answer.
Lignum #3
Posted 16 February 2015 - 02:52 PM
the variable is a local variable

Unless you have the debug API available, which is disabled in ComputerCraft, you can't.
CCGrimHaxor #4
Posted 16 February 2015 - 02:54 PM
the variable is a local variable

Unless you have the debug API available, which is disabled in ComputerCraft, you can't.

But we are overriding the variable in the same file as the override function
Lignum #5
Posted 16 February 2015 - 03:01 PM
But we are overriding the variable in the same file as the override function

Um, as InDieTasten said, I'm not sure how you define "override" but isn't the solution just the obvious then?

local txt = "" -- The variable we need to override
function os.pullEvent(filt) -- We are overriding this function
   txt = "your text"
   os_pullEvent(filt) -- Execute the original pullEvent
end
Dragon53535 #6
Posted 19 February 2015 - 06:37 PM
If I understand the problem he's facing here, He's trying to edit a local variable from the bios, which i'm pretty sure you can't do.
KingofGamesYami #7
Posted 19 February 2015 - 10:24 PM
If I understand the problem he's facing here, He's trying to edit a local variable from the bios, which i'm pretty sure you can't do.

Yeah, he is. The only thing I can think of is overwriting a function it calls (ei rednet.run) which we can obviously do with TLCO, unless I totally missed the purpose of it.
Bomb Bloke #8
Posted 19 February 2015 - 11:32 PM
You still wouldn't have access to the BIOS's local variables at the time when you were defining your new function, so you still couldn't have it refer to them.
InDieTasten #9
Posted 20 February 2015 - 10:54 AM
Well his Fire-Root thingy is actually a replacement for the bios, so in my understanding the code in the OP is actually part of the bios. This is as far as I would imagine. Otherwise true, accessing the bios chunk out of the bios is not possible. only globally defined things can be redefined
CCGrimHaxor #10
Posted 27 February 2015 - 11:14 AM
Updated it sorry for not responding.
Sadly that's not what I was looking for
Lyqyd #11
Posted 27 February 2015 - 04:45 PM
You'd likely need the debug library to get the value, and that's obviously unavailable. What are you actually trying to retrieve?
CCGrimHaxor #12
Posted 27 February 2015 - 05:19 PM
You'd likely need the debug library to get the value, and that's obviously unavailable. What are you actually trying to retrieve?

A string idk what it contains but I know it is used for some sort of "key" in the custom bios. While this string is only available to certin computer IDs. The reason I know is because I helped develop this bios. Now if you think that why not just check the source for the key here is the reason it is dynamic meaning it changes every time on of those IDs want it to change.