+ Reply to Thread
Results 1 to 3 of 3

Thread: E2 Fader

  1. #1
    Wire Noob EmilHem's Avatar
    Join Date
    Mar 2009
    Posts
    2

    Post E2 Fader

    My own E2 fader.
    I programmed this for over two hours to make sure all the bugs were fixed.
    To be honest I don't believe there is such an E2 programmed yet.

    Anyways, here is what it does.
    It makes an object slowly fade away and back. (Just watch the video.)

    There are three versions of the E2.

    The first one will make you able to walk through it when it's fading away and when it's hidden, but not when its fading back to normal or is solid.
    Code:
    @name Fader(By EmilHem)
    @inputs EM:entity Activate
    @outputs NoCollide 
    @persist Alpha Used Dir In Sel
    interval(100)
    
    if(duped() | first())
    {
        Activate=0
        Used=0
        NoCollide=0
        In=0
        Sel=1
        EM:setAlpha(256)
    }
    
    if(Activate & !Used & (Sel==2))
    {
        NoCollide=1
        timer("Timer",1)
        Dir=1
        Used=1
        Sel=1
    }
    
    if(!Activate & !Used & (Sel==1))
    {
        NoCollide=0
        timer("Timer",1)
        Dir=2
        Used=1
        Sel=2
    }
    
    if(clk("Timer"))
    {
        if(Dir==1)
        {
            if(!In){Alpha=256 In=1}
            EM:setAlpha(Alpha)
            Alpha=Alpha-1
            if(Alpha>0){timer("Timer",1)}
            else{Used=0 Dir=0 In=0 EM:setAlpha(0)}
        }
        elseif(Dir==2)
        {
            if(!In){Alpha=0 In=1}
            EM:setAlpha(Alpha)
            Alpha=Alpha+1
            if(Alpha<256){timer("Timer",1)}
            else{Used=0 Dir=0 In=0 EM:setAlpha(256)}
        }
    }
    The second code can't be walked through except when the object is hidden.
    Code:
    @name Fader2(By: EmilHem)
    @inputs EM:entity Activate
    @outputs NoCollide
    @persist Alpha Used Dir In Sel
    interval(100)
    
    if(duped() | first())
    {
        Activate=0
        Used=0
        NoCollide=0
        In=0
        Sel=1
        EM:setAlpha(256)
    }
    
    if(Activate & !Used & (Sel==2))
    {
        timer("Timer",1)
        Dir=1
        Used=1
        Sel=1
    }
    
    if(!Activate & !Used & (Sel==1))
    {
        NoCollide=0
        timer("Timer",1)
        Dir=2
        Used=1
        Sel=2
    }
    
    if(clk("Timer"))
    {
        if(Dir==1)
        {
            if(!In){Alpha=256 In=1}
            EM:setAlpha(Alpha)
            Alpha=Alpha-1
            if(Alpha>0){timer("Timer",1)}
            else{In=0 Used=0 Dir=0 NoCollide=1 EM:setAlpha(0)}
        }
        elseif(Dir==2)
        {
            if(!In){Alpha=0 In=1}
            EM:setAlpha(Alpha)
            Alpha=Alpha+1
            if(Alpha<256){timer("Timer",1)}
            else{In=0 Used=0 Dir=0 EM:setAlpha(256)}
        }
    }
    The third code can be walked through all the time except when it's solid.
    Code:
    @name Fader3(By: EmilHem)
    @inputs EM:entity Activate
    @outputs NoCollide
    @persist Alpha Used Dir In Sel
    interval(100)
    
    if(duped() | first())
    {
        Activate=0
        Used=0
        NoCollide=0
        In=0
        Sel=1
        EM:setAlpha(256)
    }
    
    if(Activate & !Used & (Sel==2))
    {
        timer("Timer",1)
        Dir=1
        Used=1
        Sel=1
        NoCollide=1
    }
    
    if(!Activate & !Used & (Sel==1))
    {
        NoCollide=1
        timer("Timer",1)
        Dir=2
        Used=1
        Sel=2
    }
    
    if(clk("Timer"))
    {
        if(Dir==1)
        {
            if(!In){Alpha=256 In=1}
            EM:setAlpha(Alpha)
            Alpha=Alpha-1
            if(Alpha>0){timer("Timer",1)}
            else{In=0 Used=0 Dir=0 EM:setAlpha(0)}
        }
        elseif(Dir==2)
        {
            if(!In){Alpha=0 In=1}
            EM:setAlpha(Alpha)
            Alpha=Alpha+1
            if(Alpha<256){timer("Timer",1)}
            else{In=0 Used=0 Dir=0 NoCollide=0 EM:setAlpha(256)}
        }
    }
    FacePunch Thread:
    E2: Fader - Facepunch

    Video:
    YouTube - E2 Fader

    You can download it here:
    Attached Files Attached Files
    Last edited by EmilHem; 08-09-2010 at 04:23 PM.

  2. #2
    Wire Sofaking Jack37's Avatar
    Join Date
    Jul 2009
    Location
    In front of Tatra T6A5
    Posts
    779

    Default Re: E2 Fader

    Works fine
    Btw: You don't need interval


    Wanna add me?:


    My Apps: Adv. Dupe -> E2 Code

  3. #3
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,679
    Blog Entries
    5

    Default Re: E2 Fader

    Uhh, the max alpha is 255, not 256.

+ Reply to Thread

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