1. Post #481
    Gold Member
    whosdr's Avatar
    July 2008
    3,016 Posts
    I scanned through and thought I recognised this. Simple but useful.

    Edit:
    Idea:

    Loop through constrainted props, find the 5 heaviest, and apply stabalization to the 5 with the highest mass.


    Gunna test something like this...

    Code:
    @persist E:entity Ents:array Props:array
    if (first()) {
    E = entity()
    Ents = E:getConstraints()
    for (X = 1,Ents:count()) {
            Ents[X,entity]:setColor(255,255,255)
        for (Y = 0,5) {
            if (Ents[X,entity]:mass() > Props[Y,entity]:mass()) {
                if (!Props[5,entity]) {
                    Props:pushEntity(Ents[X,entity])
                    break
                    }
                } else {
                    Props:remove(Y)
                    Props:pushEntity(Ents[X,entity])
                    break
                }
            }
        }
    runOnTick(1)
    }
    for (Z = 1,5) {
        E = Props[Z,entity]
        E:setColor(vec(255,0,0))
        E:applyAngForce(( -E:angles():setYaw(0)*20 - E:angVel())*E:mass())
    #    E:applyForce(( (-E:pos())*20 - E:vel())*E:mass())
    }

  2. Post #482
    Decoy Ocelot's Avatar
    March 2009
    237 Posts
    I'm just leaving this code here, as it comes in handy a lot in my opinion. It is a keep upright code, made by whosdr.

    Code:
    E:applyAngForce(( -E:angles():setYaw(0)*20 - E:angVel())*E:mass())
    If you need to support multiple props, times the mass by something.

    Why not just add up the mass for the whole contraption?

    Code:
    if(first() | duped())
    {
        Props = entity():getConstraints()
        Mass = entity():mass()
        for(Index = 1,Props:count())
        {
            Mass += Props[Index,entity]:mass()
        }
    }

  3. Post #483

    April 2010
    2 Posts
    I'm new here, and a complete and utter noob to E2. Just wondering if there's a way to make and E2 chip that can connect to an Adv Pod's brake for an RP server I play on. I basically want to make a foolproof car anti-theft system, that reports itself stolen to the police if someone does steal it using a /me chat command. It has to be able to wire into a keypad as well.

    Also, any nudges or points to somewhere I can pick up some tips on E2 would be appreciated.

  4. Post #484
    Lambda 77 :D's Avatar
    December 2009
    462 Posts
    I'm new here, and a complete and utter noob to E2. Just wondering if there's a way to make and E2 chip that can connect to an Adv Pod's brake for an RP server I play on. I basically want to make a foolproof car anti-theft system, that reports itself stolen to the police if someone does steal it using a /me chat command. It has to be able to wire into a keypad as well.

    Also, any nudges or points to somewhere I can pick up some tips on E2 would be appreciated.
    I really don't get what you mean with the Keypad and Brake, but here's something to make you say something if your car is stolen.

    Code:
    @name Anti-Theft
    @inputs 
    @outputs 
    @persist Owner:entity Car:entity Driver:entity
    @trigger
    
    if (first())
    {Owner=owner()
    Car=entity():isWeldedTo()
    runOnTick(1)}
    
    Driver=Car:driver()
    
    if (changed(Driver) & Driver & (Driver != Owner)) {
        concmd("say TEXT")
        #Car:ejectPod()
        #If you want the stealer to be ejected from the car remove the # from the above line.
    }
    Should work, I haven't tested yet. Replace text with what you want said and do "wire_expression2_concmd 1 " in console, then put the E2 on a car.

    EDIT: Alright, better version up.

  5. Post #485

    April 2010
    2 Posts
    I really don't get what you mean with the Keypad and Brake, but here's something to make you say something if your car is stolen.

    Code:
    @name Anti-Theft
    @inputs 
    @outputs 
    @persist Owner:entity Car:entity Driver:entity
    @trigger
    
    if (first())
    {Owner=owner()
    Car=entity():isWeldedTo()
    runOnTick(1)}
    
    Driver=Car:driver()
    
    if (changed(Driver) & Driver & (Driver != Owner)) {
        concmd("say TEXT")
        #Car:ejectPod()
        #If you want the stealer to be ejected from the car remove the # from the above line.
    }
    Should work, I haven't tested yet. Replace text with what you want said and do "wire_expression2_concmd 1 " in console, then put the E2 on a car.

    EDIT: Alright, better version up.
    Thank you! This is almost exactly what I wanted. The only thing is, on the server I play on, it has to be stealable. Basically, I have to have some sort of override that I can wire into a wire keypad, so people with keypad crackers can still override the chip and steal the car. But its still allowed to vocalize that it's being stolen, I asked. Me and a few people that sort of understand E2 are trying to figure it out, but any help is very appreciated.

  6. Post #486
    Lambda 77 :D's Avatar
    December 2009
    462 Posts
    Thank you! This is almost exactly what I wanted. The only thing is, on the server I play on, it has to be stealable. Basically, I have to have some sort of override that I can wire into a wire keypad, so people with keypad crackers can still override the chip and steal the car. But its still allowed to vocalize that it's being stolen, I asked. Me and a few people that sort of understand E2 are trying to figure it out, but any help is very appreciated.
    I'll get right on that :buddy:

    While you wait, check out these pages on how to use E2.

    Guides:
    http://wiki.garrysmod.com/?title=Wire_Expression2:Guide
    http://www.wiremod.com/forum/express...ssion-2-a.html
    http://docs.google.com/View?id=dfzr9bx7_12f6nzspgk

    E2 functions:
    http://wiki.garrysmod.com/?title=Wire_Expression2

    EDIT:
    Done!
    Code:
    @name Anti-Theft
    @inputs Valid #Wire to a NON-TOGGLED wire keypad's Valid output
    @outputs On #Outputs on in case you want a indicator or anything
    @persist On Owner:entity Car:entity Driver:entity #Save these variables
    @trigger
    
    if (first()) #Has the E2 just been spawned?
    {Owner=owner() #Owner never changes, so we can save it for less op uaage.
    Car=entity():isWeldedTo() #The car is what the chip is welded to.
    }
    
    interval(500) #Run constantly
    
    Driver=Car:driver() #The driver is car's driver
    
    if (~Valid & Valid) { #If the keypad changed and keypad is 1
    On = !On #Toggle on
    }
    
    if (On) { #Security only runs if system is on
    
    if (changed(Driver) & Driver & (Driver != Owner)) { #Has the driver changed and is there a driver and the driver is not owner?
        concmd("say TEXT") #If so, say this!
        #Car:ejectPod()
        #If you want the stealer to be ejected from the car remove the # from the above line.
    }
    
    }
    Wire the Valid input to a NON-TOGGLED Wire Keypad's Valid output. When the right code is entered, the system toggles between on and off. When on, you will say something when the car is taken. When off, you will not say anything when the car is taken. On is a output in case you want a indicator or something.

  7. Post #487

    December 2009
    15 Posts
    hey i saw this e2 where it was just like the talk swep but it was combine voices so i was wondering if anyone had it k thnx
    Reply With Quote Edit / Delete Reply United States Show Events Bad Spelling Bad Spelling x 1 (list)

  8. Post #488
    Dioxybenzone's Avatar
    May 2009
    330 Posts
    1. its kinda annoying when someone spawns an "anti-"minge e2, that blocks your view, or a "sims for everyone" including you. i was wondering if there was a way to block other peoples e2's on yourself.

    2. this is for people who leave their HUGE props laying around with anti-noclip: an anti- anti-noclip.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 1 (list)

  9. Post #489
    Gold Member
    Mooee's Avatar
    June 2008
    1,131 Posts
    Okay, not a request but more of heads up, working on a drone right now (movement functions more specifically) and looking at others' codes, but not having any luck so I might need a favor or two, haha.
    And yes, I'm new to E2.

  10. Post #490
    Gold Member
    whosdr's Avatar
    July 2008
    3,016 Posts
    1. its kinda annoying when someone spawns an "anti-"minge e2, that blocks your view, or a "sims for everyone" including you. i was wondering if there was a way to block other peoples e2's on yourself.

    2. this is for people who leave their HUGE props laying around with anti-noclip: an anti- anti-noclip.

    You can block other peoples holograms with
    wire_holograms_block_client "name"
    Which means you no longer see the holograms of that player.

  11. Post #491
    aurum481's Avatar
    November 2008
    1,917 Posts
    You can block other peoples holograms with
    wire_holograms_block_client "name"
    Which means you no longer see the holograms of that player.
    e2 holos :downsowned:

  12. Post #492
    aviator1223's Avatar
    October 2009
    21 Posts
    Hey Divran, I'm making a small plane for the fight to survive server, It is going to be remote controlled, But I need a plane e2, For realistic or crappy flight, Can you do it? Please? ;3

  13. Post #493
    Gold Member
    whosdr's Avatar
    July 2008
    3,016 Posts
    Base drone E2.

    Code:
    @name Drone Base Model (DBM)
    @inputs W A S D Ent:entity
    @outputs Cam:vector Eye:vector E:entity
    @persist Pos:vector Speed1 Speed2 E:entity Driver:entity
    
    if(first() | duped()){
    
        if (entity():isWeldedTo()) {
            E = entity():isWeldedTo()
        } else {
            E = entity()
        }
    
        Speed1 = 5
        Speed2 = 5
        Pos = E:pos()
        runOnTick(1)
    }    
    Driver = Ent:driver()
    
    E:applyForce(( (-E:pos() + Pos)*(Speed1+Speed2)/2 - E:vel())*E:mass())
    
    Torque = E:toLocal(rotationVector(quat(Driver:eyeAngles()+ang(0,0,0))/quat(E))+E:pos()) #change ang(0,0,0) to rotate the body if the camera and or movement is going the wrong way.
    E:applyTorque((Torque*20-E:angVelVector()*10)*E:inertia())
    
    if (E:isPlayerHolding()) {Pos = E:pos()}
    
        if (Driver) {
            Eye = Driver:eye()
            if (W) {Pos +=E:forward()*Speed1}
            if (S) {Pos -= E:forward()*Speed2}
            if (A) {Pos += -E:right()*10}
            if (D) {Pos += E:right()*10}
    
    if (W) {Speed1 += (Speed1 < 50)/5} else {Speed1 -= (Speed1>5)/2}
    if (S) {Speed2 += (Speed2 < 40)/5} else {Speed2 -= (Speed2>5)/2}
    Cam = E:toWorld(vec(0,0,0)) + vec(0,0,0) + E:vel()/66.7 #change first vec(0,0,0) for local pos, second for world position on camera view.
    }

  14. Post #494
    aviator1223's Avatar
    October 2009
    21 Posts
    Kickass, Thanks man!

  15. Post #495
    aviator1223's Avatar
    October 2009
    21 Posts
    It doesen't work, I wired it up did the entity markers correctly, and it will float in midair but won't do anything else

  16. Post #496
    Gold Member
    whosdr's Avatar
    July 2008
    3,016 Posts
    It doesen't work, I wired it up did the entity markers correctly, and it will float in midair but won't do anything else
    Entity markers?


    Ent:entity goes to adv pod, as do all the inputs.

    You place the chip on the central object, and set its weight up to 50k for balance.

  17. Post #497
    Gold Member
    Mooee's Avatar
    June 2008
    1,131 Posts
    you place the chip on the central object, and set its weight up to 50k for balance.
    50000?!

  18. Post #498
    Gold Member
    whosdr's Avatar
    July 2008
    3,016 Posts
    No, 50000.

    More mass on main body = more balance when it comes to alot of entities constrained together.
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Informative Informative x 1 (list)

  19. Post #499
    aviator1223's Avatar
    October 2009
    21 Posts
    I'll try that thanks, Would you like to see a pic of my plane, maybe you could help me out a bit more.

    Edited:

    It didin't work, The plane just stays in one spot and one angle and won't move. i did exactly as you say.

  20. Post #500
    Gando346's Avatar
    June 2008
    49 Posts
    I was thinking, can you make an e2 that, when you right-click with the crowbar, floats PHX 1x1 metal plates in between you and other players? That way, it would blok bullets and such.

  21. Post #501
    The-Legendsmith's Avatar
    January 2009
    30 Posts
    I really need an e2 to provide yaw friction. I've got a nice e2 at the moment that provides movement (not turning) friction slowdown as well as providing applyforce for actual movement on a prop. But the steering is terrible as there is no friction involved in it.

  22. Post #502

    February 2010
    25 Posts
    i got this idea, but i need an E2 to strip ppl for weapon if they walk past a ranger, or atleast tell me what weapons they have

  23. Post #503
    Gold Member
    whosdr's Avatar
    July 2008
    3,016 Posts
    I could probably do a check for all weapons on a player. I can't strip them though.

  24. Post #504

    February 2010
    25 Posts
    oh, that will work to.

    Edited:

    could you make it tell me what weapons they have and make a sound if they walk past the ranger with weapon. like on airports etc

  25. Post #505
    JasonG5's Avatar
    December 2009
    26 Posts
    I would like to request the following :

    A sword
    A shield
    and a knight helmet..

    All in one e2, and stick to the player

    If its not too much work =)

    Thanks in advance. :D

    EDIT :

    Oh and sorry a cape =D
    If anyone makes this il be really thankful.
    If no one can be bothered its alright.
    Since I fail at e2 =/

  26. Post #506
    hello friends
    Lambda 217's Avatar
    March 2008
    3,402 Posts
    Also Divran, that Lollercoaster you did is just beautiful. I can't read your code, so what did you use for that awesome movement? I'd swear I was moving on a prop rollercoaster track.

    Edited:

    I would like to request the following :

    A sword
    A shield
    and a knight helmet..

    All in one e2, and stick to the player

    If its not too much work =)

    Thanks in advance. :D

    EDIT :

    Oh and sorry a cape =D
    If anyone makes this il be really thankful.
    If no one can be bothered its alright.
    Since I fail at e2 =/
    Here is a sword someone kindly released.

    http://www.wiremod.com/forum/finishe...on-slayer.html

  27. Post #507
    JasonG5's Avatar
    December 2009
    26 Posts
    Also Divran, that Lollercoaster you did is just beautiful. I can't read your code, so what did you use for that awesome movement? I'd swear I was moving on a prop rollercoaster track.

    Edited:



    Here is a sword someone kindly released.

    http://www.wiremod.com/forum/finishe...on-slayer.html
    Yea ive seen it thanks, Ive got it :D

    But i really want a shield and a helmet, and possible a cape

    =D

  28. Post #508
    Gold Member
    Divran's Avatar
    April 2008
    2,528 Posts
    Also Divran, that Lollercoaster you did is just beautiful. I can't read your code, so what did you use for that awesome movement? I'd swear I was moving on a prop rollercoaster track.
    Quaternions.

    Edited:

    I would like to request the following :

    A sword
    A shield
    and a knight helmet..

    All in one e2, and stick to the player

    If its not too much work =)

    Thanks in advance. :D

    EDIT :

    Oh and sorry a cape =D
    If anyone makes this il be really thankful.
    If no one can be bothered its alright.
    Since I fail at e2 =/
    Making hologram equipment is very time consuming... So no. At least not right now.

  29. Post #509
    ChronoMagus's Avatar
    August 2009
    114 Posts
    sorry bout the bump but id like a e2 that works with damage detectors to set a sort of patern on the props say i have props lined up like this () () () () and i hit the 1st 3rd 4th then the 2nd and it opens if possible can you make the pattern in which it activates the output to something i can set?

  30. Post #510
    JasonG5's Avatar
    December 2009
    26 Posts
    Okay, so I now have my own SpaceBuild server.
    and succesfully made an auto tracking defence turret thing for my planet.
    Problem is, i dont want it to target 2 people who are living on my planet
    I have no idea how to do this, because I see no option in the target finder, and thought one of you guys could make it in e2 ? =D

  31. Post #511
    Gold Member
    Balto-the-Wolf-Dog's Avatar
    June 2009
    1,735 Posts
    Thanks diviran. Since my questions here I have learned e2. It turned out rather logical, and for several months now has been my favorite passtime. My current project is a purely holographic starfox used to dogfight in prop made minimaps. They shoot holos, are damaged by holos shooting back, can do barrel rolls that deflect said shots and loops. They even go into a death spiral when they are shot down, deleting when they hit the ground. Then autorespawn several seconds later. Flight dynamics very similar to starfox. Thank you, you are one of the people I attribute my success to.

  32. Post #512
    XplodingNoggin's Avatar
    July 2009
    655 Posts
    Make me an E2 out of displacements.

  33. Post #513
    Gold Member
    Divran's Avatar
    April 2008
    2,528 Posts
    Okay, so I now have my own SpaceBuild server.
    and succesfully made an auto tracking defence turret thing for my planet.
    Problem is, i dont want it to target 2 people who are living on my planet
    I have no idea how to do this, because I see no option in the target finder, and thought one of you guys could make it in e2 ? =D
    Code:
    @inputs On PlanetPos:vector PlanetSize
    @outputs Target:entity
    if (On) {interval(250)}
    findByClass("player")
    findClipFromSphere(PlanetPos,PlanetSize) #makes it ignore everyone on the planet
    Target = findClosest(entity():pos())

  34. Post #514

    May 2010
    2 Posts
    I would like an e2 sub

  35. Post #515
    Gold Member
    Divran's Avatar
    April 2008
    2,528 Posts

  36. Post #516
    hello friends
    Lambda 217's Avatar
    March 2008
    3,402 Posts
    This is driving me mad.

    I have a turret, but I decided to make it be able to auto-detect Wire Turrets you own and add them to itself, and it worked. Code looks like this:
    Turrets=Array of turrets
    TC=Turrets:count()
    FA=Found targets
    FC=Amount of found targets

    for (Y=1,TC) {
    TargetN=clamp(Y,1,FC)
    TargetPos=FA[TargetN,entity]:pos()

    *aim at TargetPos*
    }

    But I ran into a problem:

    The turrets need to change targets every two seconds or so, so they don't keep shooting at the same person. I have a variable that increments every two seconds, but can't figure out how to add it to the code. By the way, found entities are updated as fast as findCanQuery().

    Any help?

  37. Post #517
    Gold Member
    Divran's Avatar
    April 2008
    2,528 Posts
    The turrets need to change targets every two seconds or so, so they don't keep shooting at the same person. I have a variable that increments every two seconds, but can't figure out how to add it to the code. By the way, found entities are updated as fast as findCanQuery().

    Any help?
    Try
    Code:
    Target = findResult(Variable)

  38. Post #518
    hello friends
    Lambda 217's Avatar
    March 2008
    3,402 Posts
    Whoops, sorry. I meant the turrets need to independently track their own target.

  39. Post #519
    Gold Member
    Divran's Avatar
    April 2008
    2,528 Posts
    Code:
    timer("NextTarget",2000)
    if (clk("NextTarget")) {
        Variable++
        if (Variable + TC > FC) {Variable = 1}
    } elseif (tickClk()) {
        for(Y=1,TC) {
        TargetN = clamp(Variable+Y,1,FC)
        ...

  40. Post #520
    hello friends
    Lambda 217's Avatar
    March 2008
    3,402 Posts
    Thanks! Now I can finally finish my turret!
    EDIT:
    Wait, it seems to have problems if there are only two targets (works fine otherwise, thanks!). All the turret just aim at the first target.