Hey everyone funshine X here welcome back to another computer craft tutorial for Minecraft 1.6 we are today going to discuss monitors both basic monitors and advanced monitors if you missed the beginning episodes we covered how to craft these already so I’m not going to show that I’ll pretty much show Everything you can do with the monitor and more we’re not going to go into doing user interfaces or gooeys in this tutorial I want to just cover how to use the monitor first when I write the code because the GUI once you know all the functions that you can do is basically Up to you to design and I will try and have a Advanced Course later on in the tutorial series on how to do a GUI you know the basics and best practices for displaying gooeys and handling the user input so let’s get going with monitors First thing you want to know is that we have both the standard type is the gray kind and that’s what use a stone for and we’ve got the gold cut kind which is the advanced monitor and uses a uses gold to build and when you put a monitor down It’s going to grow to the size that you place it so I can place it on top of my computer and then I can go ahead and and grow it and you see every time I make a rectangle or square it will combine and make one multi block which is pretty cool Regular monitors will not combine with advanced and that’s pretty much it the other thing you need to know about this is the maximum size you can have is 8 across and 6 tall which is a very big monitor we go look out here that is HUGE Um yeah that’s pretty crazy so you can watch a pretty nice movie on that thing and I’ll show you a movie later ok so we know how big monitors we can make the very easiest way you can do is take your programs that you’ve already written and Run them on a monitor so there’s a program called hello and all it does is write hello world right now if we wanted to display this on the monitor instead of on the terminal we would just say monitor and then we say the top or the side The monitors connected to which in this case is the top you don’t have to put it in quotes or anything and then you type the name of the program which is called hello now if I hit enter and run it up here you’ll see hello world okay now it Didn’t do it as nice blue and it didn’t slowly come in it’s all gray and stuff but that’s just the way that this monitor everything is set up to go so yeah so we can do other things like if we wanted to clear the screen you know Clear works here right well we can also say monitor top clear and it will clear the monitor so any program that you have you can run on the monitor that’s that’s easy to do okay but we want to do more advanced stuff than that so let’s let’s Clear this and let’s start getting into the actual functions monitors are peripherals so the same thing we did with disk drives and Printers to access them so we if we go into the little program we can say monitor equals peripheral rap in the top right that’s Familiar you should know how to do that already and now we have a handle to this monitor and we can call all of the monitors methods if we just type monitor we’d get a table so that doesn’t really help how do we know what all the methods Are one of the easiest ways to do it is to say just give it a name called methods and say peripheral oh come on peripheral dot get methods of the top okay and that on its own is not going to do anything but if we run a line of code I’ll explain what it means in just a minute so we’re to do a for loop we’re have two variables we only care about the second one so we just put an underscore for the first one that’s just a notation to say it’s returning you know I could do K and V or I and J or anything but I don’t really care about this one so don’t waste any memory or anything’s trying to save that value just give me the V and and we’re going to call the pair’s method and this is a way to interact With tables and I saw it sorry we’re getting away from monitors a little bit we have to go in a little bit of Lua coding logic so you understand this works but we’re just saying take this table which is a table of keys and values and I wanted you to find each Pair that’s in that table and here’s the table that we’re doing it and print out something I want to print out the value of e okay and we need to put an end loop and we need to do in here try to do this too fast okay so Basically I went through that whole table which is a list of methods and it printed out the list of methods so that’s all it did pretty easy but that pairs method a function is very handy it’s useful in a lot of applications so you can see there’s a ton of methods we Can call on this peripheral so now what we know the way are we can take that monitor value that we got up above and we can call any of these so we can say monitor dot clear and it will clear the monitor monitor your dot right you see And it’s going to write ABC up there okay so let’s talk about what all these methods do first you’ve got the ones that give you some information about the monitor that’s very helpful to know especially when you’re writing a program that might be reused by someone else you Might want to know things about the monitor that are using is they might have not have made it the same way as you so the two methods that they’re there is the is color method which is available in both American English and King’s English I guess with the oh you For color and you’ve also got a get size so let’s go ahead and say monitor dot is culling and it should return true and if we replace this guy with a normal one should return false okay so that’s pretty easy monitor that get size is very simple as well it’s going to give You two values the first is the width the second is the height so obviously you’re gonna if you want to store those values in a program you would do something like with comma height equals monitor get size and then you could display the width or do something with The width okay if we break this monitor make them a little smaller now you can see that it changes so he’s still 50 why because only five tall okay and then you can do the same thing this way now he’s is not as wide okay so that’s how to get Information about the monitor that’s really all we have that’s really all we need okay now we want to maybe do some things that change as parents of the text on the monitor that’s pretty easy we have we can change the scale of the text on the monitor we Can change the color if it’s a golden monitor advance monitor of both the text and the background so let’s do some of those let’s say monitor dot set background color it’s pretty easy and remember case sensitivity is important here so don’t do like back capital D you know ground and then we Use the colors array and we can pick any of the minecraft colors all 16 of them right so let’s do colors dot red okay and nothing happened well all we’ve done is set the background color that it’s going to use when it writes text to the screen so right now hasn’t done anything It’s set the background color but it hasn’t printed out anything right so if we do monitor dot write ABC you can see where it wrote ABC it’s going to change the background color so that’s handy if you want to make like a button and so You can print you know kind of like a background color around the text and make it look like a button on the screen but there’s another way you can just change the whole screens color and that’s just calling monitor clear basically monitor dry clear just writes a space character to the entire buffer Of the monitor and so when it’s writing a character we’ll set the background color so monitor clear will change the entire background color okay monitor dot set text color and let’s use a colors dot green it’s going to look hideous but oops no quotes what am i doing there we go So again nothing’s happened but if we now write monitor dot right hello you can see now it’s in green okay that’s pretty easy and if we were to you know change the background color back to color stop black which is the default and then clear we get back to black and If we did monitor right we’re still going to hit green text we haven’t changed the type of the text value back to white so maybe we do that as well that’s very something very important is when you’re writing a program and other people are using it It’s always important at the end of the program to set your montt your colors both of your terminal and your monitor back to black and white you know just so some of the else doesn’t run their program and all of a sudden it’s all these funky colors right so that’s a Very handy you know habit to get in is to you know always set your background color in your text color back to their default values okay and the other one we talked about was monitored set text scale valid values here you need to give it a value inside the brackets you can Go between 0.5 which is the minimum all the way up to 5 and if you do something in between it doesn’t really work very well so I would suggest only doing point 5 1 2 3 or 4 or 5 so let’s start with a very smallest which is 0.5 right this is Small now we can see wow look how small that is okay and you can see it affected all the text right even the text we’ve already written we routed with row hello there so we go monitor dot set text sky duck scale too it’s going to affect the entire screen So it moved it way over it’s big and if we go to the biggest I don’t think we’ll even see it but you can see at the biggest size one character takes up a full height of a monitor block so you can only get one line of text this is Really nice for doing marquees like a very sign in front of your Forge or your house or something you can say funshine’s house you know it’s really easy to make a sign if you set the text scale really big like that so that’s very useful there okay what’s next well You notice when we were doing this I wrote some some some text and then I cleared it and then I wrote some text again and it started way over here when I cleared it now it’s starting way over here let me get this back to a decent scale here There we go so if I were to write some more text on here you can see it’s going to output it way over there so basically monitors store where their cursor is and the cursor is always set to the end of whatever you last wrote so that’s very Easy to append text so you just start writing text and then you write some more text and it just keeps appending it but it does not there’s no word wrap so if we get to the edge here it’s just going to keep trying to write into oblivion right it’s basically not going To show up so we need to be able to change and modify where the cursor is also what if we wanted to keep writing at the left side of screen so those are really easy we can say monitor dot let’s first use the get method so get curse or Pause and that’s going to give two things with the x value and the y value so we’re over 40 characters to get to there and we’re on the first column our first row sorry 40th column first row of the monitor and now if we wanted to change that monitor dot set cursor Position or cursor pause I’m going to get two values that again the column in the row so let’s go back to the first column let’s go to the third rail and then let’s write out some text okay where is that going to go you can see it Went back all the way over to the first column and the third rail pretty easy so if you want to always write out something to a very specific position of the screen you need to make sure you reset that cursor position every time you write it it’s going to be really Important especially in Gilley’s because you want that GUI to line up and look nice okay so that’s a get inside cursor position the other thing we can do is we can make a blink so monitor dot set cursor blink and we can set it to true Or false and that’s just the same thing you see on this terminal there’s a little underscore and it’s blinking right so if we add a true it’s it’s off by default we set it to true we’re going to see just a little blinking underscore and that’s kind of helpful to know let a User know that your program is running it’s really all the cursor is for other than to know where it is if when they first design operating systems right there no cursor and people if a program hung there was no really way to tell it was hung but if they added this blinking Cursor you know that the computer is is working it’s doing something right it’s waiting for input it’s at least processing if that cursor is solid or off your program is probably hung that’s not do anything so you can use that cursor for that effect you can use it to You know kind of signal to the user hey I’m waiting for you to do something or or that kind of thing so not not useful in a ton of applications but you might have find a reason for it so I wanted to include it here okay oh so that’s how we Do the cursor we’ve already done pretty much everything I wanted to show with the right command that’s basically just right text some other things maybe just for Lua if you want to append so let’s have a value let’s just say a is equal to text screen hello B is equal to world and if we wanted to write that both out together so let’s do just of the cursor position two one five and I’m going to go monitor right and I could do a and then I could say monitor write B and it would it would do it I Mean look hello world right but there’s a better way to do this you can say monitor right the first string which is a and if I do a dot dot that means append whatever it comes next so I can append B and I can do like that and That’s going to write the exact same thing out so you hello world or if maybe I want to space a little better so I can say a dot dot put a little space in there and then append B so you can chain these as much as you want right you know Do anything you want and it’ll work fine so we can see you got monitor hello world world hello KD and all that kind of stuff so I’ll just think if you need a liver that’s really helpful to know how you append strings to get it we’ve already seen monitor clear that clears The entire screen but if you want to just clear a row which is like you know maybe you’re you’re checking the status of an engine or something it’s on or off on and often you want to clear out that value and rewrite it or something you don’t want to clear the whole screen And redraw right that’s really complicated to do so let’s just say monitor clear line and that will clear whatever the current line of the cursor is on so any clear line all that stuff about hello world is gone you can see our cursor still blinking over there but That just cleared the single line okay and the other cool thing is you can scroll monitors they will not scroll by default so if you just say NOC at your cursor position off the screen it’s not going to write any text so you might want to scroll this up you know if they If they start and I don’t know there might be various reasons to scroll things may be displaying a text and I have a story or something so you can say monitor out scroll and you need to say how many lines you want to scroll up so If we just do scroll one it’s going to scroll all the text up one value and see that scrolled off the screen that text is now gone if we scroll back remember we had some green text to the top it’s gone it doesn’t replace it here so just Know if you scroll stuff off the screen and then try and scroll back on the screen you’re gonna have to redraw it it’s gone okay so but we can scroll in the positive or the negative position let’s do minus four and I should bring it way down here so handles down how to Do that and then I wrote another program here just so we can see how that kind of works what’s it called I called it monitor methods and you can see I’m using some different things so it’s telling me you can obviously it’s detecting that this is a color monitor And putting some background color in there it’s detecting the size we got a little cursor blinking over there and let’s actually see what this program is so the first thing I wrap the monitor to the top setting the text scale to one just in case somebody else didn’t set it To one and it’s now I’m using their value getting the width and height checking if it’s color or not setting the cursor position to the first column and then the row white take the height of the monitor divided by two very handy to Center text on the screen take the Height of it / – right and I clear the monitor I’ve checked if it’s a color monitor I’m go ahead and change the background and remember what I said earlier if we change the background it doesn’t actually do anything we want to actually change the whole entire monitors Background we need to put a clear in there and then I write some text out and remember because monitor right just leaves the cursor position at the end I can just write part of the sentence and then keep writing so I changed the text color a couple Times to write out color in kind of some different colors and then I write monitor and that’s it if it’s a black and white monitor I just say we’re using a normal monitor and then the end I go to the next line which is high divided By two plus one and it right out with size and I print out the size it was pretty easy so let’s see that oops go ahead and run that and now you can see it’s and it’s all grey but if I replace this thing with a standard monitor and Run it you can see we’re using a normal monitor so that worked and that’s pretty much it for all the methods of a monitor was there anything else I think there’s a couple of the things I had at the bottom but I think I’ve covered everything I wanted to let’s look at it We already saw how to scroll if you do it in a loop obviously you can you can put a sleep in there and it will scroll kind of up over time I already showed how to set the cursor blink and to clear lines so we’re done with this program it Was just a simple little thing okay the last thing I want to talk to you guys about is the touch event advanced monitors only the gold kind know how to detect if a player right clicks somewhere on the monitor right it doesn’t work for punching especially in Creative right but if you right-click on the monitor it generates an event alright just like if a redstone event happened or some other event in the computer happen like keyboard entry or something that so we can tap that event and let’s what did I call it monitor touch test basically I wrap the Monitor I get the size I’m going to call OS pull event and I’m only interested in the monitor underscore touch event so I don’t care if the redstone or bored or anything else only monitored touch will trigger events and it’s going to return to me in the name of the event It’s going to turn what side the monitor was on generated this event the position on the X and the position on the Y after I get that event I’m going to clear the monitor I’m going to store the information in a nice little string called info and I’m going to go ahead And set the cursor position and this is another way to center text is you take the width divided by two and then you subtract the length of your string so if you use this pound sign here and basically it’s you the length so that’s why I stored this here in a nice string So I can say I don’t this might be one it might be 400 so this is a very variable length string right could be different links so if I save it an info and then I get the length of info and divided by two now this might be something like 52 I by 2 is 25 and if this is 10 divided by 2 is 5 so it printed at call them 20 something like that and then height divided by 2 is really easy okay and then I write it out that’s all I do so let’s go ahead and exit this and do Monitor it was a touch test hope so now we can just go ahead and right click and you can see that was 26 5 and remember this what did we say this well we can check so this is the first column way over here and it doesn’t work if you Click on the yellow part that doesn’t do it has to be on the black you know the actual background so this is 50 remember this monitor was 50 wide so that’s perfect and then a y side we can click all the way up there 1 2 what 12 yeah 12 Perfect and then the center you can see is 26 25 pretty easy so this is very helpful for doing touch screens so you might want to have an interface displayed here it has like some buttons or something and they go up here and they click right here and this is turn Engine on and they right click on it it turns the engine the only way you’re in a know if they clicked on the button is as turn engine on is to find out well I know that my button for turn engine on is on the 4th row it starts at the you Know the tenth column and it ends up the 19th column right so if they click on anywhere in I know they clicked on the button and then I can do something we’re out so applet redstone or something like that so we’ll get into that when we do gooeys And that kind of thing but once you know how to do this touch event it’s really just up to you to kind of go okay I want to print some stuff on the screen for them to click on and when they click find out where they clicked and then Based on that do some logic to determine what they actually clicked on so that’s going to be really helpful for you to do these touch monitors pretty cool someone on computer craft I just the forums I just look to see if it that it was done and literally 40 minutes ago before I Ran the search I had no idea was there I just went home I wonder if somebody’s done that already I went to the commuter graphed forums I typed it in a search and it’s there it just happened to be posted like an hour ago maybe now and that’s cookie clicker someone is done Cookie clicker in Minecraft and I’m not going to show it to you I’ll let you guys go and I’ll put his link in the description you guys can go download his program and play cookie click your hand minecraft on computers so that’s pretty cool what I will show you is if we got Here on the giant monitor let’s go ahead and set the mood here so it’s time set night not set time there we go and let’s go back here to the actual computer and you see the before we we had our monitor on the top This one’s just on the back and so if I do monitor back a long time ago and we go around here and we can see if you didn’t know it already computer craft has episode 4 of Star Wars built in it’s it’s there you don’t have to do anything And you just run it on a monitor you want to use a max size monitor for the best effect and of course do it at night build yourself a little car and sit down and you’re at the drive-in movie theater I’ll just let it go a little bit cool I Think this is awesome it’s one of the coolest things when I rigidly saw computer craft I’m like no way somebody put a motion picture you know minecraft animation you got c-3po and r2d2 they’re pretty cool anyway so if you want to do that yourself if you I Know most people probably know about it but if you don’t it’s in ROM programs secret and it’s called a long time ago and it’ll run on a terminal itself but it’s much more impressive to run it on a monitor a little c-3po guys that’s going to do it for computer craft tutorials on Monitors if I missed anything go ahead and put it in the comments there the next thing I think we’re going to do is modems both wireless and wired modems so until then this has been fun shine X I’ll catch you next time bye Video Information
This video, titled ‘ComputerCraft Tutorials for Minecraft 1.6 – Part 6 : Monitors’, was uploaded by FunshineX on 2013-09-25 09:28:22. It has garnered 66144 views and 518 likes. The duration of the video is 00:24:55 or 1495 seconds.
In this episode we cover both basic and advanced monitors. Topics include writing text to monitors, manipulating the display, differences between basic and advanced monitors, and how to use the monitor_touch event.
Code: Coming Soon
Minecraft: https://minecraft.net Forge: http://www.minecraftforge.net/forum/ ComputerCraft: http://www.computercraft.info/