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/01/22 15:33]
thomas [Map]
hpl3:game:scripting [2017/04/26 06:57] (current)
alexkalopsia [Callbacks]
Line 3: Line 3:
 ===== Important notes ===== ===== Important notes =====
  
-**Avoid Empty Methods**\\+**Avoid Empty Methods** \\
 Never implement an empty callback method. Calling the method takes quite a bit of cpu power compared to just skipping it. This is especially important for Update, PostUpdate, OnDraw and the like that are called every update / frame.\\ Never implement an empty callback method. Calling the method takes quite a bit of cpu power compared to just skipping it. This is especially important for Update, PostUpdate, OnDraw and the like that are called every update / frame.\\
-So if you want to remove function do NOT: +\\ 
-<code c++>void Update(float afTimeStep) ​+So if you want to remove ​an existing ​function do NOT: 
 + 
 +<code c++>void Update(float afTimeStep)
 { {
   return;   return;
   UpdateStuff(afTimeStep);​   UpdateStuff(afTimeStep);​
-}</​code>​ +} 
-Instead ​to DO like this:\\ +</​code>​ 
-<code c++>/​*void Update(float afTimeStep) ​+ 
 +Instead ​do this: 
 + 
 +<code c++> 
 +/*void Update(float afTimeStep)
 { {
   UpdateStuff(afTimeStep);​   UpdateStuff(afTimeStep);​
-}*/</​code>​ +}*/ 
 +</​code>​
  
 ===== Callbacks ===== ===== Callbacks =====
  
-When doing 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, ​that is one that is outside of class. Then you can use the prefix ''​$''​, to do that. 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 ​would have been searched ​exist in. 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.+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.
  
 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 36: Line 44:
       ....       ....
    }    }
-}</​code>​+} 
 +</​code>​
  
 ===== Base classes ===== ===== Base classes =====
Line 61: Line 70:
 All special data needed for the map (and not saved) are destroyed here.\\ All special data needed for the map (and not saved) are destroyed here.\\
 **void Update(float afTimeStep)** \\ **void Update(float afTimeStep)** \\
-Called every update tick\\+Called every physics ​update tick\\
 **void PostUpdate(float afTimeStep)** \\ **void PostUpdate(float afTimeStep)** \\
 Called after all normal Update during a tick has been called\\ Called after all normal Update during a tick has been called\\
Line 70: Line 79:
 **void OnAnalogInput(int alAnalogId, cVector3f &in avAmount)** \\ **void OnAnalogInput(int alAnalogId, cVector3f &in avAmount)** \\
 When an analog action is made.\\ When an analog action is made.\\
-**void OnPlayerDead(int aType, const tString&​in asSource)\\ 
-** When the player has died from damage. asSource is the name of the killer entity\\ 
 **float DrawDebugOutput(cGuiSet @apSet,​iFontData @apFont,​float afStartY)** \\ **float DrawDebugOutput(cGuiSet @apSet,​iFontData @apFont,​float afStartY)** \\
 This only used for pure debug purposes. Use cLux_DrawDebugText(…) for easily outputting messages. "Show Map Info" in the F1 menu must be turned on for it to show up.\\ This only used for pure debug purposes. Use cLux_DrawDebugText(…) for easily outputting messages. "Show Map Info" in the F1 menu must be turned on for it to show up.\\
Line 81: 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 ===
Line 102: Line 109:
 When the debug "draw entity info" is on, this will be called and can rendering debug geometry.\\ When the debug "draw entity info" is on, this will be called and can rendering debug geometry.\\
 **float DrawDebugOutput(cGuiSet @apSet,​iFontData @apFont,​float afStartY)** \\ **float DrawDebugOutput(cGuiSet @apSet,​iFontData @apFont,​float afStartY)** \\
-This only used for pure debug purposes. Use cLux_DrawDebugText(…) for easily outputting messages. “Show Map Info” in the F1 menu must be turned on for it to show up. ALso, if you want the text to be projected on the character, then use iLuxEntity::​DrawProjDebugText(...)\\+This only used for pure debug purposes. Use cLux_DrawDebugText(…) for easily outputting messages. “Show Map Info” in the F1 menu must be turned on for it to show up. Also, if you want the text to be projected on the character, then use iLuxEntity::​DrawProjDebugText()\\
 **void OnPostRender(float afFrameTime)** \\ **void OnPostRender(float afFrameTime)** \\
 Called when a frame is rendered..\\ Called when a frame is rendered..\\
Line 120: Line 127:
 When the container that the module reside in is entered.\\ When the container that the module reside in is entered.\\
 **void OnLeaveContainer(const tString&​in asNewContainer)** \\ **void OnLeaveContainer(const tString&​in asNewContainer)** \\
-When the container that the module reside in is left. +When the container that the module reside in is left.\\
 **void OnPlayerDead(int aType, const tString&​in asSource)** \\ **void OnPlayerDead(int aType, const tString&​in asSource)** \\
-When the player has died from damage. aSource is the name of the entity that killed the player +When the player has died from damage. aSource is the name of the entity that killed the player\\
 **void OnExitPressed()** When the exit button is pressed..\\ **void OnExitPressed()** When the exit button is pressed..\\
 **void OnAction(int alAction, bool abPressed)** \\ **void OnAction(int alAction, bool abPressed)** \\
Line 138: Line 143:
  
 === General === === General ===
-''​iLuxEntity''​ is the basic class for pretty much everything interactive in the game like Props, Areas, Agents, etc (see all below). It has a lot of basic functions that can be used and keeps track of all the data of the entity. ''​iLuxEntity''​ is never used directly, but you always use any of the classes that inherits from it. 
  
 +''​iLuxEntity''​ is the basic class for pretty much everything interactive in the game like Props, Areas, Agents, etc (see all below). It has a lot of basic functions that can be used and keeps track of all the data of the entity. ''​iLuxEntity''​ is never used directly, but you always use any of the classes that inherits from it.
 === Components === === Components ===
 +
 Sometimes the basic data that the entity (or any the classes that inherit from it), is not enough. This can then be extended by the use of components. Components are separate classes without any explicit connections and they communicate with ''​iLuxEntity''​ and one another through a message system. For a full list of the available components and more detail information see the [[:​hpl3:​game:​scripting:​entity_components|Entity Components page]]. Sometimes the basic data that the entity (or any the classes that inherit from it), is not enough. This can then be extended by the use of components. Components are separate classes without any explicit connections and they communicate with ''​iLuxEntity''​ and one another through a message system. For a full list of the available components and more detail information see the [[:​hpl3:​game:​scripting:​entity_components|Entity Components page]].
  
 === Message System === === Message System ===
-The message system is used to send messages inside the entity and use mostly utilized by the Modules. A message is sent a long with a simple data structure (''​cLuxEntityMessageData''​) where the contents depend on the type of message sent. See the enum ''​eLuxEntityMessage''​ for all available messages. 
  
 +The message system is used to send messages inside the entity and use mostly utilized by the Modules. A message is sent a long with a simple data structure (''​cLuxEntityMessageData''​) where the contents depend on the type of message sent. See the enum ''​eLuxEntityMessage''​ for all available messages.
 === Callbacks === === Callbacks ===
  
-For an extensive list of these, check the [[hpl3:​game:​entity_types|Entity Types page]].+For an extensive list of these, check the [[:hpl3:game:scripting:​entities|Entity Types page]]. 
hpl3/game/scripting.1421940830.txt.gz · Last modified: 2015/01/22 15:33 by thomas