+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 21

Thread: [Release]EGP clock+EGP radar

  1. #1
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default [Release]EGP clock+EGP radar

    Code for all contraptions provided at end!
    Clock:
    Finished, but lacks some nice features

    Features:
    Easy scaling of size, and the ratio (see pictures). I love the scaling part of it.

    Pictures:
    right click on attachments-> view in new window
    Radar:
    The radar is now finished! Keep tuned, I will add updates to it for more targets. It shows accurately the bearing position of the target, and takes his distance into account.

    Pictures:






    -----

    Code for clock:
    Ok, get out the Time: ostime gate and a selection:time decoder, wire them up, then wire the E2 min, sec.. to decoder. Rest you have to figure out, or you don't deserve to have the E2.
    Code:
    @name EGP clock by Unsmart v3
    @inputs W:wirelink Min Hour Sec
    @outputs Ratio:vector2 Test Str:string
    @persist Mid
    @trigger 
    #interval(500)
    if(first())
    {
        W:egpClear()
        timer("draw",500)
    }
    if(clk("draw"))
    {
        #base
        #edit me
        RatioReal=vec2(1,1)
        RatioReal=clamp(RatioReal,vec2(0.1,0.1),vec2(1.2,1.2))
        
        Size=220
        Size=clamp(Size,10,220)
        Ratio=RatioReal*Size
        Mid=256
        #dont edit me  below
        #base 4 digits
        W:egpBox(12,Mid-5,Mid-Ratio:x()-5,10,10,255,255,255,255)
        W:egpBox(6,Mid-5,Mid+Ratio:x()-5,10,10,255,255,255,255)
        
        W:egpBox(3,Mid+Ratio:y()-5,Mid-5,10,10,255,255,255,255)
        W:egpBox(9,Mid-Ratio:y()-5,Mid-5,10,10,255,255,255,255)
        
        #other
        W:egpBox(1,Mid-sin(30*11)*Ratio:y()-5,Mid-cos(30*11)*Ratio:x()-5,10,10,0,255,255,255)
        W:egpBox(2,Mid-sin(30*10)*Ratio:y()-5,Mid-cos(30*10)*Ratio:x()-5,10,10,0,255,255,255)
        
        W:egpBox(11,Mid-sin(30*1)*Ratio:y()-5,Mid-cos(30*1)*Ratio:x()-5,10,10,0,255,255,255)
        W:egpBox(10,Mid-sin(30*2)*Ratio:y()-5,Mid-cos(30*2)*Ratio:x()-5,10,10,0,255,255,255)
        
        W:egpBox(4,Mid-sin(30*8)*Ratio:y()-5,Mid-cos(30*8)*Ratio:x()-5,10,10,0,255,255,255)
        W:egpBox(5,Mid-sin(30*7)*Ratio:y()-5,Mid-cos(30*7)*Ratio:x()-5,10,10,0,255,255,255)
        
        W:egpBox(8,Mid-sin(30*4)*Ratio:y()-5,Mid-cos(30*4)*Ratio:x()-5,10,10,0,255,255,255)
        W:egpBox(7,Mid-sin(30*5)*Ratio:y()-5,Mid-cos(30*5)*Ratio:x()-5,10,10,0,255,255,255)
        
        #render
        W:egpDraw()
        timer("hands",100)#max FPs=12 D:
    }
    
    #Hour++ #for server thats GMT+0 and youyr gmt+1
    #Hour=Hour%24
    
    if(clk("hands"))
    {
        
        #hands
        W:egpLine(20,Mid,Mid,Mid+1,Mid+1,255,255,255,255)#sec
        W:egpLine(21,Mid,Mid,Mid+1,Mid-1,0,255,255,255)#min
        W:egpLine(22,Mid,Mid,Mid-1,Mid-1,255,255,0,255)#hour
        
        #digital timed
        Str=""
        if((Hour+""):length()==1){Str+="0"+Hour+":"}else{Str+=""+Hour+":"}
        if((Min+""):length()==1){Str+="0"+Min+":"}else{Str+=""+Min+":"}
        if((Sec+""):length()==1){Str+="0"+Sec}else{Str+=""+Sec}
        W:egpText(23,Str,vec2(Mid-50,Mid+50),vec(255,0,0),255)
        
        #circle
        W:egpCircle(-1,Mid,Mid,100,100,255,255,255,255)
        
        W:egpDraw()
    }
    
    #clock is only 12 hours!
    if(Hour>12){Test=Hour-12}else{Test=Hour}
    
    W:egpPos2(20,Mid-cos((Sec+15)*(360/60))*Ratio:y(),Mid-sin((Sec+15)*(360/60))*Ratio:x())
    W:egpPos2(21,Mid-cos((Min+15)*(360/60))*Ratio:y(),Mid-sin((Min+15)*(360/60))*Ratio:x())
    W:egpPos2(22,Mid-cos((Test+3)*(360/12))*Ratio:y(),Mid-sin((Test+3)*(360/12))*Ratio:x())
    
    
    Str=""
        if((Hour+""):length()==1){Str+="0"+Hour+":"}else{Str+=""+Hour+":"}
        if((Min+""):length()==1){Str+="0"+Min+":"}else{Str+=""+Min+":"}
        if((Sec+""):length()==1){Str+="0"+Sec}else{Str+=""+Sec}
        W:egpText(23,Str,vec2(Mid-50,Mid+50),vec(255,0,0),255)
    
    
    
    
    W:egpDraw()
    
    Code for radar: wirelink the EGP, make a beacon sensor (or 1^3 cube from phx (the small one)) and an entity marker, wire marker to beacon sensor, and then the Cube input to ent marker

    Code:
    @name EGP radar by Unsmart
    @inputs W:wirelink Cube:entity
    @outputs 
    @persist Ang MaxDist MaxPeople Arr:array 
    @trigger
    interval(30)#runontick = bad for this, finetune for the EGP FPS convar!
    if(first())
    {
        MaxDist=1000
        MaxPeople=12
        
        #W:egpClear()
        Ang=1
        W:egpBox(1,0,0,512,512,255,0,0,255)#background
        W:egpCircle(2,256,256,512,512,13,66,13,255)#circle
       
        #inner circle*2
        W:egpCircle(3,512/2,512/2,512/2,512/2,255,255,255,255)#white spliter
        W:egpCircle(4,512/2,512/2,512/2-10,512/2-10,13,66,13,255)#back to green
       
        #Lines
        W:egpLine(5,256,512,256,0,150,150,150,255)#up->down
        W:egpLine(6,0,256,512,256,150,150,150,255)#left->right
        #hands of sweeper
        W:egpLine(7,256,256,256,0,255,255,255,255)
       
        #pos info
        W:egpText(8,round(MaxDist/2)+"",vec2(256-80,256-50),vec(100,100,100),255)
        W:egpText(9,round(MaxDist)+"",vec2(256-200,256-50),vec(100,100,100),255)
       
        #render
         
        print("base drawn")
       
        
        timer("draw",100)#max FPS
    }
    
    if(clk("draw"))
    {
        for(I=10,MaxPeople+9)
        {
            W:egpCircle(I,-1,-1,10,10,0,255,255,255)
        #    concmd("echo "+(I)+" created")
        }
        
        #cover circle
        W:egpCircle(50,-1,-1,15,15,255,0,0,255)
        print("addons drawn")
        
        timer("find",50)#init timer find
    }
    
    
    
    
    if(clk("find"))
    {
        findInSphere(entity():pos(),MaxDist)
        findClipToClass("player")
        #npc_*
        #player
        Arr=findToArray()
        timer("find",500)#next find if the max fps is set high, use findUpdateRate()+0.05
        #timer("find",indUpdateRate()+0.05)#uncoment me if you want fast finds, if so, comment above
       
        for(I=1,Arr:count())#foreach
        {
            Ent=Arr[I,entity]
            Bear=Cube:bearing(Ent:pos())
           
        #find mul
        Dist=clamp((Cube:pos()-Ent:pos()):length(),10,MaxDist)
        Mul=(256/MaxDist)*Dist
       
        #angle math
        RealBear= (Bear+180+(360+90))%360
        RealBear= RealBear==0 ? -1 : RealBear
        
        W:egpPos(I+9,256-cos(RealBear)*Mul,256-sin(RealBear)*Mul)
        
        #concmd("echo "+(I+9)+" drawn")
        
        }
        
        for(I=Arr:count()+10,MaxPeople+9)
        {
            W:egpPos(I,-1,-1)
            #concmd("echo "+I+" removed")
        }
       
       
       
    }
    if(clk()&!clk("find"))
    {
        #update position, dont find new crap
        for(I=1,Arr:count())#foreach
        {
            Ent=Arr[I,entity]
            Bear=Cube:bearing(Ent:pos())
           
        #find mul
        Dist=clamp((Cube:pos()-Ent:pos()):length(),10,MaxDist+10)
        Mul=(256/MaxDist)*Dist
       
        #angle math
        RealBear= (Bear+180+(360+90))%360
        RealBear= RealBear==0 ? -1 : RealBear
        
        W:egpPos(I+9,256-cos(RealBear)*Mul,256-sin(RealBear)*Mul)
        
        #concmd("echo "+(I+9)+" updated")
        
        }
    }
    
    
    #hand circle
    Ang= Ang<359 ? Ang+1 : 1
    W:egpPos2(7,256+cos(Ang)*256,256+sin(Ang)*256)
    
    #render
    W:egpDraw()
    
    -----
    A clock my friend Zoombahh made, and yes, his clock is way cooler, here is comparison pic:



    END note: I know you could do 9001 times better in GPU, but I want to show you, that its possible to do something useful in EGP.
    Attached Images
    Last edited by Unsmart; 03-14-2010 at 01:52 AM.

  2. #2
    Lurker GawsherMcGee is on a distinguished road GawsherMcGee's Avatar
    Join Date
    Apr 2009
    Posts
    8

    Default Re: [Release]EGP clock+EGP radar

    Released ten seconds ago, going to try it out right now.

    Edit:

    This isnt a E2... Whats a EGP?
    Last edited by GawsherMcGee; 12-21-2009 at 11:57 AM.

  3. #3
    hat full of head

    Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael is a glorious beacon of light Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,947

    Default Re: [Release]EGP clock+EGP radar

    Quote Originally Posted by GawsherMcGee View Post
    This isnt a E2... Whats a EGP?
    EGP is an unofficial addon for E2 that lets you draw to screens like it's a GPU, only it's controlled directly from E2 with a special set of functions.

  4. #4
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default Re: [Release]EGP clock+EGP radar

    Oh ffs, why cant people hit the search button before asking? click me

    and thanks Azrael for explaining it.
    --------------


    THE RADAR WORKS NOW!!!!! (max 1 find for now, but it still works! and I figured it out without help )
    Last edited by Unsmart; 12-22-2009 at 05:15 AM.

  5. #5
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default Re: [Release]EGP clock+EGP radar

    RADAR IS DONE! Support for 12 players, but with some brain you can figure out how to change it

    Code:
    @name EGP radar by Unsmart
    @inputs W:wirelink Cube:entity
    @outputs RealBear Arr:array Ent:entity
    @persist Ang 
    @trigger 
    interval(30)
    if(first())
    {
       #W:egpClear()
        Ang=1
        W:egpBox(1,0,0,512,512,255,0,0,255)#background
        W:egpCircle(2,0,0,512,512,42,255,0,255)#circle
        
        #inner circle*2
        W:egpCircle(3,256-300/2,256-300/2,300,300,255,255,255,255)#white spliter
        W:egpCircle(4,256-270/2,256-270/2,270,270,100,255,0,255)#back to green
        
        #Lines
        W:egpLine(5,256,512,256,0,150,150,150,255)#up->down
        W:egpLine(6,0,256,512,256,150,150,150,255)#left->right
        #hands of sweeper
        W:egpLine(7,256,256,256,0,255,255,255,255)
        
        #cover circles
        W:egpCircle(1337,50,50,10,10,255,0,0,255)
        
        #render
        W:egpDraw()   
        timer("find",50)
        timer("draw",100)
    }
    if(clk("draw"))
    {
        for(I=10,22)
        {
            W:egpCircle(I,50,50,10,10,0,255,255,255)
        }
    }
    if(clk("find"))
    {
        findInSphere(entity():pos(),1000)
        findClipToClass("player")
        Arr=findToArray()
        timer("find",500)
        
        
        for(I=10,Arr:count()+10)#start at 10+ 
        {
            Ent=Arr[I-10,entity]
            Bear=Cube:bearing(Ent:pos())
            
        #angle math
        Dist=clamp((Cube:pos()-Ent:pos()):length(),10,500)
        
        Mul=clamp(Dist,10,500)
        
        RealBear= (Bear+180+(360+90))%360
        RealBear= RealBear==0 ? -1 : RealBear
        W:egpPos(I,256-5-cos(RealBear)*Mul,256-5-sin(RealBear)*Mul)
        }
        for(I=Arr:count()+11,22)
        {
            W:egpPos(I,-1,-1)
        }
        #make sure to remove unused crap
        
        Spawned=Arr:count()#when i get GUI done, i will add garbage colector
        
        
    }
    
    
    
    #hand circle
    Ang= Ang<359 ? Ang+1 : 1
    W:egpPos2(7,256+cos(Ang)*256,256+sin(Ang)*256)
    
    #angle math
    
    #Mul=clamp(Dist,10,500)
    #
    #RealBear= (Bear+180+(360+90))%360
    #RealBear= RealBear==0 ? -1 : RealBear
    #W:egpPos(8,256-5-cos(RealBear)*Mul,256-5-sin(RealBear)*Mul)
    #
    
    
    W:egpDraw()
    

  6. #6
    Wirererer Elmo the Emo Emperor will become famous soon enough Elmo the Emo Emperor's Avatar
    Join Date
    Feb 2008
    Location
    Lagville(Austrlia)
    Posts
    278

    Default Re: [Release]EGP clock+EGP radar

    With the clock, find it interpretable. How do you know which is the hour, minute r second hand? I suggest you make each one successively shorter, and have their width shrink as well. This is because when they overlap you should be able to easily tell what's happening.

  7. #7
    goluch
    Guest goluch's Avatar

    Default Re: [Release]EGP clock+EGP radar

    Unsmart these are awesome.
    Every day i see better things coming from EGP.

  8. #8
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default Re: [Release]EGP clock+EGP radar

    Quote Originally Posted by Elmo the Emo Emperor View Post
    With the clock, find it interpretable. How do you know which is the hour, minute r second hand? I suggest you make each one successively shorter, and have their width shrink as well. This is because when they overlap you should be able to easily tell what's happening.
    lines cant be set to have fatness, I can make every hand colored different, and different length, but you could do that yourself.


    Quote Originally Posted by goluch View Post
    Unsmart these are awesome.
    Every day i see better things coming from EGP.
    thanks

  9. #9
    Wirererer NikoKun will become famous soon enough NikoKun will become famous soon enough NikoKun's Avatar
    Join Date
    May 2008
    Posts
    113

    Default Re: [Release]EGP clock+EGP radar

    hmm, For some reason the Radar is all messed up.. Draws the players and the rotating line ok, but the green circles for the background are only in the top left corner...
    ------------------------------------
    aka "Nik of the Wired" in gmod.

  10. #10
    Wire Sofaking Unsmart will become famous soon enough Unsmart's Avatar
    Join Date
    Dec 2008
    Location
    Slovakia OR BANland
    Posts
    1,169

    Default Re: [Release]EGP clock+EGP radar

    Quote Originally Posted by NikoKun View Post
    hmm, For some reason the Radar is all messed up.. Draws the players and the rotating line ok, but the green circles for the background are only in the top left corner...
    yeah, I noticed, my server uses old version of EGP, in SP with newest version it fucked up, sorry about that, Ill remake it. Wonder what changed the behavior of the positioning.


    Thanks for actually trying it


    Code:
    @name EGP radar by Unsmart
    @inputs W:wirelink Cube:entity
    @outputs RealBear Arr:array Ent:entity Dist
    @persist Ang
    @trigger
    interval(30)
    if(first())
    {
       #W:egpClear()
        Ang=1
        W:egpBox(1,0,0,512,512,255,0,0,255)#background
        W:egpCircle(2,256,256,512,512,13,66,13,255)#circle
       
        #inner circle*2
        W:egpCircle(3,512/2,512/2,300,300,255,255,255,255)#white spliter
        W:egpCircle(4,512/2,512/2,270,270,13,66,13,255)#back to green
       
        #Lines
        W:egpLine(5,256,512,256,0,150,150,150,255)#up->down
        W:egpLine(6,0,256,512,256,150,150,150,255)#left->right
        #hands of sweeper
        W:egpLine(7,256,256,256,0,255,255,255,255)
       
        #cover circles
        W:egpCircle(50,50,50,15,15,255,0,0,255)
       
        #render
        W:egpDraw()  
        timer("find",50)
        timer("draw",100)
    }
    if(clk("draw"))
    {
        for(I=10,22)
        {
            W:egpCircle(I,50,50,10,10,0,255,255,255)
        }
    }
    if(clk("find"))
    {
        findInSphere(entity():pos(),1000)
        findClipToClass("player")
        Arr=findToArray()
        timer("find",500)
       
       
        for(I=10,Arr:count()+10)#start at 10+
        {
            Ent=Arr[I-10,entity]
            Bear=Cube:bearing(Ent:pos())
           
        #angle math
        Dist=clamp((Cube:pos()-Ent:pos()):length(),10,500)
        Mul=clamp(Dist,1,500)
       
        RealBear= (Bear+180+(360+90))%360
        RealBear= RealBear==0 ? -1 : RealBear
        W:egpPos(I,256-cos(RealBear)*Mul,256-sin(RealBear)*Mul)
        }
        for(I=Arr:count()+11,22)
        {
            W:egpPos(I,50,50)
        }
        W:egpPos(50,50,50)
        #make sure to remove unused crap
       
       
       
    }
    
    
    
    #hand circle
    Ang= Ang<359 ? Ang+1 : 1
    W:egpPos2(7,256+cos(Ang)*256,256+sin(Ang)*256)
    
    #angle math
    
    #Mul=clamp(Dist,10,500)
    #
    #RealBear= (Bear+180+(360+90))%360
    #RealBear= RealBear==0 ? -1 : RealBear
    #W:egpPos(8,256-5-cos(RealBear)*Mul,256-5-sin(RealBear)*Mul)
    #
    
    
    W:egpDraw()
    

    fixed, but I'm sure I screwed something up
    Last edited by Unsmart; 12-23-2009 at 12:02 PM.

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

LinkBacks (?)

  1. 01-27-2010, 02:13 PM

Similar Threads

  1. [Release] Balls of Steel (Re-release)
    By Moglizorz in forum Finished contraptions
    Replies: 93
    Last Post: 1 Hour Ago, 01:37 PM
  2. [Release] Holographic Digital Clock
    By Moglizorz in forum Finished contraptions
    Replies: 1
    Last Post: 08-09-2009, 09:38 AM
  3. ZP's Phys Clock
    By F12Bwth in forum Finished contraptions
    Replies: 12
    Last Post: 06-25-2008, 10:00 AM
  4. Binary Clock?
    By timas in forum Technical Support
    Replies: 3
    Last Post: 05-12-2007, 10:30 AM
  5. Clock chip
    By HL-SDK in forum Ideas & Suggestions
    Replies: 13
    Last Post: 04-02-2007, 12:24 PM

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