Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global variables in SOMA
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#2
RE: Global variables in SOMA

AngelScript doesn't really have anything for static variables. What you can do though is to use the global variable system built into HPL3.

Getter functions:

  • cScript_GetGlobalVarString
  • cScript_GetGlobalVarBool
  • cScript_GetGlobalVarInt
  • cScript_GetGlobalVarID
  • cScript_GetGlobalVarFloat
  • cScript_GetGlobalVarVector2f
  • cScript_GetGlobalVarVector3f
  • cScript_GetGlobalVarVector4f
  • cScript_GetGlobalVarMatrix
  • cScript_GetGlobalVarColor


Setter functions:

  • cScript_SetGlobalVarString
  • cScript_SetGlobalVarBool
  • cScript_SetGlobalVarInt
  • cScript_SetGlobalVarID
  • cScript_SetGlobalVarFloat
  • cScript_SetGlobalVarVector2f
  • cScript_SetGlobalVarVector3f
  • cScript_SetGlobalVarVector4f
  • cScript_SetGlobalVarMatrix
  • cScript_SetGlobalVarColor


Usage is pretty simple. To set a variable, call one of the setter functions that matches the type of the value you wish to set.

cScript_SetGlobalVarInt("some_int_var", 1);

To get the value back, simply call the matching getter function.

cScript_GetGlobalVarInt("some_int_var");

To keep your code organized, and to prevent potential conflicts from other scripts setting their own global variables, make sure that you prefix your variable names so that they are unique to your mod or map. For example, name your variable something like "MyMod_SomeName".
07-10-2016, 11:49 PM
Find


Messages In This Thread
Global variables in SOMA - by Daemian - 07-10-2016, 11:36 PM
RE: Global variables in SOMA - by Abion47 - 07-10-2016, 11:49 PM
RE: Global variables in SOMA - by Daemian - 07-10-2016, 11:55 PM
RE: Global variables in SOMA - by Daemian - 07-11-2016, 02:50 AM
RE: Global variables in SOMA - by Abion47 - 07-11-2016, 03:28 AM
RE: Global variables in SOMA - by Daemian - 07-11-2016, 05:24 AM



Users browsing this thread: 1 Guest(s)