+ Reply to Thread
Page 1 of 8 123 ... LastLast
Results 1 to 10 of 75
Like Tree30Likes

Thread: E2 Scopes

  1. #1
    Wirererer Rusketh's Avatar
    Join Date
    Jul 2011
    Location
    In your pants.
    Posts
    129

    Cool E2 Scopes (Local Variables) aka codename Lemon

    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:
    ]
    Last edited by Rusketh; 3 Weeks Ago at 09:11 AM.

    Creator of E2 Function System (udf) and E2 Scope System (Beta)
    STRP Development Blog: Blog.SpaceTownRP.com

  2. #2
    hurrr physics Tolyzor's Avatar
    Join Date
    Aug 2008
    Location
    England
    Posts
    1,043

    Default Re: E2 Scopes

    I love you.

    Edit: can you do:

    Code:
    if (A == 2) {
        local function(...
    }
    ?

    Also, when are you going to add labels to e2?
    Last edited by Tolyzor; 4 Weeks Ago at 01:07 PM.
    Comprehensive Gmod physics guide - Ballistic trajectory with drag - Autodyno engine performance test
    Quote Originally Posted by janvos2506 View Post
    i just going to type the code over and over again and maybe il remeber it then
    Don't make the mistake these skydivers did and use any of my Gmod physics models for real life situations...

  3. #3
    Wirererer Rusketh's Avatar
    Join Date
    Jul 2011
    Location
    In your pants.
    Posts
    129

    Default Re: E2 Scopes

    Nope functions are not objects (yet) so they can not be localized.

    Quote Originally Posted by Tolyzor View Post
    I love you.
    when are you going to add labels to e2?
    I assume by labels you mean a goto instruction.
    Not possible I know I have been working miracles with E2 but i would have to rewrite the entire of e2 to make something like that.
    There is no way to jump around in run time, Trust me if there was then I would have done it buy now.
    Last edited by Rusketh; 4 Weeks Ago at 04:30 PM.

  4. #4
    Wire Sofaking thetree's Avatar
    Join Date
    Oct 2009
    Location
    England
    Posts
    904

    Default Re: E2 Scopes

    Yaaaaaayyyy! Finally local variables, functions will be so much more useful now because you don't have to give each variable some random long name.

    Excellent work, hopefully this will get commited, when its finished of course.

  5. #5
    Wiremode Helper Techni's Avatar
    Join Date
    Jul 2008
    Posts
    791
    Blog Entries
    1

    Default Re: E2 Scopes

    Excellent work, any word on first class functions though? That's what I'm personally really looking forward to.

  6. #6
    Wirererer Rusketh's Avatar
    Join Date
    Jul 2011
    Location
    In your pants.
    Posts
    129

    Default Re: E2 Scopes

    Right Arrays Tables and While loops are now fixed.

    Edit: Ok just updated yet again fixed a ton of bugs!
    Just like to thank ghost who is giving me a lot of bugs to fix.
    Last edited by Rusketh; 4 Weeks Ago at 02:49 PM.

    Creator of E2 Function System (udf) and E2 Scope System (Beta)
    STRP Development Blog: Blog.SpaceTownRP.com

  7. #7
    Wire Noob Ghost400's Avatar
    Join Date
    May 2011
    Posts
    1

    Default Re: E2 Scopes

    brohoof
    Dav1d, moffboffjoe and Rusketh like this.

  8. #8
    Wirererer Rusketh's Avatar
    Join Date
    Jul 2011
    Location
    In your pants.
    Posts
    129

    Default Re: E2 Scopes

    Quote Originally Posted by Ghost400 View Post
    brohoof
    Brohoof!

    Creator of E2 Function System (udf) and E2 Scope System (Beta)
    STRP Development Blog: Blog.SpaceTownRP.com

  9. #9
    Alopex/Vulpes Lagopus DanKing's Avatar
    Join Date
    Aug 2009
    Location
    Bergen, Norway
    Posts
    652

    Default Re: E2 Scopes

    Neat, this will be useful!

  10. #10
    Wiremod Helper Donkie's Avatar
    Join Date
    May 2008
    Location
    Sweden
    Posts
    1,681

    Default Re: E2 Scopes

    This and UDF is the things I have always craved for with E2. You've made them both.
    Get out. Seriously, do it.

+ Reply to Thread
Page 1 of 8 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots