User Tools

Site Tools


hpl3:engine:script

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
hpl3:engine:script [2013/08/22 06:35]
thomas [Saving]
hpl3:engine:script [2014/02/18 07:24]
thomas [Comments]
Line 22: Line 22:
 ||m|| a member variable || class cMyClass {\\ int mlMember;\\ } || ||m|| a member variable || class cMyClass {\\ int mlMember;\\ } ||
 ||g|| a global variable, defined outside of a class or function.|| int glMyGlobal; \\ class cMyClass {} || ||g|| a global variable, defined outside of a class or function.|| int glMyGlobal; \\ class cMyClass {} ||
 +||id|| this is for tID type.|| tID m_idEntity ||
  
 a variable name always starts with a lower case letter, so anything of type not specified must start with a lower case word. Example: a variable name always starts with a lower case letter, so anything of type not specified must start with a lower case word. Example:
Line 61: Line 62:
 cMonster@ pMonster = CurrentHit();​ cMonster@ pMonster = CurrentHit();​
 float fDamage = RandomDamage();​ float fDamage = RandomDamage();​
-fDamage -= pMonster->Defense();+fDamage -= pMonster.Defense();
 if(fDamage<​0) fDamage =0; if(fDamage<​0) fDamage =0;
 fDamage *= mfHitMultiplier;​ fDamage *= mfHitMultiplier;​
-pMonster->DecHealth(fDamage);​+pMonster.DecHealth(fDamage);​
 </​code>​ </​code>​
  
Line 313: Line 314:
 bool bArg0 = cScript_GetGlobalArgBool(0);​ bool bArg0 = cScript_GetGlobalArgBool(0);​
 cVector3f vArg1 = cScript_GetGlobalArgVector3f(1);</​code>​ cVector3f vArg1 = cScript_GetGlobalArgVector3f(1);</​code>​
-**5)** When calling a global function, it is okay to have one or more asterix in the object name and then several object will be called. For example //"​My*test"//​ would call: //"​MyNiceTest"//​ and //"​MyBadTest"//​. However, this will be a bit slower, so be careful when using it (eg not during things called every update)+**5)** When calling a global function, it is okay to have one or more asterix in the object name and then several object will be called. For example //"​My*test"//​ would call: //"​MyNiceTest"//​ and //"​MyBadTest"//​. However, this will be a bit slower, so be careful when using it (eg not during things called every update)
 + 
 +Asterix is also supported for the class name (eg "​cMyClass*"​). If you do not care about the class of the objects the class param can simply be empty (""​). The following will call MyGlobalFunc in all script modules named "​MyClassObj"​ no matter the class name: 
 + 
 +<code c++> 
 +cScript_RunGlobalFunc("​MyClassObj",​ "",​ "​MyGlobalFunc"​);​ 
 +</​code>​
 ===== Saving ===== ===== Saving =====
  
Line 330: Line 337:
 <code c++>​[nodatasave] cMyClass@ mNoSaveHandle;​ <code c++>​[nodatasave] cMyClass@ mNoSaveHandle;​
 </​code>​ </​code>​
 +
 +However it is almost always better to use the tID type for these situations!
  
  
Line 371: Line 380:
  
 C++ scriptable classes with classes in can not be abstract ones. It must always be the top class in the hierarchy that is used and saved. C++ scriptable classes with classes in can not be abstract ones. It must always be the top class in the hierarchy that is used and saved.
 +
 +===== Specific Guidelines =====
 +
 +==== Helper Functions ====
 +
 +  * Helper functions should use degrees, not radians
hpl3/engine/script.txt · Last modified: 2020/07/01 07:07 by thomas