What's New
I've remade gvars from scratch. They are now much more optimized. I kept most of the old function names for compatibility.
The old syntax works just like usual, except the fact that gSetGroup now persists (it didn't before). However, it is recommended to use the new syntax for several reasons:
1) The old syntax still only supports the same data types as it did before (strings, numbers, vectors, angles and entities), while the new syntax supports EVERY SINGLE type.
2) The new syntax's syntax is a lot neater and easier to use.
I was not able to find any bugs, but please report any bugs as soon as possible so that they can be fixed.
Tutorial
I'll now take some time to go through exactly how the new syntax works.
Functions
A list of all functions now available:
Code:
Function Returns Description
- New syntax -
gTable(S) GT Returns a non-shared gtable with the group 'S'
gTable(S,N) GT Returns a gtable with the group 'S'. 'N' determines wether or not it is shared.
GT:remove*(S) * Removes and returns the variable of the type '*' at the index 'S'
gRemoveAll*() - Removes all variables of the type '*' in your non-shared table.
gRemoveAll() - Resets the entire non-shared table (ie ALL your variables in every group)
- Old syntax -
gSetGroup(S) - Sets the E2's current group. Does persist.
gGetGroup() S Gets the E2's current group.
gShare(N) - Sets wether or not you want to share the variables. (1/0)
gGetShare() N Returns 1/0
gSet*(S,*) - Sets a variable of the type '*' at index 'S' in the current group.
gGet*(S) * Gets a variable of the type '*' from index 'S' in the current group.
gSet*(N,*) - Exactly the same as "gSet*(N:toString(),*)"
gGet*(N) - Exactly the same as "gGet*(N:toString())"
gDelete*(S) * Removes and returns the variable of the type '*' at the index 'S' in the current group.
gDelete*(N) * Exactly the same as gDelete*(N:toString())
gDeleteAll*() - Exactly the same as gRemoveAll*() (Remember that this function is only for compatibility)
Usage
Here are two example E2s which show how to use the new syntax.
Code:
#Expression nr 1
@inputs Button1 Button2
@persist G:gtable
if (first()) {G = gTable("mygroup",0)} #Get the gtable from a group, and make it non-shared (non-shared means only YOUR E2s can read & write on this table.)
if (Button1) {G["button",number] = 1} #If the first button is pressed, set the number to 1.
if (Button2) {G["button",number] = 2} #If the second button is pressed, set the number to 2. Code:
#Expression nr 2
@inputs Check
@persist G:gtable
if (first()) {G = gTable("mygroup",0)} #Get the same gtable as the first E2
if (Check) { #When you press the check button...
print("The last pressed button is:", G["button",number],"!") #Tell me which button was pressed on the first E2
} That should clear things up!
Bookmarks