computercrafts terminal
Ta©ti_Tac0Z 10 Aug 2018
1. are we limited to the colors in the colors api? I know we can chance sharders or what ever right? can somebody explain? (in opencomputers you are able to give 8bit rgb values but as i understand we can only use hard coded colors)
2. in opencomputers you are able to get whats on a spesific cordinate on the screen
component.gpu.get(x,y)that returned the background color, foreground color, charecter, and color range is this possible in computercraft?
KingofGamesYami 10 Aug 2018
2. No.
Bomb Bloke 11 Aug 2018
ComputerCraft uses a sixteen colour palette. You need v1.80+ in order to change its contents.
You can't get the hardware-based terminal to tell you what it's drawn, but you can write a software buffer with that capability, and then redirect all terminal output through that. For example, it would be fairly trivial to create a modified version of the window API that simply adds a few "get" functions for retrieving buffer contents.
Not really sure why you'd want that, though. The only point I can see to gathering screen content is so that you can redraw it later, and buffers tend to be able to do that without outside help - eg.
Ta©ti_Tac0Z 11 Aug 2018
Bomb Bloke, on 11 August 2018 - 02:00 AM, said:
ComputerCraft uses a sixteen colour palette. You need v1.80+ in order to change its contents.
You can't get the hardware-based terminal to tell you what it's drawn, but you can write a software buffer with that capability, and then redirect all terminal output through that. For example, it would be fairly trivial to create a modified version of the window API that simply adds a few "get" functions for retrieving buffer contents.
Not really sure why you'd want that, though. The only point I can see to gathering screen content is so that you can redraw it later, and buffers tend to be able to do that without outside help - eg.
--OC color exaple (sorry i wasn't clear i meant 8 bit for evrey channel) compunent.gpu.setBackgroundColor(0xffffff) --r:255,g:255,b:255 compunent.gpu.setBackgroundColor(0x000000) --r:0,g:0,b:0
Ta©ti_Tac0Z 11 Aug 2018
anybody know a fix for that btw? slow processors and low RAM (yeah of course this is not the place for a OC qestion i know...)
Edited by Ta©ti_Tac0Z, 11 August 2018 - 09:27 AM.
Ta©ti_Tac0Z 11 Aug 2018
KingofGamesYami, on 10 August 2018 - 08:37 PM, said:
ahhhh ok simpler that i thouth it was but if the funcalaity is there why can't we freely define colors like this...
i know its becuse of servers and its limitations right? but OC pulled it off?
at least let us define new colors
i mean it all is just stubit... the input that goes in term.setBackgroundColor IS a rgb value the problem is that only hard writen rgb values is allowed to be used! its just stubit! again i know the idea is that the color can be send as a single byte to the client on a server but... makeing it rgb will just add 2 extra bytes to the mix i know thats a lot for the biggest resolotion monitor but... can some body back me up here?
KingofGamesYami, on 10 August 2018 - 08:37 PM, said:
fuck well there goes that idea
Ta©ti_Tac0Z 11 Aug 2018
strings in CC is limit to 63 in binary witch was a pain to figere out is that common in lua or is that one more of for-some-reson laying-a-lot-of-power-into-servers thing again?
SquidDev 11 Aug 2018
Ta©ti_Tac0Z, on 11 August 2018 - 08:54 AM, said:
Ta©ti_Tac0Z, on 11 August 2018 - 09:19 AM, said:
Ta©ti_Tac0Z, on 11 August 2018 - 09:19 AM, said:
Bomb Bloke 11 Aug 2018
That said, computers play videos that're larger than their RAM total all the time: it's simply a matter of continuously loading a bit of data from disk, playing it, and then discarding it. The entirety of the video doesn't have to reside all in RAM all at once.
Ta©ti_Tac0Z, on 11 August 2018 - 09:19 AM, said:
If you attempt to run non-ASCII characters through a text mode file or web handle, or print them, older versions of ComputerCraft convert them to \63: a question mark.
In cases where these behaviours are an issue, it's generally best to either use binary mode instead of text mode, or if that's not available (you need CC1.80+ for binary mode web handles for eg), a binary-to-text encoding method such as base64.
Ta©ti_Tac0Z, on 11 August 2018 - 09:14 AM, said:
Actually no, term.setBackgroundColor accepts indexes into ComputerCraft's sixteen colour palette, effectively rounding them off if you pass it any other numeric value. colours.orange doesn't actually hold a representation of the colour orange, for example - it merely holds a palette index.
And as mentioned, as of v1.80, you can redefine the colours within that palette.
Ta©ti_Tac0Z 12 Aug 2018
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
as i said the format is made by me and all bits are loaded at the same time (for now anyway) so indeed a computercraft computer is storeing a table with 270KB of data in side it in RAM
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
Ta©ti_Tac0Z, on 11 August 2018 - 09:19 AM, said:
If you attempt to run non-ASCII characters through a text mode file or web handle, or print them, older versions of ComputerCraft convert them to \63: a question mark.
In cases where these behaviours are an issue, it's generally best to either use binary mode instead of text mode, or if that's not available (you need CC1.80+ for binary mode web handles for eg), a binary-to-text encoding method such as base64.
yes thats why i use a table insted of a string now
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
wrong...:
the organges rgb color value is 2 (EDIT: not just the color index) as stated in the table: http://computercraft...ki/Colors_(API)
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
as mentioned i said add not chance
SquidDev, on 11 August 2018 - 09:37 AM, said:
Ta©ti_Tac0Z, on 11 August 2018 - 09:19 AM, said:
Edited by Ta©ti_Tac0Z, 12 August 2018 - 01:19 PM.
Ta©ti_Tac0Z 12 Aug 2018
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
if you look closely you will be able to see some fligere and lag mainly becuse the speed of witch lua commands are run in OC is limited to the speed factor of the proccesor used
Ta©ti_Tac0Z 12 Aug 2018
SquidDev, on 11 August 2018 - 09:37 AM, said:
Ta©ti_Tac0Z, on 11 August 2018 - 08:54 AM, said:
EDIT: i'm useing the magical ram yes
i may be stubit but the links... i don't really understand
Edited by Ta©ti_Tac0Z, 12 August 2018 - 01:34 PM.
valithor 12 Aug 2018
Ta©ti_Tac0Z, on 12 August 2018 - 01:27 PM, said:
os.clock()
Returns the amount of time since the in-game computer was started.
http://www.computerc...o/wiki/Os.clock
KingofGamesYami 12 Aug 2018
Ta©ti_Tac0Z, on 12 August 2018 - 01:16 PM, said:
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
wrong...:
the organges rgb color value is 2 (EDIT: not just the color index) as stated in the table: http://computercraft...ki/Colors_(API)
You are mistaken. "2" is not an RGB value.
ComputerCraft uses binary indexes (2^0,2^1,2^2 ... 2^15). This is primarily to support passing multiple colors as one number to bundled cables. For example, to turn on blue and green you would pass 2^11 + 2^13, or 10,240 in base 10.
The RGB value of colors.orange is, by default, red 242, green 178, blue 51, as shown in the Display column of the table you reference.
Ta©ti_Tac0Z 12 Aug 2018
valithor, on 12 August 2018 - 02:09 PM, said:
Ta©ti_Tac0Z, on 12 August 2018 - 01:27 PM, said:
os.clock()
Returns the amount of time since the in-game computer was started.
http://www.computerc...o/wiki/Os.clock
ahhh i seached for "time" (ctrl+f) in the os api overview but i some how didn't see os.clock, thanks
KingofGamesYami, on 12 August 2018 - 03:25 PM, said:
Ta©ti_Tac0Z, on 12 August 2018 - 01:16 PM, said:
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
wrong...:
the organges rgb color value is 2 (EDIT: not just the color index) as stated in the table: http://computercraft...ki/Colors_(API)
You are mistaken. "2" is not an RGB value.
ComputerCraft uses binary indexes (2^0,2^1,2^2 ... 2^15). This is primarily to support passing multiple colors as one number to bundled cables. For example, to turn on blue and green you would pass 2^11 + 2^13, or 10,240 in base 10.
The RGB value of colors.orange is, by default, red 242, green 178, blue 51, as shown in the Display column of the table you reference.
...
ohhhh well what do i saw? sorry bomb block, yeah it does make sence like that i see
KingofGamesYami, on 12 August 2018 - 03:25 PM, said:
This is primarily to support passing multiple colors as one number to bundled cables. For example, to turn on blue and green you would pass 2^11 + 2^13
yeah there is a exable of that in the wiki i can't see the use for it tho, i mean why go throw so much truble so we can do that?
anyway i find it complitly absulete that the color chanceing functions uses these large numbers when it just makes them to the (0-15) way anyway, i know we can make bit oprations becuse of that but it still sems unesesary
if i took my time and looked at the table in just 60sec more i whould see the patten (0x0,0x01,0x001,0x001, ...) but my fingers typed before that ):
Ta©ti_Tac0Z 12 Aug 2018
Bomb Bloke, on 11 August 2018 - 02:00 AM, said:
am not a fan of editing apis and even less when they are build in
i surpose a nother way to do this is that the program witch need to get screen infomation is the one running the targeted program the problem i see with that is the fact the the term api is being redefined after makeing a new lua env. witch will overwrite any chances further then that as i know computercraft doesn't like the idea of you editing a api table at runtime like this do it?
i hate the idea of haveing a all most exact copy of the window api laying around, any other way of doing that?
the other way is to rewire the gfx functions such as:
function write(str) term.write(str) --add the text and the cord'ss to some global table end --and so on
but that whould be a pain and the method is no longer universal (given that a program need to be writen with this in mind)
if the rewirting of the window api is the only option (witch i hope it isn't) have some body done that and uploaded it some where (i don't know how the window api function or work, i nerver use it)
Ta©ti_Tac0Z 13 Aug 2018
so what you're telling me is that if i make a table of function witch works at the same way then that whould work
tho am running into a qestion
so if we say we make the function:
buffer = {} T = {} function buffer.write(str) T[#T + 1] = {str, term.getCursorPos(), etc...} term.write(str) end
given that as i understand when a redirect is made all calls gets redirected to the buffer so whouldn't this try to run term.write for ever and make a infinet loop?
B = term B.writeTerm = B.write T = {} print("fine 1") function B.write(str) T[#T + 1] = str term.writeTerm(str) end print("fine2") term.redirect(B)/>/>/> print("fine3") term.write("TEST! HALLO WOLRD!\n") term.redirect(term.native()) print(#T, T[#T])
yeah there is that infintet loop i was talking about
EDIT: it sems that
bufferis a global value used by the term api or some thing becuse the computer chashes when i use buffer insted of B
Edited by Ta©ti_Tac0Z, 13 August 2018 - 12:09 AM.
Bomb Bloke 13 Aug 2018
KingofGamesYami, on 12 August 2018 - 03:25 PM, said:
Heh, well, it is, but it certainly doesn't come out to be orange.
Ta©ti_Tac0Z, on 12 August 2018 - 05:06 PM, said:
KingofGamesYami, on 12 August 2018 - 03:25 PM, said:
yeah there is a exable of that in the wiki i can't see the use for it tho, i mean why go throw so much truble so we can do that?
Bundled cables can be very useful! Being able to send up to sixteen different redstone signals through each block makes for much more compact builds, and they also allow a single ComputerCraft computer to send out many more redstone signals than it'd otherwise be able to.
If you're asking why the colour values are treated as bitflags, that's simply because it's by far the easiest way to do it. Any other method would be much more complex.
Ta©ti_Tac0Z, on 12 August 2018 - 11:36 PM, said:
No, it's not - the term API should contain the same function pointers from the moment a computer boots until the moment it shuts down.
When you use term.redirect(), you're changing the terminal object that the functions in the term table will work with in future, but those functions themselves remain the same. You can change your environment table all you like and it won't mess with that fact.
Ta©ti_Tac0Z, on 12 August 2018 - 11:36 PM, said:
I suppose you could write a "not" almost exact copy? Whatever you find fun.
Ta©ti_Tac0Z, on 13 August 2018 - 12:05 AM, said:
Yes, that's exactly what window.create() makes for you, for example.
Ta©ti_Tac0Z, on 13 August 2018 - 12:05 AM, said:
If you did it like that, then yes, you'd have an infinite loop. So instead you might do:
local parentTerm = term.current() --# Record the terminal object currently in use. local buffer = {} local T = {} function buffer.write(str) T[#T + 1] = {str, parentTerm.getCursorPos(), etc...} parentTerm.write(str) end
In this case, the previous terminal object you were directing output to acts as a "parent" to the new terminal object you're constructing: the output gets recorded in T, and then displayed through the parent.
It's also important to note that the terminal you start off with probably won't actually be term.native(). When an advanced computer boots, it starts up multishell, which in turn uses window objects to manage tabs. Even if you only have one tab open (and hence don't have the multishell tab bar visible), that tab is still outputting its content through one of those windows.
RecGif has a ten line snippet that builds a "recording" terminal like the one you seem interested in, covering lines 65 to 75. This constructs one function in the recTerm table for every function in the oldTerm table (term.current(), which is again acting as a parent), each of which runs the equivalent parent function while recording in the curCalls table. After redirecting to the recTerm object, lines 86 to 117 run the script to be recorded in a special way that allows the addition of timing and user input information to be added to curCalls, and later in the script, the data recorded in curCalls is used to build a GIF animation.
Edited by Bomb Bloke, 13 August 2018 - 03:52 AM.
Ta©ti_Tac0Z 13 Aug 2018
oldTerm = term.current() recTerm = {} T = {} for key, func in pairs(oldTerm) do print(key) --os.pullEvent() os.sleep() if key == "write" or key == "clear" or key == "clearLine" then --if true then recTerm[key] = function(...) local result = {pcall(func, ...)} if result[1] then --curCalls[callCount] = {key, ...} --callCount = callCount + 1 local x,y = term.getCursorPos() local mainArg = ({...})[1] if mainArg == nil then mainArg = "nil" end T[#T + 1] = {key, mainArg, x,y, term.getBackgroundColor(), term.getTextColor()} return unpack(result, 2) else error(result[2], 2) end end else recTerm[key] = func end end term.redirect(recTerm) --record env. start term.setCursorPos(1,1) term.clear() term.write("THIS WORKS!") term.setCursorPos(1,2) print("great with this infomation in hand i can easy do what i want") os.sleep(3) term.setCursorPos(1,2) term.clearLine() term.setCursorPos(1,3) term.clearLine() os.sleep(3) term.clear() --print(term.getCursorPos()) --record env. end term.redirect(oldTerm) print() for key,value in ipairs(T) do os.sleep(1.5) print(key) print(" command: "..value[1]) print(" text: "..value[2]) print(" cursor: x: "..value[3]..", y: "..value[4]) print(" background color: "..value[5]) print(" text color: "..value[6]) --for key2,value2 in ipairs(value) do -- print(" "..tostring(value2)) --end end
thanks!
Ta©ti_Tac0Z 17 Aug 2018
Ta©ti_Tac0Z, on 12 August 2018 - 01:27 PM, said:
Bomb Bloke, on 11 August 2018 - 02:37 PM, said:
if you look closely you will be able to see some fligere and lag mainly becuse the speed of witch lua commands are run in OC is limited to the speed factor of the proccesor used
a guy on the opencomputers forum explained that only one compunent call is allowed per tick meaning that the terminal in OC is limited to 4 updates/calls per sec! good bye OC ):
that is game breaking ):