Lua Build Series - Basic Data Screen!! - Stormworks

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone and welcome back to another storm works video I hope you're all well and staying safe today marks a new series here on the channel we're going to be starting by doing a lewis screen series now we're going to go off with the very basics on the starting episode and we're going to go and scale it up to a complete custom screen with drops in a couple episodes but this is going to be a fully step-by-step tutorial on how to build your data screens so hopefully all of you can then go ahead follow along and then build your own screams as you need them for your own creations but before we get started if you're enjoying these videos kampala and who else you'd like to see any more future videos while you're there don't forget that like and subscribe button a little bell icons mean of our current content as soon as it gets posted so with all said let's get straight into it and get started with this first episode so we're back here in stomachs at the creative island at the hangar and we're gonna start off things by just going over to our workbench now you'll notice I have got a simple square shape here that we're actually going to be building on with now we're gonna start with a very very basics of lua and we're gonna build up from that now there's a couple things you're going to need of course to start working with this the first thing you're going to need is going to be a screen now this is up to you on what size screen you would like to use the most common screen I see mostly used in most creations is the 2x2 so we're gonna start by actually building with a 2x2 now you can place it anywhere on the square you where you want to and it's up to you on what you would like to actually display for this example right now we're going to be starting off by basing some very basic creation information for example engine RPS we also probably want to know what the temperature is maybe how much fuel we have how much electricity and met possibly how much generator battery we were actually getting out of a corrosion so very very basic and as I said earlier we'll build it up and build it up as we build on on the episode so we'll add some more features some custom features and how to change colors on the fly etc etc and different touch screen options etc but let's start with the very basics in this episode so the next thing you want is obviously what you're going to be read we're going to get some basic information I'm so I'm gonna get an engine so let's go and get a very started engine here we'll quickly just go and why this up so I'm just gonna add some quick piping into this and let's go and do everything we need here so we have exhaust we have here we have the coolant and we're just gonna add a simple radiator onto that just like that we'll add some fuel on so let's get a fuel container just over here we can simply just put it down there flip it around and place it there and the last thing we have there is going to be our output we're gonna go and bring that let's say let's bring it straight to a generator so go and find a generator here and we'll put that down perfect okay so we've got a very basic setup for an engine here we can also add in a throttle that we're gonna control our engine with there we go and let's get a starter button so let's get a simple push button here just to start it off and we will need a battery also so we've got all the things that we want to read data from and you'll notice if you go over to your nodes you can see there we have the charge we're gonna have our RPS our temperature we're gonna have how much fuel there is and also how much generator power group is using with the engine and electricity so once you have all that done pretty much the last things you want to do is a way to turn the screen on now you could use a keys which you could use a button you could use on constant on signal I'm just going to use the constant on signal so our screen is always on okay you can obviously get that connected up there we can get some a trustee to a couple things make sure that's all getting correctly done I'm not showing you guys how to set this all up just yet the main thing we're gonna focus on is the little elements of this so I'm just gonna Karen just adding all the stuff together throttle is just gonna go over there and I'll start is gonna go to our engine and that's pretty much all ready to go and we can now start building on all the information we need to go and get up Luis monitor while screen or connect and I'm actually showing all this data to do that we're simply going to go to the microcontroller we're going to create to my controller now it's up to you on what size you want this to be I'm just going to go and create let's say 3x3 for now and we can build on to it later on in the future okay so microcontroller you can edit this to whatever you want to call it I'm going to call it data screen and then we're going to go into the logic what we want to do is we want to stop adding all those nodes of information we want to start reading okay so the first thing we want to read is we want to read the RPS of the engine so RPS input the next thing we can go and get is another numbers as we our battery okay battery is going to come input also the next thing you can read let's say our generator so this is gonna be generator what it's okay perfect it's fuels another thing we can read so let's go and get fuel actually change it to number of course and the last thing we're going to go and read is going to be our we've got battery over here ready we've got RPS we got generator once we've got fuel that's one we can do is our temperature of that engine yes we've got these five different inputs we're receiving data you could also read the throttle if you want in a couple of different things we're gonna stick with just these five elements the moments the last thing you're going to need here is going to be an output that is actually gonna go to the video signal all over the monitor and it's going to be an output so that's going to go to our screen which is a two by two screen okay if you want to you can reduce the size of this we're going to keep it as a three by three for now because we're going to build on this in the future once we have that I like to just copy this when we save it later on we can just obviously paste the data screen in there let's go over to the logic part of this so we have our screen just over here I'm gonna keep that separate to the right we're gonna move everything else over to the left hand side of our screen and so we're gonna get with that all across over there these are the five different things that we're reading and we want to convert them into a video output what we're going to do now is we're simply just going to go a simple way of actually transferring all that information into composite to do that we're going to go and get a write and we only need a write number because we only have numbers coming in here so you can see here we have a write number that's going to go an output as composite we can click on it we can go give it let's say five or six channels up to you on how many channels you want we only have five inputs so we only going to send five information through that so we're simply going to get that connected up so it's temperature on one fuel on two generator on three battery on a fall and RPS on five you'll notice that we can't connect the composite to our screen what we need here is we need a Lewis script block that way we can go and transfer this composite into a video art project letting go start monitor the only problem is that this has not been coded or scripted yet so that's where we're gonna come into our next thing if we click on it and click on edit script that will take us to our Lewis script where we can start actually working on this now a lot of these things that are already here are really nice and you can use them as you start off with if you ever need any more information or data you can go to the help screen here which has got some examples and it's got all the different opportunities in different scripts that you can use and we'll be using these for our example today so we're going to leave it as that for now we're gonna start editing this the first thing is we want to get all those numbers we want to read all those cut that information we're pulling in and we want to understand what it is to do that you can see we already have a value equals input get number one so we're going to simply just delete that a second line over here we don't need it when you delete all this extra stuff on here and we're going to say that we go back you can see number one was our temperature so we can go back to our Lewis script we can say temp the temp equals input get number one we can then copy this press ENTER paste it we can change number to two and we can say okay well number two was fuel we can now click on the script again and rename this one to fuel okay so the system is knowing that temperature is number one number that's coming in and fuel is number two coming in we can repeat this process for all five of our numbers so we can make sure this is value three value 4 and value 5 click out let's see we have a generator battery and RPS the back into our script so we have generator so we can call it Jenny we can call it our PS and we can call it last one and which is going to be our battery we can double check that to make sure it's right again I switch the battery and the RPS around so I'm simply just gonna go and switch my numbers here just to make my life easier ok there we go we're now switch this obvious is going to value 4 and battery is going to value 5 double check it again battery 5 RPS for generator 3 fuel 2 and temp 1 so it's not understanding what those five numbers are that are coming into the Lua script so now that we're reading these values the next thing we want to do is actually draw this information on the screen now you can use what we've already got here okay I'm going to leave the first two lines the first line is saying that W W which is a value is the width of the screen and H is the height of a screen it's actually reading that data the next thing is we can choose what color we want the screen to print its text on now this is up to you if you want to keep this I'm actually going to delete both of these lines on here and the reason why I want the screen to be completely black or I can actually change its color but we're going to go into that in an advanced video in the next episode we're going to start off by destroying the screen clear so there's absolutely nothing on it and you can scroll down to where all the functions are and you can see here we can clear the screen with a current color okay so we first need a color so I'm just gonna simply go and grab this code here paste this down and screen set color and I got RGB values if I want it to be red I can do 235 and I wanted to be green I can set it to 55 if I wanted to be blue 255 at the moment because I have 255 on all of these it's currently white I want my background to be completely black so we're going to leave it all at zero zero zero the next thing is we're going to clear the screen of this color so we're going to get black on the complete screen so draw screen clear perfect we can then paste that down so that means we're reading the words we're reading the height with setting a color of black and we are making the whole screen quality black the next thing is we can start adding our data on the first thing we want to do is add our temperature that we also want to have a name tag and then on the right hand side we want the temperature actually reading out there to do that we can simply go and add some text then I personally recommend you use a text box it's much easier to work with and just using simple text to use a text box copy and paste this in we're going to go in here copy and paste it so you can see screen draw text box an exposition of your screen Y position of your screen with the width and a height what text you want to have in there and you'll height a line in your vertical line so where do we want to write it on our screen so X is going across your screen and Y is going down so we want to start it just over let's say over here for example we don't want to start it at the edge we want to skip one block so we're gonna say at one and the same goes for your Y wage you want it do you want it to go down you want to go up remember that the screen width and height will depend on the size screen using small screen one block 32 pixels set 2x2 which we're using in our example is 64 okay 64 by 64 now you can obviously read this part so we could actually print this data out and we're going to do that just to start off with okay so we're going to print the width and we're going to print the height onto our screen so we know what it is so we're gonna print at position X 1 vision y 1 the width of its let's say is gonna be 64 our height is that's a six for our example the text is going to be our width height a line and also a vertical line you can leave it at zero which is going to be centered okay zero and zero is centered we can copy and paste this again perfect we just kind of say well wait we want to X once again relieve it at X is 1 so we're across the screen we're gonna keep to the left hand side okay and also where do you want it height wise well we're gonna skip let's say 8 okay and that means hopefully 1 actually paste on top of it will jump a line down and then carry on and this time we're going to be posting the height okay one thing you need to remember is that we haven't set a color for this text yet so make sure you click enter and again you take your color and you set the colored we're going to say we wanted to draw white so we're gonna go let's say mild white which is that say 200 by 200 not very bright but not too weak either once you've got this in we've now got the scripting in here once again we're reading what the width of the screen is we're reading its height we set in color to black we then drawing the screen completely black we're changing the color to white and we're writing two mounds of text the first text be rising is the width of the screen and the second bit of text rerouting is the height we're writing at a position of one by one so up here in the top left corner and one by eight which is also top left but a little further down on your y-axis once you're happy here make sure there's no errors click OK done and simply you can go and save this so I'm gonna save it as my data screen I can then close this off I can go to my inventory search for my data screen data screen there it is right there rabbits I place it down and now I can assign it to logic so we're gonna do the video across there make sure you got all your numbers a battery perfect temperature let's go and get that RPS right generator perfect and fuel right that's not gonna actually help us at the moment because we don't have that any other information on that screen yet let's just check that our wit to the heart is working it's morning in there we go as our obviously our width 64 and our height 64 if I was to change the monitor and I'll show you this guy's if we go and go to another screen and we go and get let's a five by three screen and place that done let's get it just over here and connect it once again connect the on/off get our electricity on it and connect its video we spawn that in once again 160 by 96 so it is working it is reading its data which is perfectly great we're going to need that again and we can go and get our 2 by 2 screen once again I think it's the most common screen that we usually use but once again that's up to you and will vary depending on build that you're actually making get that all connected up and we can now go back into the logic to get back to we don't have to go to the microcontroller we can just click on this and click on edit this will take us in back to our my controller and we can actually go into the Lua screen and we can edit the Luas screen again now that we know what the width and the height is you can actually use that to set the width of the text you're writing if you want to do you don't have to this is completely up to you but it's once again it is quite nice so we're gonna switch this to width okay the next thing we want to do is we want to write all these values on the left hand side we want to write all those values on the rev counter left hand side so to do that what we're going to do is where it says W and H this is usually where the text goes guys this is where text usually goes for can just replace this with text okay I'm gonna go and just simply copy this paste it five times because we have five values and I'm going to go and change the height at what it's displaying on my screen so you can see this was one this was eight so we stepped it up by seven okay so we're gonna say this one is 15 okay step up another seven hey there's 22 another seven from that would be 29 yeah simple nice and easy we're just bringing it up in increments of seven we can leave everything else and the only thing we need to change again it's gonna be our text and I'm also gonna change my alignment now to remember what my alignment was you can see this is height aligned and vertical align okay I'm gonna go to my vertical either I'm going to tell it to be on the left-hand side so we're gonna say one over here you can check make sure it's working in a few minutes okay and go and put that in there right now we'll check again this is actually a horizontal align so my apologies we're gonna just switch this to zero okay so once we have that all in and we've got our actual horizontal going to the left-hand side we can now enter in our text so the first thing we have is our temperature so we're going to write temp the next thing we're going to do is our fuel okay and you want to make sure that it's actually in quotation marks that way is actually typing this it's not actually crabbing that number okay so we're just gonna add our quotation marks over here simple nice and easy and then what we're going to write is the third one which is going to be our generator both one is going to be our obvious and first one is going to be our battery and so I'm simply just abbreviated for all of these we can make sure this works by simply checking it's got no errors once again clicking the done button and clicking the date once it's updated make sure you still have all your connections that you need to have and we can simply spawn this in if we've done this all correctly you will notice okay it's actually pushing it all to the right-hand side of the screen for some reason and so we can go back into it let's go back to our my controller click on the Lua script and we're going to go and do a negative one now on these values okay so it's hopefully going to push it to the left instead of pushing it to the right it's morning in update again spawning let's go and check it there we go we now have temperature fuel generator RPS and battery information over here we now want to get that actual information from here and we want to put it on the right-hand side to do that we just repeat the same process over again so we can simply go into my controller go into our Lua script and I recommend the easiest way here simply copy this jump on line paste it in okay you can differentiate if you want to where that is at the top is on your left and this is going to be our information and the only thing you have to change here is to get rid of the negative so it's not pushing it to the right hand side it's still gonna be on the same lines somebody get rid of the quotation marks make sure it's the same hey if you have lower case use lower case same goes here lower case Jenny lower case once again get rid of the quotation marks just over here RPS is also lower case perfect battery is also lower case okay so dat and that's now going to push it to the other side we can go and check that press on done click on update to confirm exponent and we should not have all those information on the right-hand side okay you can see that both things are going a little bit haywire there you can see we have temperature five we have a whole bunch of different things okay and that's not exactly what we want it's going a little bit crazy we can fix that by limiting a how much space it has okay so we're going to go back into the actual data screen here and what we're going to do is we're going to limit the script from actually grabbing all the num and we're going to compress it into what we want whether it's zero decimals one decimal two decimals it's completely up to you and to do that we're going to simply just use a simple string so we're going to do is where we have temperature we're simply going to paste in here string dot format okay you can copy this exactly the same you can google this it will come up again okay what this string format does is it takes that number that we're giving it okay and that number is going to be our temperature okay and then it's going to actually I'll put it like this so percentage here okay so that's going to be the temperature that's getting in there and depending how many quotes sorry how many decimal places you want I don't want any decimal places I'm gonna put zero now we will get into some more advanced things in the next video where we can actually add like associate sign and Fahrenheit sign but I will I won't talk about that in this video we're going to do more advanced later on we go simple string format you okay this hopefully should actually go and regulate our temperature to zero decimals and we can test that out by clicking on done before we do make sure you always check errors here click on done go and update this perfect spawn it in you should now see that our temperatures only got one value it is it's just hidden over there okay so we want to actually fix that okay and that's easy enough for us to fix okay we can go back into our actual edit screen here go in go to lua script and we're going to tell it that now hey we want you to go a little bit left so we're gonna go to where the width is okay just over here and we're going let's say negative negative six and that's how hopefully you should bring it across are enough for us yeah we can go and test that again make sure it is gone or enough to the left so it's not sitting right on the border there we go that's a little better oh look temperature five we can now go and repeat the same process for all the other things so we can go back into our microcontroller again go back to our script here and we can start adding a string format or all of our numbers you don't have to do to all of them completely up to you I'm just going to for this video why not let's get some nice clean numbers okay so we said the first one was temperature the second one is going to be fuel third one is going to be generator so Jenny fourth one is going to be obvious and the first one is going to be our battery perfect we can choose the decimal places so currently they're all on zero if we wanted to change that we could we're gonna leave it on zero for now once again if you want to reduce this down because it was too far to the left now we can bring us to like three if you want to it's up to you guys bring us the three let's try it let's see how it is got a trial and error with Lua let's go and spawn that in let's see how that's looking hi there we go look at that temperature five fuel one eighty two generators zero watts RPS is zero and batteries one perfect now you can convert these numbers if you wanted to but we'll get that into that and load more the future and I episode okay but let's check these numbers are actually updating let's get our throttle on let's turn our engine on engines running and make sure it's running okay let's have a look here so temperature 35 36 fuel 181 generates is producing 3 watts of power RPS 20 and battery 1 perfect so it's updating for us now you can shift this down you can move this in different directions up to you just play with the width and the height of it but that is the very basics of getting a simple data screen here in Lua as I said we will do another video we'll be going into more customization more advanced things the next video I'll show you how to add actual litres and how to add wattages and things on Insull seus and fahrenheits onto this outta time on etc I said we'll get that into that in the next video but I think that's a great place to end this episode off with hopefully you guys have enjoyed this and obviously it's been somewhat educational also has helped you building your creations here in the future so I think we'll go ahead and in today's video over there please comment below and let me know what else you would like to see in upcoming episodes and what other custom features you would like to see on the lower screens here in storm works but thank you very much for watching I hope you enjoyed it and found some entertaining and informative has always and we'll see you in the next one [Music] you
Info
Channel: MrNJersey
Views: 78,691
Rating: undefined out of 5
Keywords: Stormworks, update, news, major, next, island, map, area, snow, mountain, land, friday, improvements, thumbnail, screens, monitors, radio, camera, lua, code, script, laser, distance, shark, megalodon, attack, bug, electric, battery, winch, cable, fuel, rockets, space, space engineers, missile, composite, seat, new, speaker, mic, server, dedicated, dedicated server, hosting, friends, v2, guide, doors, sliding, hinges, custom, windows, modded, xml, train, simple, basic, step, step by step
Id: njAcMZCudPI
Channel Id: undefined
Length: 25min 30sec (1530 seconds)
Published: Tue May 26 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.