+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Can someone write an Expression for a drone?

  1. #11
    Wire Sofaking SpectreCat's Avatar
    Join Date
    Mar 2008
    Location
    Sammamish, Washington
    Posts
    504

    Default Re: Can someone write an Expression for a drone?

    Apparently I forgot to add the trig example :S

    Here it is

    V = owner():pos()+(cosr(curtime()*2)*5,sinr(curtime()* 2)*5,0)

    New to the E2? Try my Tutorial:
    A Beginners Guide to Expression 2



    ***Please send a PM before you add me to friends***

    Quote Originally Posted by chinoto View Post
    E2 is not complicated, but many of the people who use it do complicated things with it.

  2. #12
    Wire Noob ryan1271's Avatar
    Join Date
    Aug 2008
    Posts
    22

    Default Re: Can someone write an Expression for a drone?

    Thanks but when I validated it says
    No such function: number:rotate(angle) at line 15, char 52

    Can someone explain the way to do it with trig?

  3. #13
    Developer Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    3,109

    Default Re: Can someone write an Expression for a drone?

    Look at the post above yours...

    Quote Originally Posted by SpectreCat View Post
    Apparently I forgot to add the trig example :S

    Here it is

    V = owner():pos()+(cosr(curtime()*2)*5,sinr(curtime()* 2)*5,0)
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr

  4. #14
    Wire Noob ryan1271's Avatar
    Join Date
    Aug 2008
    Posts
    22

    Default Re: Can someone write an Expression for a drone?

    OK, I got it working now

    [highlight=e2]@name Holo Drone
    @inputs
    @outputs
    @persist
    @trigger

    interval(10)
    if(first()) {
    holoCreate(1)
    holoModel(1,"sphere")
    }

    holoPos(1,owner():shootPos()+vec(cosr(curtime()*2) *75,sinr(curtime()* 2)*75,-10))

    [/highlight]

    I hope this is the right way to do it because I don't want to learn wrong. Also let me know if I am over complicating things. I think I can take care of the rest myself but I will post any questions I have.
    Last edited by ryan1271; 08-01-2009 at 07:50 AM.

  5. #15
    Wire Sofaking nescalona's Avatar
    Join Date
    Apr 2007
    Location
    Shoreline, Washington
    Posts
    1,299

    Default Re: Can someone write an Expression for a drone?

    Here's why SpectreCat's line works. You start with the usual parametric equations for a circle in the plane: (X,Y)=(cosr(T),sinr(T)). To embed this in 3-D space, you add the Z-component. (X,Y,Z)=(cosr(T),sinr(T),0). TO center the orbit on the chip owner's position, you just add that to the vector. (X,Y,Z)=owneros() + (cosr(T),sinr(T),0) Finally, you add in some extra parameters to vary the radius and speed.

    I'll expand SpectreCat's line a bit to explain. curtime() is a function that returns the number of seconds since the server started.

    Code:
    T = curtime() / 0.5
    V = owner():pos() + 100 * (cosr(T),sinr(T),0)
    0.5 is the angular frequency (how many radians orbited per second).
    100 is the radius of the orbit.

    If you'd rather use degrees instead of radians, you can change cosr to cos and sinr to sin, then multiply your angular frequency by (180/pi).

    EDIT: I messed up with 2 being the angular frequency. fixed now.
    Last edited by nescalona; 07-31-2009 at 06:28 PM.

  6. #16
    Wire Noob ryan1271's Avatar
    Join Date
    Aug 2008
    Posts
    22

    Default Re: Can someone write an Expression for a drone?

    Thanks that helps a lot. I haven't used E2 for very long and that line was too confusing for me but broken down it makes sense.

    Anyways, I changed the hologram into an orbiting expression so I can include the ram function later and added some chat commands.
    Heres the expression if you don't believe me.

    [highlight=e2]
    @name Phys Pet
    @inputs
    @outputs
    @persist V:vector Orbit
    @trigger All

    interval(10)

    if(Orbit){V = owner():shootPos()+vec(cosr(curtime()*2)*75,sinr(c urtime()* 2)*75,-10) - entity()os()
    entity():applyForce((V*25 - entity():vel()) * entity():mass())}
    else{V = owner():shootPos()+vec(0,0,20)}

    if(owner():lastSaid() == "-orbit") {Orbit = 1}
    if(owner():lastSaid() == "-stoporbit") {Orbit = 0}
    [/highlight]
    Last edited by ryan1271; 08-01-2009 at 07:51 AM.

  7. #17
    Wire Tutor chinoto's Avatar
    Join Date
    Apr 2008
    Location
    Brooklyn Park, MN. Lost my thumbdrive yet again...
    Posts
    1,983

    Default Re: Can someone write an Expression for a drone?

    Looky here: Text controlled props (by Shoffing), but it takes all the fun out of coding an expression yourself...
    (\__/) Expression 2 Resources: E2 Beginner's Guide | E2 Formatting Guide | E2 Function Reference | E2 Examples | Me
    (='.'=) PM me code and I'll send it back optimized if possible. (I find it fun dammit!)
    (")_(") Drunkie referring to an E2: "It's obvious that Chinoto made this, his coding style is all over it."

  8. #18
    Wire Noob ryan1271's Avatar
    Join Date
    Aug 2008
    Posts
    22

    Default Re: Can someone write an Expression for a drone?

    I am having trouble with the ram function. I want a chat command where you can specify the person you want to ram. Ex: "-ram Bob" and it would ram Bob.
    I also want it to go back to orbiting if it was orbiting me before it started ramming. I don't know how to do either of these things so help would be appreciated.

    I also want the model of the expression to be a ball but there is no concommand "wire_exp2_model" How can I change it?

  9. #19
    Spucatum Tauri Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    6,010

    Default Re: Can someone write an Expression for a drone?

    "wire_expression2_model"
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

    Quote Originally Posted by Anticept View Post
    By the way, Bull is in charge.

  10. #20
    Wire Noob ryan1271's Avatar
    Join Date
    Aug 2008
    Posts
    22

    Default Re: Can someone write an Expression for a drone?

    OK I got the model now but I am having problems with a function: findByPlayerName(String)
    It says it doesn't exist. Do I need to add something?

+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Cannot write or see my expressions.
    By T3h in forum Installation and Malfunctions Support
    Replies: 3
    Last Post: 07-28-2009, 01:04 PM
  2. E2 help: file read/write?
    By Nikita in forum Expression 2 Discussion & Help
    Replies: 5
    Last Post: 07-02-2009, 11:10 AM
  3. I want to write ugly code, help me!
    By Echo51 in forum Installation and Malfunctions Support
    Replies: 18
    Last Post: 06-05-2009, 08:55 PM
  4. file.Write getting screwed
    By ZeikJT in forum Installation and Malfunctions Support
    Replies: 13
    Last Post: 03-04-2009, 09:51 AM
  5. Write-Only (4 store)
    By Anthoni_C in forum Gate Nostalgia (Old School Wiring) Discussion & Help
    Replies: 6
    Last Post: 08-12-2007, 02:51 AM

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