User Tools

Site Tools


hpl3:game:scripting

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl3:game:scripting [2015/09/11 10:32]
ian.thomas [Important notes]
hpl3:game:scripting [2017/04/26 06:57] (current)
alexkalopsia [Callbacks]
Line 17: Line 17:
 Instead do this: Instead do this:
  
-<code c++>/​*void Update(float afTimeStep) {      UpdateStuff(afTimeStep); ​ }*/+<code c++> 
 +/*void Update(float afTimeStep) 
 +{ 
 +  ​UpdateStuff(afTimeStep);​ 
 +}*/
 </​code>​ </​code>​
  
 ===== Callbacks ===== ===== Callbacks =====
  
-When setting a callback for a function, the callback function will either be searched for in the Entity or the current map script (depends on the function, but most will be the map script.+When setting a callback for a function, the callback function will either be searched for in the Entity or the current map script (depends on the function, but most will be the map script).
  
 However, if you want to call a global function, i.e. one that is outside of the map or entity class, then you can use the prefix ''​$''​. For example: ''​SomeFunction(…,​ "​$CallbackFuncDecl"​)''​. Note that this class must be in the same file (or in one of the included files) as the class objects that would otherwise have been searched. So if you do ''​$SomeFunc''​ for a callback that checks the map file normally, then this will call the global func ''​void SomeFunc()''​ in the map script or in a file included by the map script. However, if you want to call a global function, i.e. one that is outside of the map or entity class, then you can use the prefix ''​$''​. For example: ''​SomeFunction(…,​ "​$CallbackFuncDecl"​)''​. Note that this class must be in the same file (or in one of the included files) as the class objects that would otherwise have been searched. So if you do ''​$SomeFunc''​ for a callback that checks the map file normally, then this will call the global func ''​void SomeFunc()''​ in the map script or in a file included by the map script.
Line 28: Line 32:
 To be clear, here is the difference between a global function and a class method: To be clear, here is the difference between a global function and a class method:
  
-<code c++>//​The following is a global ​functuion+<code c++> 
 +//The following is a global ​function
 void DoStuff(){ void DoStuff(){
   ...   ...
Line 83: Line 88:
 === General === === General ===
  
-A user module is a class that has all kinds of functionality. It is really just base class that can be filled to take care of some kind of behavior. Normally the modules are not used directly, but instead have helper functions that simply the calling of various methods.+A user module is a class that has all kinds of functionality. It is really just base class that can be filled to take care of some kind of behavior. Normally the modules are not used directly, but instead have helper functions that simply ​handle ​the calling of various methods.
  
 Modules are added in "​Modules.cfg"​. Modules are added in "​Modules.cfg"​.
  
-The games come with pre-made ones that can be find in [[:​hpl3:​game:​scripting:​user_modules|User Modules page]].+The games come with pre-made ones that can be found on the [[:​hpl3:​game:​scripting:​user_modules|User Modules page]].
  
 === Callback Methods === === Callback Methods ===
hpl3/game/scripting.1441967557.txt.gz · Last modified: 2015/09/11 10:32 by ian.thomas