Lua Build Series - Touch Screen Menu - Stormworks

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone and welcome back to the fourth episode of the lure build series I hope you are all well and staying safe in this episode we're going to be building a touchscreen here in the newest series we're going to be building a menu with it that we can navigate to different screens and also click on different buttons to do things in our corporation we'll go over all the logic all the components just you're going to need however before we get started if you join these videos kampala and we else you like to see any of our future videos why there they'll get a like and subscribe button I make a lot well I come to me not for my plain content as soon as it gets posted so said let's get straight into it and get started with this episode so getting started with this episode we're back here at the creative base and you can see we've got our example that we've been building up in the last three episodes now I'm actually gonna just take this back to the workbench and we're going to actually just extend the base here and we're gonna be starting a new block here so we're going to keep it completely separate from my current system just because just in case some people are new and they just want to learn how to do the touch part of this so what we're going to do is we'll get a 2 by 2 screen so that's going to get a simple display and you can use any monitor you want to it's up to you I'm just going to use a 2 by 2 for this example the next thing we're going to do is we're gonna need something to turn the screen on so I'm gonna use a simple toggle button that's going to turn the screen on and off now we're gonna start by getting the screen to actually display something will then get it to press a button and we can turn a light on so we'll get our simple light and then eventually we'll actually get it to switch screens by pressing a button ok so and going into a different menu for example it's up to you but this is the very basics we'll need so far so let's get that connected so we're gonna get our on signal to our monitor and then we're gonna get electricity to our button our light and our screen we can then go into our microcontroller because that's pretty much all done we're gonna call on my controller the touch example and I'm gonna straight away just go and save it it's just going to make our lives a little bit easier save it close the large here go back to inventory look for the touch example and then we can edit it from there okay so we've got that in there so once we have that we can actually click on the touch example go to edit and now we can start working on it I prefer this way sometimes now the first thing is we're going to need some way of reading the data on that screen so that's composites or composite inputs and that's going to be touch great we're going to need a video art so that's gonna go to our screen so it's gonna be art screen alright so we've got a touch in a video art and then we also need a way of controlling that light so we'll use a simple on/off node and that's going to be an output and that's gonna go to our alright cool so we've got that we can now go into our logic so you can start splitting everything else out like I like to do one thing to remember you need to do is make sure that output to the screen is actually an out I forgot to change it and we're gonna change to an output now okay go back into our logic and you can see now we can push to the right the most important thing we're going to need is a lure block that's where all of our coding is going to be in so we're going to go from my composite touch into our screen and then from our screen into the actual real screen so this is a lure screen okay we'll also need some way of turning this on and off okay so we're gonna go and simply go and use a read we're going to read the composite and we're gonna convert it into an on and off here perfect and tastic and you can see there it's going in outputting let's now go into our actual lua script and let's start doing everything we need to do inside there we're gonna go into our lua script and you can need most of the stuff in here I'm gonna get rid of the circle and I'm gonna get rid of these different things at the top you now the first thing I want to do is actually want to draw my menu because I want to make sure that's working so I'm gonna set the color and let's set the color to a hundred by 100 by 100 which should be like a nice white color okay and then we're going to go and draw a rectangle at the top so let's go and get a draw rectangle you could type it in I sometimes just find it easier just copy and paste it from here okay and now we can decide where we want to draw it I'm gonna draw it one by one and the width is going to be lets say width of the screen minus two and the height will be let's say 8 and so we should now I'll have a rectangle at that position so let's go and press down again well update it because it's already placed on our controller and now let's make sure we connect our composite connect our lights and connect our video spawned in we should see that rectangle on the screen and we do fantastic ok it's 1 1 2 big on that sides will decrease it and then what I wanted to do is I want to press the buttons actually want to press it right there and I want that light to come on so go into our little script again go into our actual Lua I told you I wanted to just increase the size so I'm just going to do that okay we're gonna say if someone is pressing that then we want you to output a number or an on on channel whatever we want so an easy way to actually set up the touchscreen data is all the information is here inside the actual help which is really cool so if the first thing we're going to do is we're actually just gonna go and grab all this data over here okay so all that and I'm gonna go paste it at the top here right so now what it's doing is it's reading the input egg since reading it it's right it's reading the input get number 3 from a composite touch screen input get up a fall from our touch screen and if we're actually pressing it from our touch screen then what it's doing is it's saying okay well if a player is pressing the screen and they pressing it inside this box then this is active ok so then it's pressing rectangle what we're going to do here now is we're gonna say whatever these numbers were we're gonna actually go and delete them and we're going to paste what we down here okay so that means that if someone is pressing it inside that box then is pressing rectangle on now you could say that you could call that t1 if he wants to up to you completely up to you let's say touch one okay then we can go back to our help text and then we can just go and make sure that this is all set up also okay so we're just gonna go and simply go and copy this again it's an extra function that you do need right there and paste it in simple don't touch anything just leave it literally passes but back to our help and we can see we actually don't really need anything now cool now we want to go and output on channel 1 okay so we're gonna up on channel 1 and we're gonna steal this one perfect let's copy it and we'll come in here and after our t1 we're gonna come in place there we're gonna say output set bull which is sent on off channel 1 and it's this t1 so we can just copy t1 here and paste it so what this is pretty much doing to reading the composite is then saying okay if someone's pressing the screen and it's within this area then activate t1 if t1 is activated and going out put on set pull one perfect press done again update it confirm spawn our creation and we should actually get it to work so let's see we've got our menu let's press it there we go we got our lights it's coming on fantastic look at that we touch the screen and the light comes on cool now we could if we wanted to also we could go back into our controller back into all the other scopes and we can get a simple text box we can write in a text box and we can scroll it light so we're gonna get our text box again go back down to the end of this make a new line text box we're gonna create it the same height and width of this exactly the same as this triangle box or the rectangle box that's why we always start with this first before we do anything else the text is going to be in light so it's good and put that in and then our heart alone and a vertical line will be zero because we want it in the center and then let's go spawn that in let's see now if it writes the light in the center of that box in let's go and activate it there we go we've got light okay it's a little bit high so we might need to drop it down one that's fine but that's easy enough to do press it and there we go now the next thing I want to do is I wanted to press on I want to have another button that I press and I wanted to switch screens for me so let's go and make that button so we're going to come back into our loo here and we're gonna say okay draw a rectangle and where do we want this well we know that this rectangle is going eight down so starting at one that's going eight done okay fair enough so let's go and start this let's say 10 and we're gonna go eight down again leave everything else the same and then we can copy the text again do exactly the same thing where we have this will make a 10 and we call this let's say camera okay so now if we press the screen over here we should get a camera fantastic we should get that little box with a camera written in it cool we can even change that to 11 because we thought we said earlier that it was a little bit too I up great okay now where we can come again is where we have list t1 we're gonna go and copy that exact same thing again control paste we're gonna make this t2 yeah t2 cool so that's gonna and now we can replace this again with what we have in the second box so let's copy paste it here and that should work okay we don't need to do anything else just yet but now we need some way of actually switching to our cameras so we need our video to switch so you could do this a couple different ways you could in theory go and have this video switch box or you could build another Lua script now once again this is completely up to you on how you would like to do this let's let's do the very basic way which is actually going to go and just switch the video signal for us so we're gonna up it again and we're going to add puts on channel 2 and it's going to be T 2 so if T 2 is pressed then we're gonna outputs on channel 2 or alright we can go to this composite and we're going to add an extra note onto it so we're gonna make two notes FX actually sorry we're gonna go and bring it to one and we're just going to copy and paste that my apologies and there we go and we're gonna open on channel 2 great so that's gonna go and switch our video signal itself and so we're gonna come back into our design we're gonna add a new node and that new node is going to be for our camera so a camera coming in perfect camera coming in is just over here so what we want to do is if we press this we want to see the camera screen so we'll get a simple video switch box and place it there so we're gonna say if everything if we're not pressing then we want this Lewis screen to go through is off into our output and therefore pressing it on then we want the camera feed to go through yeah biggest problem with this is that now we don't have any way of giving back we don't have any way of getting back to our actual main menu screen okay well we'll figure that out in a few months it's just update us in let's just go and add our camera because I haven't added a camera yet at a simple camera and let's face it that way cool let's get our video connected and our electricity connected and we can go and spawn at it let's go and see if our second menu bar is there okay it is but it's in the wrong place so let's go and see what we've done wrong with the height of that so we can go back into our Lua script and it sees we got draw a rectangle I came so I went and increase that which I should have actually increased this okay we're just go and change that so that should have been one we should have changed the why not the X okay who's that increase that so ten eleven one two and then same over here so make sure it's one and eleven cool okay so we just got that switched around then update it again spawning in let's go and check I mean you should be in fixed because we switch the X&Y around there we go so we got our lights our camera so we repress the lights like goes on and a press camera a there's our camera screen and actually because it's not receiving any touch anymore it switches back automatically which is pretty cool okay now you could have this lead to another lure okay so we could go into our microfarad gain and creates a whole nother menu subdirectory okay so you could say if we're pressing that button on to then we're gonna go to another lure block so you could actually literally just have like another little block here and then it could extend extend extend extend you can have as many directories as you want to just have to have more and more lure blocks and make a way to go forwards and backwards because as you simple touch which is on and off it automatically went back for us so yeah that's pretty much about it you could add more and more and more as it always start by doing the actual menu once you have the menu it makes it much easier to actually then going to all the touch or the touch goal and and some buttons and do your outputs and things like that but yeah you can create as many menus as you want you can create it going along vertically horizontally you can make it on a huge screen you can make it on a small one by one screen once again completely up to you and I think it's pretty cool I like having screens instead of having a row of a hundred buttons I think it's a little bit easier but once again up to you hopefully this tutorial has been really nice and helpful let me know in the comments what you guys think we should be doing and the next one what would you like seeing being added on to the systems that we have here let me know in the comments and also let me know how you liked this one on how to do a touch screen so I think we'll go ahead in today's video there thank you very much for watching I hope you enjoyed it and found some entertaining and informative as always and we'll see you in the next one [Music]
Info
Channel: MrNJersey
Views: 16,759
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: ls61pYx4wco
Channel Id: undefined
Length: 15min 17sec (917 seconds)
Published: Wed Jun 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.