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


LinkBack URL
About LinkBacks











Reply With Quote


) 

Bookmarks