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.



@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.



@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.



@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)}
    }
}


Wiremod Thread:
http://www.wiremod.com/forum/expression-1-2/21914-e2-fader.html

Video:

You can download it here:
http://www.garrysmod.org/img/?t=dll&id=106768

The download contains an example/contraption.

Ok wow,

I’m sorry but you have SERIOUSLY overcomplicated that aye.

basically all you needed was a variable with

A++

whatever plus the associated code

good try though, I appreciate people trying things… but fail soz

if derp ent:setalpha(0)
heeeyaahh

to be honest this is a contraptions forum, not an E2 forum people expect contraptions. Also this E2 code isn’t very good and i couldn’t read it. One last thing to bitch about before you go and release your code don’t include a goddam Zlib license link, if you were afraid of people stealing it don’t fucking release it. This is what pisses me off, a bunch of E2 junkies realeaseing their code but being afraid of people stealing it.

Anyone out there with me about my rant about stealing?

Haters gonna hate

Overcomplicated. Doesn’t the license violate some kind of ToS?

E2 belongs in the wiremod forums, not the contraption forums. And your video needs music. If your so worried about Copyright laws, get yourself some music with a creative commons license. Nearly all the music I use is from the newgrounds audio portal. Free music without the worry of getting your audio killed by youtube. All you have to do is give credit to the artist.

Cloaking device?

you shush

Yes.

[editline]04:04PM[/editline]

It includes a contraption in the download.

^~~~~~ HUHUH LOoK AT ME I AM HUNTA, I AM ON HIGH HORSE~~~~~^

I was just being honest >_>

This is a dick post and you know it. He was being very nice, and simply stating the facts. Like he said, he was being honest. He sure was a lot nicer than I would have been. Go crawl back into your introverted hole.

Anyways, @OP: Interesting expression but you made it wayyyy overcomplicated and long. All you need is an incrementing variable…