Hello Guys and Gals of wiremod.
You may rember me from my last project witch was to add UDF to E2.
Well today I launch the beta of my new project to provide Scopes and local variables to E2.
Usage:
The usage of this is to grant the ability to localize variables to code blocks.
This also grants the ability to change variable types over differnt scopes.
Before you use:
Please understand that this is work in progress and is still full of errors.
If you have any issues or queries please post them in this thread do not pm me because I ignore pm's.
Instructions:
As you should know by now I am terrible at explaining things but I shall try my best.
Code:
@name Demo Of E2 Scopes
@inputs VarI
@outputs VarO
@persist VarP
VarG = 5
All the variables here are in the Global scope and are called global variables.
All Inputs Outputs Persists and variables declaired normaly are global.
Code:
VarG = 5
if ( VarG == 5 ) {
local Pinapple = 6
}
Right now here you can see a local variable be created this is only avalible from inside a 'code block' (between the {}).
So if I was to try and acces Pinapple from outside the 'code block' I would get an error because the variable does not exist.
If how ever i was to declaire Pinapple with out localizing it (local) then it would be a global variable.
Code:
Trains = 2
if ( Trains == 2 ) {
local Trains = "I like trains"
}
The above example shows how variables declaired on differnt scopes can be of differnt types even when the variables names are the same.
Trains on the global scope is classed as a differnt value to Trains on the first local scope.
Code:
Scope = 0
if ( 1 ) {
local Scope = 1
for (I=1,10) {
local Scope = 2
if ( 2 ) {
local Scope = 3
}
}
if ( 1 ) {
local Scope = 2
}
}
The above example shows you that there are unlimited number of scopes. For every time you enter a code block you move up a scope and once you leave the code block you move back down a scope.
Code:
variable = 4
if ( 1 ) {
local variable = 7
print(variable) #Prints 7
if ( 1 ) {
print(variable) #Prints 7
}
}
print(variable) #Prints 4
The above example shows you that when you call a variable it will return the varible on the nearest scope.
Another thing to take note of is that user defined functions run inside thier own set of scopes. This means they are unable to acces any other varaible declaired outside of them, however they are able to acces variables from the global scope.
Install and Download
NOW OFFICIAL WIRE SVN
Update Log:
Fixed Functions returning nill when retuning from an if statement.
Fixed Global Vars are no longer nil.
Fixed DupeVars (Thanks to Divran).
Fixed bugs with Variables being null.
Fixed Bug with *@£$%^ statements not working after 1st execution.
Changed E2FS (udf) function to run inside a seperate set of scopes.
Added Argument Lists to E2FS (udf) as requested here.
Fixed huge bug with E2FS (udf).
Fixed for each (Confirm?).
Fixed Arrays (Thnx Syranide).
Fixed lots of broken stuff.
Fixed Tables and Arrays.
Fixed While Loops.
Please Read:
If you wan't this project to succeed then it does require proper testing, where as I do test everything myself sometimes bugs slip though and I need you guys to find them. So please support this project by downloading and testing you can also support this project by liking and commenting.
Known Bugs
Nope, I don't know of any bugs yet.
Special Thanks:
I would like to thank the following people for feedback and beta testing.
Oskar94
DanKing
Omicron
Ghost400
E2 Scope Servers:
]
Bookmarks