User:SoulStealer9875/Programming With Lua

From Legacy Roblox Wiki
Revision as of 11:32, 4 September 2011 by >SoulStealer9875
Jump to navigationJump to search

Introduction

What's your story?

  • Are you the kind of person who wants to produce your own code?
  • Do you want to understand Lua code?
  • Are you someone who wants to know how code talks to the computer?


Well, if you want to write Lua code - I suggest you read this whole guide. This guide avoids the "of-course-you-already-know" assumption and describes Lua programming from scratch.

Icons used in this guide

- Tip. I use this when I want you to have some extra information; something helpful that will make you a bit more aware with coding in Lua.

- Warning. I use this when fiddly things come about. Things you may forget. For example, if I think you may capitalize a letter that may cause your script to break. I will use this icon.

Part 1

Chapter 1: Getting Ready

There's a few things you need to do before you start learning how to code in Lua. The first thing is to get ROBLOX Studio. If you don't already have this software, click here.

When you've downloaded ROBLOX Studio, or if you already have the official ROBLOX Software, click 'Start' -> All Programs -> Roblox -> ROBLOX Studio. This will open the software taking you into ROBLOX Studio.

When ROBLOX Studio finishes loading you will find a toolbar at the top. Find 'File' -> New. Selecting new will open up a new place, you will be required to use this while you read this guide.

Next, we need to insert a blank script. To do this, find 'Insert' in the toolbar -> Object. Selecting object will open up a dialog window with several objects you can insert into your game. Scroll around the dialog window until you find 'Script' then select OK.

If you don't already have the Explorer panel open, go to 'View' in the toolbar -> Explorer.

In the explorer panel, find '+ Workspace'. Press the + next to workspace then double click on 'Script'.

After double clicking on Script, you will be taken into a blank white window displaying the text by default: "print 'Hello World'". Highlight that text and delete it.

Exit out of the script's window and go to 'View' in the toolbar -> Output. This opens up the output window. This will come handy in later chapters when we learn to display text on it.

Chapter 2: Printing

Everyone knows social life is important, so why not be social to the computer? With Lua, and any other programming language, we can talk to the computer. Not literary, 'talk' to the computer. More like, allow the Lua programming language to turn the code into binary and send it to the system which reads the binary and does what's it told to do. Here's a diagram of how it works: