User Tools

Site Tools


hpl2:amnesia:script_language_reference_and_guide:quick_start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl2:amnesia:script_language_reference_and_guide:quick_start [2012/12/21 22:26]
thegreatcthulhu Checkbox Change
hpl2:amnesia:script_language_reference_and_guide:quick_start [2013/08/08 21:21]
killer339494 Checkbox Change
Line 18: Line 18:
  
 It is not required for the script file to exist, but if you create one, it must not remain empty – otherwise, the game engine will not accept it. The file should contain at least one line of valid code. When the level is loaded, the game will look into the script, and it will call the OnStart() and OnEnter() functions, if they are defined in the file. OnStart() is called once, when the level is first loaded, while OnEnter() is called every time the Player enters the level.\\ It is not required for the script file to exist, but if you create one, it must not remain empty – otherwise, the game engine will not accept it. The file should contain at least one line of valid code. When the level is loaded, the game will look into the script, and it will call the OnStart() and OnEnter() functions, if they are defined in the file. OnStart() is called once, when the level is first loaded, while OnEnter() is called every time the Player enters the level.\\
-So, we can start by defining the OnEnter() function. Type in this code in sandboxMap.hps (<​todo ​#>​sandboxMap coming soon</​todo>​),​ or in a script file for your own map:+So, we can start by defining the OnEnter() function. Type in this code in sandboxMap.hps (<​todo>​sandboxMap coming soon</​todo>​),​ or in a script file for your own map:
 <​code=c++>​void OnEnter() <​code=c++>​void OnEnter()
 { {
Line 42: Line 42:
 '' ​   void OnEnter()''​\\ '' ​   void OnEnter()''​\\
 declares the OnEnter() function. The token in front of it denotes its return type; in this case, it is ''​void'',​ which you can think of to mean "​nothing"​ or "​empty"​ – it simply states that this function does not return any value (some functions you'll write //will// return a value, e.g., a result of some calculation). OnEnter() just does something (starts the fade in effect), but nothing is returned from it (you'​ll learn more about return values in the section on functions).\\ declares the OnEnter() function. The token in front of it denotes its return type; in this case, it is ''​void'',​ which you can think of to mean "​nothing"​ or "​empty"​ – it simply states that this function does not return any value (some functions you'll write //will// return a value, e.g., a result of some calculation). OnEnter() just does something (starts the fade in effect), but nothing is returned from it (you'​ll learn more about return values in the section on functions).\\
-Everything that follows after that line is the //body// of the OnEnter() function. It is the function'​s body that defines what the function does. It is enclosed by ''​{''​ and ''​}''​. You can think of these symbols as of boundaries – they bound the space of the function body. Everything in between them belongs to the function.+Everything that follows after that line is the //body// of the OnEnter() function. It is the function'​s body that defines what the function does. It is enclosed by ''​{''​ and ''​}''​. You can think of these symbols as of boundaries – they bound the space of the function body. Everything in between them belongs to the function.\\ 
 +If a region of code is bounded by ''​{''​ and ''​}'',​ it is also referred to as a //code block//.
  
 The text behind ''​%%//​%%''​ represents scriptwriter'​s comments. These are completely ignored by the script engine, as if they weren'​t there at all. They are intended for the human reader – you can use them to explain what a certain peace of code does. You can delete them, and the script'​s functionality will remain exactly the same. The text behind ''​%%//​%%''​ represents scriptwriter'​s comments. These are completely ignored by the script engine, as if they weren'​t there at all. They are intended for the human reader – you can use them to explain what a certain peace of code does. You can delete them, and the script'​s functionality will remain exactly the same.
hpl2/amnesia/script_language_reference_and_guide/quick_start.txt · Last modified: 2013/08/08 21:21 by killer339494