User Tools

Site Tools


hpl3:game:scripting

Link to this comparison view

Both sides previous revision Previous revision
hpl3:game:scripting [2017/04/26 06:54]
alexkalopsia [User Module]
hpl3:game:scripting [2017/04/26 06:57] (current)
alexkalopsia [Callbacks]
Line 26: Line 26:
 ===== 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 32: 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(){
   ...   ...
hpl3/game/scripting.1493189679.txt.gz · Last modified: 2017/04/26 06:54 by alexkalopsia