Perhaps their only target platform is Windows Matthew? Targeting multiple platforms rather than one introduces some additional complexity, and not everyone wants or needs to deal with that. That's really pretty unrelated to the point of this article though, which aims to provide a relatively simple example of how AngelScript can be added to an existing project. I've only skimmed this article, but I like that it gives a structured approach to the task of adding scripting to a game.
|Published (Last):||23 February 2005|
|PDF File Size:||19.46 Mb|
|ePub File Size:||12.29 Mb|
|Price:||Free* [*Free Regsitration Required]|
Greetings, reader. Welcome to this tutorial on scripting in SOMA. SOMA is the latest iteration in a long line of games by Frictional Games, and in true Frictional fashion, the game has been opened up to the public for widespread use. Among other things, the scripting interface was overhauled from the ground up, giving modders a lot more powerful ways to control the engine.
Want to make a 2D RPG adventure? How about a high-octane racing simulator? Those things and more are possible with HPL3. This tutorial will be primarily geared toward people who have never programmed before in any language. While this tutorial does take some looks into the interaction between AngelScript and HPL3, it is not for people who are looking for a comprehensive guide to modding in SOMA. This tutorial focuses on the AngelScript language specifically so as to hopefully provide a more rounded programming experience.
This tutorial will not teach you how to set up a map to make it playable, but once you have created a map, you can use the knowledge in this tutorial to do the scripting for that map and make it come to life. Most popular programming languages nowadays use an Integrated Development Environment, or IDE, to speed up and streamline the development process.
An IDE typically contains various helpful features, such as an auto-complete feature when you start typing, the IDE suggests names of various things that you could be looking for , code generation type in a code word and the IDE creates a full block of code for you , syntax highlighting color-coding the script to make it easier to understand what is what or refactoring a fancy term for renaming all instances of a certain word or name. This process is laid out on a special page in the wiki , which will show you step-by-step how to setup Codelite for AngelScript use.
A recent update to CodeLite broke the compatibility for AngelScript, so you will have to try and get an older version. Try going to this page and downloading version 9. Alternatively, you can just use a notepad program. There are many such programs. You can check around in other sections of the HPL3 wiki. There are plenty of active people in the community that can help if you get stuck on something, so feel free to ask. The first thing to do is to take a look at what a typical script file for a typical SOMA map would look like.
When the LevelEditor saves a map for the first time, it creates a bunch of different files at least Open the. You should see something resembling the following which has been formatted for reasons of length :.
A bit wordy, perhaps, but it all boils down to the following categories, each of which you will learn about in a particular lesson:. Most of these aspects are explained in later lessons.
There is one that I can teach you about now, however: comments. Most of the things that go into a script is part of the program's execution - you want it to do something here, then do something there, then do something to those two somethings over there. Sometimes, however, you just want to write a reminder of what some code does so that you don't have to go through it all and figure it out later.
That's where comments come in. Anything that has been marked as a comment is ignored by the program, so you can type in whatever you want without worrying that it will screw up the program. Inline comments are just for a single line. Block comments are for multiple lines. This can span many lines, and can even mark your entire program as a comment if you aren't careful. When you open this file, it starts SOMA in developer mode.
For the first little bit, the game will be loading, but once you hear sounds start to play, hit the F1 button. This brings up the developer panel, and on it contains a lot of commands and tools for testing and proofing your map.
Click that button, then navigate to where you saved your map. Once you do, you should get basically a black screen with a handful of text around the edges. This is because the game is effectively frozen while the panel is visible by default, so the script may not appear right away if the panel is visible.
If you still do not see the text, press F5, which reloads the map and causes it to become visible again. If all went well, then congratulations.
You just created your first SOMA mod. It may not be very shiny, but like I said in Lesson 0, we all have to start somewhere. This is a function call, which you will learn more about in Lesson 6. The important part to note here is that it is the text that actually appeared in the game itself.
And finally, after the closing parenthesis, there is a lonely little semicolon. That semicolon marks the end of a line of code. If you do not put a semicolon at the end of a line of code, SOMA will complain about it and refuse to run your script. I cannot stress this enough: do not forget the semicolons!!! I say that, not to make sure you remember the semicolons, but because you will forget about semicolons at least once in a while.
As long as you remember your semicolons, then when the errors happen, you know what to check first. In the next lesson, you start to learn the basics for real. The very first thing that a programmer needs to know about programming is the concept of variables. If you've taken an algebra class in the past, the term may sound familiar, which is helpful as variables in algebra and variables in programming are similar. Imagine that you needed to write a program that took some numbers and added them up.
The first thing you would want to do is to tell the program what those numbers are. Say you told the program the numbers 3, 7, 2, 8, and 5. Well, the program is going to need a way to remember those numbers so that it can work with them later on. This is where variables come in. A variable is a construct in a program that is designed to hold a value and store it under a label.
For example, take a look at the following code. Let's break this down. In short, this line of code creates a new variable x of type int and gives it the value of 5. There are two things going on in this code. The first is that a variable is being declared , which means that the program is creating a new variable to remember.
The second is that a variable is being initialized , which means a variable is being assigned a value for the first time. Now that our variable has been created declared , we can access it elsewhere in our program. If, say, we wanted to assign a different value to it, we could do the following:. Note that the int is gone from the second line. That is because the int is only required when declaring a variable for the first time.
After that, the program knows what the type of x is, so you don't need to keep telling it. In this code, we create a variable x and assign it a value of 5. Then we create another variable y and assign it a value of x. This means that we take whatever value is being stored in x and copy it into y.
At the end of this code, y will also be set to 5. Before, I talked about declaring and initializing a variable and how it was convenient that you could do both on the same line of code. It is not necessary to do so, however, and in some situations, you may want to declare a variable without immediately initializing it.
You can do that in the following way:. See how the first line doesn't assign a value to the variable x? This is a declaration without an initialization. The value of a variable that has been declared but not initialized is the default value of the type assigned to the variable, which, in this case, is 0 due to the type being int.
More on types and defaults in a bit. The technical term for the name of a variable is an identifier. In general, you can name your variables whatever you want, but there are a number of rules and recommendations for how you do it. Any identifier that starts with a number or other symbol will not be recognized and will cause an error in your script. After the start of the variable, you may use letters or numbers as well as an underscore character.
You cannot use a space as part of a variable name. Second, the identifier cannot be one of a number of specific words. These words are called keywords , and they are reserved by AngelScript to mean various things.
The full list of keywords are:. Following those two rules, you can otherwise name your variables whatever you like. For example, if you have a variable that stores the water level in a pool, you might name it WaterLevelInPool. While giving your variables ambiguous or nonsense names won't result in an error, it will result in your code being incredibly difficult to read and understand, even by you.
While as a general rule it's a bad idea to give single letter names to variables, it is acceptable to do so in situations where the variable is used in a temporary setting. In addition to this, HPL3 recommends a particular convention for naming variables. It involves prefixing the name of a variable with letters that signify both its type and its scope more on scopes in Lesson 7.
For example, if I had an int variable named count that existed on the class scope, then I would call it mlCount. For a list of the prefixes, see this page on the wiki.
Tutorial: Angelscript overview
Programming By Example - Adding AngelScript to a Game Part 1
This tutorial will show you the basics on how to configure the engine, compile a script, and then execute it. The code in this article is not complete, it only contains the relevant parts to explain the basic structure for using the script library. For complete source codes see the samples that come with the SDK. In this tutorial a couple of add-ons are used to make the code easier.
Greetings, reader. Welcome to this tutorial on scripting in SOMA. SOMA is the latest iteration in a long line of games by Frictional Games, and in true Frictional fashion, the game has been opened up to the public for widespread use. Among other things, the scripting interface was overhauled from the ground up, giving modders a lot more powerful ways to control the engine. Want to make a 2D RPG adventure? How about a high-octane racing simulator? Those things and more are possible with HPL3.
Subscribe to RSS
Remember me. Although it may seem like there's more work involved, there are sometimes significant advantages to be gained by writing your program in more than one language. Why is this? The two most significant reasons are that a artificial intelligence coding in particular involves a lot of tweaking and tuning - tasks for which compiled languages are not ideally suited - and b artificial intelligence code ties in to the game design in a particularly fundamental way, so it is often written by the game designers, who may or may not be experienced programmers. If a game designer wants to implement a simple new feature, and that involves asking an already busy programmer to put it in for them, and a two-day turn-around, then the game as a whole will suffer.