It's Time For YOU To Learn Circuits v2 (Beginners Tutorial Rec Room)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey you way over there do you want to learn how to make cool circuits v2 things like this helicopter well that's cool and all pretty exciting uh but before you learn how to do cool stuff like this you got to learn the basics and i think i need to learn the basics of how to pilot this oh my gosh this video is going to teach you all of the basics that you need to know about circuits v2 even if you have no knowledge of circuits or programming at all pretend you can actually see the circuits rec room doesn't render them if you aren't looking at them this video is going to be pretty long and pretty different so if you're an absolute beginner that wants to learn about cv2 stick around and watch this entire video and use it to practice and if you aren't interested in this then i recommend you to watch the video anyways to see if it might be something that you end up being interested in this tutorial is going to already assume that you already have at least a basic maker pen knowledge and that you know how to navigate the palette so yeah you might be able to see we've got uh quite a bit of stuff to cover here so let's get into it right now okay so i know i said you'd probably already know this but just to be clear you can get to all of the circuits in your palette by clicking on this circuits v2 button if you want to search for anything you can click on the search chips button here you can type in whatever there's a bunch of different categories here you can go through if we go back to the circuits v2 tab there's this logging tab here that's useful if you use the log string chip i'm not sure how much we're going to go over that in this video if you go back to the tab again you'll see your cpu net and chips limits we're not going to worry about these too much in this tutorial because we're not going to be making anything super advanced but i will probably bring them up when i'm talking about good practices to make sure you're not using up too much cpu or net or whatever and finally if you go to gadgets and then cv2 gadgets down here at the bottom you'll see all of the buttons and pistons and stuff that work with cv2 all right now that you know how to find everything let's get into some basic logic so just to start here i've got two different kinds of chips the ad chip and the show notification ship and you can probably pretty quickly tell the difference between these you'll notice that this show notification chip here has this orange thing on either side of it whereas the add chip doesn't in fact you'll notice that quite a few commonly used chips have these orange things like the if the delay the log string all of these have these orange ports on them whereas a bunch of other commonly used chips don't have those orange ports like the add the equals the two string so what's the difference between these well for the purposes of this tutorial i'm gonna be calling these execution chips and i'm gonna be calling these non-execution chips and that's because the orange port on a bunch of these chips is called the execution pin or just the exec and these execution pins are just the main way that you send a signal in circuits v2 so if i connect the output execution pin here to the input execution pin on this one then after i run this show notification chip the second one will run and then if i connect this output to this input this first one will run the second one will run and then the third one will run if i send a signal to this first one so basically everything on the left here is an input and everything on the right is an output so the execution chips in circuits v2 are basically the way that you like make things happen that's how you run things whereas with these non-execution chips they're basically constantly running so let's say i want to use this add chip here to set the delay for this delay chip so here on this delay chip we have the delay in seconds as an input and if we wanted this to be like three seconds let's say obviously we could just configure this to be three seconds but for the purposes of this tutorial if i hook it up to this ad chip i can then make it one plus two and then because this ad chip has no execution port on it this will always be outputting three so the way you can configure inputs on a chip is by grabbing your wire tool on your maker pen and then just clicking on it like that and a menu will pop up you can't really see this but i just have to type in a one there you'll see it changed and if i type in a two here that's 32 then you'll see that if i hover over this it's now outputting a three here's a better view of that it's now putting a three and because this is outputting a three and it's hooked up to the delay chip the delay of this is now set to three seconds but you might be wondering what the heck is this delaying and you'll see that it has a bunch of the orange execution pins and that's because it's an execution ship so for this to start the delay we just need to send a signal into the run input here and then for now let's just say we want it to wait three seconds which we've already done here and then we can use this after delay chip into the show notification you'll see that this is purple instead of blue which means that we can input text we'll get into data types and stuff in just a second here but for now you can just use the wire tool again to click on that type in whatever you want i'll just do key smashing you'll see it's now updated there okay cool pretty clear what's gonna happen we're gonna get this notification after three seconds of sending an input to this delay chip but how do we set an input to it there's a couple of ways to do this but the main way we're going to do it right now is with a button v2 so if i put this down here you don't really need to worry about any of this right now i'm going to get into gadgets and stuff later on for now pretty much all you have to know is that when i press this button an output is going to come from this pressed signal so we can hook this into whatever we want to run to test it i turned off my streamer cam so you'll be able to see the notification but when i press this button it sends the signal to the delay which waits three seconds and then activates the show notification which you can see right there and boom that's our first circuit and again i would like to emphasize that you wouldn't use an ad chip in this way you would just configure this to be three seconds instead i just wanted to demonstrate that chips without executions are constantly running so this circuit will do the exact same thing except like you know it's simpler so you probably still have quite a few questions on what the heck just happened but hopefully that got down for you the basics of how executions work how it like goes to one ship it runs it and then it moves on to the next chip and just continues the execution chain like that you can just think of executions as kind of a straight line whatever's hooked up first happens then the next thing happens then the next thing happens and then also hopefully that got you a little bit of an idea of why some chips don't have executions because they're constantly running like math chips so let's get a bit more into the nitty-gritty now you're probably wondering why this input that is a number is blue and this one is purple and it's words and i just said earlier it's because they're different things which is true so these are called different data types different data types for example are integers which are just numbers they're strings which are just words so there's a bunch of different data types in rec room that can be used for different things with different chips so let's do a quick rundown on all of the most common ones so these chips right here are called variables and we're going to get into them later all you really have to know right now is that they're going to be representing the different types of data that we're going to be going over so firstly here you'll see we have an int or an integer this is the most basic data type that you're probably familiar with it's literally just whole numbers so an integer can be 1 2 or 3 or it can be negative 1 negative 2 or negative 3. you'll see here i can set it to 43 if i want to boom integers are super easy to work with and they're usually used for counting things so if you just need something to increment by one you'll use an integer and you can just make it go one two three easy like that oh yeah and every data type has a color associated with it so if you just look at a pin you like know what color it is so you know what kind of data you're working with this isn't something you need to like memorize and it's just something you'll pick up on as you do circuits more but i figure i should go over them here anyways so yeah as you can see integers are green this is a float its color is blue and it's basically the exact same thing as an integer except for that it can be a decimal number so here you can see i can set this value to 45.6 if i want and there's no problem with that because you know it can handle decimals oftentimes floats and ins can be used interchangeably but floats are generally more useful you would use a float to set like the exact position of a piston or like the example from earlier the delay chip takes in a float for the amount of seconds to wait so if you wanted to wait like one and a half second you would use a float of 1.5 this is a boolean its color is red and i think earlier i said that integers are like the most basic data type i lied this is booleans are literally just true or false and you just toggle between them by clicking on that with the wire tool just think of booleans as like a one or a zero or off or on booleans are used very often with the if chip to decide when something should be done like let's say you want to move a player up but only if they're holding an object well whether or not the player is holding an object would be a boolean either true or false are they holding it or not and then you would use the if chip to decide that and then do something if they are this is a string and it's just text you can set it to any text you want you saw this earlier with the show notification chip i just typed in a whole bunch of letters there and it counted you can see here i have it set to abc and things get kind of confusing here but i can set it to something like 67 and you'll be like well that isn't text that's numbers well this is the text 67 and not the actual number 67 if that makes sense so yeah strings are pretty easy they're purple i don't know if i said that but it's pretty much just anything you can type in so those are all of the main data types we're going to be working with mostly in this video that you need to know obviously there's a whole bunch of other data types and most of the other ones are just colored yellow don't worry about these for now too much but some other important ones are players vector threes and lastly is a rec room object so there's the rundown on all the basic data types and a little peek into some of the more complex ones i hope that at least that gave you a better idea of the kinds of data that we're gonna be working with when it comes to circuits so for that demonstration i said that i used variable chips and you could probably see it literally said like variable on them and then the type they were and i said that right then you just had to know i was using them as a representation of that data type but now we're going to get into what a variable actually can do and basically what a variable does is it just saves data so to put together everything i've just said and also introduce variables we're going to be doing a little mini project all we're going to create is a button that when you press it it will display a number that goes up the more you press it so thinking about how we can do that we're obviously going to need to save the last number that was displayed so we can add one to it and then display the new number and the way we save data like that is through variables so first when you place down a variable it's always good practice to change the name because it just starts out as variable and then whatever type you used because we're going to be using this variable to count i am going to name it counter and then hit the submit button and boom so how variables work is that each variable of the same name and type so all of these are integer variables named counter these will all output and hold the same value so hopefully you can see here if i hover over all of these they'll say that their current value is zero so how can we set a variable well we're going to need an execution and we've been using buttons for that so far so let's do that again so when you send an execution to a variable it will set the value of that variable to whatever this input value here is so currently if i hook up this pressed exec signal into the input one there it will set this counter variable to zero once i press this but you know it's already zero so that's not gonna do us too much help so i'm going to configure this and make it set it to one instead so you can see here counter is zero once i press this button if i look at it again you'll see it now says that it's one and because all variables of the same name and type share the same value even though i didn't do anything with these counter variables they're technically the same as this one so if i hover over these you'll see that they are now one as well so let's say i want to make a system that when i press down this button it sets the counter variable to one and then when i release it it sets it to two firstly we're not going to need this third one here so i'm gonna get rid of that so we're gonna take the pressed exec on this button and send it into this first one and the released exec and send it into the second one so we already have it set up that when we press the button it sets it to one that's what we just did and the value is currently one so all we have to do now is configure the input on this one to be two so that when we release it it'll send a signal into this and set it to two and then what i wanna do is set this button's text to visualize what this variable currently holds so i know i said we talk about objects and stuff later but just all you have to know is that this button's set text if i hook it up to the button it will set the button's text to whatever this string is and i want this to run both after it's pressed and after its release so we'll take the output execs from these and make them go into the button set text but currently if i do this and i press the button you'll see it's just totally blank because the text is currently set to nothing so if you want to set it to whatever the value of the variable is you might think you just want to hook up the variable into this but if you remember what we said about data types earlier this is an integer and this is expecting a string remember strings are like words and stuff integers are just whole numbers and those aren't really compatible so all we have to do is take the output of one of the variables and use this two string chip to convert it into a string so then all we have to do is hook that into the button and now if i press this you'll see it's one when i release it it's two just as easy as that okay now that we understand variables a little bit better we can modify this so that it counts up one every time instead of just setting it to a static value when it's pressed or released so firstly when the button's released we don't actually want it to do anything anymore that was just for demonstration so i'm going to get rid of this second counter variable but now when i press this it's just going to get set to one every single time i press it so all we got to do to make it go up by one you might remember this chip from earlier it is the add chip and remember this is another non-exec chip so if i hook up the output of counter here and we want it to go up by one so i can configure this to be the current output of counter plus one so if we hook up this add chip into the input of counter you'll see counter stays the same because for us to set the counter we need to press the button does that make sense i hope so so now every time we press this button we're just going to be adding one to the variable and then updating the button text to what the variable is okay does that make sense let's test it out we press the button and yep it's going up and you can see if we check the value of counter here it is going up as well cool we've now made a button that every time we press it the number goes up and you can use this uh to distract players in your map i guess because people like trying to get high numbers and that should be about it if you can make this then you should hopefully now somewhat understand basic logic and variables just as a recap we learned what an exec signal is why so many chips have it and that it's basically what makes things happen with circuits and that circuits with exec chips won't run until a signal is sent through them and then we also learned why some chips don't have an exec port because they are always running we also learned about different data types and how they can be used for different things like you'd want to use a string for the button text but you would want to use like an integer if you're counting up and we also learned about variables and how they save values and how that can be useful for things like this if you understood that then great you are on your way to understanding the back end of circuits v2 obviously there's a lot more but these basics are basically just what you have to grasp before we can move on to cooler things but no one cares about logic and boring stuff okay we want to see some things happen in the actual world here which is why we're now going to be going over lesson two this is a one lesson two basic gadgets you'll notice in the palette cv2 gadgets section there's a ton of stuff we haven't even touched yet for now we're going to be messing with pistons that spawned right in front of my thing and text so you'll notice that each gadget i've spawned in comes with its own little circuit thing above it right and this is called the control panel of a gadget and the control panel is permanently attached to the gadget like you can move it around but it'll follow it uh there is a setting you can enable where you configure and hit detach from object so that it does not follow around the gadget i usually like to turn that on so with everything you've just learned this is probably pretty self-explanatory right like if we look at the text gadget here you'll see there is a set text input with a string under it that will set the text right so if you send an exec to this set text it'll just set the text to whatever this text is that makes sense hopefully because you just learned it but here's the thing control panels are actually lying to you if you click the edit thing on your maker pen and then you edit a control panel you'll be taken inside of it and then you can see that that set text and text input we were talking about earlier is actually just using a set text chip to do it for it same thing with the color and the material and the piston is even worse look at all this stuff it has it like play and all the play does is that it sets its max distance to whatever you set the max distance to it uses a chip to set the speed and it starts moving it if we go to the objects section of the circuits of e2 search and let's go to like text per se you'll see we have access to all of the chips that were inside of this control panel so here's my first tip for gadgets i would pretty much never recommend using the inputs that are on these control panels but i should clarify that i'm just talking about the inputs not the outputs on some things like buttons and trigger volumes the outputs are very useful like we've been using this button output you remember the press thing that's what sends the exact but in general using inputs like the play one and the set text one is probably a bad idea because once you want to start doing more complicated stuff like let's say i want to set this text to something and then like wait a second and then set it to something different well you'll see there's only one text input here so you have to like put an input into the set text and then have a delay out of this one and then have it like change the input here and that's all so complicated when again we have access to this ourselves we could just use two different text set text chips the only difference here is that this control panel is tied to this text so if you use this input it knows what text it's affecting already whereas this chip can be used with any text object in the game so you have to specify what text object you want it to affect and that's really easy you'll see that every control panel has a little yellow port here on the top and you might notice that when you hover over them it says piston or text these are actually different data types like we talked about before each object has its own data type that can be used with circuits and you'll see that the text set text chip also just takes in a text data type so all we have to do to tell this chip that we want to affect this text is hook in the output into this input and that's all we have to do so what are some things that we can do with these gadgets well we can set the text and we can set the distance of the piston so let's start with those so let's bring back our little counting system from earlier and modify that to do stuff with the text and pistons you might notice this is starting to get pretty messy i move the piston control panel over here and the text one's here now so i'm gonna do here is clean things up you'll see that this text control panel is now actually just the pin because that's all we're gonna be using because we've decided we're not using any of the inputs or outputs on it you don't need to know how to do this currently but if you configure it you can delete all of the functions that are on the control panel and just use that one output and for the button we aren't going to be using anything other than the pressed function so i'll keep that okay so we now have this control panel representing the text the control panel representing the piston and we're still using the button as before so firstly you'll notice this just keeps going up and we currently have no way to reset it so i'm going to go ahead and clone this button here you'll see that we also now have a second button control panel right there i'm gonna configure this button to say reset because we're just going to have this reset everything back down to zero so we're going to need another copy of the variable here because we want to set it to a different value other than itself plus itself likes right here and we want to set it to zero so we can do that and then when it's pressed we want to set this variable to zero and then have it update the button text again so we can count like normal here and then if i hit reset it will set that variable to zero remember it updates on both of them and it sets the button text to the variable which is now zero so we now have a reset button okay but we have some perfectly fine text here how about instead of setting the text on this button we set the text on the text that would probably make sense so first let's configure this button to say something like count up so there's no confusion between it and the text and then instead of using the button set text here let's use the text set text we have to rewire both of these outputs to do it because we want to update the text both when we add one to the variable and when we reset it we need to set the target pin of the text here to the control panel like we said earlier and we need to rewire the string version of the output into the text so now if we hit count up the text changes as well and it works when we reset cool so what can we do with the piston well we can set the distance that it's pushed and just to show how pistons interact with actual rec room objects i'm going to draw a small cube here and hook it up to the piston so i'm going to put this right in front of the piston and then if i wire this yellow rod here on the piston onto the orange cube you can't really see the wire because perspective but they are now parented together so when this piston moves the cube moves as well so we already have the text updating with the variable so how about we set the piston's distance to the variable as well so we can put this piston set distance right there i know it's probably not the best location but i have to fit this all into frame so we want this to update every time the text updates as well so we can just take the output of the text set text and put it into there and then for the target remember we just wire it to the control panel like that and then all we have to do is wire the variable into the distance but you'll see that isn't working because you might notice that this is blue and this is green and if you remember from a while back a blue value represents a float which is a number that is a decimal it might seem kind of stupid that you can't wire an integer directly into a float because like it's really easy to convert whole numbers into a whole number point whatever but they are different data types so we're going to need another conversion chip like the two string so what we're going to use is the int to float so we have to do is use the value of the variable for our input and then it will output a float that we can use for the piston set distance now when we hit count up this text will change to one the variable will change to one and this piston's distance should be set to one meter let's give it a go okay well the piston kind of went off screen but it worked you'll see if i press this again it gets set to two the piston is up there i swear you can't see it so we don't want the piston going that high so how about instead of setting it directly to whatever our variable is we make it smaller before we set the piston's distance to it for this we are going to use a divide chip now because we're dividing we're pretty much going to have a decimal so we want to take the float output of the variable and this is just the same as the variable except as the float data type so let's say like when the text is 1 we want it to actually just set the piston's distance to 0.1 so all we have to do is divide by 10 and that will make the piston not move up as much and then we just have to take the output of this divide and then set that to the piston distance value instead so if we hit count up instead of moving up one full meter it now moves 0.1 meters and we can keep doing that and it will keep moving up 0.1 now instead of just one until we reset it of course instead of counting that up by one every time we press this button let's have it set to whatever the text of this button is so like let's say i configure this button and i set the text to say four when i press this button i want the text to be set to four and i want the piston to be set to point four meters so how do we get the text that's on the button well there's a very convenient chip called button get text who would have guessed and you'll notice here it has a target because we're talking about a button we just need to wire it into the button you'll notice here that this output is a type string uh you'll see that it does say four but it's in quotes which means that it's text and we need to convert that to a number so we need another type conversion chip and we are going to use parseint for that and basically that just allows you to put in a string and it will return the integer version of that string if it's valid like if you put in a string here that says a bunch of words this parse success will be false but we're just going to assume that the input on the button is valid so you'll see here the result here is 4 except in integer form instead of text form so then whenever we press this button instead of setting the counter variable to itself plus 1 we just have to set it to the parsed into that and we don't even need the plus 1 ship anymore so see here if i press this button it moves up 0.4 and the text now says four if i keep pressing it it'll stay at four if i configure the button text to say like six instead and then i press it it'll set it to six and it'll set that to six and this reset button basically just acts like a permanent zero because it resets everything back down to zero so just thought i'd throw in this like button text thing here as a little bit of a added thing at the end just to show how flexible circuits can really be when interacting with objects you can basically make them do anything you want to so just as an overview every single object comes with a control panel pretty much the only thing i'd recommend worrying about with this control panel is the yellow output next to the name of the control panel you can use chips for that object and you set the target to the output on the control panel to specify what object you're doing things with and then you can use these chips to integrate the values and logic that you've been doing before with the actual physical rec room space so hopefully you now have a good grasp on gadgets and how you can integrate them with your logic alright everyone i hate to tell you but it is time for the third and final section of this video that's probably the scariest for most people networking if you've already tried to learn circuits v2 or done anything with it you've probably seen this chip get local player and you've probably thought what the heck does that mean what is a local player so in rec room with each room you visit there is the room obviously when people join the room they can move around objects and jump and open doors and stuff and all that cool stuff if one player grabs a cube and throws it across the room it'll do that the same on everyone else's device too that is because the cube is synced which just means that its position is the same between all players most things in rooms in rec room are synced mostly like the positions of objects the positions of players however there's one main thing that is not synced meaning that it is local and that main thing is circuits v2 chips so when a player joins they get a copy of all of the circuits in a room on their machine so each player ends up with a copy of all of the circuits that run locally on their machine and unlike positions of objects because circuits are run locally everybody can have different copies of variables and have different things running at different times so for example this boolean variable by default is false if i set this to true and sent an exec signal through it for me this variable would be true however for everybody else in the room the variable would still be false for me to set it to true for everybody i would have two options i would need to have my signal that i'm sending go to everybody else's machine as well or i would need to make this variable synced between all players luckily for us there is an option where we can set variables to be synced so now if i switch this back to false and send an exec signal through it you'll see this little symbol up here in the corner that means it is synced between everybody so the value of this will always be the same between everybody now so if i set it to false on my machine it would automatically update on everyone else's and be false on theirs so you might be wondering wow that sounds super confusing why do they not just have everything synced between everyone i think that would make a lot more sense and the reason is that having circuits run locally for everyone adds a ton more flexibility and makes things way more efficient it may be harder to grasp at first but once you do grasp it you have so much more control you might be wondering when would you ever need a value that isn't the same between all the players so as an example here i've set up a button that adds one to this coins variable every time we press it it's basically the same thing we made earlier so if you're in a room and you want players to have coins or whatever obviously you would want them to have different values of coins right if everyone in the room had the same amount of coins that'd be kind of weird so if i press this button you'll see coins is now one if i press it again coins is now two but because this variable is local you'll notice it doesn't have the little symbol in the corner these are my coins other people's values of the coins variable will still be zero and of course if we ever do want something to be synced we can easily just configure that set it to be synced you'll see the symbols here now and now everybody will have the same amount of coins you'll see it reset back down to zero if i add a bunch of things you'll see everyone's coins are now five because it's synced so hopefully that gives you a little taste and better understanding of why we would want things to be local in the first place another reason is because it makes things way more efficient for example this get local player chip you might have a better guess as to what this actually does now so as a little experiment here i will let you know that this outputs a player value but by hovering over we can't actually see what player is however if you send a player value through a two-string chip it will output their name so if i do that this will now output the name of whatever git local player is outputting so take a guess as to what you think this string will output i think it's pretty obvious if i hover over it here it will say billabob because that's my record name and that's because this get local player chip outputs the player that is running that set of circuits so like if hairy man legs came in this room and used his maker pen to hover over this two-string for him it would output hairy man legs and that's because for him this get local player is outputting himself whereas for me this is outputting me so hopefully that helps you understand how this chip can output different values for different people at the same time i'm the only player in this room currently and if you're making a single player experience you technically don't need to worry about anything like local versus synced because everything is going to be local for the only player who's in the room but this is all really important to know for making multiplayer experiences so let's do another example as to why having things be local is so useful and hopefully this will kind of get your mind in like oh i can do this so let's say i want to get the player variable of the player named gribly in my room and for the purposes of this we're just going to assume that gribly is in the room i guess so i have a synced player variable here i want to set this player variable to the player value of gribly you may be thinking the best way to do that is like when i press this button it will get every player in the room and then it will search through all of the players in the room until it finds the one named gribly and when it does it sets this variable to gribbly so here's an example of what that would look like uh you don't really need to worry about all this right now because it uses lists and for loops which i haven't really talked about yet but just kind of talk it through in english uh this chip gets every single player in the room so then when you press this button it will go through every single player and then for each player in the room it will get their account name and check if it equals gribly which you can see here equals this output's a boolean it will output true if the player's name is gribbly and so then this will output the then and set the player to this you don't really need to worry about that uh this is one way of doing that technically yes if i press this button and gribbly was in the room this player variable would be set to gribbly's player but you'll notice here when i press this button this is only going to be running on my copy of the circuits which i'm the only player in the room right now so it would be only running on me regardless but pretending again that there are other people here and gribly is here pressing this button would make this only run for me and looping through every single player in the room can be kind of intense on the cpu and network limits which again you don't really need to worry about but all you have to know right now is that this is pretty inefficient and over complicated for what we're trying to do so instead of having my copy of the circuits take the entire workload to check through every single player in the room why don't we just have all of the players check themselves so now i've modified the circuit and it's a lot cleaner you'll notice so if there were more than one person in this room and i pressed this button only my copy of the circuits would get this signal but worry about that in a second so let's just pretend that this signal is going to go to everyone's copy of the circuits so then instead of going through every player in the room and checking if any player is gribbly it will only check if the local player is named gribly and if you remember the local player is just the player who is running that copy of circuits so if this signal gets sent to everybody in the room everybody will check if their name is gribbly and if they are it will set themselves i forgot to wire that it'll set themselves to the player variable but as i said before if there were multiple people in this room and i pressed this button this would only run for me because buttons only run for the person who pressed them so how would i take this signal that is only running on my copy of the circuits and send it to everyone's copy of the circuits and the answer is events events are a core part of circuits v2 and it's basically just how you send a signal from one player's copy of the circuits to another's so there's three main things that you need for an event an event definition an event sender and an event receiver so first let's configure the event definition let's give it a better name because you never want to leave anything with the default name i'm going to name it something like gribbly check because this is going to be wired up to circuits that check whether the local player is gribbly and then when you configure the event definition you'll notice there's a bunch of stuff for like add new property and all that you can choose what type it is we're not going to worry about that right now that just lets you send additional data between players but right now we're just going to worry about sending an exec between players so then you can configure the event sender and you want to set the event to the one you just made which i called gribbly check and then also here it shows your target and this is what's important if i choose local it will only send it to myself which isn't going to be very useful considering the whole purpose of this event is to send it out to everybody in the room we'll talk about room authority and authority later but for now we just want this signal to go to everybody in the room so everybody can check whether they're gribbly or not so we have our event set and we want it to send it to everybody now we just need to configure the event receiver to receive this event gribbly check we've defined what the event is this has no inputs or anything you can just put it wherever and then we have the event sender and the event receiver if i hook up the event sender to my signal because it's set to send it to everybody every single person will receive this event which will then go into this if chip to check if their local player which is them is named gribly and if they are it'll set them into this player value so if i press this button and gribly was in the room uh theoretically this variable would be set to gribbly but it's still empty because gribly uh did not come to my room sadly remember that we can check uh what a player value is by wiring it into a tostring we can see that it's still empty there let's say cause you know i'm the only one in the room so this is going to work if i change this from gribly to billabob my account name so now when i press this button it will send out the event to everybody to check if their own name is bilibob and if they are it'll set them to this player value and because i will also receive this event and my account name is billabob i should get set into this player event so if i press this button and then we check the string you'll see that the account name is bilibob i just hit my wall so yeah hopefully if you got all of that you should at least now have a basic understanding of the difference between local and synced and why we have things be local in the first place and maybe how you can properly utilize that however with networking there is one last big topic we have to cover before we're done with it and that is authority so in each room in rec room with players in it one of those players is assigned to be the room authority it doesn't really matter too much how the room authority is picked it's usually just the player who joins first or the player with the best hardware this is kind of not true in some cases but for the purposes of right now i'm going to say that the room authority is the one who basically handles all of the calculations for pistons and rotators and making sure that everything stays synced so you might have noticed with our event sender earlier there was the option to send it to room authority and that's because you can kind of use the player who is room authorities machine to kind of do all the calculations for you so instead of needing to have all your variables synced between everybody and need to do like all the math and stuff that you're doing with your circuits on everybody's machine you can have all of your variables be local to the room authority and then keep all of the math and stuff on their machine that way it's nice and simple so that you don't need to send as much data between players with events because pretty much everything is going to be on the room authority and because the room authority keeps track of all the positions of the pistons and rotators and gizmos and stuff like that in the room you might have actually noticed this everything on room authority's screen is really smooth so if you move a piston on the room authorities machine the piston will look like it's moving smoothly because it's running locally for them but everybody else has to download that data from the room authority which is a little bit laggy and it takes a bit so whenever you update a piston everybody in the room besides room authority sees it kind of be jittery and weird so whenever you change a piston or rotator or do a gadget of some kind you pretty much always want to do it on the room authorities copy of the chips because they will do it the most efficiently hopefully that kind of made sense i guess there is probably one last thing i should go over that kind of intermixes that idea with something else that's pretty important to know so you might have noticed earlier the only way for us to get an exact signal that i showed you was using a button and that requires some kind of player interaction so what if you have circuits that you want to be running constantly in the background like a couple times every second and these circuits can do checks and stuff to like see if a variable has reached a certain number or something and then do something well all you need for that is an event receiver and then you can configure this to be set to the update 30 hertz event and this exec pin here is going to fire 30 times a second so i've brought over this text from that thing we made earlier remember the like button thing uh if i hook up that circuit into this update 30 hertz you will see that this number begins to fly up at like 30 times a second actually to be exact so now instead of needing to press the button every time we want to add one to it it's just doing it automatically so what i also explained earlier is that when a player presses a button they only get the output for that pressed thing on their copy of the circuits and that's another thing that's different between this update 30hz event and buttons because everybody's copy of the circuits gets this update 30 hertz event so for reference i brought over that circuit from earlier except without any of the piston stuff or the buttons or like resets literally all this does is add one to the variable and then set the text to what that variable is and the thing is we only really want this to run on one person's copy of the circuits for me right now if i hook this into here that's fine because i'm the only player in the room so this is only running on my copy of the circuits but if there was another player in the room and that was happening it would be running for both of us so we would both be trying to update this value at once which i guess it's local here let me sync it so let's assume this variable was synced the entire time uh me and the other person would both be trying to update this variable that's the same between us like at the same time and we would also both be trying to set the text at the same time to the same thing and all that we'll do is waste the cpu and net limits that i talked about before and if there's like 10 players in the room and we're all trying to set the text and update the same variable at the same time we're gonna run out of our limits real quick so if you remember from earlier i said that we basically just want to use room authority to do all our calculations like this and there's a convenient chip for that called if local player is room authority and when this gets a signal it basically just checks okay the person's machine i'm running on right now are they room authority if they are it will send the output here so we can hook this together and now even if there were like a million people in the room uh it would only be running on one person's machine you'll notice the text has stopped moving and that's because updating text 30 times a second is incredibly expensive on net so it is still running out you'll see even if i hook it in directly here without the authority thing it runs out i'm not sure why it wasn't doing that before honestly oh it's because this is synced now okay well if i set the variable to be local you'll see that boom okay now it works so this is how you can get something only run on one player's machine and room authority is usually the best fit person in the room to run it anyway so that's good rec room handles all that for you so there's some other stuff with authority like objects having their own authority like the last person who touched them and then room authority shouldn't handle them that person should but whatever we're not going to worry about that right now that should have taught you the basics of networking and as a recap each player has their own copy of the circuits you can use events to send signals between those copies of the circuits between players you can check if the local player's room authority if you only want one person to be running a copy of the circuits which if you're doing a bunch of math or if you're updating a synced variable you probably only want one person running it and you can use the update 30 hertz event receiver if you want a constant signal going into your circuits but also be warned that the update 30 hertz can make you hit your cpu and net limits pretty darn quickly so be careful with what you plug into it teaching you how to make things run more efficiently like only one time a second is outside of the scope of this video because i'm freaking done there's still a ton more stuff to cover about circuits v2 so if this video does well or if people seem to find it helpful i might make another video going over some more intermediate topics that aren't just the complete basics if you followed this tutorial the whole way through and you actually learned about the things i talked about and you think you understand it i have an assignment for you to make sure you understand everything and this isn't going to be super easy but i think it's worth it for you to give it a shot so the fibonacci sequence is basically a sequence of numbers where the next number is the previous two added together so it's like 1 1 two three five eight i think i don't know look it up so your assignment is to have a button and you can configure the number on the button and then when you press the button it will output that number of numbers of the fibonacci sequence onto a text gadget so like if i configured the button to say five it would output the first five numbers in the fibonacci sequence onto a text gadget this requires some math it requires some variables it requires some logic uh good luck figuring it out i'm pretty sure i stole that little practice thing from sun i think he told someone to do that a while ago but i thought it was a really good exercise so thank you son hopefully now you should have a better understanding of the three main topics i covered in this video which i think are the three most important topics for beginners to know in cv2 these topics are the basics of logic what the heck an exec port is how do you like make things actually happen the basics of gadgets and how you can incorporate pistons and text and stuff in with your logic and the basics of networking what the heck a local player is how you can use room authority and how you can have a constantly running signal if you have any questions on any of those things or more you can check out the gadgets of e2 channel in the official rec room discord server there'll be a bunch of people there to help you including me i spend quite a bit of time in there so if you ask a question i might answer you okay i can't think of anything else i need to say right now even though i'll probably remember later in editing and i'll be like why didn't i record that uh so i guess that means it's time for me to go make sure to subscribe if you enjoyed i know it's not usually what i make but i really want to help educate people on circuits v2 especially those who don't really want to go to a class and would rather use a video to learn so yeah i hope you enjoyed and i'll see you next time goodbye
Info
Channel: BVR
Views: 187,429
Rating: undefined out of 5
Keywords: rec room, circuits v2, bvr, tutorial, rec room tutorial, circuits tutorial, cv2, cv2 tutorial, rec room weekly, bvr rec room, billehbawb
Id: L4yvvoWdpWA
Channel Id: undefined
Length: 39min 2sec (2342 seconds)
Published: Wed Aug 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.