I've been writing up a bios for my drone with one major snag: text output will be a nightmare. I can't think of a "clean" way to implement a way of searching for a new line, since every space on the monitor technically has the observed text value of "" (when I added an if function to see if gpu.get returned "", it pulled through and outputted gpu.set(1,2). the previously non-occupied line had a value of "" rather than nil. also, type() is saying the type of the unoccupied space was a string).
First I took a peek at the term API, since I couldn't figure out where print was defined in openOS.
function term.write(value,wrap)local stdout = io.output()local stream = stdout and stdout.stream
local previous_wrap = stream.wrap
stream.wrap = wrap ==nilandtrueor wrap
stdout:write(value)
stdout:flush()
stream.wrap = previous_wrap
end
Surprise surprise, it relies on the IO library, which is a part of the filesystem library. Naturally, I took a look at the IO library's output function.
function io.input(file)return io.stream(0, file,'r')endfunction io.output(file)return io.stream(1, file,'w')endfunction io.error(file)return io.stream(2, file,'w')end
It simply returns io.stream, so that's where I look next.
function io.stream(fd,file,mode)
checkArg(1,fd,'number')assert(fd>=0,'fd must be >= 0. 0 is input, 1 is stdout, 2 is stderr')if file thenif type(file)=="string"thenlocal result, reason = io.open(file, mode)ifnot result then
error(reason,2)end
file = result
elseif not io.type(file)then
error("bad argument #1 (string or file expected, got ".. type(file)..")",2)endrequire("process").info().data.io[fd]= file
endreturnrequire("process").info().data.io[fd]end
This is what confuses me. io.output is passing file. Not a string, not a file path, not anything. Just file. What is this 'file' and what does it have to do with text output? Why are so many basic lua functionalities missing without openOS?
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I've been writing up a bios for my drone with one major snag: text output will be a nightmare. I can't think of a "clean" way to implement a way of searching for a new line, since every space on the monitor technically has the observed text value of "" (when I added an if function to see if gpu.get returned "", it pulled through and outputted gpu.set(1,2). the previously non-occupied line had a value of "" rather than nil. also, type() is saying the type of the unoccupied space was a string).
First I took a peek at the term API, since I couldn't figure out where print was defined in openOS.
Surprise surprise, it relies on the IO library, which is a part of the filesystem library. Naturally, I took a look at the IO library's output function.
It simply returns io.stream, so that's where I look next.
This is what confuses me. io.output is passing file. Not a string, not a file path, not anything. Just file. What is this 'file' and what does it have to do with text output? Why are so many basic lua functionalities missing without openOS?
Link to post
Share on other sites