Learn Lua quickly with no coding experience necessary

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
alright hello everyone and welcome to for the first time ever an intro complete introduction to scripting for games using Lua and core as the example I am slinkys I'm super excited about this we've got a lot of cool things that we can cover with this and so I'm excited to break down what's really happening in a way that you can use right away and we're gonna try to do the whole thing in an hour so if this is too fast in the future I'm gonna try to break it into smaller segments if people are still interested in kind of walking through this and yeah this should be good for if you are completely new to programming don't know anything about it if you have like some experience with another programming language maybe not Lua and/or you know how to program but you don't know how it works in core we're gonna cover all of these things if you already know how to program in core and you're already making scripts and things like that then boy do I have the stream for you because at 4 p.m. today Chris is doing a stream entitled advanced Lua with lasers yeah III it is the best stream name I've ever heard in my life it's it's the one it is glorious so yeah if you know some stuff I don't think you need to be super advanced you can probably still follow along and Chris does a really awesome job of explaining so if this is like yeah I know uh uh advanced Luo with lasers star felt um I'm psyched I'm gonna be watching it and yeah and that's not all for the rest of the day we've got some awesome things so right after this stream Steve Isaac's who does a who for participate which is like this like online learning community platform and has a course which I'm going to link in the chat right now for discussing the first course on cork had me which was an intro to game design it's very like thinking about what makes a good game and less about like how exactly do we make terrain in core that's there too but it's not really like the focus so it's a really good one for discussion and being like okay well how do you approach making games what's a good way to start and it's a little bit biased towards core and that it's really designed to be like I know jump in and make some stuff its core you can just make it you know like it take apart make it again and you know where it kind of in in contrast with when you were doing big projects with lots of people you would need like really a lot of very rigorous planning the beauty of core is that you just you just make it you can plan not saying you can't like absolutely plan but you don't have to so that'll be happening at noon hello foreign King welcome we're gonna be talking about intro to Lua today it's gonna be awesome yeah and if anybody who's here could just emoji in the chat if you have a zero programming experience I'd like to find out if we got some people who are ready for this and then at 2 p.m. today is the patch note stream so you can find out everything that was just released in the patch which by the way if you haven't launched core today go ahead and start downloading that patch this was a pretty quick one for me but yeah it is patch day and so there's awesome new stuff coming with that and then again 4 p.m. advanced Lua with lasers I can't I can't I can't even with how good a title that is but yeah today we are gonna be talking about Lua basics so there's actually a document for this that I wrote with some help from my friends but yeah so that is now linked into the chats if you want to follow along you want a visual aid besides the visual aids that I'm putting up here that is a great place to start and I am going to I've thought about this couple time a little bit and because it's hard to see things on the event log this prints out very small we're actually going to start in repple so this is rebel just like an online tool for for me anyway testing really basic code and let's hope that I can yeah look how giant we can make this this is fantastic ok so what's gonna happen is we're gonna have output here the code here we would we'd do the exact same thing in core awesome start field I'm glad that you've got some experience and are trying out core for the first time that's awesome because I'll definitely hook you up in the context of core and right after this if you want to just see some projects people made in core they're going to be streaming that so should be very cool but yeah we are gonna get started with programming like you've never programmed before lasting worthwhile shoutcast is the auto-generated name man they got some good words in there okay so essentially at the end of the computers form computations right and scripts are basically a series of computations for them to perform but if that were it alone it just wouldn't be enough to like control the logic of a game right so if I do like I think I can do it over here but I say 5 plus 4 plus 4 let's say I get 8 so it can it's like a calculator right but when we're using a calculator right besides like in math class if you're using a calculator the numbers probably refer to something real and then like if I say okay so I had 4 t-shirts and then I got 4 more because I went to this super awesome convention and got 4 more t-shirts and now I have 8 t-shirts I now have this number that is number of t-shirts I have that I'm remembering right and the way you remember a thing because the computer you're like okay so what was that again it doesn't know it's gone it's done you didn't ask me to remember it if you need a computer to remember a program you're going to use a variable and a variable is just a name that you give some data so that when I change that data it stays associated with the name so I can say oh and the keyword we used to do this in lua is local actually don't want to do this here so let's clear this and we're getting it here so we're gonna say local number of t-shirts right and I had 4 right and then I say number of t-shirts and this is a funny thing I did that capital let's see we can't just fix that their shirts of t-shirts is okay it's however many I had before which is number of t-shirts plus I got four more right and then I want to say okay so how many do I have tell me computer and I'm gonna use this print command we'll talk about this hello mr. Isaac's awesome to see you we're jumping to your stream after this so that people can see stuff that made in core it sounds like we've got some new core people so this is gonna be a really excellent day for bringing people into you can program games I believe in you I can help you we can do this and so we're just gonna print the number of t-shirts that we have and we'll talk about what print actually is and why we have this magic a little bit later but we're not there yet so I'm gonna do this and it says eight I have eight t-shirts okay so I a go to another convention and this time I get like sixteen of them so I'm going to say number of t-shirts is the number I had before and I know this is like crazy to think about it because you just want to be like well plus four right is okay and then I got like 16 of them now so now I'm gonna print how many did I have after this boom okay so on a secret level we're doing what word + number and that is because we know the computer knows that if I say number of t-shirts that just means whatever number is here and it just knows that that doesn't mean the word number of t-shirts plus the number 16 right that wouldn't that wouldn't be something that it could compute easily and yeah so this is what we're doing is we're making changes and we can even make changes on the fly so let's say somebody wants to borrow one of my t-shirts they want to borrow three of them so I'm like well how many t-shirts would I have now so I'm gonna say print number of t-shirts minus three how many would I have okay so we've got and we can actually we could put more print in there so sorry it was gonna explain these variable types first if you borrowed three of my shirts okay so we're just that's gonna be a sentence I'll talk about what that is going on there for a second and I broke it does it not like this stop play it steadily happy so it doesn't actually like me doing this math in here but we could we could assign it to a variable the point of the story is okay we've got basically three types of variables we have numbers right which is local no shirts let's make this that sounds like we have no shirts will just say shirts equals what did I have last time like 20 okay and then we have strings which are sets of words so local sure text equals core alpha right that's what my shirt says core alpha okay and the final thing we have is a boolean which is my favorite and equals true and the basically the thing that we're gonna kind of take note of here is all right let me annotate that is that there's basically three ways that I write what I am assigned to the variables so if it's a number and you'll find this is actually totally fine with a decimal number but I don't have a decimal number of t-shirts so this mr. Isaac's this is repple so it allows me right now to just like print and the reason I'm using it is actually very very simple which is that it allows me to make the text really big because it's all web so this is a web-based system for running code and it's great for like I just want to test some things in lua and you can actually you can actually set up forces in here too so it's great for teaching programming I have really but I think that in we're talking about a new upcoming Lua course and this may be a place that we put some kind of introductory stuff just so that it's like faster run and I'll show you how we're gonna run this in core in a second it's just it's going to be really hard to see the output so this is nice but yeah so basically if I have a number I just write the number and the computers like oh yeah numbers we know numbers we we can add subtract multiply modulus which I'm not going to talk about today but is like another operation that you can do a bunch of operations on numbers and then if I want it to be really anything else I need to put that in quotes because if I just wrote yeah core alpha let's see how fast this thing breaks because there's a couple things going in here which is that there yeah so it's basically expected near local so line six basically this broke it so it doesn't know what's happening down here because it's like oh just cuz I'm supposed to core alpha I don't know what that is so but if I put it in quits I can put anything I want in there because it's just like just take it as it is don't mess with it I mean there's ways we can mess with it and they're called string operations but for the most part just don't even worry about it computer and that's it and then with bullying's are really funny which is basically true and false are keywords so you see this blue for local and true these are special words I can't use them to mean anything besides what they mean to Lua and to Lua local means hey I'm about to give you a variable and true means true or false and that's it and if I were right so like in here what I did is I was like well I just want to label on this and you can see it's this kind of light gray and the reason it's light gray is because we're trying to be like this is it's what's called a comment it's like this is just something that's written there for the humans the humans need to know what's going on but computer you don't read this and so if something breaks which maybe you guys saw me do but let's say I break this again and then I don't know what I do is I take this and there's actually there's a shortcut to basically hey put these things in me and I can just toggle it so on my text editor and here on repple it's control slash actually can't ever remember a regular slash and that lets me think so if I do this and I press play it's not broken it's not broken I lied why are you unhappy with me oh it's not broken and it also wasn't asked to print anything yet so I can print all of these and actually use comma to separate things so I'll say shirts shirt texts shirt texts and is my favorite okay so if I print all of these then right now it's gonna break okay it says nil cuz it's like well I don't know what things it so that's a third data type that I forgot to mention which is local new shirt I don't have yet write equals nil so nibble is a special keyword which is I want a variable but I'm not gonna tell you what it is yet but it is something is gonna be something probably but it's not anything yet and I use this I'm like let's say I've got like you know the new winner and I want to have a variable name for it but I can't know who that is yet so I just set something up that's nil so that I can later assign it to them right and right now everything runs all one so this doesn't make sense but we're gonna get into that in a second I'm so nil is another value variable we can add that here and if I uncomment this and put it back in quotes then we'll play this and it'll say twenty core alpha is a string and true and those are basically the things now secretly within numbers two types of numbers secretly within numbers there are decimals local decimal number equals 3.14 let's say and it's and actually I'm going to change this to what we actually call it they're called floats and they're called floats because basically where the decimal is could be anywhere in the number right is like if I add this and you were asked Lee okay well what like spot two is the decimal in right now it's there but I can add more decimals here I can add more numbers here and you can't just guess where the thing is it's floating around so it's a float yeah I that's that's a little bit of a slink as explanation and then the opposite is an inch for integer so this is a number that can't have a decimal 23 now in some programming languages not Lua if I were like okay print 10 plus 2.5 it would be like I'm sorry can't be done you're insane that's that's absurd adding an int to a float nonsense right and so what you'd have to do is you have to say okay well I'm going to convert this so I'm gonna make them both floats so that you can do it but blue is actually really flexible and the only reason I'm bringing up the difference between instant floats is because it's going to matter when we get to custom properties and because the way Corps is working is we write our scripts in Lua core writes its scripts in C++ because it is on Unreal Engine so what that means is that you can your code is going to become C++ when it's actually running in core and that's a lot of magic but basically if I were teaching C++ this would not be a one-hour stream I promise you that much so Lua is a lot easier I think than C++ because you when you're starting out because you really don't have to worry about too many things like you could actually not know that flows and ants are a different number and it wouldn't be that much of a problem but yeah so those are our variables ok so now we're going to talk about we already talked about operations but basically let's say local we're just going to do a equals 10 local B equals 30 30 okay so I can print a plus B controls the C okay all right hopefully there's a shift tab yeah okay shift tab absolute magic what is happening with these colors because there's like a slight indent in this okay what happens if I do this this is very strange okay so Lua indentation matters okay so we do a minus and times and / and let's get one more and we're gonna make this up caret which is how you would do an exponent okay so boom okay so what we have here is the calculations that it did and we can see that when it did division it went ahead and give us a decimal number so in some languages if I had done that it would just give me basically no remainder and then this is scientific notation so this is 10 to the 35th which is what we asked it to do if I said a to the two then I'd probably get a hundred right because that's 10 squared so these are like your basic operations they're pretty useful um yeah thank you tops for talking about the differences between corn Unreal Engine which is you know core is doing a lot for you and it's its own kind of system so it uses the power of Unreal Engine but it is doing it in a core kind of way and the ways that core does it are actually like really very clever when you think about how we're kind of taking all these pieces that everybody has downloaded and then like swapping them up into a game so that you can just like jump in it like boom and it's not this like massive load time and you can you know move between core worlds and stuff like that very cool stuff ok so this is these are my math operations and then we also have some things that allow me to basically create these boolean x' which is I can do comparison so I can say a is less than B or a is less than or equal to B or let's try this one a is less than or equal to 10 so we can see that it works and then you'll notice okay so we'll talk about the equal signs really quickly which is right here every time I want to say let's make a variable this is what it's gonna be I use one equal sign I say a equals ten a is 10 I have decided and made a 10 if I want to know is a 10 if I want to ask a question I'm gonna use a double equal sign so I'll say a equals equals 10 and and that this is so this is a declaration from me I'm telling you what it is and this is a question so it could be false I could say a equals equals 11 right and let's go ahead and play what we've got so far we've got true true and that's false if I make it 10 then we should get true true true which we do now have so you see this is kind of the output in order from the print statements and this is really useful when I need to find out like say I've got a local number of players is right now let's say it's 2 and I want to do something with if the number of players is greater than 3 and 3 then I would say number of players is greater than or equal to 3 it's to say okay if there's at least 3 people and to do that I'm going to use if statements so we'll go ahead and move into that now so these are called conditional statements which is here's the big idea that we're going for here right now everything I've shown you just goes I'm like do a plus B do a minus B but it added up but that is very very rarely the way we're actually going to use programming what we need to do is create basically decision trees that are like okay in this scenario this is gonna happen and in this scenario this is gonna happen and I need you to do some quick calculations here and there but we can't calculate it all at once because sometimes the stuff that we need to do the calculations doesn't even exist yet and especially like when I'm talking about number of players in the context of core Core spins up engine this spins up servers for us right so new players can be connecting in the middle of my game I can't just know how many players that are going to be at the beginning I don't or at least it would always be zero because there's always zero at the beginning so we need to have a way to do code that happens when certain conditions are met so I'll say if this is how we do it number of players is greater than or is greater than or equal to three then print we have at least three players and then to end an if statement I'm going to use this keyword and you can see it's showing up in blue so again more special words special keywords that you can't use I can't make a variable named if-then or end because these are reserved reserved for Lua to use for Lua things so I'm gonna press run and it's not gonna say anything because we don't have three players greater than or equal to three players so let's go ahead and make it so that we have five players repress play and we have at least three players all right I'm gonna take this back down to two and it's a little inspecting here we're gonna add an else so I don't need an LC yet because this is all connected so we'll say else and then I don't have a condition with else because this is just literally if this wasn't true then you're gonna do this part if it was you did the first part so we'll keep this end here and we'll say else print not enough players I don't know why we're capitalizing all this a lot of it's kind of a kind of a core things we end up using a lot of capital letters because of using capital letters for all of our classes okay so now we know it has not enough players because we have two and we didn't make three now we can make a an interim thing so let's say we have three and we need to have more than three so we'll say we have three players and we need to have greater than three we have more than three players right and we want an another one for like we're really close and so we'll use this else if and then else if is another condition that is I'm only going to check if the first one was true so we definitely I know we don't have greater than three players we have to have less than three or three or fewer players so let's say if we have exactly players so a number of players equals equals three then we're gonna say print almost enough players okay and so now we know we have three so we will not have greater than three and we won't get two else if this one is true this is only one of these is going to happen based on checking each one in order and we have almost enough players and if we had to we could say boom not enough and if we had five we have more than three players okay so that is basically my else if statement that's awesome foreign King that you're taking a video graphics course and that you're good at making maps for me ah my maps were terrible I want to think I'm like more of an artistic person but like I don't know it's it's very challenging for me you should see some of the some of the cool stuff people made where they really like they can find the space really nicely it's really awesome to see I don't know good level design it's something I'm working on and I'm writing about a lot and there's a couple streams back where I was talking about map design for the Valor --nt style game that were pretty into but yeah okay so the last thing that we need to talk about is a function and there's sort of four essential components to function so we'll go ahead and give this a title functions and the keyword that you used to make a function go ahead and try to guess yet you won't get a chance before I type it but the key word is function so I created function and just like creating a variable with local I'm going to give my function a name and the function that I always end up making that no one would ever use because there's an do math magic and I probably shouldn't have done do I'll call this math magic okay so let's just say this is like a sequence of okay is there a do keyword in this my now I'm suddenly trying to remember function math magic I think that's all I do okay and then just like with an if statement functions end with an end statement and I've given it a name and that I've done this thing where I added these parentheses at the end and that is a lot to do with how we're gonna always be talking about functions you're just going to keep seeing these parentheses and there is a case in core where we don't use this parentheses and I'm going to talk about it but what we're gonna say is okay so what I want you to do is I've got I can make a variable inside of here I'll say local a is 10 and local B is 20 and then I'm gonna say a equals a plus B right which is not a question because it doesn't this is a declaration so we're going to change a and then B equals a and then a equals B plus B times B up B squared let's say and then print okay so I'm going to do this I'm going to separate these sections and there's a couple things to notice one I'm going to press play and nothing happens oh yeah mr. Eisen's let me let me throw that link in there it we have it blocked but the link that he is referring to foreign King is this one right here and that is for the participate class and it's super awesome lots of interesting discussion going on and it's a good course for discussing yeah I know the shop so the shop actually exists in community content so it's possible to sort of start using now we just don't have a lesson about how to hook it up but if you get into core and you open community content and look for the shop by standard combo it's the same one he's using in his valor strike game that we have streams about is the same person who's going to be doing our patch notes at to so that is it does exist and then we're going to be kind of breaking it down so that you can use it for your purposes but yeah so if I do this nothing all right let's try another experiment just so that we understand something kind of complicated which is if I print a right now it says no and that's basically if I make a variable inside a function it is born and dies entirely inside that function it is like this tiny little micro universe that is totally uh-oh did it was it blurry sorry that is totally self-contained it doesn't know what a is but we can print a in here we should be able to and the answer is is that functions or recipes they're like a set of instructions to you're like okay when I say math magic this is what you're going to do but this on own doesn't say do it to say do it I just say math magic with those parentheses afterwards so now I press play and it's 900 when we could probably go back through the math and figure out why that was but let's say this was 30 and then B was 30 and then 30 squared is 900 okay cool so that's that was what's happening there and this is how I call it and yeah I forgot what the point was there with these magic parentheses so let's say so this is a function that literally always prints 900 if I say math magic math magic it's just gonna be like 900 900 900 this function is basically standing in for the number for printing the number 900 it doesn't like do anything but let's say okay that's what's happens when a is 10 but let's say I can give it a number so I'm actually going to say okay a I'm going to put in these parentheses and I'm gonna take it out here so now a is gonna be whatever I tell it to do this time so I'm gonna start with a again starting us 10 like it did the first time and then we'll make it 2 once and we're gonna do something weird and we're gonna make it three point one four one time okay so now when we run we have three different answers and basically we can use an input to make things and it's like my recipe analogy then [Music] like you know I was like okay I've got to make cookies what kind of cookies I'm gonna make ah well if it's chocolate chip cookies I'm going to do this and so I would supply that is like an input into the whole thing okay so right now we're telling it to do something which is to print something but this is this input is called an argument or parameter and basically the parameter is this a thing and then the argument I gave it was 10 - and 3.14 but you can see basically it's basically like I made a fair variable a and then I could sign it which I could also do it here so let's say it's basically like I said local a equals 10 and then just use a in here because if I took this away yeah that'll still work because it's gonna look up here for what this was and it's always going to know a refers to this but then I can't change it here and this is all gonna break because it doesn't expect to have anything anymore so anyway it's basically like a is gonna be like a variable name it's gonna be whatever I give it in parentheses and a is 10 when I called it this time it's 2 when I called it this time and 3.14 when I called it the third time okay so those are function inputs and parameters but let's say I'm not gonna tell it to print I'm just gonna tell it that okay I want you to give me back whatever's left over at the end of the things I'm going to say return a so I press play and nothing happens but all of these when they operated they got something back we just didn't do anything so what I can do is I can say print like this and we'll skip the middle one just so you can see what's happening we're gonna say okay print whatever you got back when I said math magic and we can even okay so if sorry no parentheses it's from different language a is greater than 100 I'll say 1 say 8 prynt turn I think I can do this a big number and okay so here's a funny thing which is basically return also ends a function and you really can't have more than one return but this works because if I got to this return it would just stop it wouldn't even get to the part where it says return a so let's see if that happens oh sorry I missed the then okay let's try it again boom so this time it returned a big number and it didn't give me a because it just stops when it gets there and so that'll keep it from getting to the final one okay so we have done this is it that was the intro to programming in Lua I'm skipping loops and tables because we'll talk about it kind of in the context of core but how am i doing timewise boom four minutes over but that's alright we got this so now we're going to talk about how this works in core um so did i fullscreen this okay yeah so now we need to talk about what an API is so I've shown you the Lua programming language and the Lua programming language has some things built in like if and else and function right but it doesn't have moved this object over here but what we did in making cores we made an API and that's it okay we're gonna give you a bunch more functions besides like say print was one of the functions that we've used we're gonna give you a bunch more of that that's specific to our game and when you use it it will do things related to the game and basically when you create a bunch of like functions and information and handles that you can pull that's an interface right like you when you drive a car you have an interface for driving your car you can't actually just like activate you know the eject button because that's not one of the buttons that's built into your car somewhat could make that but it's not in your interface right we can't just make up things that would be there there's a fixed set of stuff you can do for a night you don't need to be good at math to code the computer does it for you that's the beauty of we don't have to ever do math again just like computer math math yourself and one of the things we've talked about after the intro to Lua course is talking about some like game math programming if that is like I don't know tell me in chat I would like to know and if not then this is a useful thing so we're going to talk about the core API so okay API means two things one it's the set of things you can do and then the other thing and you'll see this is pretty common is the website that tells you what all those things are also gets called the API so if you're wondering like which one is the API I'll be like oh yeah it's on the core API and what I mean is on this page that lists the things that are part of the core API alright tabs game math it is we're gonna do some vectors we're gonna do some quaternions which I understood for the first time in zurich 'is advanced lewis stream absolutely magnificent stuff and so basically this is a set of stuff that you can information you can get about objects that are in core stuff you can make them do and events that happen when they do stuff and it is all organized around these things these capital letter things which are core objects which means that when I go to these core object object boom this thing is every thing in core is a subset of these things which is it's really funny because it means like things that don't make sense to have because okay so all of them have a is at a type I don't know where the core object thing is but like you'll find it basically a bunch of things have like positions and stuff in core and so these are all the different types of objects we can do and so we're now we're going to talk about objects so objects we're just actually I'm just going to look at let's get player as a complex one but it's also a familiar one so in this player section I'm going to find three sections there's the event section right the function section and below the massive amount of functions because players are I think we do a lot with yeah right I definitely think I am on star tract being like have you reconfigured the primary power couple like every time I say quaternion there's like a Ching so mathematical about it that I really like and then a property section so three sections so an object has properties and you access those with dots so I could say player dot name and actually I think let's see if I could do a local version of this so this is about to get weird because I basically got here is what you're normally used to seeing and then here is this event log and I'm actually gonna bring it down here bring it down into here and then make it take up about half this base so you can still see the world because it seems to pull the world forward if I don't and then I made a script called demo script and we're gonna open it here just a okay why are you being weird okay boom okay so now let's just we'll just quick overview of what we're doing to make a script in court there is a button called create script UI to make this demo script said create new script and named it demo script then I went into project content and in the my scripts tab it shows up here to make it run when it starts I put it in the hierarchy which is just go right away and not everything you do you can make 2d games there is basically they're not really 2d so they're like a 2d camera on a 3d game but there is possible ways to do that and there's also our UI system floats in the front so that's pretty 2d so if you look at there's a game MIDI something it's like a rhythm game but you can play that and you can see it's very kind of like you know the the ramp like in Guitar Hero is like at an angle but for the most part the information is pretty much one plane and then most of the stuff that you need is just floating in front of you and so that's kind of like one example like a 2d interface and then the other one is that under game components and camera we have a couple of different let me make this bigger camera options so top-down top-down is like kind of a 3/4 view actually you can kind of see that it's not like full-on top-down now you can kind of adjust where that camera and then side-scroller is the one that would be most like you know your kind of Mario 2d look and it still technically is 3d but I use because core is just like so skewed towards like creating 3d worlds a lot of times for 2d things I'm using 3d objects like when people are making like paintings and stuff you just take 3d objects and just decrease one axis a lot because there's just a lot more options for things there and they're really easy to control so just it's where we live in amazing times where 3d is easier than 2d who even knew oh my god definitely send me your isometric game I would love to see it I spent way too much time trying to learn isometric pixel art and I mean not way too much time but boy howdy was that a challenge okay so where was I so I make a script and then I drag it into this hierarchy to say I want this to be the kind that runs right away and right now what it does is it prints 2+2 and the place that it prints is this thing called the event log and it's not open by default so to open it you have to go to view and then event log and then it puts it out there I could just have it like floating here but it would get covered out actually that's that's not bad that's not bad all right and then when I press play it's gonna run my script and what it does is and this is why I didn't end up doing this in I can't make this bigger this is like the event log so this is a tiny four and you're just gonna have to believe me it is it calculated 2+2 and it printed for printing it for me and it was for I'm gonna bring this back down here cuz it's just a little bit easier so the things that I need to be able to access just for this are being able to press a play button to say run the script which I was pressing a play button on the repple too and this and here's where I'm getting my output so anytime something's going wrong in my script I just start printing things to figure out well what do you think this is here what do you think this is here am I actually getting the thing that I want or not okay so let's talk about I want to we're just going to talk about basically how we're going to get reference to an object yeah so yeah I don't want to do now contacts so I'm going to use what I think is the easiest way to do it which is an animated mesh and I'm gonna get my girl Nala where are you without her there boom but yeah she's my favorite character in the game and we'll have her look at us and I'm gonna toggle V so I don't see as much busyness okay so this is Nala and I want to make this do something so the first thing I'm gonna do is I'm gonna go to the where are you alright so I was at the player section but Nala this animated mesh is not a player it's an animated mesh okay so look at its animated mesh and there's actually one event all right I haven't talked about these that much but I the only way I know how to do it is by example so an event is something basically okay awesome mr. Isaac's I will see you on stream thank you so much for tuning in and yeah hang in on at noon we're gonna be jumping to seeing a bunch of user-created I student-created I don't actually know but I'm gonna find out and I'm excited too it's 3 p.m. Eastern Time noon pacific time and it's right after this so we're really excited and you know there's going to be discussion happening afterwards on the yeah you don't have to jump over its it'll be here as well it's gonna be everywhere and yeah and if you want to check out the participate course they actually have their old discussions on youtube so it is not too late to like jump in and just start talking about basically concepts and game design you do not need to be versed in core to start talking about this at all this course was really designed to be like let's just talk about what makes good games at all and then core is just a really easy way to do it and a really easy way to do it alone especially ok so animated mesh I've got events and the what events are is in a multiplayer online game you can't just say do this do this do this do this right because you're getting input from different people probably like across the world from each other and you're getting all of that input and people are moving around a different in in different like you know worlds and stuff like that and they each have basically a version of the game playing on their computer that's updating from a central version that's on a server right so I can't just say like do all of this cuz the whole thing would get out of sync and it breaks really quickly if you've ever been in some game where you got like this glitch we're like the horses on top of the building or something like that a lot of that is the sync errors but just like it didn't update this the right way to get everything looking things so on somebody's computer it looks totally fine and on yours it looks ridiculous the horses on top of the ship or whatever and and so one of the things we do to kind of keep this all distinct is have events so in this case with the animated mesh there's only one event and that is it does an animation and when it does that animation it does this event that tells us that it's happening and it's client only for reasons that sparkly visual effects things are all happen on your computer because if I needed those sparkles to be on the same exactly the same between my computer your computer and the main server we basically wouldn't build house of our khals anymore because it's just like tons and tons of moving things and it doesn't actually matter if my firework is like Boop to you and yours is like Boop we both saw fireworks we're fine and sorry if this destroys a little bit of the illusion of multiplayer games but it's really important so an animated meshes are basically visual effects right there doing a bunch of movement I guess I haven't explained what they are exactly which is they're just this like non collision thing that you can make do stuff that looks like a person and they don't all look like a person if you look at what our options are and make them big you can see we've got dragons and foxes and fantasy human guy is that from the patch that must be from the patch I don't think he was there last time I saw this but yes so now we've got one that's not wearing all of the people were wearing this outfit before this patch and so now you've got a guy that makes more sense in a medieval context but you can actually attach things to them and put like armor on them and stuff so anyway yeah I'm sorry tabs I know I'm breaking your heart we're not staring at the same fireworks at the same time I know heartbreaking but yeah so what we've got is sorry we need to go back up to a anime mash take me you to the anime mesh and made it alright we've got one thing and then these functions are all stuff you can do with this animation mesh animated mesh so you can get the socket name sockets are where you would attach the like about armor and stuff so I can say all right just tell me all of the sockets I can call an attached core object nice I own this animated mesh attach a core object and then here the same way we supplied a is the number we're going to give you the core object to attach and the string it which is the socket name that we want to attach it to and the one that we're going to try right now is play animation with the animation name and it just called wave I should probably check this twice I had a list of all the animation names right I have a list of all the human ones but there is there is a project by the way where you can just play with animated meshes and see all the things that they can do so I highly recommend you it's literally a game you can also like make a copy of it for you to edit locally yeah hella fashion so what we want to do is we want to say okay I need to have a way for my script to know about this because if I'm just like local animated mesh it doesn't know what I'm talking about because I the script is here and the animated mesh is sort of in my project but they need a way to talk to each other and it's not as easy as just making a number because it knows that numbers exist so the way that we're going to do that is we're going to add a custom mmm there's two ways we could do it we're gonna okay we're gonna do it we're gonna do it the funky way okay which is I'm going to drag you see I've got demo script highlighted I'm gonna drag it onto human gal and if you look at it now demo script is sort of like indented and it's basically inside of human gal or you could say demo script is a child of human gal and human gal is its parent right so I can actually close it up and I don't see the script anymore so now in demo script I can say local Animesh is script that's me dot parent and we could just print it print and in mesh and I do this all the time anytime I'm programming literally I just like make a variable print it right away because I need to make sure that it's doing what I think it's doing so we'll pull up our thing here we will ctrl s to save this and then I'm gonna press play and it says down here you'll have to believe me it says animated mesh and then there's a long string of numbers and that's actually an ID so what's happening right now in the game is this is my character version of dollar and then this is not lo the animated mesh and you'll notice I can I don't know how she had collision they have collision okay cool and we're probably about to change that so I'm going to create new networking context and so that whole thing about how the animated mesh has to happen on this is not gonna work so I pulled this out and then I'm gonna put these in here which is basically if I wanted to move that's like a visual effect which means that needs to be client-side we need to be like ok wavings gonna happen everybody's gonna wave but it's gonna happen on your computer and not like the server is like hand is here hand is here everyone sees exact hand motion and yeah we don't want that so now we're gonna take out this print because we know now what it does and I'm gonna say Animesh and I can art you know it will print something else so we're gonna print and we're gonna try one of these properties so let's look at the properties available for the animated mesh hmm don't need the repple anymore where are you okay yep so properties that we have our animation stance animation stance should loop and it's basically because animated meshes are meant to be animated so let's go ahead and find out its animation stance so we'll say Animesh that's you know let's call this uh not low mesh I think I someone tell me if that's not actually this character's name I like mess up the vowels on it all the time so we're gonna say just so it's not like all animated meshes and we noticed this one particular so now amish dot what did we say animation stance all right so we'll print that and we press play we say it first and then we press play and it says and you'll have to believe me on this I'm gonna copy it I'm gonna paste it into here just so you can see unarmed idle relaxed which is uh that's a fair description of what's happening here and then the other thing is that you can actually change these animation the animation stands it's actually a property on it so if I look here Stan's unarmed I don't relaxed it was the the information was available here but I just want to see okay this is a property and I could access it so now what we want to do is we want to do a method so we're gonna say now lo mesh and then when you do a method which is sorry a function which is these here they all start with capital names and it's basically properties you'll always see with lowercase when you're gonna use dot to get them for a night awesome to meet you excited to see more of your stuff encore in your isometric game and fake zombie crafts I don't I don't know about never but what I know is that the way kora works is about everybody has these building blocks downloaded and we can distribute up ship ship ship ship them into place for your instance of the game and it makes it so fast especially if you've used another platform you can just feel it's so fast and like I don't know I don't want to like flex on you right now but I am about to show you my greatest accomplishment which is yeah this milk crate behold no blender involved sir friend sorry this is just I modeled all of this using core parts it's a lot of core parts I'm not gonna lie to you it's quite a few and one of the ways you can kind of like deal with like the way too much collision that that creates is there's basically a box around it that is the collision and these are all basically client-side they're like the mesh I can see right now I should be able to just walk through this mesh no problem yeah so and that that saves a lot of computation power so you don't have like the ability like in blender to like create lots of vertices but essentially like you can do a lot and it just takes a little while I think when you've got one workflow from blender to get used to this one and like I you know some things are harder than others so like I was trying to make like hanging fabric and it's really hard to find the right shape for that but it's kind of like the world is your oyster if you just kind of start getting used to a slightly different core way to do it and the benefit is like mega fast load times which when you're talking about putting something like online for people to connect to on a server you can't prioritize that enough and like honestly if I had to like actually go back through an old project and optimize it that would be that would be hell so we're gonna make this animated mesh do things though if it kills me and to call a method so the method that we're gonna call sorry I jumping around between topics but that's because this is all excited exciting is we're going to do play animation so I'm going to use a : bright play animation and I'm going to need the animation name and that's all I need right now and I'm gonna put it in quotes because it says that it needs a string so we'll say novel mesh play animation and the animation I think it's just wave it might be unarmed wave we'll find out if this breaks so saving that pressing pressing play and animation string way provided to animated mesh you Miguel okay so I can actually go in here and there's autocomplete in this so if you go in here what do we want unarmed I don't know if you guys can see this is sort of low on my screen unarmed no we could try throw use unarmed wave okay so it's an armed underscore wave right so with this we give it a string but it needs to be a string that it knows about because again this is an interface right there's a set of different things well what kind of plugins are you thinking I'm just a fake zombie said why not make if there's no blender support why not make plugins I'm kind of I'm interested we're definitely you know I will forward feedback and suggestions to people like I you know we talked about what community want all the time this is one of our favorite topics of conversation so we got play animation and unarmed wave and when I do that BAM look at that she's waving so that is awesome and that is kind of like my basic look at we can do this but there are these magnificent things so we've talked about this is a core object the core object has properties we talked about properties and we talked about methods right which are functions which are this when I use : and I tell it to do something right and one sometimes I use a function to tell it to give me information like a property and that's sort of like there's kind of some magical reasons involved in why you would end up using a method to say if it starts with get then it's like a property it's just giving you information but sometimes you're get and you're set or separate and that's a I don't know you just have to look at the API doc to see what it's going to be for your individual thing and yeah sorry guys we got a plug in here and that is so now we're we're going to talk about is an event and we're also going to talk about the script generator so let's see what is the easiest thing I can do for this what I want to do is I'm going to change this slightly so right now I've got a client context and I've got this demo script and the demo script figures out what the knowledge mesh is because it's the parent mm-hm how do I do the trigger if the client side this is a problem okay anyway I'm gonna take my script out so my script is not going to be it's gonna be independent of this and I'm going to say okay but I want you to know what this this animated meshes and the way I can do this is because it has these things you see where it says I don't know if you guys can read that it says add custom property and I can add custom property and I can this is actually why we talked about int and floats before it lets me pick the types of properties that I know about so colors are objects in core and things like that I wonder if I could change her t-shirt color that'd be kind of cool yeah well I won't get too much into this but essentially like I can make a variable and then use it in the script so that means that like I could basically change it here inside of properties and I don't have to go like edit the script and for things that I want to be able to change like that it makes sense to put them there not everything right not the like okay so tell me the location of the thing there that's not something I would want as a crop custom property but I can also basically take this human gal add her here as a custom property and it gives me it says human gal here and human gal and then it gives me this variable local prop human gal equals control sweep and I'm just gonna paste it in here there's no chance you can read it on there and let's head back but yeah it's a prop human gal and it's a script and then it uses this method that you can use on a script which we could look up oops we could look up the script things which is get custom property and then it has a name which is human gal I mean you can see it's the nospace version so it's exactly what's written here and then it says wait for object which is another method and that is because the object is inside of the hierarchy and what that means is when the game is loading it's loading all of the objects and so what that means is it doesn't exist at the exact same second that the script exists and it would break things if it was looking for something that doesn't exist yet so it has this method says just like hold up hold up just like wait for something to load that matches this description and it's actually probably doing this using the ID so it knows which one we're talking about and then so what I'm going to do is so that I now Nalla mesh doesn't exist and what I have is this variable that created for me prop human gal so we can do this we can paste this in we can save this and have the glorious experience of demo script for server script attempted to access a client only object okay so to put this demos group back in here see if that fixes it blam server-side script glorious okay so that's what we've got going on there do triggers work on client side they must okay and what we want to do is instead just having her how am i doing on time wise I am it is noon okay so that is as far as we got I think on Friday we're going to change the subject to working more on this and we're going to talk about more of like the core context of Lua if people like that get on the discord core Academy channel for all of your requests about stuff that you would like to see covered that you are curious about and you want to see more coverage of especially probably don't have that many Spanish speakers on the stream right now but I will do a stream in Spanish if that is what the people want so post your feedback and things like that and then stay tuned to see the participate crew mr. Isaac's and a mr. Washburn talking about user created content in core thank you guys for tuning in this has been slinkys see you guys later
Info
Channel: Core Games
Views: 40,110
Rating: undefined out of 5
Keywords: twitch, games, core, alpha, core games, manticore games, game development, video games, live, streaming, game design, level design, designer, making, video, open alpha, content, creator, unreal, epic, unreal engine, engine, platform, social, pc, lua, roblox, minecraft, virtual, nvidia, post, processing, visual, effects, tutorial, educational, programming, program, fortnite, fortnight, world cup, lets play, game, fps, graphics, render, trailer, game dev, tips, tricks, core live, livestream, createdwithcore, vfx, top 5, list
Id: TAjh6AXLk-Y
Channel Id: undefined
Length: 60min 55sec (3655 seconds)
Published: Tue Jul 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.