Blog
-
An Optimization for Lua Scripts
Lua is a powerful, lightweight, scripting language, and is often used in video games due to fast execution and a short learning curve. World of Warcraft, Angry Birds and Mafia II all use Lua script. Today, Chief Scientist at ROBLOX, Erik Cassel, d...
| February 29, 2012 -
Tech Note: Scripted tools and weapons
Our head gear programmer Deepak Chandrasekaran explains the steps that went into creating The Dagger of Shattered Dimensions . The ROBLOX creative team meets regularly to plan new items for publication in the Catalog . Recently they were inspi...
| February 7, 2012 -
The Evolution of Voxels in Video Games
How do you represent objects and terrain in a 3D video game? A partial list includes triangle-meshes (very common), geometric primitives (ROBLOX), and height maps (terrain). Today I’m going to talk about another way of modeling objects and t...
| December 27, 2011 -
A Brief History of Physics in Video Games
Objects in the real world operate under the laws of physics – so it seems quite intuitive that everything in video games (console, PC, online, mobile, arcade) should as well. The graphics world has evolved towards hardware acceleration on dedica...
| December 14, 2011 -
Announcing the First Ever Rich Tester Day
ROBLOX is a game built by its players. Players help us test the game too – on our test sites such as gametest.roblox.com and sitetest.roblox.com . Many of the bugs our early testers find are fixed prior to release, so most ROBLOXians don’t ev...
| September 22, 2011 -
The Terrain Game
Hail ROBLOXians! Today has been an exciting week at ROBLOX HQ. The new terrain feature is 98% done; we did our first public test of terrain on gametest.roblox.com yesterday. What is terrain? I could tell you, but maybe you’d rather hear from the...
| August 26, 2011 -
ROBLOX Plugins: Power to Scripters
Last night, ROBLOX released an exciting new feature for scripters… My friends, we offer you nothing less than total control of your ROBLOX building experience! It’s my pleasure to introduce the ROBLOX plugin architecture: it allows scripters, ...
| August 12, 2011 -
Teleportation: The Art & The Science
It has been a long journey, people. A long journey. In the beginning, there was no notion of space (or spaces) in ROBLOX. When I joined the company in June 2006, the only playable place there was was Crossroads . Then we allowed the users to host ...
| July 22, 2011 -
Scripting With Telamon: Debugging
Howdy! Today’s article is for Roblox power users who want to learn how to develop scripts in Roblox. This is not a programming language tutorial - I will assume you know enough about Lua to look at a piece of code and guess at what it does. Rather I am going to teach you how to deal with buggy scripts and show how to debug them. Debugging in general is a mystical art - I use the word "art", which is the product of innate creative forces, in contrast to "science", which can be dissected, reduced, and taught. We’ve built some tools into Roblox Studio to help you though. strong We’re going to build a secret door. An easy way to make a secret door is to make a brick and set its CanCollide property to false. Anyone can them walk through such a brick. No. Our secret door is going to be special. It’s eventually going to guard the treasure room in my castle and it’s only going to let approved members of the Pirate Army through (Arrrrr!). Clearly we need some scripting here, me hearties. strong When I’m making a complicated script, I try to test it as I go along. I’ve seen a lot of people in intro programming classes try to write all their code at once and then test it. This is about the most painful way to write code. Don’t do it. Instead, write the shortest bit of code that you can test. Test it. If it works, add some more stuff. Then test it. If something broke, you know where to start looking. A more simple version of the door we want to make is a door that just turns transparent whenever anything touches it. a strong Ok, time to break out the power tools. If you have been scripting without these, I feel sorry for you. There are two that I will talk about today: the Output window and the Command toolbar. The first is by far the most useful, so I will focus on it. To bring up the Output window, use the View -> Output menu option. This is add a window pane to the bottom of your screen. This window will show the output from your scripts while they are running. If your script has an error in it, the error will be printed here along with the line number telling you where the script broke. Let’s look at both of these right now. In your new script, paste the following code: p As you can probably tell, this script prints "Hello world!", spits out the numbers 1 to 10 and then crashes on an error. If you press the Run button in Studio, you can see this. The output will look like this: p This is telling us that line 7 of our script is bad, which is something we already knew. However, in a more complicated script, it can be very helpful to print out stuff as the script is running so that you can see where things are going wrong. It may seem obvious once I’ve said it, but if something is broken with your script, start printing stuff out - rare is the bug that will not succumb to this level of scrutiny. I once wrote an entire operating system, using only printf to debug it. a p And if you have a part named "Door" in your level, it will be immediately teleported to (0, 100 ,0) while the game is running. This is kindof arcane, but I mention it because I have found the Command Toolbar useful on occasion. strong Here it is: p If you have ever seriously tried to learn lua scripting for Roblox, you have looked at some Roblox scripts. The code for listening to a Touch event should look familiar. Basically I have wired up the Part.Touched event to call the onTouched function whenever the part is touched by another part. When this happens, the door will turn semi-transparent for 5 seconds. Add this to your Door script, save your map, and try it. If you touch or shoot the door, you will see a nice effect. If you have the Output Window up, you will also see a "Door Hit" message printed whenever the door is touched. If you did not see this message, you would know that the onTouch function was not being called and that you had not wired up the event handler correctly. strong Like I said, this is not a tutorial on actually writing code, only debugging it. So here is the finished script: p It has one bug in it. Without using the Output Window, the only thing you will be able to tell is that the script is not working. With the Output Window, the problem becomes obvious: p Since the script prints out "Door Hit", but not "Human touched door", we know the problem is somewhere in line 18 or 19 of the code. The Output window tells us that there is a problem on line 18 - FindFirstChild is failing. Ah! That is because in Lua methods are invoked using a colon (:) instead of a dot (.) (all other languages of consequence use dots for this - curse the inventors of Lua!) Change the line 18 to be: p a - Telamon a
| June 30, 2008 -
RocketPropulsion
There’s a new “RocketPropulsion†object in town. It works similarly to the BodyGyro and BodyPosition objects, but this one moves a part around in a manner not unlike a rocket. For a sample of this new feature, visit my place...
| June 28, 2007 -
Scripting with Telamon
Howdy! Today’s article is for Roblox power users who want to learn how to develop scripts in Roblox. This is not a programming language tutorial - I will assume you know enough about lua to look at a piece of code and guess at what it does. Rather I am going to teach you how to deal with buggy scripts and show how to debug them. Debugging in general is a mystical art - I use the word “art”, which is the product of innate creative forces, in constrast to “science”, which can be dissected, reduced, and taught. We’ve built some tools into Roblox Studio to help you though. strong We’re going to build a secret door. An easy way to make a secret door is to make a brick and set its CanCollide property to false. Anyone can them walk through such a brick. No. Our secret door is going to be special. It’s eventually going to guard the treasure room in my castle and it’s only going to let approved members of the Pirate Army through (Arrrrr!). Clearly we need some scripting here, me hearties. strong When I’m making a complicated script, I try to test it as I go along. I’ve seen a lot of people in intro programming classes try to write all their code at once and then test it. This is about the most painful way to write code. Don’t do it. Instead, write the shortest bit of code that you can test. Test it. If it works, add some more stuff. Then test it. If something broke, you know where to start looking. A more simple version of the door we want to make is a door that just turns transparent whenever anything touches it. a strong Ok, time to break out the power tools. If you have been scripting without these, I feel sorry for you. There are two that I will talk about today: the Output window and the Command toolbar. The first is by far the most useful, so I will focus on it. To bring up the Output window, use the View -> Output menu option. This is add a window pane to the bottom of your screen. This window will show the output from your scripts while they are running. If your script has an error in it, the error will be printed here along with the line number telling you where the script broke. Let’s look at both of these right now. In your new script, paste the following code: p As you can probably tell, this script prints “Hello world!”, spits out the numbers 1 to 10 and then crashes on an error. If you press the Run button in Studio, you can see this. The output will look like this: p This is telling us that line 7 of our script is bad, which is something we already knew. However, in a more complicated script, it can be very helpful to print out stuff as the script is running so that you can see where things are going wrong. It may seem obvious once I’ve said it, but if something is broken with your script, start printing stuff out - rare is the bug that will not succumb to this level of scrutiny. I once wrote an entire operating system, using only printf to debug it. a p And if you have a part named “Door” in your level, it will be immediately teleported to (0, 100 ,0) while the game is running. This is kindof arcane, but I mention it because I have found the Command Toolbar useful on occassion. strong Here it is: p If you have ever seriously tried to learn lua scripting for Roblox, you have looked at some Roblox scripts. The code for listening to a Touch event should look familiar. Basically I have wired up the Part.Touched event to call the onTouched function whenever the part is touched by another part. When this happens, the door will turn semi-transparent for 5 seconds. Add this to your Door script, save your map, and try it. If you touch or shoot the door, you will see a nice effect. If you have the Output Window up, you will also see a “Door Hit” message printed whenever the door is touched. If you did not see this message, you would know that the onTouch function was not being called and that you had not wired up the event handler correctly. strong Like I said, this is not a tutorial on actually writing code, only debugging it. So here is the finished script: p It has one bug in it. Without using the Output Window, the only thing you will be able to tell is that the script is not working. With the Output Window, the problem becomes obvious: p Since the script prints out “Door Hit”, but not “Human touched door”, we know the problem is somewhere in line 18 or 19 of the code. The Output window tells us that there is a problem on line 18 - findFirstChild is failing. Ah! That is because in Lua methods are invoked using a colon (:) instead of a dot (.) (all other languages of consequence use dots for this - curse the inventors of Lua!) Change the line 18 to be: p a - Telamon
| February 14, 2007