11 posts
Posted 19 September 2012 - 03:56 PM
Hi,
I want to have own "wrapped" functions, like I do with peripheral.wrap(). Can you please give me any link to documentation or anything? I really don't know what to search, so I had to write this.
Thanks a lot,
Trip.
871 posts
Posted 19 September 2012 - 04:14 PM
Wrap isnt magic, it just returns a table containing functions. I'm assuming you want to make something you can redirect term to, in which case you just make a table, write your versions of getCursorPos, setCursorPos, write, etc. and set them into a table, like this…
--can define funcs outside...
function myWrite(text)
--code here
end
--or in the table itself
local myTermWrap={
setCursorPos=function(text) <code> end,
write=myWrite,
etc.
}
I just showed two to demonstrate, you have to do 7 for a proper redirect - set/getCursorPos, getSize, clear, clearLine, write, and setCursorBlink.
11 posts
Posted 19 September 2012 - 04:16 PM
Nice, this is what I wanted. Thanks! :)/>/>
8543 posts
Posted 20 September 2012 - 06:30 AM
Wrap isnt magic, it just returns a table containing functions. I'm assuming you want to make something you can redirect term to, in which case you just make a table, write your versions of getCursorPos, setCursorPos, write, etc. and set them into a table, like this…
--can define funcs outside...
function myWrite(text)
--code here
end
--or in the table itself
local myTermWrap={
setCursorPos=function(text) <code> end,
write=myWrite,
etc.
}
I just showed two to demonstrate, you have to do 7 for a proper redirect - set/getCursorPos, getSize, clear, clearLine, write, and setCursorBlink.
Oh? Is scroll not required?
871 posts
Posted 20 September 2012 - 01:32 PM
oops, no, scroll is definitely required, I just forgot to list it!