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

[CC 1.51 | MC 1.5.2] Scanner Peripheral v0.4

Started by Orwell, 03 November 2012 - 04:27 PM
Orwell #1
Posted 03 November 2012 - 05:27 PM
The Scanner Peripheral does just what the name says. You put a printed page in the scanner and read the contents of the page from a computer.

In the meanwhile I've been ever busy with studies and other semi-important stuff. I have a code base ready for a more universal version that will be able to scan all sorts of things like items all through the same API. I kind of lost interest when I couldn't find a good return format that was intuitive to use, but I received a decent comment on that from Symmetric. So it seems that I will finish this for CC 1.52 when I find time in between my finals.

Until then, gamax92 did a great job porting version 0.4 (the one without the extras) to CC 1.51. You can find it in the downloads section under here. gamax92's explanation can be found in this post. Thanks a lot man for helping out! Be sure to give him a +1!

Download here:Old downloads:
Spoiler- 0.3: Universal (Dropbox)
- 0.2: Universal (Dropbox)
- 0.1: Universal (Dropbox)

Requirements:
- Minecraft 1.4.2 or above
- ComputerCraft 1.46 or above
- latest stable release of Forge

Changelog:
Spoiler0.1:
- First upload
0.2:
- Fixed Shift+Click bug
0.3:
- Added support for reading the writable books from vanilla Minecraft
- Added the method 'getAuthor()'
- Added the method 'getPageSize()'
0.4:
- Fixed incompatibility with BuildCraft (computers without textures)

API:
SpoilerWrap the peripheral as always:

local side = "right"
local scanner = peripheral.wrap(side)

Get the page count, zero when no page is inserted:

scanner.getPageCount()

Get the title of the page:

scanner.getTitle()

Get a character at specified position:

scanner.getChar(x,y)
scanner.getChar(x,y,page)

Get the colour of a character at specified position:

scanner.getColour(x,y)
scanner.getColour(x,y,page)
or

scanner.getColor(x,y)
scanner.getColor(x,y,page)

Get the author of a vanilla writable book (returns nil for ComputerCraft printouts)

scanner.getAuthor()

Get the size of one page depending on what is in the scanner (ComputerCraft, vanilla or nothing)

local x,y = scanner.getPageSize()

Recipe (always open to suggestions):
Spoiler

Stone + Redstone Lamp + Glass Pane

Screenshots:
Spoiler
Spoiler
Spoiler

Please, don't hesitate to post bug reports and comments under this post.
Tiin57 #2
Posted 03 November 2012 - 10:59 PM
Absolutely amazing. Well done.
Orwell #3
Posted 04 November 2012 - 03:33 AM
Shift+Click on an item in the scanner caused a crash. Fixed in version 0.2.

And thank you, tiin. :D/>/>
darkrising #4
Posted 04 November 2012 - 07:21 AM
Really love this :D/>/>
Orwell #5
Posted 04 November 2012 - 04:49 PM
Added support for reading the 'Book and Quill' and 'Written Book' items from vanilla Minecraft. Also added the methods 'getAuthor()' and 'getPageSize()'.
If you have anymore suggestions, please post them and I'll be happy to consider them.

Thanks for the kind remark, darkrising. :D/>/>
darkrising #6
Posted 04 November 2012 - 04:58 PM
Added support for reading the 'Book and Quill' and 'Written Book' items from vanilla Minecraft. Also added the methods 'getAuthor()' and 'getPageSize()'.
If you have anymore suggestions, please post them and I'll be happy to consider them.

Thanks for the kind remark, darkrising. :D/>/>

Really nice work mate! already made myself a cheque book reader :)/>/>
masterdisasterHD #7
Posted 04 November 2012 - 10:32 PM
your scanner v3 removes the textures from the computers O_o

i dont know if it is suppose to do that

–HD–
Orwell #8
Posted 04 November 2012 - 10:48 PM
your scanner v3 removes the textures from the computers O_o

i dont know if it is suppose to do that

–HD–

No, that's not supposed to happen. :D/>/> And I don't really get how my mod could cause this.. But I'll look into it tonight, when I'm home.

Are you sure it's my mod? Is anyone else encountering this problem too?
Orwell #9
Posted 05 November 2012 - 04:40 PM
I've just did multiple tests and I've got no issues at all with version 0.3; computer textures are just fine. I just noticed that this version is installed on the BlackWolf server (also got no problem there), so the owner there probably doesn't have the issue either.

Still, If anyone else is encountering this problem, can they please post it? :D/>/>
TecmagDiams #10
Posted 05 November 2012 - 05:32 PM
I also have that problem. I am using a handful of other mods, but it specifically if I put scanners in that the computers lose texture. I'll get back to you later when I have more details on what causes it, perhaps I will find another mod that I have that it specifically happens with, don't know yet though.

I really want to use this peripheral too! :D/>/>
Cloudy #11
Posted 05 November 2012 - 11:54 PM
Screenshot?
Orwell #12
Posted 06 November 2012 - 01:01 AM
Yes, a screenshot would be nice. Also, can you post a list of the mods you're using? And do the computers loose texture when placing a scanner anywhere, or only when placing it next to each other? Do you use a texturepack?
TecmagDiams #13
Posted 06 November 2012 - 05:12 AM
There isn't really anything to take a screenshot of…
When your mod is installed, computers lose texture. End of story, invisible computers. Again, ( already said I would look into the mod list I am just busy at the time.
Orwell #14
Posted 06 November 2012 - 07:25 AM
My question was directed at you and masterdisasterHD. :P/>/> I've already heard of about 7 people for which this version works just fine. So I'm quite sure it's due to incompatibility with some other mod (or texturepack maybe?).
TecmagDiams #15
Posted 06 November 2012 - 12:13 PM
I had some time and thought I would go back through my mods to isolate which one this was having a strange conflict with.

When using your Scanner Peripheral in combination with "BuildCraft-universal-3.1.8.206" the computers lose texture and become invisible.
Orwell #16
Posted 07 November 2012 - 05:41 AM
Thank you TecmagDiams for putting your effort in this! Version 0.4 fixes the incompatibility with BuildCraft and is now up for download (see OP). No more disappearing computers.
masterdisasterHD #17
Posted 08 November 2012 - 04:38 AM
Thank you TecmagDiams for putting your effort in this! Version 0.4 fixes the incompatibility with BuildCraft and is now up for download (see OP). No more disappearing computers.

told ya
Orwell #18
Posted 08 November 2012 - 05:31 AM
told ya
Indeed, thanks to you too. :P/>/>
Ehrlingby #19
Posted 26 November 2012 - 12:08 AM
Is this compatible with MC 1.4.5? If not, please update this amazing peripheral. I've been using it all the time for secure password storage.
Orwell #20
Posted 27 November 2012 - 05:39 PM
Is this compatible with MC 1.4.5? If not, please update this amazing peripheral. I've been using it all the time for secure password storage.
Sorry, I have been out of town for the last few days. I was planning on upgrading this peripheral but I sort of forgot. A version for CC 1.47 is now available in the OP. :)/> And thanks for the positive feedback, it's always nice to get that.
Ehrlingby #21
Posted 27 November 2012 - 10:46 PM
Thanks for the update. I can dig out my old auth server code now!
ryanertel #22
Posted 16 December 2012 - 10:43 AM
Hello, i have been using the scanner peripheral for a bit today and i made a door lock that requires a key card(pieces of paper with a string of text on it) and i couldn't put the information from Title = scanner.getTitle() into an if statement because even when it was true it was acting like it wasn't and it was going on to the else. I tested to make sure that it was true by doing print(Title) and it was correct but the if still didn't work so i was wondering if anyone has any idea how to fix this.
Orwell #23
Posted 16 December 2012 - 03:31 PM
Hello, i have been using the scanner peripheral for a bit today and i made a door lock that requires a key card(pieces of paper with a string of text on it) and i couldn't put the information from Title = scanner.getTitle() into an if statement because even when it was true it was acting like it wasn't and it was going on to the else. I tested to make sure that it was true by doing print(Title) and it was correct but the if still didn't work so i was wondering if anyone has any idea how to fix this.
We will need the actual code for that, then we might be able to help you out. :)/>
ryanertel #24
Posted 16 December 2012 - 04:22 PM
Hello, i have been using the scanner peripheral for a bit today and i made a door lock that requires a key card(pieces of paper with a string of text on it) and i couldn't put the information from Title = scanner.getTitle() into an if statement because even when it was true it was acting like it wasn't and it was going on to the else. I tested to make sure that it was true by doing print(Title) and it was correct but the if still didn't work so i was wondering if anyone has any idea how to fix this.
We will need the actual code for that, then we might be able to help you out. :)/>
oh sorry i was kind of in a hurry :mellow:/> anyways here's the code
it probably isn't the best code that you could use but i'm a beginner to lua and coding in general so it's the best i could do.
Spoilerscanner = peripheral.wrap("left")
Title = scanner.getTitle()
if (Title == Password)
then redstone.setOutput("back", true)
sleep(6.5)
redstone.setOutput("back", false)
else print("Wrong Password")
sleep(1.0)
os.reboot()
end
immibis #25
Posted 16 December 2012 - 08:25 PM
Hello, i have been using the scanner peripheral for a bit today and i made a door lock that requires a key card(pieces of paper with a string of text on it) and i couldn't put the information from Title = scanner.getTitle() into an if statement because even when it was true it was acting like it wasn't and it was going on to the else. I tested to make sure that it was true by doing print(Title) and it was correct but the if still didn't work so i was wondering if anyone has any idea how to fix this.
We will need the actual code for that, then we might be able to help you out. :)/>
oh sorry i was kind of in a hurry :mellow:/> anyways here's the code
it probably isn't the best code that you could use but i'm a beginner to lua and coding in general so it's the best i could do.
Spoilerscanner = peripheral.wrap("left")
Title = scanner.getTitle()
if (Title == Password)
then redstone.setOutput("back", true)
sleep(6.5)
redstone.setOutput("back", false)
else print("Wrong Password")
sleep(1.0)
os.reboot()
end
"if (Title == Password) then" compares the contents of the variables Title and Password. Password is always nil, because you haven't set it. Title is a string, so it can never equal Password.
ryanertel #26
Posted 17 December 2012 - 12:01 PM
Hello, i have been using the scanner peripheral for a bit today and i made a door lock that requires a key card(pieces of paper with a string of text on it) and i couldn't put the information from Title = scanner.getTitle() into an if statement because even when it was true it was acting like it wasn't and it was going on to the else. I tested to make sure that it was true by doing print(Title) and it was correct but the if still didn't work so i was wondering if anyone has any idea how to fix this.
We will need the actual code for that, then we might be able to help you out. :)/>
oh sorry i was kind of in a hurry :mellow:/> anyways here's the code
it probably isn't the best code that you could use but i'm a beginner to lua and coding in general so it's the best i could do.
Spoilerscanner = peripheral.wrap("left")
Title = scanner.getTitle()
if (Title == Password)
then redstone.setOutput("back", true)
sleep(6.5)
redstone.setOutput("back", false)
else print("Wrong Password")
sleep(1.0)
os.reboot()
end
"if (Title == Password) then" compares the contents of the variables Title and Password. Password is always nil, because you haven't set it. Title is a string, so it can never equal Password.
no no no Title is the output from the scanner after Title = scanner.getTitle() and if the output from the scanner is Password(which is the actual password) then it runs redstone.setOutput("back", true)
ryanertel #27
Posted 17 December 2012 - 12:04 PM
Hello, i have been using the scanner peripheral for a bit today and i made a door lock that requires a key card(pieces of paper with a string of text on it) and i couldn't put the information from Title = scanner.getTitle() into an if statement because even when it was true it was acting like it wasn't and it was going on to the else. I tested to make sure that it was true by doing print(Title) and it was correct but the if still didn't work so i was wondering if anyone has any idea how to fix this.
We will need the actual code for that, then we might be able to help you out. :)/>
oh sorry i was kind of in a hurry :mellow:/> anyways here's the code
it probably isn't the best code that you could use but i'm a beginner to lua and coding in general so it's the best i could do.
Spoilerscanner = peripheral.wrap("left")
Title = scanner.getTitle()
if (Title == Password)
then redstone.setOutput("back", true)
sleep(6.5)
redstone.setOutput("back", false)
else print("Wrong Password")
sleep(1.0)
os.reboot()
end
"if (Title == Password) then" compares the contents of the variables Title and Password. Password is always nil, because you haven't set it. Title is a string, so it can never equal Password.
no no no Title is the output from the scanner after Title = scanner.getTitle() and if the output from the scanner is Password(which is the actual password) then it runs redstone.setOutput("back", true)
Nevermind btw i figured out why it didn't work, still dont know how to fix it though so if anyone has any ideas.
Orwell #28
Posted 17 December 2012 - 02:43 PM
Immibis explained it quite well to you. But here is the solution.. Change this line:

if (Tile == Password)
to:

if (Tile == "Password")

In your code, Password is a variable. We can suppose that that variable is a string (basically the same as plain text in this context), but the variable is never defined anywhere, it isn't even declared. So lua has no value for Password and uses nil (no value at all). So it can't compare it against Tile, which is a string. (It's basically checking if "a" == 0). So what you have to do is making clear to Lua that Password is a string and not a variable, which is done by using "Password". You could also put this at top of your code instead of using the quotes:

Password = "Password"
This way, the variable gets the string "Password" assigned, so your if statement know against which it has to compare Tile.

And if you care, you can drop the parentheses as well.
Meni #29
Posted 17 December 2012 - 02:50 PM
You may do an animation of the lip opening and closing and add it to peripheral methods would be funny :)/>
Orwell #30
Posted 17 December 2012 - 02:59 PM
Doesn't the lid open and close for you..? :mellow:/> It does for me on both single and multiplayer. I thought of adding it to the API, but I thought it would be sort of unrealistic. Also, I'm not sure if anyone found this out yet, but when someone is in the scanner GUI (and thus the lid is open), the scanner will return all empty strings and black text color for each position on the paper. Kind of what an actual scanner would do when the lid is open. :)/>
theoriginalbit #31
Posted 18 December 2012 - 01:15 AM
this is awesome! One request though. Is it possible that you implement a full scan? that returns a table of the document lines.
Orwell #32
Posted 18 December 2012 - 05:33 AM
this is awesome! One request though. Is it possible that you implement a full scan? that returns a table of the document lines.
I was thinking about this yesterday. :P/> I didn't do that originally because I wanted to keep consistence with the terminal, monitor and printer. But when you're scanning an item, it cannot change because the item is in the scanner. Thus I could as well return a 2D array, because it's static data at that moment. So your request will be worked on. ;)/> My exams are coming really close though, so I'll have trouble finding a free moment somewhere to work on it.
seal6000 #33
Posted 04 January 2013 - 07:15 AM
Please update to CC 1.48, I really miss this peripheral.
Orwell #34
Posted 04 January 2013 - 07:17 AM
Please update to CC 1.48, I really miss this peripheral.
Well, I'm having exams at the moment, but I'll try and squeeze some time out in the near future. :)/>
Meni #35
Posted 29 January 2013 - 04:26 PM
Orwell im sorry for the time that a took to reply this post but is everything working fine! A very cool peripheral that can be use,for exemple, to translate codes.
Nice work!
Aquilamo #36
Posted 01 February 2013 - 08:54 PM
This is such an amazing peripheral, I really hope that your exams ends soon so you can update it :lol:/>
Orwell #37
Posted 10 February 2013 - 04:33 PM
The end of my exams ran late because of illness. :mellow:/> I'm done now and just catching up with other business IRL that got postponed. I've basically ported this to the latest version of CC for about 2 weeks now, but I stranded on implementing a new format.

I decided to return the content in the form of tables (yes, this would break compatibility, but it's worth it IMO). So you'd still have getTitle() and getAuthor(). But also a getScan(). getScan() would return a table which has the values ['title'] = "some title" and ["pageSize"]={25,29}, but should also have the actual content.
For now I had something like this:

local scan = scanner.getScan()
local pages = scan.getContent()
local page = pages[1]
local pixel = page[y][x] -- with an actual x and y
local char = pixel.char
local textColor = pixel.textColor
local backgroundColor = pixel.backgroundColor
This is basically the layout of the table. However, I am totally not satisfied with the structure of this table as it doesn't seem intuitive to me. I'd love to get some input from you all on how I the table containing the character/color data should be structured.
masterdisasterHD #38
Posted 24 February 2013 - 12:19 AM
Hello orwell i was wondering if you had a release date for the next update yet.

sincerely HD
Orwell #39
Posted 26 February 2013 - 05:49 PM
Hello orwell i was wondering if you had a release date for the next update yet.

sincerely HD
I'm sort of waiting on input on the post above yours. I just can't figure out which format to put the data in and as this seems to get a bit of attention I hoped to use a format favorable for all.
Jamboozlez #40
Posted 04 April 2013 - 04:47 AM
I really hope that this peripheral gets updated soon! It looks amazing and would be really useful.

EDIT: Maybe you should put this in your signature? Then it will bump up your thread popularity and get some answers to that table thing ;)/>
Aptik #41
Posted 12 April 2013 - 02:19 AM
Waiting for support of CC 1.52
Sariaz #42
Posted 15 April 2013 - 06:34 AM
Realy great have some ideas of some cool stuff to do with this mainly involving tubes shooting mail through my home and being displayed on computers :P/>. I would suggest thought that you add support for printed pages and printed books not just single printed page if that is possible if not still great mod.
Orwell #43
Posted 09 May 2013 - 06:34 PM
Realy great have some ideas of some cool stuff to do with this mainly involving tubes shooting mail through my home and being displayed on computers :P/>. I would suggest thought that you add support for printed pages and printed books not just single printed page if that is possible if not still great mod.
It does support those allready. Since I picked CC up again after 3 months today, I'll look into updating this peripheral.
Mandrake Fernflower #44
Posted 25 May 2013 - 07:08 PM
A piece of hardware like this should be added to a future build of CC
Symmetryc #45
Posted 27 May 2013 - 07:15 PM
It seems like a hassle to get a single character or pixel, how about you add arguments to help people get specific things? Like this:

pages = scan.getScan() -- returns the whole table
page1 = scan.getScan(1) -- returns specific pages
page4 = scan.getScan(4)
text = ""
for i=1, 10 do
  pixel = scan.getScan(1, i, 1, char) -- args are (page#, x, y, "char"/"textColor"/"backgroundColor")
  text = text..pixel
end
print(text) -- string of 10 numbers at start of page 1
gamax92 #46
Posted 01 June 2013 - 06:24 PM
After getting permission from Orwell, I'd like to present a port of CCScanner to 1.5.2 Minecraft

CCScanner_CC1.51-0.4.zip - Download here

This port is kinda hacky, in the regard that no effort has been made (yet) to properly impliment the new texture changes brought on by 1.5 MC.
The code is still exactly the same as the one in 0.4, just a few changes here and there to get to 1.5.2 minecraft, no reduced functionality.
One minor detail is that breaking the block will act like its missing its block texture, but all the textures are there and do show up.

I'm currently working on properly implimenting textures but for now, it works and is properly usable.
Script Kiddie #47
Posted 10 June 2013 - 05:04 AM
can i use this peripheral with printer? so i can duplicate a printed paper :)/>
and please add a video to use the scanner add an example program for it
thanks
ccbad #48
Posted 10 June 2013 - 02:10 PM
You know what would be a good implementation of this? Making a fax machine. scanner and a printer hooked up to a computer, run, say, fax. scan. Sends through rednet via wired, wireless or immubus LAN cables. prints out page on other computer. Now all i need is to figure out how to code it….
Orwell #49
Posted 10 June 2013 - 10:01 PM
can i use this peripheral with printer? so i can duplicate a printed paper :)/>
and please add a video to use the scanner add an example program for it
thanks
Yes, you can use it with the printer. Usage is in the OP. If you can't read that, a video won't do you much good either.
You know what would be a good implementation of this? Making a fax machine. scanner and a printer hooked up to a computer, run, say, fax. scan. Sends through rednet via wired, wireless or immubus LAN cables. prints out page on other computer. Now all i need is to figure out how to code it….
I've seen people do it before (quite often actually), so it is possible. :)/> Have fun coding that! Also (shameless self-promotion): http://www.computercraft.info/forums2/index.php?/topic/4515-142apimulticolor-printer-api-mcp/
Script Kiddie #50
Posted 11 June 2013 - 05:07 AM
You know what would be a good implementation of this? Making a fax machine. scanner and a printer hooked up to a computer, run, say, fax. scan. Sends through rednet via wired, wireless or immubus LAN cables. prints out page on other computer. Now all i need is to figure out how to code it….
yeah, i think so.
Yes, you can use it with the printer. Usage is in the OP. If you can't read that, a video won't do you much good either.
I've seen people do it before (quite often actually), so it is possible. :)/> Have fun coding that! Also (shameless self-promotion): http://www.computerc...rinter-api-mcp/
can you give me an example code to do it?
now i can only print it on the screen after scanning :(/> . and only scan 1 character + title.
can you tell me how to scan the whole page?

please answer!
vitzli #51
Posted 21 June 2013 - 06:11 AM
can you give me an example code to do it?

loop over character coordinates:
http://pastebin.com/3TRPSr7n

I've got a strange behaviour: I cannot put a book inside with pipes, buildcraft chutes and vanilla hoppers: pipes look connected, but drop books when they arrive. I didn't try AE buses, but Factorization's Routers and MFR's Router-like machines (and conveyors too) cannot put signed books inside. The only machine that somehow managed to insert book was AssemblyLine's manipulator.
NOTUSEDPLEASEDELETE #52
Posted 19 July 2013 - 04:51 PM
Great work on it but can you update it to 1.6.2?