Thursday, December 11, 2014

Basics of Scripting: Print()

     So, before I start reading up on advanced scripting, I will tell you what I already know from previous programming experience. What I currently know should be pretty simple.
     Assuming you're already in ROBLOX Studio and in edit mode in your game, the two things you ALWAYS always always want to view are the Explorer and Properties (select to view these from, well, the view tab). Another thing you want out when testing your game is the Output window. When running your game, this will display the results of every code in your game, even when a player dies. You can run the game with the "Run" button, the "Play Solo" button, and the "Start" button on the Test tab. Run will activate the game as if a player is in it, Play Solo will actually put a player in the game (to test things that affect the player), and the Start button will put as many players into the game as you like (it will open a new RS for each player you choose, and an additional one that is an overview of the game as your players are being used as lab rats). The scripts in this article do not involve players, so you can simply click run and watch things work.
     Alright, let's finally do something involving code. In your Explorer window, you will see a bunch of items in a list (Workspace, Lighting, Players, etc.). We will only worry about the workspace. The workspace is every single item in the game and will be listed inside it once something is put in your game. Right click on this "Workspace" bar and mouse over Insert Object in the window that I hope you know should appear. A very long list will pop up, and buried in it is something called a Script, which you need to insert (by clicking it, of course. If you can't find it, be wary that the objects are listed in alphabetical order). The script will then appear inside the Workspace. Double-click on it and an entirely different RS window will appear, with numbers on the side and at the top, it says "print ' hello world! '." I am fairly certain that's for an outdated version of Lua, but just ignore it anyway. Erase it, y'know. The numbers on the side show how many lines there are. In the traditional script, there are only 2 (line 2 is blank). This is helpful because if there's an error, the output window will tell you what line it happened in and a very complicated description of what went wrong.
     We're going to rewrite the code that appeared. The line used the print() function, a command that will display text only in the output window. It doesn't sound very useful because the public won't see it, but it can be unbelievably helpful, because sometimes the output doesn't detect an error but things don't go how you planned. You can use print() to display text to tell whether or not something worked. Moving on, the parenthesis in functions are crucial, because whatever you type inside of them elaborates their job. Between the parenthesis, type, "Hello world!" (quotation marks included). Then run the game and see what happens in the output.
   
     Yeah, you will see a lot of stuff appear in the Output window. But the most important thing is that there is "Hello world!" buried in there. Actually, you might see it twice, because a lot of stuff happens in the Output from the start page and on. I'm not entirely sure if it appears twice when you run the game, but it is in there a 2nd time.
     *Cough* Moving on, I'd like you to know that beginning programming by saying "print("Hello world!")" is a programming tradition. If you want to teach someone else programming, start with that code, for it is illegal not to.
     I would explain more about this code, but I can't find a way to give a vivid description without showing you more functions first. This article is getting pretty long, so I think I'll just end right here. See you next time!

Tuesday, November 25, 2014

Starting on ROBLOX

     I'm sure creating fancy games is a dream all ROBLOXians share. While creating a game with fun mechanics seems like a good idea at first, there is something deeper and more complicated to it. In ROBLOX, this is called scripting. It's where you create all of the functions of the game with a programming language (and, yes, there are multiple programming languages). There is only one programming language that ROBLOX uses to let you create what you want, and it's called Lua.
     According the book I'm reading, Lua itself is a very difficult language that is hard to understand. On the other hand, with the ROBLOX engine, it is a lot easier (mainly because a bunch of presets are added to lighten the load). If you're wondering what this ROBLOX engine is (let's just refer to it as ROBLOX), it is an online game where you... well, make your own online games. You can sign up and check out what other skilled game creators have made here.
     You do not need a huge building and scripting experience for this. I will be sure to efficiently tell you what you need to do to create a functioning script (part of the game's code). There are also helpful models on the Develop ► Library page that you can use for your games. Just be aware, overuse of them is frowned upon and people will... deeply hate you. But that's just a minor detail.
     Now that I have that cleared up, it's time to get started! First up on the agenda, you might want to create a new place to test the code I will present to you later on. To edit your place, you click on the "Configure" button on the main page everyone sees when viewing your game (don't worry, they can't see those buttons). Here, you can edit the name, description, access, and more. You can also set the player limit, the amount of users that can be in a server (or the game) at one time. If no servers are available, the game will be copied into a new server (and will be listed in the Games tab on the bottom of the normal page). The copylock option is pretty self-explanatory. It prevents people from being able to use your game as their own. Also, there is an option that allows certain types of gears, items their owners can interact with and use on others, into your game. Just be aware, there is a gear called the "Golden Fleece" that allows players to fly. It's labeled categories are Navigation Enhancer and Personal Transport. If you do not check any of the boxes, no gear will be allowed (which is what I recommend). I'll let you figure out the other settings yourself. Just remember to always click the "Save changes" button (running servers are not changed).
     It doesn't matter whether or not you make your game active or inactive from the Develop page (active meaning it shows up on your profile and anyone can play it, inactive evidently meaning the opposite) at the moment. Also, just so you know, the description should be what the game is about and maybe some help if people might need it. I'm also hoping you know what to do with the name. Both have a character limit, though, so be careful.
     But, other than that, just make the game any way you want. Just be sure to choose a starter map from the "Basic" section, because the other templates have preset scripts that will get in the way, but you can use them to your advantage when you get a good scripting experience later on.
     If you already know everything I just said, you are definitely prepared to start building a game. You have to be painfully specific in programming. You have to answer who, what, where, why, when, and how for who, what, where, why, when, and how. This... is not good motivation to get you interested. But, once you get familiar with programming, it will all be worth it. You'll be able to create games as fantastic as your favorites! Maybe even better.
     If you are just starting on ROBLOX, you might want to go around for a bit, learning about everything. While you are doing that, I will be concluding this article. See you next time! Also, why don't you check out my Python blog (Python being another programming language) if you want? You'd be surprised, if you know more about that, then ROBLOX Lua is easier.