Learn The GDScript Programming Language | Michael Mcguire | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Learn The GDScript Programming Language

teacher avatar Michael Mcguire, Author | Programmer | Twitch Streamer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

41 Lessons (4h 15m)
    • 1. 01 Introduction

      2:37
    • 2. 02 Our IDE and GDScript Examples

      5:41
    • 3. 03 Printing To The Console

      13:41
    • 4. 04 GDScript Arithmetic

      7:51
    • 5. 05 Comments

      3:48
    • 6. 06 Variables

      9:41
    • 7. 07 Constants

      4:34
    • 8. 08 Object Methods

      5:38
    • 9. 09 Signals and Assigning Your Input to Variables

      8:05
    • 10. 10 String Interpolation and Display Text

      7:00
    • 11. 11 Integers, Floats, Rounding

      4:04
    • 12. 12 Converting Between Floats, Integers and Strings

      9:29
    • 13. 13 Booleans and Comparison with the Equality Operators

      7:38
    • 14. 14 Less Than and Greater Than Operators

      4:00
    • 15. 15 Introduction To Methods

      5:02
    • 16. 16 Local Variables

      3:55
    • 17. 17 Parameters and Arguments

      6:42
    • 18. 18 If Statements

      4:37
    • 19. 19 elif Statement

      5:36
    • 20. 20 else Statements

      3:48
    • 21. 21 Multiple Conditions I

      3:45
    • 22. 22 Multiple Conditions II

      4:35
    • 23. 23 Nested if and internal Function calls

      10:20
    • 24. 24 Ternary Operation

      4:14
    • 25. 25 Default Parameters

      4:42
    • 26. 26 The in Operator

      3:16
    • 27. 27 while Loops and Yield

      7:00
    • 28. 28 Range and Random Numbers

      9:34
    • 29. 29 What is an Array

      1:57
    • 30. 30 Getting Array Indeces

      3:34
    • 31. 31 Array Methods

      7:57
    • 32. 32 Convert String to Array

      5:11
    • 33. 33 Dictionaries

      10:03
    • 34. 34 Keyboard Input

      2:54
    • 35. 35 Saving and Loading Settings Files

      13:47
    • 36. 36 Further Your Knowledge and Thank You

      8:07
    • 37. 37 Using and Getting OS Info

      9:56
    • 38. 38 Custom Signals

      6:51
    • 39. Exercise 1

      3:16
    • 40. Exercise 2

      6:51
    • 41. Exercise 3

      3:38
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

413

Students

--

Projects

About This Class

A comprehensive course on the GDScript programming language. This language is a great starting point being easy enough for a new person wanting to learn to program without any of the intimidation! Whether you've never written a line of code before or are looking to learn a brand new language, this course covers all bases!

Lessons include:

  • Installation and configuration

  • Common Programming Concepts and Terms

  • Objects and Methods

  • Strings, Numbers, Booleans

  • Ranges

  • Arrays

  • Methods

  • Functions

and more!

GDScript is a high level, dynamically typed programming language used to create content. It uses a syntax similar to Python (blocks are indent-based and many keywords are similar). Its goal is to be optimized for and tightly integrated with Godot Engine, allowing great flexibility for content creation and integration for software and video game development.

Meet Your Teacher

Teacher Profile Image

Michael Mcguire

Author | Programmer | Twitch Streamer

Teacher

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. 01 Introduction: welcome everybody to my course on learning the programming language. GG script. Now, to give you just a little bit of an idea of what this language has been used to create, we have one example here, a game. Somebody sorry, um, of a software somebody has created. Rick is up on steam, as you can see, and this allows you to create particle events little vfx that you could make or that you can use for thinking gaming. Happy more of the pixel, retro style or an HD style. And you can export this into a Sprite sheets or easy animation. So that's kind of a cool little software that has been created using this language. Next up, we have a game called Final Storm, which is a twin stick shooter. Quinn stick shooters are fairly old at this point, though. There are there still that group of people out there that love to play them. You can see just an example here of what you could make game wise. You could make a lot higher quality things, but and, of course, a lot lower. Graphically, things are only always getting better, and you'll see more examples in in our next video. But another little program that people have made here using this is this little over here. We can actually create a fantasy map for your so where you can use all these tools. Ground ground painting, lad. Vast Generation River tool path tool. As you see, they've added mountains, trees in branding little pathways and text for little villages. And all these really cool things that you can dio. Look at this. It's awesome. Now, if you want to make software or games or anything like that, you can do that with this language. And once you're done with going through this course, you'll know everything that you need. They get self going and either direction. 2. 02 Our IDE and GDScript Examples: already everybody. So in order to jump into teaching you the g d scrip programming language, we're obviously going to need on I d e of some sort to use the language in north script. So for this, we're going to use go dot or good. Oh, you prefer? So come on over to the website and download. Let's go ahead and pick up the standard version here. And if you would like to grab the templates to export any projects that you make with this language in the future, scroll down and you see the template here. Now, if you're curious about what kind of things have been made with the GED script program language because maybe maybe you've never heard of it or you just knew the coating off together Well, we just take a look here with God. Um, well, software and games here, for example, who got Wonder draft, which is a little program, or creating Max here? You see, Now that's pretty cool. We've got a little three D presentation here for making presentation over on steam. We got rvp in a box which is used for people to allow the creator on games. Got blast FX and other software that you can use for creating particles. Different particles, both HD and retro style. We've got final Storm. A nice little twin stick shooter you made with him with a brick wall. Who got city gave studio made in this language. Three. We've also got some three D things made in here with intrepid. Over. We have somebody's own little personal project here as 1/3 person suit. I'm gonna assume here. Clear They haven't admitted their doors. We've got a first person here. Maybe that's more your thing. If you're into you're looking to maybe make a game in the future with this language, we got a variety about come here or examples. So you whether you wanna use this language for creating games or software, you'll be able to create that using this language if you so choose, um, you could also develop for mobile as well. They do have mobile export if you want to make a game or software or just a nap in general or in mobile device a concert. But now that you've got our little i d downloaded, you've seen some examples people have created you know, I feel like I showed you guys a little more games and have on the software side. So we'll see that. Want to make software or some sort? I've got some quick, random things together. So if you want to make, like, maybe your own little animated E book or just a visual representation of maybe a guidebook that you make, you can have something intractable like that. My well, you just our little example. Um what else? I've also got an RSS reader that I've created within the script. Language open. You see, We go home, we could get our little laying. We get our little description here, but through So you could do that. Orson settings you could put in a New York. How? If you want it, I've got a little test thing here with, Apparently does not have any interface, but over here in the council, we can use this for checking to see if we have any input drops to see if maybe a key on your keyboard something is learn to screw up, you know, so you can do something there. We got a text editor, which I showed up in another course on how to grate a text better. And if you do not want your lives listed, I sure you know how to remove all that and everything open, say, new save elections everything you need for a little text editor. So there's a wide variety of possibilities out there that you can use the script for or use this programming wing tour. Avi it software or gaming two D three d mobile. Whatever it is, you'll be able to do it in here. There's gonna be up to you, your imagination and your ability to pull it all together. All right, I'll see guys in the next video, we'll jump into starting the language. 3. 03 Printing To The Console: all right, now, when we opened up, go dot or again, Goto whichever you prefer. This is the screen will be met with. And you may not have all of these down here. Some of these are templates for you to take a look at and learn from. Um, but again, depending on where you got your from, you may or may not have them, but we're not going to need them for this. Displaying all that you're may be different. So we're gonna go over to the right hand side here, click new project, and I'm just gonna call mine. Keep the screw course. Now, if you'd like to change the path that this will be saved in, you can go ahead and hit, browse and things that if you're fine with where it is, which will be your documents by default, let's go ahead and create Boulder and your render you have open G l three and two two is going to be more compatible now, potentially less issues with some devices. What if you like to go with three? You definitely can not to be completely up to you. Um, I was gonna leave my hat on three. But it shouldn't make any difference how we go through the course. So when you made your decision, go ahead and create and edit and I don't just give go down a moment to go ahead and open this up. And here we are. So a quick overview of the U. S. He don't get lost over on the right hand side is our inspector and are no panel. And over here on the left, we have ever seen and import pigs and then under that, we have our vital system. Now, if you would like, you can feel free to just pick them up and move them wherever you would like. There's your doctor positions. I'm just gonna leave mine as default here. I am probably fine with this, And in order to attach a script, we're gonna need something to attach it to. So you can click on any of these and they will work just fine. Using either the two D node really node control user interface. Or if you want to use custom no, then you can just select the default. I am gonna go ahead and used user interface eso and now to give me a control note here now to attach a script so we can start going into our code. You just click this little script icon here on our left hand side over and are seeing through here right up here. Yes. Quick. That and that's gonna open up this little window here to attach a script to it. Now, language course, we're gonna slay Jean de Script because that's what we're learning here. Gonna inherit from the control node, which is fine. Um, if you chose to use a No. Two D, this inherit here is going to say no to D If he did three d, then this is gonna say spatial. That is perfectly fine. It's not gonna affect anything for just going through the scores here, template. We're gonna go ahead and slipped no comments, just so that we can keep our script nice and queen and not have any distraction going to go through. And then if you look change the path within your holder, fear you can. But I'm just gonna leave it where it is perfectly fine and hit. Create. Now, here we are in our very first script. Now, the first thing we have here is extends. And then we have a word here which is gonna be control or spatial or No. Two D. What have we had selected there? And that's basically gonna tell this what we can and can't use as far as some some of our kind of commands, for the most part. And it's not gonna anything that we're doing but rather going into some specifics. So, for example, one note may be able to do something that another note can. And that's where getting that right type is gonna be very specific. But let's not waste any more time we're gonna jump into are ready section here. And this ready section is basically just going to we see, do whatever we say underneath here as soon as the script runs. Now, our script here in Judy script does work off of a tab function. So you see, if we were all the way to the far left here, we're going to get an error because we need an intent inside of here to stick it inside of our ready function. So just keep that aware it get that red line going across. So if you have never it might just be because you don't have something indented so we just erase or delete the word passed there. Bergen New print, right on out to our cup, our council, which we write down here at the bottom where you see output. If you click that, that would just open up now for a script in order to print something to our council. Here it is very simple. We just type of word print, open and closed parentheses. And now, whatever we stick inside of these parentheses, it will print out to the council. But what we're going to need to do is do with double quotes. Or you can use single quotes to surround what it is you want to print on out. So we could do double quotes. Just type in there. Hello, world. And to show you the same there we use single quotes. We're gonna get these same. Let's go ahead. Just hit. Play up in the top, right here. Yes, to confirm and just go ahead and hit So you And now you see down here in our output council , we have hello world written out there and then see what to do. Single quotes were double quotes. It's going to come out exactly the same now when we're printing things, go and delete are second line there. When we are printing things we can do, we can actually attacks two groups together. So if we had the word hello written here we have another one here for world. Now this is gonna ever out because we need to either put a comma to split them up. We just hit, play select and open. You'll see we don't have any space in here when we just put that comma. We don't have any space in there where we put that comma. But so what we can dio is at the beginning Ah, world here just before the W or after the Owen Hello. We just for a space. And if we play that again, we run that. It'll look exactly the same as it did before. So we'll have our space in there now. Another way that we can attach to things together is we could just simply put a plus in between now. This, of course, is only gonna come in handy when you need Teoh attached two of these together so depending on what it is you need, Teoh put out. You may or may not even need to worry about that. But print isn't the only way that we can print something out to our consulate there. If we just come on down, we can dio prints with an s on the end and then our open closed parentheses and our quotations inside. And we could do hello world here, but and it would look exactly the same. However, this time, if we have our two seconds like this with our comment between and we just run that it's gonna automatically put a space in between are words here. That's because with Prince that last s on the end. Is there space? So whenever you're listing things off like this, it's gonna put a space in between them, which is nice. If you don't want toe, remember to put spaces in between your lists and you just wanna get him out there another way that we can print. Our council is with print with two teas. Now this second t stands for tab, so we'll just go ahead and do hello world with our comma in between again. But this time but when we run it, it's gonna look a little different. It's gonna have a tab space in between rather than just a normal space. So you can see there are very different ways that we can print out to our council and depending how we do it, we can get different results. So which one you use will be up to you for the most part and usually dependent on maybe the information that you want to print and how you want it to display to make it easier for you to read. But in most cases, we can't just leave prints and Prince. There is, ah, some other ways of printing through council, says Printer with two R's, but it looks exactly the same as print, so I'm not really sure why this version of printing exists. We just come in here we could do hello and world and run that and you see it looks exactly the same. It's smashed together. Uh, we could do it with the plus, and we put our space in there. Now it looks the same as print did, so I'm not sure why printer is its own function, or it's old method in here just because it functions exactly the same has the regular print . We went over at the top, but those are all the different ways that you can print out to your counsel. So go ahead, mess around with that. If you want to practice a little bit more, print out some messages to yourself. Experiment with the different print methods there, and when you feel comfortable with that, go ahead and move on to the next step in the course. 4. 04 GDScript Arithmetic: All right, everyone. I've got ahead and deleted our all the print that we had there. But we're gonna go ahead and continue using our print that we weaken. Keep getting everything out to our council. So arithmetic or maths weaken do that pretty simple. Here in TV script, we can just simply put out our number. And then operator, what could be like, plus minus, um, times divide, etcetera, and it will print out our total. It would complete that math equation for us so we can do like five plus two. And predictably, that's going to give us seven as our result down here in the council and the gang do by and we can subtract two R minus two with that operator and that will provide us with and predictable three that we can continue and do that where oh, are multiplier here, which is just the Asterix key up there on the num pad. Or if you don't have that, you can hold shipped and press it and we run that that will predictably give us 10. Now, where you might run into an issue is when it comes to your division. If we do five divided by two. You see, that's only going to give us too, because they could only go into it two times 24 and then it can't go in anymore. It would have a desperate We have a remainder left over. But we're not seeing that here. And that is because this is these are integers. And when we use integers in our mathematical equation, it wants to spit back out as another integer. Now, if we use a floating number, which is a number that has a decimal point in it, then it will return to us a decimal point. So we all weaken Dio to fix that is to five decimal zero or we could do to decimal zero. You need to do this for one of them. And now when we run that world, get our whole 2.5. So we get our whole equation that way. So that's something to keep in mind when you're doing division equations. Now, what if you want to do something a little more advance in your math, you know, maybe dio and exponents while to dio exponents or do a number to the power of simply, we can simply print this out and and say We want to continue with our train here and do five. And we wanted to be to the power of to allowed to do that. We're gonna do p o W for power open and closed parentheses. And inside of there were do five comma two and that's going to give us five to the power of to what's a simple BR five times five. And we print that out now to give us our 25. And of course, if we did this to power three, we have five times five times five, giving us 125. If you need to do something like square root, this is gonna have again a similar process. U s que are tee open and close parentheses and inside of that where we'll go ahead and stick a number. Ah, Would you, uh, let's just 25 and we run that and we will see the square root 25 year, which is five. Of course, if we have and off number you see, we don't have to do. We do not have to make that a floating number. It would just give us our whole decimal number down here when we do square roots. So that's nice, toe. Keep in mind with that, you don't have to make any changes. Now, we don't have to just stop at one operator here. We can add on to this so we can do, say, print. We didn't makes, like, all these together. We wanted to Let's get by to the power of to And then, outside that parentheses of our power, we could go ahead and say, plus five. And then, um I don't know we can. It's a minus the square root of 89. And now you see, we've got multiple got three equations. We have two separate equations going on, and then we have another equation in the middle. So first, we're going to get our exploded here five to the power to, and we're gonna get our square root of 89 that we're gonna add five and then subtract or square root of it. So we go ahead and run that you see, we're gonna get 20.5601 night so you can go ahead and uses many of these operators, as you would like, or your math equations when you want square root. If you want to dio exponents division Just keep in mind that make one from a floating number, which just simply means making one of them a decimal number. That way you get more exact results. And then all of our other simple ones, they're multiplication addition and subtraction. Um, the other way, who are using something like our addition Operator, is what you saw in the last video when we're going over the prints method where we can add to two things together that are within our quotations. But that'll, for most part, cover up our respective Keir and how that works within G D script. So if you wanna mess around with some of that makes him our equations or figure out your own, you can go ahead and do that mess around with that until you feel comfortable and when you're ready. I'll see you in the next video. What? We will continue with our lessons 5. 05 Comments: All right, everybody in this video, we're gonna talk about comments. And what are they? How we can use though, and why we should use them now. You can see this time I've left everything that we printed from the previous video, and the reason for that is so we could really explain comments a little easier. Now, what is a common a comment is anything that follows this hash tag or pound symbol, whatever you would like to call it. And anything after that on that line will not be considered part of the go. It won't be printed. It won't be. It won't run within the script so won't trigger. In this case, it would trigger an error because that's just complete nonsense. Now we can use this to just make notes to ourselves or to anyone else that may have to look at Angkor, go through our code in the future. And one example of doing this is we could do this after our code. Such is like this. Just let us know. Prince, If I was to what would you do it that way? And if we go ahead and run that you'll see that won't affect our code. It'll still print out seven. But it's going Teoh, ignore everything that came after our comments on here. Now you can completely comic help, a piece of code. We're going ahead and placing that before. And now you see, we're not gonna get that five times to that's not gonna run. And our three that we have down here in our output is not gonna be there anymore. We're gonna go from seven straight to the 10 because we want from our addition straight to our multiplication there, so that could be useful. If you need Teoh, make a comment to yourself or you want to write something else The steps to make writing a code easier or, if you need you may be remove a part of your coat or just disable apart temporarily. Now you can do this quickly instead of going through doing that, especially if you need to do multiple lines of code at once. You can just hold control and hit Kay. And that'll commented, although and again this control k again uncommon. If you're just doing one line, it doesn't matter where your quick this control. Okay, now just comment out that entire line. So that's if every what comments are, how we can use them and why we may want to use them. It makes it a lot easier if we want to. Maybe jump to us, sir. Part trip. This will help us maybe in the future, or help other developers that may have to go back and look at it or whatever. It is very useful, and you should get in the habit of using them. You don't keep your code a little more organized. That'll do it for comments. Also, you guys in the next video. 6. 06 Variables: Alright, everybody in this video, we're gonna go over variables. What are they? How can we use them? And how can we change them? A variable is something that we can used to almost like store data into. Now, this can be anything from just some information that you may need to reference later or if you're maybe playing or creating a game where your player gets to name themselves and you want to be able to call it a player by that name in touch form, for example, Um, some other reasons in software you may need to store it so you can use it later or in another part for some reason. But the way we create variables is one type B a r space, and then we type the name of our variable. Now, to do this to stay in good practice, you want to use all lower case and cannot use any space is if you need a space such as for doing first name, and you need that space in there this deal and underscore Now variables are very case sensitive. So that variable and this look and this variable, for example, would be two completely different things. Same as Epley. You know where to go like this, for example, they'd still be completely different variables. So your case does matter here now to assign some kind of data to this variable If we want to assign something to it immediately well, we have to do with this equals. And then whatever we wanted to be, we can make this afloat weekend. Just make it an integer We can do a string, which is anything inside A quotation marks Uh, weaken Dio. We can simply just look for pure boss. Whatever we want to assign to this variable, that's all we have to squint equals and whatever data we want to put it there and out when doing this. Whatever happens on the right of the equal sign, what happened? Burst And then that will assign to the variable. Now, when we select our variable names, you have to be careful not only for the case, but yet Make sure you do not use any keywords that is already in use by Genie script. For example, if we just his name, it's not gonna yell at us. We got name already exists, so we would have to go first name or acne or something differently. Now we can easily print this out with our very wolf just to print. And instead of doing our quotations inside of our parentheses, we can see us type are variable name and you see, as you start typing it out, the auto complete is gonna pop up with your variable and just finished typing that out or hit Enter in. That should fill it in for you. And now if we run it, we'll see we planted are variable and are variable Gives us this data here and which is what we granted. Now, of course, we could dio another one with We're gonna age and again we could simply just print age And there we go. That was just pop up just like that. Now, if we were to do change age, do something like 25 plus four, that's going to give us the exact same result because our were going to do everything on the right side. Verso 25 plus four, which would give us 29 then it'll assigned 29 to our age like you, just like you see there. Now we can change our variables before printing them out. And to do that, we simply just go later on in our script, just like we have here after we already have our variables established. And we can just go time bar. We just type in our variable name equals and then change that to anything else. Such as is go, Jackie. Now, when we print, since we're changing our variable and then printing, that's gonna print out our new data, Jack. But if we printed first and then changed our data, we're gonna print out the data that we had initially. So the order that changed your variable does matter and can affect the outcome that you may be looking for. Now we can take this a step further with variables and a sign or tell it that the variable can only be a certain thing, such as with our age here. So we can edit are variable. We can tell our variable that has to be a certain tight, um, easily. Rafter are variable name. We just do a colon space and then whatever we want in this case, we want age to be an integer because we don't want to float. Nobody tells you that they're 25.3 years old on the and first name we had a door colon space on. Then we could tell it that it's str which is a strength. Here we go. So that would be string with a capital s and interferes this I nt Now if we were to try and change, uh, first name or age to something that's not string or not an integer this would ever out. So since we're changing first name to Jackie, which is still a string, there's not gonna be any problems. However, if we tried to change this to se integer 26 you see, we're gonna immediately have an error to say assigned value type integer doesn't match the variables tight, which is a strength, so we're not allowed to do that. And if we try to run that anyway, we're just gonna happen ever and it's going to immediately crash. So that is how you can make sure that your variable stays a specific type. If you want to, just make sure that you don't have any or you're not changing the tight end variables and something like Eve Now since again we said that it's an integer we wouldn't be able to say , Turn it into a float age we can assign to a flow, but it's still gonna print it out as an integer, so we're never going to get 29.3 printed out. It's always just gonna be 29 so that'll do it for variables, what they are, how you can change them and how you can assign them to a specific type. If you want to go ahead, mess around with that changeup. Some variables assigned Different tights, um, print them out. Mixing together. However you want to play around with that, go ahead and do that. Make sure if you probably understand variables here and when you're ready again, move on into the next video. 7. 07 Constants: All right, everyone in this video, we're gonna discuss Constance now, a constant will work very much like a variable. We can assign it a specific tight. We can assign it a set amount of data, though there are a few difference, though we can print and use the data later on. We cannot change the data. So once we assign it, we cannot change so much like variables. Uh, for constants, we're gonna do see oh, and s t instead of e a r. And then we're going to give it a name. Would you? Gravity equals nine point. Now, if we want, we could do the colon space and assign it to type. In this case, it would be a blow. But we cannot, uh, try Can't get later If we try to change it to a different tight, it is going to yell in us because we cannot assign new bearable to a constant And that what happened regards If we had this type in there or not, we would still have this issue. Even if we try to eight number, we still cannot assign it. You know, we could, however printed look for use it in an equation, their age minus gravity. But I brought my clothes right there. There we go. You see, we could print gravity and we can use gravity 9.81 which is what we have gravity assigned to and under that we have 19.19 which is our age of 29 minus gravity 9.1 so we can print it and we can use it. But we cannot change it. So a constant is very similar to a variable. Why it has the restriction of never being able to cheat once it's assigned. Yeah, will never change now if you had se, so he left an empty up top. You just had a constant named gravity. It's going to yell at you because it needs something assigned to it, so we have to assign something to it, whereas with a variable, let's just call it gravity's ah, variable. We can leave it blank and then assigned something to it later. That's just some of the differences between a constant and variable, so there may be some situations where you want out, have a constant guests so that you don't accidentally change a piece of data that shouldn't be changed. So with that, hopefully you understood understood that between a constant and a variable on. If you I feel like experimenting a little bit, see what you can and can't do with a constant so more. Then go ahead. And when you feel comfortable already we can move on to the next video. 8. 08 Object Methods: Alright, everybody in this video, we're going to talk about object methods. Now there are a variety of methods that we can use on objects, but the methods that we can and can't use is gonna be very depending upon the type about. It is so things that we use on a string we can't use on, say, like an integer or float or any of the other a rayo different object types s So let's go ahead and jump in. We were just come on in here like So we have a string. One of our methods that we can call on a string is going to be length got late and we do that. We can see that that is going to get our character count here and notice it says 15. If you were to count these out, you may. You might only count 14. And that is because since length is counting characters, a space is also considered a character. That is something to keep in mind. If you're doing something like this, if you just want your character count for something like this. It was just the name Weaken. Take our leg. And then when he just slipped. Subtract one out of it and we could get our numbers that way. What? Some other things that we could dio Yes, we can use a method called to upper. And what this is gonna do is this gonna capitalize? All of our characters that would be like this. You see, everything is now a capital, and as you would expect we do to lower and everything will be in lower case. We do, however, still have yet another method that I personally don't really see use all that often myself . But it is something that you may want to use, especially if you're maybe storing something of the name and that is capitalized. Now, what that will do is they don't capitalize the beginning of each word. So in this case, we have our first word here. That is capital. But then our second word isn't so dot Capitalize is gonna go ahead and makes that tough year for storing again. Something like name. You'll be able to get that problem that proper capitalize structure. Now, even though we have a string here, what we can do is we can actually use this same thing. Ah, are variable name. So if we have a strength or invariable, we can call those methods. So you how are variable? First name will be able to get the same result with not cap as you see there and that will work in with to upper to lower and are capitalizing length. You can go ahead and do something like just put in a test. Ah, little string here, put in a dark and then you can see all the different kind of methods here that you can call upon it Na z Some of these or the majority you may not want to use what they're all here And last the last method here object methods that I wanna touch on is trim, prefix and trim some picks. Now, what this will do is this'll actually trim off beginning of word or your variable, uh, or the ending of it as you would resume with pre fictions. So we just do dot trim prefix and then inside of our opening close parentheses here we just go ahead and say in this case would do it using test word as our screen. If I just get rid of t e from the beginning, we're just gonna have esti space word because we're cutting off that beginning and we get a very similar thing. If we dio some picks, we'll need what, more there and we can cut off the end. Say org an hour. Just have test w and s. You assume again you could use this on your variable if you wanted instead of having toe type in a string. So that will do it. Or our introduction hearing too, using object methods. There is a huge amount in there you saw as we just kept scrolling down to stop strings alone in it's all gonna be dependent upon what kind of calling. So if you feel comfortable with that and you feel ready, I'll see you in the next video. Not feel free to mess around with this a little bit more. Don't be shy, Otto. Ask questions and I'll see you the next video 9. 09 Signals and Assigning Your Input to Variables: All right, one in this video, we're going to go over how we can get input from our player or whoever. If you're going to get software and you need them to input something, we're gonna look at how you can get that info from them and store into our variable here. Now, in order to do that, let's go ahead. And I would just leave. Just are two quotes here and our first name variable. And that way we can have an empty string. It's blank. And that way, when we sign it to something, you know that it's working later. So if we go up here to the top and we just go back to R two D, since our output doesn't have any way receiving and put from us, we can't type in it or anything we're gonna have to create this are so so it's going to come over to our seen tree over here on the left. We could just click on control it this plus sign, and we want to do a line at it that we get input this in here, you're able to type into it. I'm just gonna hit layout here at the top and just center that. And we're also going to need to hit control again. Our control note here and plus and let's get a button. Just a regular button will do. Now over on our right side here with button selected, we have a section context and let's just go ahead and put in there in the world said that way. We know what our button nose now, in order to get information we are not using, tell or give a signal rather that something has happened or three act that's actually called a signal. And a lot of these, which we call knows, have signals already. So with button highlighted, click the No tab beside Inspector over here on the right and you'll see signals, and we have a lot of them. But the one we're looking for is pressed that way. When this button gets crest, it will send a signal to our script and that will tell, of course, our program what to do next. So what is going to go ahead and double click on pressed here and we're gonna make sure we have control selected because we have to attach it into a script and that Noda has one. We have our our method name here, and we'll go over methods later. I low later on in the course, but, um, are you are you need to know is that we haven't named down here And while we have the was hit the connect button, all right, Now, if we go ahead and hit the play button and tested so you'll see we can type into our line at it and we can hit the send button, but nothing happens. And the reason nothing happens is it's sending that signal. But we haven't told it to do anything here yet. So what we want to do, if you want to assign, are variable birth name is and one equal sign who want to assign it in that chair. And we're gonna assign that to the text that we have in our line at it. And the easy way to do that. Yes, we just dio a dollar sign and it is called Lined at it. So we should have dollar sign line at it. And then this is where we're going to use an object method on this known, which is just gonna be got text and we know it's dot text because if we look at this note here, over in the inspector, we can see we have text here, and a lot of these are going to be self explanatory. But if you ever need to find something specific, he could just hold your mouse over and you should get a little pop up military. But that is all we need to do is first name equals our dollar sign line at it dot text. So what that is going to do is get the text that our players and put it in there and assign it to this variable. Now what we can do after that is we can get our wine at it again and get the tax. And we can set that just being an empty string, that we we can clear our techs out of there. I don't Let's just go ahead and print are variable first name and we'll see if it works. Let's go ahead and hit our play button. If we look down here in the council, we have nothing. We can go ahead and type in a name. Let's go with Joe Billy and we hit the send button. And that should a sign our sex here that we haven't hear Joe Billy to our first name. Variable here. And then it'll clear this text out and we should see it burnt out. Yo, Billy, down here in our council and there we go. So we've taken You have learned in here How did hook up a basic signal on how to take a players in point here, which we have to do with our little text box here? And then we've taken that input we've assigned to a variable, and then we just simply cleared that out. It's really simple. Barely. I want to say street or but if you feel confused by that, don't worry. If you need to go back and re watch the beginning of this again, if you need Teoh, ask questions. I helped make yourself comfortable. And, of course, as usual, mess around with this. Maybe try storing some other variables. Ah, on your own. If you feel like you really want to a lot to explore deeper within that, Of course, we know up here are ready function man. If you want to have a little more. I guess you say immersion would be like, What if you're name that way? Our council here, front and center questions. So we would know what we want to enter in here. All right, so that'll do it for this. This video on our very briefing production onto signals how we get player input and then how we can use that in court, which, in this case, we use it this Why printing it right back out to us. 10. 10 String Interpolation and Display Text: All right. You guys say we're gonna talk about how Teoh inter plate our spring into our for our variable. As you see, we can just print birth name. But we couldn't well, like this who are string and this way, something like this. As when we take the cells as our screen, namely whatever we want here. And you see, it's just gonna time about the name of our bearable and not actually put in what we want. So there are two ways that we can go about doing this. We can just dio hello with our space on the end and our second and it would just dio space a lot. And we'll do another space for keeping things neat. The name of our bearable, his first name, space again life. And then we'll do our second string which start with the space. So we have room between our name and our second part of screen to finish your sentence. Oh, are so we'll just go like that. So that is one way that we could do this. Now we look down at our council here. Go ahead. Just time. Name in ese now displays the way we wanted. It doesn't say the name of our variable now, another way that we could accomplish doing this same thing, which is a shorter version and quicker. So even though it's more beneficial when you have a lotto data to replace all at once, we can still use it just to speed up. So we don't do our variable name there and its pluses and my brother spaces and everything like that and do it that way to our prints. And then we could just do one straying like this. Hello, space and where we want our variable to be. I would just do percent. Yes. And with this continue going. How are you now? On the outside of our quotations here was going to do percent and then the variable that wanna fill in where we have that asked which in this case is going to be are variable called first name. So wherever we have percent s, it's gonna replace where their variable first name. Now, if we change this 2% 8 here, it's going to replace R percent s here with our age number. Now we have play that should show up exactly the same. Let's go with Johnny this time. And there you go. So we have two different ways that you could interpret your text in. So now you know how to get texts from our person had to get input and then assign that to a variable. And I know how to use that variable into your chest if you would like. Now, for just so we don't have to keep looking down the council here, I'm gonna go ahead and just said it so we could have our text display on our screen here. And to do that, we're just gonna go our control note. And we just add a text that it it's right on in here when you know the layout and hit center, pull that up and then all we have to do in our scripts is instead of using print here, will you still are dollar sign text at it because that's name hard node equals purser takes that it dot next equals I didn't just leave our string and variable just like we had it. And we could do the same thing down here we wanted. And we would get the same result. Of course, having these both at the same time. Doesn't make much sense since it's gonna switch the one and then quickly switched to the other. So I'm just gonna leave our bottom one here as print so we can have our Harrison. And when we run this look, what we should do is also appear where we have our question. What is your name? I'm just going to change that as well. From print Teoh from print to our text on so we don't keep looking all the way down at the bottom here. Now, when we start up, we'll see What is your name? We could type in. Let's go with Jackie this time send. And now we see that update right here and we see are attacks here. It's exactly like what we had in our council here. So if you if you don't want to display your text on screen like this, you want to just keep using print down there, That's perfectly OK. But myself. I'm I just want to be able to see mine up here without having to look all the way down here at the bottom. That's how we take our very well. We inserted into our strings. And if that confuses you, before you spend a little time with this practice inserting your variables into different strings see which of these two methods of using it you prefer, whether it's the percent s where percent variable name at the end or if you prefer doing the plus variable name plus where the whole thing and I'll see you guys in the next video. 11. 11 Integers, Floats, Rounding: All right. Welcome, everyone in this reader, where do not talk about rounding integers and Lopes. Now an integer is simply put. It's a number with no decimal places. So if we had we grow up here 25 just like this would be an interfere. Ah, okay. Float would be 25 0 But in G D script 25 25.0. Even though once an integer and one's afloat, they are both considered to be equal as being the same thing. Now there are some methods and that then we can only call on introduce and some that we run Medio where low. So depending on the situation, you may need to convert a blow to an intern, interfere toe afloat, but generally speaking, integer and float the way it's written out here, I mean the exact same thing, but something like this court will be completely different now. Another option here is we can actually round a number. Just that comment, Elle. So we do not have that error, um, with rounding numbers with someone just ground open closer parentheses and we can stick whatever number in there that wouldn't do our 25.1, and it'll round our 25.1 now. It's just it's showing an error because can be up there. So let's go ahead. Move it down here into our function. Just get rid of that. Could be more pleasing. So with this, this around our float of 25.1 to just 25 because if it is 0.4 or lower is going around down . And if it's 0.5 or higher, it will around so 25.1. If we just print that out and let's use please prints. And if we were to round 25.5, we'll see that old around. So in this case will see it down in our consul here. So we see our 1st 1 25.1 that rounds us down 25 and 25.5 will round us back up to 26. So in some cases you may need to or may want to, around your numbers up or down and an integer and float. If it's 25.0 and the interest 25 they're considered the same thing. That gives our Wiccan short overview over what and insecure, they float is and how can round our numbers. In the next video, we'll go over how to convert our interferes loads floats into cheers both those two strings , etcetera. So if this was a little confusing again, as usual, spent some time on this Brownson numbers, and we'll see you in the next video when you're ready to continue. 12. 12 Converting Between Floats, Integers and Strings: All right, everyone in this video, we're going to go over how to convert indigenous, the floats, blokes integers converting the strings and back. Now, the reason you may need to do this is you may need a string to get to perform certain actions, but you officer would be able to do that with an integer seed. Have to convert that, or you may need to pay that and the string and may be converted into something else to do the math for, you know? So let's start with would just create a new variable. I'll just call it number. And we just set that Teoh 53.6. All right, now in in our little ready function here, I'm going to go ahead and for texted are disk latex. Now, you're not this way your text on screen here and you want to just continue with using the council? You can do that just by continuing by using your Frank's method here. So all we're gonna do here is Well, we're gonna learn how to confirm things into a string first. And to do that, it's easy. Would just do S t r. Open and close our parentheses, and then anything we stick inside there will become a string. So if we dio number, which is our variable, it'll convert our 53.6 into a strength which we could then assigned to our text here and there we go. And again, if you're not using a display tax like this, this will show up down in your output as long as you're using prints. Now to convert integers, the floats and our floats to introduce. Because right now we just converted our load of 53.6 into a string. So let's convert our bloat here into an income here it is effectively the exact same thing that we just did only instead of str Rooney's I n ki and now it is an interview. Oh, and of course, we had a small ever there. I just like this and there is a way we had air there because I was assigning it to our kicks in our display text there, and that has to be assuring. So I'm going to use prints here. Just were displaying this and we can see it's just 53 without the decimal point. So it is now an integer, whereas before if we didn't do that, we would have 53.6. We have our float there now in. Or if you have, say, just off course are 53 we want to convert that into a low again. Same thing. We're just gonna talk and sound are variable our number with parentheses and in this case is just gonna show Opus 53 because it would be 53.0, which is the same thing is 53. Now we can convert these together if we need Teoh now for explain our texture. As I stated earlier, we had to make it a string. So well, make a string so str and then inside of our parentheses Um let's see, we can take our number here cheeses by 53.6 Oh, you know, I just leave. That is 53 So we can dio we can convert our number into a flow and then we can divide that by another number Light 20 because that'll give us a remainder and we'll know the float is working if we get a float back in return and of course, that would be converted into a strength and then applied to our text or your printing the cell. It would look the exact same down here would just do Prince. And instead of our parentheses who had happened just like that, let's go ahead and hit this and we hit 2.65 so we know it converted toe afloat properly. Otherwise we would not have to 65 We would just have to your answer. And just to show that will change. I'll change my display here to an integer and will leave the print as a float. Does he see 2.65 there? And to hear it's a simple is that for converting these all into numbers? You know, you can mix these as much as you want. So if we really wanted Teoh, we could do something like this. Which case? Well, take our number. Variable turned into a low divided by 20 that would take that number and turn that into an integer. And then when you turned that into a string which will return us to once again because our final number is an integer Before we turned it into a string. So most cases your I'm gonna use maybe two of those and insecure or float and then maybe converted into a string. Um, oftentimes, you're not gonna do both of these at the same time, but the option is there. If you wanted Teoh so we could go even more should we really want to? And now we get a change. Our number toe afloat. Divide it, ground it and an integer and instru So you can see that we could just keep keep going with this and now work to free because we're rounding BC and it will just we could just keep going with this kind of thing. We really, really wanted to or if we had to for whatever, um, math equations going on behind the scenes or whatever else, but that'll cover turning our our numbers and that into floats and inter strings. Um, so something I do want to show us how we can turn a is that we can turn a string into a number, an interviewer or low, which is effectively the same thing. So we're just gonna change number here into a string of 53 and then all we would do here who just do int I anti and then in our parentheses you just give number. And we could do the same thing down here with Prince Decimal and out here prints. Well, let's do it with Loht. And there we go. And I was with that will of comparative are our strength into an integer And down here we've converted our string into a flow which this actually work Because we need a string there. So print this as well and we can see that right down here. So that's what we can turn strings into integers and bloats and how in turn into tears the floats, integers and both those into strings So that you found out maybe a little bit confusing Go back and watch this again if you need Teoh And when you feel comfortable I'll see you in the next video. 13. 13 Booleans and Comparison with the Equality Operators: All right. Welcome, everyone. In this video, we're gonna go over what? Billions are the equality operator and the inequality operator. So a bullion basically just checks whether or not a statement is true or false. And that's all it can send back as a response is saying that this a true statement or this is a ball state. Now you can't compare a string and a number but can't compare to numbers. So if we compare 53.3 with 53.3 by doing to equal signs in between them, like so and I'll just do it down here as well. For those of you that are using the print math there and not using it this way text, you'll see that this will come back true because these are the exact same thing. It's gonna come back the same. And since they're the same, that's true. But if one of these were to be different, it will now come back false. Now there are no longer, it seems. If you want to check If something is not equal, then there are two ways that we can do that that is by doing exclamation point equals meaning not equal Now we're checking, not equals. Now, if these two numbers here do not equal the same thing, then it will come back true because now we're checking if they're not the same. If they were to be the same, it would come back as both Because we're asking if they're different. Now there is another way you can check if two things are not equal. And that is by using the Equality operator and then at the beginning, using the word not every do not 53.3 equal to 53.3. We should get the same result, uh, balls because they are equal and we're asking again, it is not so There's two ways there that you can check. If something is not equal, you can use either one. I intend to switch between them myself, just depending on how I feel in the moment. And I suppose, um and I have some friends that always do. The exclamation point equals just because that's what they're used to. So I just remove that coming here once again, we'll go like that and out these two statements here are exactly the same. Those are both ways that you can do that. And of course, here's false. So we're getting our Boolean back in return Now we can do that with words as well. So if we were to do our first name here, I've just gone ahead and given it a name up here instead of putting my including And if we were to do this and we did looks and we get to upper and we checked, if it was equal to first name to Lower copy that in here for print. Here we go. If we're to check this, these would come back false. Now, the reason these comeback balls, even though they are the same characters, is when you're comparing two strings in his case sensitive, which means a Capital J. It's not the same was a lower case. J. P. Capital A is not the same as a lower Casey. They're considered to different two different characters. So if you wanted to compare to strength of texts, say if you were to be doing a logging system that was not case sensitive at all, then you could take instead of first name here it would be passwords usually take password and to convert all the upper case or lower case, and they could take their input. They put in and just seems that to upper like this and then year, comparing both. What you have stored is the password and what they inputted with your password, both converted to uppercase. They could do a direct comparison of whether it's the same or not. Now, of course, that is less secure. Is that, um, that is a little less secure because the reason for having caps having case sensitive or your password is to make it harder to guess which, of course, if you want to go that route, then we wouldn't do. We won't do any conversion with this. We just do a direct comparison. Is the store past the if the store password is equal to on the person's input password? If that was, then where should go through you? Lachemann. So that's how you can compare strength. And again we can do the exclamation point equals If you wanted Teoh for do the two equals were not at the front so we can compare whether they are the same. We're not the same. We're checking if they're not the same. That is false, because Jack in this case is in all lower case, and I could hurt it it to all lowers. So it's exactly the same if we did upper and compare checking it. They're not the same is true because they're doing so. That's how you compare your numbers as well as strings together to see if they're equal or not equal. That the same or not saying, If you have little trouble understanding, go back, we watch video. If you have any questions, we'll redolent No, and when you feel confident, comfortable and ready to move on, see in the next video. 14. 14 Less Than and Greater Than Operators: all right. In this video, we're gonna talk about the greater than and less than operators now greater than and less than do exactly what you think. And of course, they swell. Return a Boolean, whether to your boss. So we can easily check whether something like 45 is greater than 20. Let's do that here. And of course, it's gonna come back. True, because 45 is a larger number than 20. Of course, if we did it the other way and tried, looking at 45 is less than 20. That's gonna come back both because it's not the greater than and less than operators are this simple as that. But what you can also do is you can do a greater than or equal to, or a less than or equal to operator. And that's simply just having your greater than or less than sign that an equals. So if we were to make these equal here work that on the long side, there we go. Then, as he went thes being the same appear that's going to give us a true statement because they are equal and then down below, we had less than or equal to which is going to be falls down here in our council because 45 is not less than 20 and it does not equal 20. But of course, if we make this match that it would be equal, but not less than so. That will be true now if we try and compare, they float toe an integer as you see that comeback truths that we can compare floats two integers if we need Teoh without having to do with the type of conversions or anything, and that's all there is to it as far as the greater than the lesson operators, if you really wanted to for some reason, you could say not 45.5 greater than 45. But at that point, you may say, Well, just say less than this of saying not greater than which there's nothing wrong with doing it this way. It's just an unnecessary way putting that extra word in there when, of course, is that doing that you could just do that, but again that would come down to your situation. I think using not in there might be a little more confusing when reading it out or newer people that maybe just getting into program. So if any, that was confusing again, as per usual experiment with it for a bit. If you need. Teoh tried out for a bit. Go back. We watched video. Whatever you need to dio ask questions, and when you feel comfortable and ready, I'll see you in the next video. 15. 15 Introduction To Methods: welcome one. And in this video, we're gonna start introducing talking to you about methods. Now, we've already used some methods, but these are usually ones that already built a burger and talk about what methods are and how to create our own methods. So a method is a collection or a group of statements that are pretty much like bundled into one into one thing that we can easily call multiple times. Methods are meant to be reused repeatedly. And if you find yourself writing the same code over and over maybe two or three times or even more, then you should probably take that coat and just put it into a method. So in order to create a method, all we have to do is type in bunk f, you can see space, and then the name of our method was anything. And you do not want any space in this. So let's call this in crow ducks, and then we're gonna open and closed parentheses and then put a colon. Now, when we press the enter, key will be ready to start in putting our statements into this function. So for this, we're gonna go ahead and We're gonna print three statements out of this. Let's go with. But hello? I, um one. And we just copy that into our over here. Dont have to statement to and three. Now that we have this, what we can dio is we could just come up into our ready function here, which gets called as soon as our program runs and we can just type introduction, open, close parentheses and make sure you spell that right. And now when we run it, you'll see down in our council are output that all three of these statements are gonna print just by putting in our method name here. Now, for something as simple like this, we may it may not seem as useful. Why, we're just doing this. Yeah, that if we wanted to do this multiple times and execute this coal code multiple times if we could just go like this. Well, of course, in a real life situation, you're not going to do it repeatedly like this all in a row. But just for example, sake, we just did that within a few seconds just because all we have to do is just put in our method name over and over. And I just see we printed that statement or those statements a ridiculous amount of times. So take a look at how that is. That's what. 123456789 times The equivalent of that would have been if we came down here. Well, you just went Boom. Now look how much space that takes up and how much how that Messi this looks in comparison . Teoh just using are met here. It just looks a lot cleaner when we go over this. So hopefully that helps you understand what methods are and why we would use them land. When you start going through our code is gonna you just keep just are one here. So any time that you need to execute the same code multiple times, just put it in a method and then just call that method when you need it. All right? So if you want to mess around with that may make some or methods of your own and test those out. You can go for go nuts go. And I keep experimenting. Keep on practicing when you feel comfortable. I'll see in the next video 16. 16 Local Variables: are any but one. In this video, we're gonna go over local variables. Variables. Now we've gone over variables in the past as we can see up top here and constants but a local variable. It's something that you can define within a method. Now it's on the surface. Looks exactly like a variable, but it will Onley remain local to that method and cannot be used anywhere else. So let's go ahead and jump in here and inside of our introduction method here, Let's go ahead and create a variable call. Um, compliment. And we will set that to genius. And it's a stew ring we go. And now from here, we can go ahead and print. Now compliment. Now what Introduction runs. It's gonna print out our compliment down here in the cops. And as you see here, it worked just fine. Now, wherever we want to do inside of our method here, we will always be able to call variable just like you would expect. However, outside of that, if we come back up here to are ready section, if we try to print that, that's gonna yelling us. Tell us is an error. Since we have not identified what this is. It doesn't know what compliment is that's going to go right back to the fact that are variable here is local and Onley exist within our method. Now, it doesn't matter if we put this above or below our method, it's still gonna Aargh! So I hope that clears up What a local very boys compared to a regular variable. Um oh, I should also know that if we go ahead and if we made a variable here, the same thing that we have up top We changed this to number, which is the same bearable that we have a copier. Then inside of our method. As you see when we go in, print it, it's gonna print the one that's inside our method here. So our local variable is going to take precedent over our our regular parable here. And if we were toe print it here, let's just go Where What's that? Just kind of looking up a bit. There we go. Now, when we run it, we'll see local variable and our normal normal variable. They're both have the same name with one that is in our That's in our method being our local variable takes precedent over our normal there. All right, so if you want to experiment with that, makes some variables within your own methods and do some comparison, see how that kind of works. Get yourself nice and comfortable with that. And when you're ready, I'll see in the next video. 17. 17 Parameters and Arguments: I have one in this video, we're gonna go over what parameters and arguments are now a parameter or an argument goes into a method. And that is actually what goes inside of these parentheses here. So we could stick anything in here and that will become a parameter. And then in order for us to call that method, we will have to build that parameter with something. So in this case, we could put in. That's a compliment. And now that will become a parameter that we can use. Well, we don't have to just use one. We could use two or three or however many we want, So we're just gonna put a comma space and and insult. So now we have two parameters in here and in our print statement here, Let's go ahead and would do a string and we'll print You are so and then we'll add in our compliment and then add on another screen. Yet somehow still So then add on our insult just like that. Now, if we wanted, we could take that and still put that into our extend it like so And now up here, where we have our error it's called it says, were this wrong because we now have parameters and we need to pass something in. So for a compliment, passing a string of, um, friendly and then comma and it will pass in another string or insult argument. Uh, gum. Now, when we run this, you'll see in your text box or down your counsel. If using grinned, we're gonna see you are so and then, you know, insert our birth parameter compliment, which we friendly. And then yet somehow still so and then call for a second parameter, which is in salt, which were passing in as dumb. And there you go. We see it right there. Now we could always Addison again. So come down here, do another introduction and then passing completely different parameters. Who would like? And that's what's nice about grounder. In fact, we could do things that don't even make sense. 50 45 and then 30. It doesn't make any sense, but we could do that because the parameter is just a word is just a place over. Oh, that's right, because we're in this case, we're adding it in as a string, so we are gonna need to put our quotations in here to turn our numbers industries. Or if you wanted to go the other route, you could just go like this, turned into a thing. So whatever way you want it to go about, that would be fine. And the only reason we need to put that into a string is because we're adding it into a string here. It's now when we run it, we'll see down here in our consul. We have both of our things here being exactly the same, but with different parameters. They've been built in differently now if we wanted to use numbers, but we just comment this out. We've come here and print compliment Plus. And so now, Ugo, we can go ahead in these numbers because now we're just simply adding our Q parameters together. So it's okay if their numbers, which in this case comes up to 75 and if we're doing a string, it's in this case, just friendly, dumb. So those are parameters are, or who may hear them referred to as arguments that you can add into your methods and how we can use thumb to insert whatever gated we want into their um, under Oh, another way that we can go about doing that. I just stopped this. We could instead of using number here, we could actually use our variables. We could use AIDS and gravity, I would like because those are still didn't refer to our numbers up top there. And that's still gonna work out. Just finally down here and the same thing with strength year. We could change this to birth name and then our 2nd 1 into number. And we'll get those votes down here so you can use go ahead and pass in your variables and constants into your parameters if you need Teoh. If that's what you're using them for. That way, you can maybe take ah player or persons input, storing it toe a variable and then use that variable as I passed that variable into your parameters for one. So if you want to go ahead and experiment that gets self comfortable, maybe watch the video again. Go ahead and do that when you're ready. See in the next video 18. 18 If Statements: all right of one in this video, we're gonna talk about the if statement now, an if statement is something that you're going to see a lot when it comes to program. And no matter what it is, the true feeling and in programming, the if statement basically checks to see whether it something is true. Then do this. So if you were to let's take a real world example if you were to go and buy something and if you had to be, say, at least 13 to purchase that video game or something, um, we would then check. You know, if your age is greater than or equal to 13 and, you know, sell you the game or give you the product, you know, whatever it is. And that's like a real world example of what, like an if statement would be late. So in in here were like, if a greater than or equal 13 and then we end up with a colon and then on the next line, we would, you know, do something like friends. Here you go. Here is your We could do something like that. And there you go. You can see that right down here at the bottom. Here you go. Here is your game. Because age, which we defined up top here 29 is greater than 13. Now, if our age WAAS class will say we were 12 here, which is not greater than or equal to 13 it's not gonna run because our if statement here is not true. Since it's not true, it is being skip. So that's pretty much how an if statement works. Now you're going to check it for if on so many things here in this. But we can check so many different things so we could check even character, like so we wanted to check with the first name, not link. If that was, I will say less than or equal to 10. Then we could execute our code, which in this case is still here. You go. Here is your game because we have less than 10 characters in our first name, so it doesn't have to be a number. We can check for something like a weight here. If we're were want to test see if two things are equal to each other. Yeah, we could do that with we can use first name here. Birth name don to Tucker is equal to the other double. There we got, we wanna check you will. Comparison is equal to first name. If it's equal, then it's gonna run. But it's not because, as we know, it is all lower case. So to upper would not work there, but rather to lower would be the equivalent here, and that would return true and thus it's gonna run our code with them that if statement here so you can check for a variety of different things with an if statement, just to see if it's true. And if it does, we perform the code. If you want to go ahead. Mesereau. That makes some if statements, try out all different things that you can do or comparisons. You can go ahead and do that. If you wanna watch this back again to help clarify something, Dad, feel free. Once you feel comfortable and ready to move on, I'll see in the next video 19. 19 elif Statement: All right, everyone in this video, we're going to talk about the else statement now, So we're just gonna go ahead and create a variable and we'll set it. Teoh apple. All right, Now, in our if statement down here, we're going to say yes. Fruit is equal to Apple. We'll print apples are great. And now what we could do is we can come down here Would be like if green IHS equal Hain apple print Pineapples are amazing. And then we could come ahead, continue on fruit equal to, um I don't know, banana friend Bananas are her for you. Now, doing this is perfectly fine because it in this case, were set to Apple. But let's go ahead and change this to Pineapple and always gonna check. Is it really? Is it Apple? No, it's not. So it's not going to do this at all. And that's just gonna end. We're going to check if it's pineapple. It is. So we're gonna do this and print out this statement, and then we're going to check this and check if it's banana, which it's not. So we're gonna skip this name now. We could do it this way But what we can do instead is due and l A Which is spacey gonna check if it's an apple? Do this else. It's hot Apple do this and then that's it. We're gonna start. We're not gonna do any more checks. And same thing if it was banana. We check this. If it's apple, it's not. Move on is a pineapple. No, Move on. Oh, it's banana. We're going to do this. And if it's not that, either, then we're not going to do anything. So L f is like checking going down a checklist and we're gonna execute whichever one is first in the road. So we're to execute this. We're gonna with grouping pineapple. This should be the only statement that prints. And what are we have a lower case, That's why so in that case, we or not, in our case, sensitive. Yes, I put a capital P there, my pineapple. So technically as we've gone over before, lower case and capitals are not considered the same characters. And because of that, our fruit, which was a lower case, all lower case pineapple was not equal to pineapple with a capital P, so nothing was executed there. But now, since I fixed that, we're going to get our statement here. Pineapples are amazing printing and nothing else is gonna check. And of course, we're changes to Apple and run. It is going to run our first commander. This is Apple's agree. And then if we were, uh, were things that too banana, that's gonna run our last one. And of course, only our last one bananas are good for you. And we saw what happens when none of those were true. It just skips all of them. So that is what in l F. Or else if my comment section area is here, um so we use if statements as well as LF statements and the difference is here is with LF we're going to say this isn't true, let's check if this is true instead, whereas if we do use all ifs, then if somehow we have multiple if statements that are true, all of those air going to run at the same time, and in a lot of cases who probably aren't gonna want that to happen, so go ahead. Familiar. Rise yourself with this a little more. You need to play around with ifs and LF statements and when you feel comfortable and ready . Now see in the next video 20. 20 else Statements: Alright, everybody in this video, we're going to go over the else statement now, unlike the if and LF, statement, the else statement is gonna be an end All catch off. It is a fail safe, um, statements. I guess you would call it so all else fails and nothing else is true. We do this. So if we were to come down here, use a else, put our colon on our next line, we can pray, whatever we would like, um, let's see if we could do Steve proved Plus, did not match any of the requirements. Bernie, I don't think maybe there anyway, uh, Ellis is gonna You can. So if it's not, Apple is not pineapple in its not banana. Then instead of doing nothing like we're seeing before, it's gonna do this. So we're just change this, Teoh, do we imprint that? Since it is not an apple, pineapple or banana, it's gonna do our else statement. So because since nothing else is true, we're going to resorts. The one thing that we can dio what you're saying Kiwi did not match any of our requirements . Now keep in mind the sense again. They are case sensitive. If we had a capital p like pineapple, that's still gonna be considered not the same as lower keys, pineapple. And therefore, we're gonna result back or L estate. Now, if you wanted to in this case, we could do fruit to lower. And now if we did it this way, it's okay if we have a capital in there cause we're gonna convert all of it into lower characters. Lower case. And now that would match pineapple. So we would get our pineapple race here. So to go over that again, the else statement is the end. All catch. If nothing else is true, this is what we're gonna dio instead of doing nothing like we did before previously. If out f the f statement and the l of statements were all false, nothing would have. But with our else statement those air balls, then the else is what we're going to dio. All right? So you can go ahead and play around with that. If you want to start, try making some else statements and mixing them in with your ifs and l efs and when you feel comfortable of metric got a good grasp on the idea and how else state it works, and I'll see in the next video where we could move on to going into multiple conditions. 21. 21 Multiple Conditions I: Alright, everybody in this video, we're gonna start taking a look at multiple conditions. Now, multiple conditions is what we're checking in. Two things are true in this instance. So we're gonna check Air route is equal to Apple am. Age is greater than equal to 25. You would score 21. Now if that is true, which with this change this to make that true. So if it's apple and age is greater than 21 then we'll get our apple result. However, if only one of these air true, then that will not pass. So what's changed down to 20 which is smaller than 21. But Apple is still going to remain true. But since both of them are not true, we're going to move on and it's going to check our other statements which will not be true . So we will have to resort down to our else statement just like that. Now we can do this and put in as many requirements as you want. So weaken, go ahead and put in and gravity equal to 9.1. And then again, since two of these are the same but not all three of them we'd fall back down to another statement in this case would go on. We down to our else. Now, as he saw me start typing there, we can do these and operators another way. If we just come down here and which exists to pineapple, we can't do them like so we actually type up the word and and that will equal out to being the same. It would just change this 21 and you'll see it all print out because all of these are the same with the and operator. Acting the same ecstasy isn't being too, eh? Percents there. So whichever route you want to go, whether you want to use the double AM presents here in here and statements or if you actually just want to type out the word and whichever is better for you, the double ever since is more common in code. But in G D script, we can use either one. So that's completely up to you. And they were both read the same and act the same, right? So that'll do with our first part of multiple conditions here. So go ahead, get yourself comfortable with that practice without a little bit if you need to. And when you feel you've got a good understanding of it, comfortable with it, we can move on and I'll see you in the next video where we were go over the second part of multiple conditions. 22. 22 Multiple Conditions II: fire at everyone in this video, We're going to go over the second part of multiple conditions. Now the second part here is actually going over or statements. So whereas the and statements you need everything to be the same with or statements on Lee one avere checks need to be true. So right here in our last LF statement, we can go ahead, do our two lines like this. If you don't know where this is on your keyboard, it is probably above your return or enter key next to your square brackets and you would just hold shift Teoh access that one. So that is theon paraded for And I'm sorry, not end the operator for or so in this case, we in check if fruit to lower equals banana. Yeah, A is greater than or equal to 21 and out one of these air. True which in this case, age is equal to it. But pineapple it's not. And since gravity has to be equal to 9.1 what change? That's a 9.82 there. So now the 1st 1 It is not gonna match because apple It's not that the 2nd 1 pineapple matches. Age matches within gravity does not. So it's going to skip that and then we get here does not equal banana. But age doesn't since rapper or will you need one of these to be true. And since ages true, We're going to get this statement here just like you see there. So instead of needing everything to come back true with an or statement, he only need one thing to come back. True. Now we changed gravity here back to 9.1 and word way that you see, we're going to stop pineapples because like we went over with the LF statements we're checking in order here is this is false. So we move on and we check this one our 2nd 1 hand. Everything is true. So we print that and we stop because there's no reason to check for anything else. But when that's false. We skipped down here and we checked to see of this or this is true. Now you don't have Teoh use those two lines if you don't want to, just like before, we can simply type the word or and it means the exact same thing. So there we go. And of course, we're print that now. If we were to print that now, we, of course, get our bananas are good for you because we changed this back to 9.82 Gravity does not equal that. So our second statement here is completely false. And then our last one, we'll need one to be true, which, in this case, we have to be true, but we'll need at least one. So that's the one that we print out here. So that's how the or statement works and the two ways that you can write that or multiple conditions here so you can mix these together and go with ends and doors, but within the same. But it kind of gets a little messy when you start getting things like that. But you could, and you see we have are two waster and end two ways to do or whichever way you chose refused to go about that, whether you want to use the operators or the actual words that's completely up to you, and both ways are accepted in TV script. Now, when you get yourself comfortable with that and you're ready to move on, I see in the next video 23. 23 Nested if and internal Function calls: everybody in this video, we're gonna go over nested if statements and calling functions within functions. So, first of all, in order to do this, we're gonna need to create a function for ourselves. Great. A method after that, of course. Is this our boat space And our name, which we're gonna call it Schedule open, close parentheses. Colon, I don't know how to do it that way. We hit enter to go underneath and begin sorting himself. So for now, I'm just gonna hit pass on that to get rid of our era, and I'm gonna pull it to arguments in Here are two parameters time of week and time of Okay , so now we can do our normal if statements here so we can go. Time of week is equal to the string weekday. We could do this and that would do An l F. Time of week is equal to weekend. Well, we will do this. So this would be our basic if statement here. And of course, we're gonna have our else if one end. But what we want to dio is we want to get the time of week, and then we want to do something based off of the time of day for a schedule. So underneath are a time of week. We're actually gonna put it, have tabbed in here another if statement, our time of day. And if that is equal to morning, do this and we can do l up in here. Time of day is equal to afternoon. We could do this. And then LF our time of day is equal to evening, we'll do this. So what we're doing here is first off we're using are taking our first parameter. Here are time of week and we're checking to see if that is gonna be weekday or weekend. And for this, and it's gonna copy this statement put in our weekend as long So we're gonna take our time of week and see if it equals week, day or weekend. And then based off of that, we're gonna go inside of that tree to our second set of if statement here and we're gonna check our time of day. And with that, that's when we're gonna know what What to Dio or what I've result is So I'm gonna change this to so inside of morning, Bruna, break out um, go to school or afternoon se do homework on her evening, go to bed. And on the weekend here, we could dio, um I want to still standard eating here because they eat breakfast, have one and make dinner. So now you know how this works we can go into are ready function here, and we can go ahead and call these schedule the schedule function. Here are method and we can pass in two parameters. One for the time of week, one for the time of day. I will say it's a week day and it is afternoon. So now when we run, this is gonna check the time of day secrets, weekday or weekend. In this case, it's a week day and then we're gonna movinto are nested section here inside of that and check our time of day, which would equate to afternoon. So should tell us to do homework. And it does. Now we simply have this as a week and instead of a week, day do the same thing. Only it's gonna check are kind of weak here weekdays. Gonna say it's false, so it's gonna skip all of this and come straight down to our LF statement here, where will see time of week this equal to weekend. And then it will check in our time of day, which is afternoon. Our 1st 1 would be false. 2nd 1 here would come back true. So it's gonna tell us to have long, and it does. So that is how a nested out if statements are a nested, if statement work and you can do this, however, some people are gonna consider this Ah, very bad practice and can equate to possibly some messy code in the future because we're taking up Wait a large amount of lines here 21 to 37. That's just about 20 lines of code what we're doing in here. Of course, we want to have our space in here to keep it separate. Otherwise, you can really start looking messy, as you can see. So what we could do instead is we can create two methods here to functions, and we can call one of them weekend and we'll create one cold weekday. Now we're going to do is we're just gonna grab all of our nested if statements here and stick our weekend ones inside of our we get about one. Here we go. And listen, stick. What are we missing? All right, we're missing the time of day, so we're still going to need our argument here from the time of day. Ah, right here. What? Just do a pass up here for now on and then we'll go ahead. Come on in here and we'll grab. All of these are weak day. What? Yes, This section Grab those come down here to our weekday paste that in a day Rio time of day. Now all we have to do here is we could just take our weekend function or method and our weekday and just plug those in the appropriate section. So if time of week and see what a weekday. We're just gonna call the weekday function, and we're gonna pass in the time of day and for the weekend were into the same thing. The time of week is equal to the weekend. We're gonna call our weekend function and passed in our time of day. And now if we run this, we should get the exact same result as you see down here. We have it said, have lunch and we should get that same thing. There you go. And now anyone that goes through him looks of this is gonna be a lot cleaner looking and again for those that consider all these nested of statements to be bad practice, this would be a much better solution and a lot cleaner to look at. So that will do it for this video. If you understand the concepts here, then go ahead and move on into the next video. And if not, go ahead, Wash this back again. Gets more practice in doing this. Grace some of your own. If statements Rachel nested ones. Make sure those work and then when they dio take those and re factor it into its own methods here's own functions and call those. So with that, I'll see in the next video continue learning. 24. 24 Ternary Operation: All right, guys, Welcome to the video. And today we're gonna talk about the turn ary operation. Now the turn ary operation will allow us to simply take a quick if else statement and put it into one line of code. So if we were to well, with this comments, that so we only have one thing printing in our council. So if we were to go like this and say if AIDS is greater than gravity, you know, praying eight wins and it would come down else, friend, age loses, and I simply put, we'll check if age is bigger than gravity, which it is. 29 is definitely bigger than 9.8. And in a print, age wins. And of course, if it wasn't it was smaller would get the else of age loses. Now we can take all of this and put it into one line of code. So we're just shorten that up and we could do this in two similar ways at the other. Now we can dio we didn't do print open parentheses and then put in our string of age wins close are quotes, of course. Space age greater than gravity space and else space. And then would you age loses and in close up our fantasy, and that will give us the exact same thing that we have down here. So now if we look down on our consulate, get the exact same result twice. Age wins and age wins. So that's one way that you can take all your code like that and stick it into one mine. To frank it down another very similar way like this. This might be a little less confusing for some of you, but we do print just like we normally would. Open parentheses, rotation eight wins. Those are quotation, closer parentheses, and then we'll do if age greater than gravity in the Manu else space else and another space quotes here, man. Print. Of course, Oprah and age loses, and we'll get the again the exact same result doing it this way. So you may find one of these two methods or one of these two ways to do this less confusing than the other and see the all good support the same thing. So you might find one of these weighs less confusing than the other. But of course, if you don't like either these You could still just go with your standard set up like this If you really wanted to. All three of these. Yeah, Perfectly fine waste. Do your code. It's just up to you which way he would prefer. And if you really feel like you need to do a, uh, turn every operative operation here or not. So if you feel comfortable with that, go and continue on. If not, then sit here. Do a couple more f statement, Um, turned him into the Trenary operation here to get into your one line. And when you're ready and comfortable with that, you can follow along and I'll see in the next video. 25. 25 Default Parameters: All right, everybody in this video, we're gonna go over how to set a default parameter is that you don't have Teoh pass in any arguments. So we're doing this. We're just going to use our schedule function here as our example. And with this, we're just gonna go ahead and add in and and else down here and which is Crane. I string here of these. Enter a please enter valid arguments. Okay. Now, for our time of week and time of day, they eat their way to do this is in our first argument here. Got schedule, open parentheses, the name of our argument with time of week. And then we're just going to space equals space and then our quotations and we're just going to set our deep old here. What's in this case would just set it to what, say default. And then we've got a time of day and do the same thing at the end equals strain, default. And there we go. And now, if we come into already function here and we call a our schedule, only this time we don't pass in any arguments, time of week is gonna automatically be set to default in our time of day will automatically be sent to people. Now, you can change this to whatever you would like your default to be, whether you want it to be a number four to say something specific or however you want it for your situation. But in this case, they're gonna be such a depot. What could be the exact same as if we went like this? Now that would be the equivalent of were to type this in ourselves. But because that is already are people we don't need to and you see, is gonna check for the time of week. It's gonna check. It's not a week day, it's not a weekend. So that takes us to our else state, where it should tell us to put in Boyd or sorry, boy put invalid arguments. And we do that. And that's exactly what it says Now, even though these are I default, that set, we can still come in here and tell it weekday and afternoon if we wanted, and we will still get the result that we're looking for, which is do homework in this case. So it's is simple to that as that to set some set your parameters to have a depot they go to. Um, if you were to do this with, like, a phone number, you know, maybe your default for the area code would be, like 64 or 619 something. Um, of course. If you want to make it No, you can't just go like this. What? You're still fine. Um, this just means that your default is nothing. But even though it is nothing, that's just means we by doing it this way instead of leaving them blank like that, we don't have to pass in an argument. I don't not sure why you want to do it this way, since you're probably gonna want that ever to pop up. Unless, you know, Hey, you need to pass some arguments in here. But if you wanted Teoh, you could send it to know and know simply just means nothing. It's the equivalent of saying Time of week is nothing. It's empty, and the time of day is nothing. So you can go ahead and pass in default parameters like that. Teoh. Any argument that you have for your function and again that's confusing. Go back we watched through. I'm trying to sell on a few of your own functions that you can make, and when you feel comfortable with that and ready, we'll go ahead and join us and I'll meet you in the next video. 26. 26 The in Operator: All right. Welcome, everyone. In this video, we're going to go over the end operator. Now the in operator simply is used within if statements to check whether something is in another thing. So, for example, if we take a look at our fruit, we have that said as Kiwi. So we do it. The scoring W I we in fruit on our fruit is kiwi. So we're checking If w I is in a kiwi now, it doesn't have to be in beginning. It does have to be the antic me in the middle. It could be anywhere as long. This w ay is in that sprays in that string somewhere we can print. We'll just go ahead and print we is in through. And if we print that out was seen in the council, We is in group because it is. And if it's not, let's say yeah, see? Well, we'll see if t is it true, which it's not. There is no t and Kiwi. It's not gonna print any now for numbers. It's like in two years is going to be a little different. Just get a little space there so we could say like if five in 5 68 And as you see that is immediately going to give us a problem. And the reason for that is because in has to do with strings. So we have to convert this into a string by doing S t R. And then wrap our parentheses around our five and we'll do it again. Or 5 68 And now the error is gone and we just simply print five is in 5 68 which it is. So the in operator is specifically for checking to see if one string is inside of another. But we can do it with numbers a za long as we convert those numbers into a string first. Now you can use this in operator for many different things, but it's gonna again that's gonna be very dependent upon what it is you're trying to dio. So if you found that confusing Oxus back, go over it again, practice with the in operator a little more, and when you feel comfortable, come ahead and join us in the next video 27. 27 while Loops and Yield: so a while loop is something that's going to continuously run while a second edition is true. So to do this, a very common variable that we used on while loose is the variable I. So we could go ahead and create that. And let's set that to one and will use this for numbers here. But theoretically, this could be anything says Go ahead and do while and then we need a condition. So we'll say while I is less than or equal to 10 and then we need our colon and then our next line. What do we dio? We will simply right? Would this print die? Now we can't execute this yet. If we were to execute this, we'd run into no only infinite loop. But the engine will actually not run them completely. Lock up because it will be stuck in this infinite loop. And the reason for that is because if I is less than 10 we're printing it, but whenever increasing it, so it's always gonna be less always every time. So what we need to dio this Do I less equals one now, whatever this execute, it's gonna print it, print the number and then it's gonna add one to it. And then once it goes higher than 10 so once it becomes greater than 10 it's gonna stop building. The wild loop is going to end, and we can see that if we go ahead and test this out down in our output here, Macy, that happened, like instantly. So in this case of just doing numbers like this, we're probably going to want to have some kind of positive. And we can do that by using the yield function, and we could do the yield function. We're gonna do this with the yield function, and the yield function is basically we're going to use it to tell it to wait a set amount of time and then continue the screen So we can do that after we add one or before we add one, or if you really want, before we even print it. So it doesn't really matter in this case where we put it, I'm just gonna put mine right here on the end. So that's just gonna be healed. Open your parentheses and then get underscore tree open and close dot Create timer, open your parentheses, and then right here. We put in any number that we want to wait for. So if you want, wait for five seconds. Put five. You went away for two seconds were to one second one. I'm just going to use to this and then we're closer parentheses. Put a comma and you'll see this pop up here. And we can just go ahead and select time out, which will be a string and then close our parentheses. And with that that is now gonna cause this script to wait in my case, two seconds and then after two seconds and continue quick. Since it's a wild loop, it well, loop back around. So going on, as we have are variable called I, which is set to one. And while I is less than or equal to 10 we're going to print the number and then we'll add one to it. And then we'll wait two seconds and then do it again until I becomes 11. And then we won't go through this at all. So now if we go ahead and play, you see that one? We wait two seconds to another two seconds three or and so on all the way up. And once this good all the way up to 10 that should be a last number that we see. Hey, nine, 10. And we should not see anymore, because now I is now greater than 10. So this wild loop has ended. It is not gonna go through this anymore. Now, if you a first whatever reason you need you, you can go through an do if statements inside of your wild loop or calling your functions and methods in your wild. Just make sure that you always have some sort of exit to your loop. Otherwise you'll be stuck in this rubber. And in this case, within this engine, it'll completely lock up and wanted to start. And there's a lot of other programs and other languages that I'll have similar kind of outcomes when you just put it stuck in a while in an infinite loop like that. So what are we doing here? And you? We're getting our tree, which is are all of our notes over here and we're basically creating a timer for two seconds, and then yield is telling us the weight around. So if I were to set this to you again. Five. We've been waiting five seconds in between. We want you want we could wait for one second in between. If you want. You could even use lot's like this. Is there a 0.5? You see, there's gonna be a lot quicker, but we're actually got a little bit of time to see The number before is added so you can use an integer or float if you would like there and that'll about cover it and wrap up Wild Lukes and how to use the yield function there in order to cause a pause in the script. So if you need to go back, we watch clarifying a little bit more. You still have questions for for ask. And when you feel comfortable with this with making wild loops and using the yield function , then continue on and I'll see you in the next video. 28. 28 Range and Random Numbers: All right, everyone in this video, we're gonna talk about range and range is exactly what you would expect. We have say, number five and then the number 10 and range is gonna be going from 5 to 10. That's your right. So that's effectively what we're gonna do here in the simplest terms here. And to do that, we're gonna start this by creating a veritable numbs equal, and then this We're gonna put our range just to make it easier, so we can just type numbers, whatever we want it. So we just do the range open parentheses, our first argument, which I'm going to use zero comma. And then our second argument is our second number. Now, keep in mind this is not your last number is never gonna be counted. So if you put 20 then the range is actually gonna go from 0 to 19. So if you want to be 0 to 20 we would do 21 and in close parentheses. And now we have a range from 0 to 20. If we were to just sprint that friend numbs, you'll see the result that we get here is in this square box and we're going one by one. Now this the square brackets and Arana is indicating that this is an array. And that is something that we will get Teoh a little later. But we have it going this way in our little box. But we could do this another ways around as well. If you wanted to say, print one number out on each line and to do that instead of just printing our range, we're going to do for I in. And then we would put our range, which in this case, we're just using our variable numbs withholding our range colon and then on our next line was gonna print. Hi. Now we see a print. The same thing on Lee is going to do one number on each line here in our council rather than giving us an array. Now, there is another thing that we could dio in this we could do for I in you. Just what a little space in there we go. And this time I'm actually used use range because I'm only gonna put one argument this time . So say for I in range and want to say 21 and print guy and these teams is gonna comment out so they don't get it. So you don't get computers when you're looking for here. So when we do one number, you see, we still get that same type of rank here. So we don't have to put in to arguments like that if we don't need Teoh. But that is something that you can dio now who are another example here. What we can do if we don't want to go one by one, we can actually count this going in a different way. So we could say for I in range and let's these are zero and 21 that we use before. But now we're gonna pass in 1/3 argument of to that were Colin on the end and front guy. No, What this is gonna do is we're gonna get our rain's going from zero 21 Onley said accounting by one, we're gonna count by twos. So now we're going to see 02 or 68 10 12 avalanche 20. So if you want to limit your numbers there in a way, if you need to for some reason, maybe whatever you're making, you need you can only go by 5/10. So that's how you would go about doing something like that. Now, if we want to get, say, the size of this we have this many numbers. What? We don't know how many numbers it is. What we can dio Isn't this comment? No. And here we will simply just print numbs are variable. What should be our range I'm gonna do. You got sighs and then that will tell us how many numbers we have in our thing here. So if we were to change this and have it count by twos, obviously we're not gonna 21 numbers, there's going to get severely cut down 11. And the reason why that's gonna be 11 and not to is because zero those counting that is our first. So if you wanted to change, that would go like this and go 12 21. And now, since your Countywide to chemical feast 10. So those are ranges and how we can kind of use them to get an array or to print out numbers in a line. Go on sort of one point to another. That's how we can print them while counting in this example by twos. That's how we get the size of Find out how many numbers are within this range. Now what else Weaken dio is we can actually do a random range. So inside of our print here, we're going to do Rand underscore rain and I believe yes, On the outside of those parentheses of the random range, we just do percent And the number which will our example has been 21. No, I'm sorry. This one is friend of rain. So again, we can come in with our one and 21. My apologies there. And when we print that, it's going to give us a random number in between. Now you'll see, In this case, it's going out the same number over and over in our council. To fix that, we can easy. Just do randomize open and close parentheses. Put that above it now, don't. It surely will be random every time. 9.639 2.36 18 points. Or or and of course, if you want to change that to an integer, we can easily dio this wrap our random range into our integer conversion like we would with any other number. Now, that's not the only thing that we could dio that would come down here. And we can print a brandy which are a nd I would stand for random integer opening close parentheses and then we'll do percent 21. And now this is gonna select a random number up to course are 20 there, just like we've been having. But it's gonna be a lot smaller. We only need Teoh percent and whatever number we won't. Casey, when we hit, play and start that well, we got 19. Do it again. Eight. And if we were to get rid of this randomized, we're looking at zero and again. Zero. So you see, we're getting the same thing over and over. So any time that you get a that you want to get a random number, make sure you always have randomized here that goes for anything that you want to get a random around him. Anything for in this. All right. So that do it for this video on ranges so we know how to get random ranges. How to print our reins in tow, Ray How? Print them out one by one how to get size, how to count by X number and are established. We counted by two. And if this confuses you a little bit, go ahead and spend a little time here. We watched the video practice this a little more on your own you need, and when you feel comfortable, I'll see in the next video. 29. 29 What is an Array: fire and everyone in this video, we're gonna quickly go over just ah, sore introduction off. What Ray is now an array is anything that you see for the most far that is surrounded by these square brackets. Now what is contained within this is can be thought of as, like, a list or a collection. And this could be anything from strings to integers to pretty much whatever you want to put in there. And of course, we can start us in our little variable here so you can just call this my race equals And then we could go like this. Just are square brackets and technically, that is a valid array. It's an empty array, but it is valid. So if we were to go ahead and print this, you'll see it will pop up here, but it will be completely empty. Now we can put loads in here. We can put integers in here so to for a four again 36 24 92. And let's even put in an insecure under sorry low, and that can all go in there. So we have a combination of integers, floats and even strength. If we wanted to, and we just separate each item by placing a comma. And for the most part, that's what an array is. We'll get into more details on that in the next video player. And that's the general idea of Wonder Ray is it's a list or a collection of items. All right, so if you feel like you understand it, raise or at least the idea of whatever it is, then come on over when I will see you in the next video. 30. 30 Getting Array Indeces: are and everyone in this video, we're gonna go over how to hold a number. It's from a specific position within our array. Now, when we talk about position in array, normally you would think started one to three or center. But instead of starting with one I want we're dealing with programming languages. Thes start with serious. First enter here is zero and then one to three. And so on. Now we can grab something from a position in a few different ways. Here we can just have what we had in the beginning where have print Mireille and I just feel a bind with a bunch of numbers and we can just dio to square brackets and on the inside of this something just put a position. So if we put position uh, six, you're saying we should get zero 123 or 56 So we should get 92 printed out here and we dio Now, if you're looking for a specific ah string or number of whatever it's inside of your race, we can actually search that rate. Could get the position using something like find last. If we do find the last, it's gonna search from the end and company come forward here. So if we look for a four, which we have two of them here and we do this, it's gonna get positioned. Three. Now we have 01 We have in position one here, but we also have a position three. But since we did find the last, we started from the back and went work away backwards to find it. Now, alternatively, we can use my radar while you're ray dot front. And we could try just doing that. It doesn't take any arguments. And what that's gonna return is the first item in your ray ran at the frontier, which would be positioned zero and then last air. You know what item it is in within your rage. Just another position we could use. Fine. And then type in whatever we're looking for, such as 36 as an argument. And that will tell us exactly the position, which is four and number 36 right here is 012 three and four. So there's a different ways that we can get Ah, find a position of a number or rather, the position of an item within your way and how we can search for something within your array to get the position of that and how we can print the item that is in a set position within your array. Hopefully, that made sense, and that was clear enough for you guys. As per usual, you can go back. Watch the video again if you need clarifying practice with this. If you need Teoh and when you feel comfortable, we'll see in the next video. 31. 31 Array Methods: welcome everyone in this video, we're going to go over some of the methods that you can use with a race. So you see, I'm already printing my race. That's we're gonna use that. Get our final results here. Now we're going to use mireille dot and we'll start with upend. Now. What upend is going to do is it's gonna add an item on to the end of our ray so you could see at the end. Here we have 85.23 but a power to upend cookies onto the end of that. You see, when we print out, my array will have all those numbers and right after 85.23 we'll have an item car cookies and there is So that's how we can add an item or a penned an item on to the end of our ray . Our next item here that we could do is going to be clear and simply put, that's just gonna empty out our array and making empty. So if we just play, you can see our Ray is now and everything that was in it is now gone. Next up, we can get a count so we can do this. This is useful. If you have multiple of the same item in this case, would do count and when used them before and in this case, we're actually going to print it. Otherwise we won't be able to see it. And what that's going to do is that's gonna look insider. Our right here. It's gonna look for this item, which is for as an integer, and it's going to count how many times that is in our array and you'll see that comes back as to because we have two that are four and something like 24 does not count because it's not equal to is considered a different number, of course. So we have four an hour array twice. That's what Count is going to do for us. Next up, we have empty. Right now we have empty. And what's that going to do? Is we see check if our array is empty to check. If that's true, basically, which in this case it's gonna come back balls so we could do like if array empty in this case like this current Mireille and because it's not empty, it should not print like you see there. But of course, if we asset, if not empty, which is not is gonna go ahead and print it for us. So that's how the empty method there on a race gonna work. Next up. You see, we got we got tons of things that we can use here. Ah, we can use insert. Now, what insert is gonna dio you can see it with our little popular we need a position and then a value. So let's say we want to insert into position three. I remember going to the front. We're starting zero 10 one to three. So we're gonna inserted in between this eight our second floor, and what's gonna insert the value? Um, let's put one in there now when we burnt that outward C two or a Juan or 36. 24 all the way to the end. So that's how we getting insert a value directly into our a ray. If we want to put it into a specific position next up, Weaken dio removed. And all we need is a position in this case. Off we remove our second position was is gonna be our eight here of 012 It's gonna pull that eight and remove it. So we should have to four or 36. There you go. So you can imagine that we can use a couple of these two. Insert something into end, replace a position eso for help. We could do my radar removed to so we can remove that eight out of there. And then we can go like this and insert and to to our put Wanda in there. So now we're gonna take the eight out and put one in its place. There you go. So you can combine these together to get a different kind of results if you need to, or to replace a variable or an item within your right. If you need Teoh. And, of course, we can just come back in here. We really need We could go like this and present our print position to if we don't have any of these position to will be eight. And if we remove the eighth position too, will become a or then we can insert into position to in between those fours the value of Juan you see there so knows are some of the methods that you can use on an array. And as with getting methods for just what everything that you would like, you can go ahead, just type of thing in Put your period and you got a whole list of options here that you can use and like you saw with insert once you put in, we get a little pop appear turning us. What kind of arguments it's expecting us to put in here so we can see it needs to positions or two. Yeah, items here. Two arguments, first on being positioned in the 2nd 1 being the value we want to put in. So it's good with that with allowing us to know. I know what we need to put in, although some things it might not. So curiosity. Let's try in. But let's see what invert does. Room 24. Why? Because we're looking at Position two, but we flipped it backwards. So now our end here, 85 this is position one or zero, this 92. His position one and then 24 is positioned to So we're going drop the back now because we inverted it. So if you need to do that or some kind of reason. There you go. You've got that kind of box there. So feel free to mess around with some of these of ray methods. Get some comfortable with, um, and you feel ready. See in the next video. 32. 32 Convert String to Array: are. And everyone in this video we're gonna go over. How do you convert a string into a set of a race? So we're gonna go ahead and create a variable What's gonna call it Demo String. And let's just use Jack. Went would be okay. So now we have our spring and we need to convert it into an array. So we're just gonna create ourselves a new Barry Bowman call Demo Array. We're gonna make that equal to Dembo String. Done. Now, in this case, since we're working with a sentence, our first argument here is gonna be a quotation marks, space quotation work. And this is basically gonna split it up at each space that we have Jack space when? So to split that into its own, um, array object there. So Jack will be the first object. What, in there and then went will be the next one up and then the being stock all right, we'll do Ah, common cause. We need to put our second argument, which is gonna be either true or false, which is gonna allow us to either put a lot of ah rate to be empty or not. And what's gonna put true and in comma or third variable this is how many pieces regularly lets you really want to break it up into. So if I want to each individual word we've got 01234 So if I put a four here, that should break it up into each word being its own peace. So we now friends our demo, our Ray. We can see the comma in between each piece and we see each piece is its own thing, which is great. And we can check that easily by just coming in here and let's pull out slot. Very the third object. 0123 It should be the word the and there it is. Now, if you don't want to split this up into in this case, equal pieces one for each word they were to do something like three. Then you'll see that our third show is gonna be the being stopped. And the reason for that is we does. We're gonna screw up object zero in the position. This jack object one is went object to is and a three will be everything else. So if we were to change this to a to we would have jack way, and then our last peace will be up. The beats stop bills. That's an error, because we got a call position three wister is done and there we go up the beanstalk. Now, if we had we have this split up with commas, for example, like this, then instead of a space in our first argument, we make it a string of a comma. And now, if we get that, you see, it's gonna split up at our commas. But of course, here we didn't do a full split reach individual character. Sorry. Word, of course. Sent it back to four. And there we go. Now, if you don't have the right split here, which that's not do anything, let's say let's say that we try to swing it with a comma, but we don't have any comments in our string. Well, that's just gonna error right out because we have a problem here. We're trying to crawl four object in the second position that we don't have. And it would do that if we try to call on one. So we have to call off zero, which is going to be our entire string because it hasn't bound a comma in there at all. Well, that's just quickly how we can convert a string of any type into an array that you can use later on. And, of course, we can always add to it removed and everything, just like we did in a previous video. So when you feel comfortable with that bill had move on and I'll see in the next one. 33. 33 Dictionaries: Alrighty. Welcome, everyone. And in this video, we're just gonna go over dictionaries what they are and how we can use them. So a dictionary is different from an array. However, we have a raised within the dictionary. So just like how in a ray is a collection of data like we see up here, it's just one string or one line. One line of data. A dictionary contains multiple arrays of data, so it contains a collection of collections. So let's go ahead and create one with the V A r. We only my underscore dictionary and we're equals. And now this is where we get a little different. Like how we use square brackets here to create an array actions, curly brackets or curly braces to create a dictionary. Now, if you've used another programming language in the past such a c sharp or something, you're gonna recognize these curly braces. And this is the only place that we really need to use them within Judy script. And now something that's also different as opposed to a race is we can actually hit, enter and weaken, split them up into lines. No, to create a dictionary entry. We have to do in a key name and then our values that are associated with. So in this case, I'll do 51 you want to set your name as a screen Colin. And then from here on, this is where we can create our data that goes into this key. So if we compare this to an array, if we look up top here, my array would be my key name. And then everything in here would be my data. So we do. He won square brackets. And inside of that Weaken Dio 25 26 98 65 43 of course, all separated with our calmness. Now what we do at the end of wanna insert another key as we do a no comma. And then we could just hit enter to go to our next line. And then we name our next one key to Colon. And then let's make this one just one string. This is a very long going for dictionary, and that would work she would into a single screen. Would you will come on the end, we do. Our next one with wolves is called P three and now we could do an array value one to no, you three, and we'll just leave that of an three values. Come on, the end. Enter our next line for And we could make this just some kind of mixture of them. All of all of them here, New value. Um, 64. 32.59 And let's even put pie in there. So, as you can see, we can have our keys can have an array, which in most cases they will. Or it could just be a string. Or it could be any kind of mixture of strength floats, integers and pie, which would be a key word here, forces we really wanted to weaken even. It's good like that. And we could even add in, um, age so we can use our variables in here number and fruit so you can use all different types of data within this within each key. Now, how we actually call this key to use it is a little different than we do for an array. So let's do print. If you want to make sure that this is working and the first thing we do, the access this we do the name read dictionary, which in this case of my dictionary and then we do, Yeah, And then you deal your key name so we'll say he won. And if we just leave it is that it's gonna print out all of our values here that are inside of key one. There you go separates out the entire thing. Now we can treat this as an array and you are square brackets and we could pull out, say, value three. Which if we look here, let's go. We want zero one to three. So we should get 65 back. And there we go. Now what we can do here if we just pull out of there and just go back to key one without our square brackets, because we don't want to pull anything from the next. But instead we could here. What we could do is print on this are not French, but we can a pen just like we could with them normal array, because that's effectively what this key is. So let's upend 26 are we already have 26 in there, but let's upend in 1250 and now when we printed out, it's gonna be added right here onto the end of our right so we can continue adding onto it just like we could within a right echoes along with all the other calls that we could dio in the array section that we went over. Now there is one difference year where we wouldn't be able to call in array or do any of our array functions. And that is because key to who are, uh, late. So he to we have to serve one string. But if we try to add anything into it Burkey to and we try Teoh pend You know that, right? Um, the number 25. All right, We play really come into this error because this is just a string, and that's all it is, and we cannot upend onto a string. However, if we turn this into an array, even if it's just one object here and rerun that now we've got 25 added into our data right after I was playing. So you're gonna need to modify or add information onto it, then definitely at least put your square brackets around it, even if it's only the one value. It's gonna be a lot more useful for you and with this, some of that and we'll print out key force. You could see all different a race here, things that we put in here. So we've got our strength. New value. We got 64 our integer 32.59 our low. We've got our keyword pie, which comes out to 3.141593 We have a judge number and fruit, which are variables from up top and the all translate in just fine. So that's all different ways that we can make keys and something to keep in mind, even if you only do one variable or one value in our key and on just all different ways that we can add things into it or the different types of values we can give to a key. Now, remember, your key name has to be unique, but your value within it does not. If I wanted, I could name this one value one and keep, or just like we didn't keep three and it would be perfectly fine because they're separate keys. So that'll some up how we use dictionaries, how we create them and how we can call. We're different keys and the values within them at to them and everything. Thank you would do with your normal ray. And that will wrap up dictionaries here. So if you need to go back, go over this practice with this. Create some dictionaries of your own. You some of them in practice, and that will do it that'll wrap up dictionaries here. 34. 34 Keyboard Input: All right, everyone, end this video, We're gonna go over how to take input from the keyboard. But to do that, we can use a built in function monk underscore input with the argument event. And then from here, we simply need to have an if statement, you bet. Input, Banky that we have a nested if statement here, if event breath and event scan code equals and then right here, you can put whatever key you want and to do that would just be key. Underscore. And you can see we have a whole list of all the buttons on your keyboard. So for this, I'm just gonna use Let's see, I'm just going to use the zero key. And if you do this one, this is the zero that is at the top of your keyboard. If you want the one on your numb pad, then that's gonna be KP underscore. Zero keep at zero, and then we just put in a colon. Now we have under that we have exactly what we want to happen, which in this case will print. Obviously, if you were, think of something happened. You know, printing. You're gonna make whatever you want to happen happen? Been a print zero p press. All right. Now, when we run that if we press zero we see in our council says Txeroki Breast and want to change that to anything else, we simply use this baby to the peaky, and then we just go like this peaky press. Just keep it updated. Well, now, we never passed peaky. That's gonna pop up and change in our council. And of course, it's not gonna happen. We press anything else. Only the one key that we assigned to it. So that's how you can get input from the keyboard to make whatever you want. Hop in happened when that bought this crust. 35. 35 Saving and Loading Settings Files: are at everyone welcome. And in this video, we're going to go over how you can create a type of save system Sagan store game settings. If you want to make a video game, you want to make software, you can store those kind of settings. And I pulled up in example here on the right of a game called Skyrim, and this is essentially what our value was gonna look like when we're done. So we're gonna have a section here and we're gonna have keys. And to do this, we're gonna do this using a dictionary. It's gonna be a little bit different then. The dick snares we made in the past purely just because we're gonna have sections in there and we haven't done over how to make sections, but rather just our keys. So to do this, we are gonna need a few things. We're gonna need a location to save our project so we'll call the safe path, and we're just gonna store this in our repository down here where a project is. So this is gonna be our s colon flat. That's like you see down there at the bottom, and then you could put in the name of the file and the extension. So for this, we're gonna go with Con Pig and I'm gonna use a dot i n I file You can go for a txt, a dock CFT, whatever you want to go with. But I'm gonna go with an eye and I file next we're gonna need Well, we don't need to buy that. We're just gonna make it a little easier on myself. Another variable, would you on big underscore file. And that's just gonna be equal to conflict. Bio. The new open closed practices and the last variable we're gonna need for this is our dictionary. Now, how to do this? We're just gonna We're gonna create one called Settings People's and then open and close our curly braces here. Now inside of here. I've already got what I'm going to use, Copied, ready to paste in. But to do this work is going to do open and close pregnancies. And in here we would have a string of the section name that wants a poor example audio. And if we look here, this is what we see here for general display audio grass decals, lighting shader and so on those air on your sections. So you're just gonna name your section there in the form of a string doing colon and then we're gonna have another set of curly braces and then inside of there is where you're gonna store your key and the values just like a normal dictionary. I'm just gonna go ahead and load my set up here, and when you're done, it'll look something like this. So we have our section Curly brace opening are key our value and, of course, comments that we could do another one Our next key cold in our value and someone all the way down. When you're done with that section, we use a curly braces to close it, followed by a comma, and then we'll repeat that. So next we have the next section name Colon, open your curly braces, your key colon value next line and all the way to row. You've got enough settings. I'm that you would like to start. If you would like to pause the video and copy what I've got here, feel free to If not, go ahead and just make up some of your own keys and values and sections here that you would like to use. So to continue with this, we're going to need to create two functions. One to save our settings and one to load our settings. I was gonna create, save underscore settings open close and in here, nor to savor settings. We're gonna need to get our information. So we're gonna have to go into we're gonna look for this section in settings. Got these. So we're gonna look into our setting sticks near here for per section with this is gonna be audio in this way. Make sure to put your colon at the end of their and then and they're gonna look for he in settings Square bracket and inside of there we're just gonna put second. And that was Colon. So what we've got so far is we want to look at our settings dictionary here. One look for the key for that, which is our section audio this way. And then inside of there, I'm gonna look inside those sections and get those keys that we have. Yeah, and those Those are what we're looking for. Next up, we just need to save it. So convict file. Yeah, set value, and now we need to pass it section he and then settings inside or square brackets section. And then immediately following that, we'll have another set of square brackets for key. It's a few to look over that again. That's convict underscore File Got set value open parentheses, section comma key comma settings, square bracket, open section square bracket close square bracket open he square bracket and then close our parentheses. And then the last thing that we need to do here, it's just con fig, Our conflict viol year save and inside of our parentheses, we just have are safe back. All right now, I'm gonna go ahead and put my safe settings when I press the button here. No save settings. And now, when I hit, when I run this and I pressed my button, it doesn't look like anything happened. But if we come over to our repository over here, right click open and file manager, you'll see I now have my conflict that I knife older and you'll have your your file of whatever you named it and the extension. If we open that up, we can see what this one looks like. And we can see the version from Sky Room. Is it worth following that same kind of set up an organization. And of course, the more keys you have, the longer each section is gonna be in the more sections, like documents gonna be So that's great. So now we can come in here and we could modify these files. If we were to come in here and change six and then we're to load this up inside her program , then our files would, Of course, we changed. So I'm just gonna go ahead and close that. And now we need to load our settings. So for this, we're gonna need another function and look out load settings. Now, this is going to be slightly different to start off we're actually going to look for we're gonna load our file, and then we're gonna check to see if there's an error that there's an error loading it. We need to know. And if not, then everything will be good to go. So it is gonna make a variable con ever, and that's going to be equal to our conflict. Bile, no load and inside of our parentheses is gonna be our seat. The first thing we're gonna do is we're gonna load it, and then we're gonna pass that variable to ever. So what this is going to do is it's gonna return whether or not the load was okay. So what we're gonna do is we're gonna check if error is not equal to okay, and that's okay. Caps. You're gonna go ahead and just do a simple print statement to let us now What happened? I'm gonna say they old loading settings, however, code and I would do percent s and we'll throw that in with they were. Then we will return. No. All right, Now, if it does equal okay, what we're gonna do is similar to what we did up top are safe settings is we're gonna look for section in settings, not keys, and inside of there would have four key in settings section. Now, this is a line that we go a little different here. We're going to dio settings square brackets, section square, bracket keys. Key is equal to right here. We're basically going to take our dictionary of settings and set our section and keys to equal what we have inside of the file. We loaded assuming that it was okay and there was no errors. So this is gonna be con big file. God yet value section he section comma key comma and will pass in null in case there is a value that is empty. And that's all we need to dio Now, Teoh show that it works on ready. We're gonna go ahead and print the settings and I'm gonna go ahead and change music, ducking our music undocking seconds. It is currently set to eight. Let's set it, Teoh 800. And then when we pressed our button instead of saving, we're going to go ahead on load our settings and then print the settings again that we can see it or we load it And after we load our settings cause we already saved our old ones course, which is back over here. I'm sorry, that scar we close that one. So let's go ahead and run it. And the one we changed is f music undocking seconds in my case. And we just look for that f music undocking seconds. We see that right here said to 800. And now when we loaded it is now loaded back Teoh when it waas, which was eight. What we have in our, um, configuration files are settings file. So there you have it. That's how we create a I save settings any load settings file. And this is a nice way to do it because we can store everything right into a dictionary that we can easily add sections two or add things into at any point. And this is general enough that it should work with pretty well any game or sock wear or any project that you work on within G D script here. 36. 36 Further Your Knowledge and Thank You: All right, everybody. If you've made it this far, then you made it to the end of this course for learning G D script. Now, before you go off on your own, remember, there's some things that I didn't teach us for simply because they're either they could be redundant or the majority of you won't need to know, and I'll show you show you a few of those here. So if we take our number, here are string are variable number and it's a string of 53.3. And I taught you that we could go like this and put it inside, and that's going to convert that into a float. Now, when I'm talking about things that are redundant, we're looking at things such as this would go number to float, and that will be the exact same thing. The Florida print those out. So Boehm, who print those out doesn't give us the exact same thing. 53.29999 repeating And likewise, if we turn these into an inter here and printed it, we will now just have 53. So I talked to you one way like this int with your parentheses around it, or low with your parentheses around it, which I prefer using that over the to int or too low as personally just because weaken use the same thing, whether we're doing a and entered your toe afloat, load to an indigent and are starting to an integer string to afloat. And we used that same thing on all of them where something like two int or to float we can only use on a string. So though there is two different options there, when we're talking about strings, they will effectively do the exact same thing. So there's no reason to use one over another. So that's an example over some things that are redundant that I didn't cover because I already taught it to you in, like, another way that we don't We don't We don't have to go over again now. Another one. I just think you comment, though, So if we look at create a variable, we'll call it stringy, and it would just be a string that says, Go down now in some very, very niece situations, you may need to make a hash out of this string, and if you want to do that, we can actually just call a function. And this is one of the things that I didn't teach you because the majority of you out there aren't going to need to be able to do this. So what we would do is with print, and we take her her thing here, stringing. Or if you didn't have one, we could just usual quotations and create a string. They would have done F a a 2 56 underscore text open and close parentheses, and this is gonna force print it out. But it's going to give us a hash of the word go down or ghetto gado. However, you'd like to pronounce that, of course. And you see, it's gonna be this long string of letters and numbers. So if you ever need toe, make a hash for whatever reason, that's the way that you can go ahead and do that. So, of course, if you wanted to store that in something, uh, what do stringy? Uh, that is a variable equals stringing. Uh, that's a J 2 56 text, and now we have that mm string there hashtag and saved into another variable of which we can always just come in and print that out. Or you sent a future used for comparisons, whatever. So he ever need to do something like that is there? But again, that's one of the things that's gonna bone Teoh a little more of a niche where the majority of you that are using this language probably won't need it Now there's gonna be other things out there. Just a string go like this, for example, begins with big rooms Seascape See on Escape K C M P two didn't ends with find format based , direction based name. You could see all of these in here that that we haven't got over There's hash again, but again, we just use that that little method there to call it and do that for us. What you can see. We have a lot of things that we did not go over. But if you ever need or find something and it's not obvious to you, for example, let's take a look at, um, pure to utf eight. That's something the majority you probably won't needing. But if you need it is there, and if you don't know what that does you can hold control and click and I'll bring you straight up to that section in the documentation, as you see right here, two on a scoring utf and in get a little description of what that does Now, For some reason, holding, controlling, clicking does not work. And we could do that on anything that we need here. Obviously, bringing a string isn't gonna do anything. Interferes pie. Look on that. You see the number here Grassi got everything else that you may need down there in the constants. So does a variety. Thinks What if he ever If holding, controlling, clicking does not work for you, you can come up here to search out and you could type something in, like to float here and you see well or strength function to float. We can see it's a method getting hit open, and that will take us straight to that section as well. So that'll work. If we weren't goto something up, I see that here. That's part of G script. It's a constant open, and it'll bring us here, So if there's something that you find that you're not really sure what it does, you can't figure it out. Then when all else fails, begin refer to here and it will give you a short description on what it does to give you a better idea of how to use it and that a little boat Do it better wrap it up. All right, so with that, I'm just gonna say half bun. Enjoy doing some of the practice sheets that I include with this help you get going, help make sure that you can get, you know, Well, what you doing that you pretended knowledge that you understand everything. And don't forget to leave a rating of this course and a review with that take care and happy, happy coding everybody. 37. 37 Using and Getting OS Info: All right. Welcome, everyone. Today we're gonna go over. How do you get information from our OS and how to use our OS to do certain things now to simply do this? Anything that we start with, it's gonna start, do A That we do is gonna start with OS. I'm gonna go dot and then this is a part of this. It was going to change. So, for example, we could do something like shall open and inside of our parentheses. It will take a string argument and this argument we can use for I say, uh, you well, so we could take something like Twitter, for example. And since this is in my ready function, that's gonna automatically run, and that's gonna automatically open up the Twitter Web page and your default browser. Now, if you were to do this on a mobile device, this is going to open up on your Twitter app that is on your phone because the twitter app becomes your default device for Twitter links. So as one instance that we can use information but for getting information we can print so we can actually see what we're getting here. And we do os dot Get underscore name and, of course, our open close parentheses. And this is going to return one item from a list. Now we can get things like, I believe would get IOS costing a BlackBerry 10 android html 50 SX Windows X 64 were x 86. I mean, is that 64? But the point is, you can get the operating system that is running on it. So if you want certain things to be active or disabled or whatever, depending on your OS, you can do that. One example of this is if you're doing an app or a game, say, maybe went to a mobile poor. But instead of re creating a whole new version from scratch, you could use some. I like this. Where if the OS is, uh, android, then you know, show these buttons or enable these buttons and yeah, not disabled them completely or delete them, whichever. So if we just go ahead and print that you see down here in our output for me, that system return windows because I am on a window system. There are many, many other things that we could do here. We just going to go down Class command line arguments date. There is one and you see we'll get in and order like this. So day is 14. So it's the 14. It is not daylight savings time. It is the second month. So February 14 on the fifth week day, so Friday and it's 2020. So it is Friday, February 14th 2020. Now you can use these for all kinds of things, as you can see here who just go bonkers or feeling it time. Or maybe check and get time zone information. If for some reason you need that can. Oh, that is It's all right here. Easy, Teoh. Go ahead and just grab if you need to. Of course, Audio Driver. Um, dynamic memory, usage environment, excusable path permissions and coming connections. Medalist Method lists names again. Name. It's just gonna return R O s looks. You don't have that. It's just tons of things that if we just to roos dot you see, we're gonna get even more things here. So let's take a look at this. A last dot day Friday, you see a five. So according to our or less, Friday is the fifth week day. Fair enough. That's what we saw earlier when we looked at our time. Um, you get borderless full screen resync you can so the virtual keyboard on screen, if you wanna, you need to do that or if you want to have as an option I was in your program, you can set it so the windows always on tops that your window title We just come down here , you can get of your window size or position. We just goto window size here that's gonna print out the resolution, which for me, is gonna return 19. Yeah, 10. 24 by 600. Oh, it's the just the size of that window. It so right. Once I was thinking of Waas, You get screen new, get screen size. There we go. There's when I was thinking I'm now in a club with 1920 by 10 80 which is your whole screen area. So all different things you can go ahead. You can browse through that. I'm depending on what you're doing. Using a less commands like this may or may not be useful for you, but if they are in the future now, you know how Teoh used, um, or how do you get the information that you can then use in whichever way and this way this will very depending on the platform that it's on now. You don't have to rewrite parts of your script toe work or rewrite parts of your script based on the OS. You can simply check the OS if you need to. You are, um, this case check your screen size and then we could then take that if we wanted Teoh and do something. Why, uh, come down here? Screen size yet screen sighs and now are variable. Screen size will have 1921 10 80. And then what we could do is set our, um, maximum window sighs. Let's see if that is. Here we go. We set our max window size equal to our screen size, so you do something like that. And now whoever's using this application of game will no longer be able to make the window bigger than the skirting. Bigger than there monitor screen size here. So that's just one example of how weaken take information and then use that practically so If I were to go like this now and just stretch this out. I can't stretch it. Dario, I can't go past this onto my other monitor. Kind of stuck here so you can see. Oh, okay. See? I can, like, See, I seems that I can, like, kind of a glitch it through, which is interesting. But you get the idea with the being locked here based off of our screen resolution or screen size, sir. And part of that might just be because I haven't pulled it off to the other side yet. But there you go. Yeah. You need to learn this. There you go. If this will help you with something that you need. Awesome. I'm with that. I hope you enjoyed. 38. 38 Custom Signals: Alright, guys, I'm gonna show you how to connect, create and connect a custom signal, and when that is emitted, we'll show you exactly how to I have a response to it. So to do this, I'm just gonna add a script onto my line at it here and all we're going to do, we're gonna start with signal, and I'm gonna name this text that it did, um, test. Yeah. So now we have a signal inside of our line edit script. Now we're gonna need the ready function so that we can connect it as soon as it launches. And for that, we're just going to use Connect. And this is gonna take three arguments. Our first argument is the name of our signal. So text at a test that we need a second argument, which is our our object, the target that we want to connect it to in this case, Let's go ahead and connect it to our were our control note up there, which is the parent of our line at it. So we're just gonna do sell, uh, yet underscore, parent. And then our third argument here is gonna be the name of our function that responds to the signal. So let's go ahead. And what should we call this, Um, text You don't do on text edited test just to keep it simple. Now we have it connected with our signal in our first argument what we're connecting it to in our second and the function that responds to our signal. That's great. Now we need to actually emit armor signal so that it can actually be used. So I'm just going to use a process here, bunks. And what this is going to do is this gonna check every frame if whatever conditions below are met and then So I'm just gonna come in here we're gonna do If so, that tax, because we want to get the text field of our line at it, we're gonna say, does not equal or is not equal to. And we will do an empty string. So basically, we're checking f if our line it it is blank. Do nothing. Otherwise, if there's anything in it, do this. And what is it that we're going to dio Bernie, emit the signal and for argument is just gonna be the name of the signal. Now we have connected here. So text at it test and were connected to our parent, which is the control note. It's over. And that script we will create a function called whatever you use for your third argument. So on that it test, and I'm just gonna double check that on text and it test? Yep. So I got that right. And then in here, I'm just going to print, um Os, I don get underscore name. So now when are signal is sent? Our script is gonna print what roos is, what operating system we're using and when it's gonna admit, that signal is when we have anything typed inside of our text field. Well, new type, anything in here, it's going to send the signal. And when it's blank is going to stop. Let's go ahead and start that up. We see nothing is happening. And as soon as we type anything in here, it's going to start typing r O s now because it's it is the process function that we're using here it is checking every single brain, so if this is going at 60 frames a second, it's going to be printing your OS 60 times. every second that you have something in here when his blank it won't print anything. Now that's all fine and dandy. But what if you want to connect a signal Teoh itself? Well, that's simple. All we dio is we just remove the second here and make our second argument. Just so now if we were to load this up and put anything in here, nothing happens. In fact, we're going to get a lot of errors because we're emitting the signal, but nothing's receiving it. It doesn't know what to do. It doesn't know what it's doing. And that's because we're this is connected to itself. So we need the function within here bunk on text edited tiff and now we can go ahead and do the same thing. Print our O s name. Now that's going to give us the exact same result that we had last time. Only now we're connected to itself. So our function has to be in the same script rest. Before, we were sending it out to another node. It has a script. So you see, if we just type and elite, it printed out Roos quite a few times while we had something in there and that while it's empty, it stops. We type. It goes empty, it stops. So that's how we can create a custom signal connected. Emit the signal and do something. When that signal is received, buy whatever is connected, Teoh. 39. Exercise 1: All right. Welcome, everyone. This is our first practice exercise. And in this I want you to to get input and assign that to the R variable. And this is gonna be a number because we're gonna use it to find the area. Avi Circle. And if you do not know the equation to find the area of a circle as high r squared again, that is Hi. Are square to go ahead and positive video. Take a stab at it, do your best to figure it out. Just can't get it or after you gotten it. And you think you've got the result. Come on back here and I'll show you through the way I figured it out. All right, Welcome back. Let's go ahead. And the first thing we're gonna need just want to start off with our variable are otherwise we can't assign it to anything. And now when our button is pressed because, remember, we cannot take input from our council. So we need Teoh. Get our input from here. So we're gonna sign Our are variable if you, um to detect that we have been there with starting line at it, we'll grab the text now we can't do math with a string, so let's convert it into a float, just in case someone puts in a decimal point. And now we're gonna prince, and we're just simply gonna print out. Hi. Times are square like so. And now, if you want to display it in text upon our little screen, do that, we're simply going to get arm text that it was the new of our screen. We're gonna assign the text of it to our equation to fight times our squares now one or two , a sign, a sign into text and needs to be a stirring. So it's gonna convert our equation here into history. All right, now go ahead and start up. It's enter a number like we'll go with 4.2. And now when we hit our button here, we're gonna go through this convert are 4.2 into a float from a string sign that are, And then we're gonna go through our math equation and they would go and you see down here in our council and up on our display, they're both exactly the same. We got our answer. And if you got this far and you figure it out. Congratulations. Give yourself a pat on the back, and if not, keep practicing. And I hope you learned something out of this. 40. Exercise 2: All right, welcome to our next exercise. And in this practice, I want you to use either the button and display text, or you can create a function with parameters. And I want you to script something that will tell me if a number is odd or even to go ahead pasta video here and take a shot at it, do your best. And if you think you figure it out where you get stuff, then come on back and I'll show you my two solutions here. Okay, let's start with the disc way, text and the button. So to do this, we're gonna need to variables one for number one and one for our results. Now, once the button is pressed, we're going to assign numb one to our text. That was inputted. Next. We need to assign our result, and that is going to be a lot's num one, and we're going to divide that fine, too. Now, the reason why we're gonna divide this by two is because we're going to see if we get an even number or if we have a remainder. If we have a remainder, then our number is obviously not even That's gonna be the way that we essentially use it to tell. So here comes our if our results is equal to the integer of the result. So the float is equal to the integer, which if it is even, they will be. Then we're going to assign our text at a text because this will be our just way. I want to set that equal to percent us is even. And we're gonna fill that in with someone now, If it's not, they're not equal. Then they must be on. So are simply is gonna take the text at it in our text and assign that to percent s is on area. All right, now, if we go ahead and run that we will see, we can take our input here, put any number life six and, you know, tell us six is even and we try something like five. It's gonna tell us five is on. So that's how we do it. If we're going to use the button and this way, text and now we're gonna use the If he chose to do this the function way, we simply going to create a function I'm gonna call mine not even and running two parameters. Number one, Then someone bristle, and we're going to sign a default value to the result of zero. That way we don't have Teoh put anything in for our second argument in the go. So we're just gonna set the num one results equal to be bloat num one divided by two. And then if our float of numb one result is equal to the temperature of number one result, then simply somehow lost our apprentices there and we're just gonna print out exactly what we had up top here Percent s is even and percent number one else print percent s is now to do it this way. Of course we have to go into our code, so we're gonna use are ready bunks. So it runs as soon as we start and we're just gonna run are odd. Even we're gonna pass in our first variable will do six again. And since our 2nd 1 has a deep on of zero, we don't need to assign anything to it. And now when you run, it will seat in the council six is even. And if we choose to go with by you don't tell us. Five is on. So those are the two ways that you could have gone about getting to this result. How did you dio? Did you get it? If not, hopefully you learned a little bit here. And just a note. Since we did turn it into a float here. We don't have Teoh do a flow conversion here, but I do that just to be on the safe side to make sure we don't run into any weird issues. But hopefully you learn something from that. If you got it. Congratulations. Give us up a pat on the back. He did it. And if you didn't get it, keep on practicing. And maybe come back to this in the future, when you feel a little more competent, feel that you couldn't do this. 41. Exercise 3: All right, everyone and this exercise. I would like you to take input for my keyboard. And when I pressed the s key, I want you to bring it out. Five stars, starting at one and increasing on each line. I want you to have a go one to three four by when I pressed the s key once on the keyboard . So go ahead. Positive video, take on that challenge. And once you've got it figured out or if you're struggling too much, come on back and I'll walk you through my solution. Eric. Now way I would go about this situation is we're going to create our and putting that underscore employees passing event for parameter, and then we're gonna fall in with them if event is and put key than are nested. If statement here if event breath and event scan code equals key, underscore s and out from here you might want to print no five lines like this for each line of stars. And that's perfectly fine if he did. That coding is about solving problems and finding solutions. And if your solution work, then you've solved the problem. However, I'm going to go about this in one line. So hopefully hopefully I'll show you guys a little something new that you didn't know here . But to do this, we're simply going Teoh print in our string, Our first star, You have space. And now we're just gonna do slash n do our next Thursday. What? To flash end one. What other way? This way. 123 Flash and wanted before crush. And 12345 All right, now, let's go ahead and play this. Run this. And when I hit the s key, you'll see in the council we got all five rows showing up. Now again, if you went through and did this and did five print lines, that's perfectly fine. That's more than fine. It's valid. It was a solution to the problem. So there's nothing wrong with the way you did it. I didn't teach you guys how to do a line break within the string. But if you've done this exercise, hopefully you've now seen a way to do that. It's never really necessary. But sometimes you might want it for a situation like this to save yourself from doing multiple print line. So if use you able to solve that, then give yourself a pat on the back. And if you've struggled with that, then maybe this scenario for you to practice on a little more practice on taking input from the keyboard.