+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: An Expression a day keeps a clear mind away

  1. #1
    Inactive Peruanischer Speckkäfer is on a distinguished road Peruanischer Speckkäfer's Avatar
    Join Date
    Jan 2009
    Posts
    14

    Default An Expression a day keeps a clear mind away

    Hey it's me again,
    I'm currently performing a "confuse yourself, build stuff" project which is meant to last about a week. As such i built a hoverplatform today. After about 6 hours of being confused now i only have one question left. The coloured part makes my platform turn, however it only turns by the entered amount and not further, i want it do to something like:

    0 + 45 = 45
    45 + 45 = 90

    (I'd use smaller values then)
    It'd also be nice if the platform kept the value afterwards

    Code:
    @inputs Numpad Active RightRoll LeftRoll Right Left PitchForward PitchBackward Space Num5
    @outputs Plateforward:vector Gyro:angle
    @persist V:vector
    
    
    interval(10)
    Plate = entity()
    Me = owner()
    P = Plate:angles():pitch()
    Y = Plate:angles():yaw()
    R = Plate:angles():roll()
    V = (Me:pos() - Plate:pos() + vec(0,0,-22)) * 500
    Plateforward = Plate:forward()
        
        if(Active == 1){ 
            
            if(Space == 1){Plate:applyForce(Plateforward * 100)}
            if(Num5 == 1){Plate:applyForce(-Plateforward * 100)}
            if(Right == 1){Y = Y + 90} 
            if(Left == 1){Y = Y - 90}
            if(RightRoll == 1){R = R + 45}
            if(LeftRoll == 1){R = R - 45}
            if(PitchForward == 1){P = P + 45}
            if(PitchBackward == 1){P = P - 45}
            Gyro = -ang(P,Y,R) * 100   
            Plate:applyAngForce(Gyro + $Gyro * 5)
    }
    
    if(Numpad == 1){Plate:applyForce( V + $V * 5)}
    
    A big box of cookies for the first one to deliver me a useful answer
    advance payment:
    Last edited by Peruanischer Speckkäfer; 07-02-2009 at 12:00 PM.

  2. #2
    billywitchdoctor.com Whosdr has a spectacular aura about Whosdr has a spectacular aura about Whosdr has a spectacular aura about Whosdr's Avatar
    Join Date
    Dec 2008
    Posts
    2,120

    Default Re: An Expression a day keeps a clear mind away

    timer and clk()? also Y=Y+90 use instead Y+=90
    .siht daer ot gniyrt emit detsaw ev'uoY

  3. #3
    Inactive Peruanischer Speckkäfer is on a distinguished road Peruanischer Speckkäfer's Avatar
    Join Date
    Jan 2009
    Posts
    14

    Default Re: An Expression a day keeps a clear mind away

    It's the same actually...i used += before but i was not sure whether it was the same.
    Could you give an example for the timer code please?

  4. #4
    Wire Sofaking mjmr89 is on a distinguished road mjmr89's Avatar
    Join Date
    Mar 2008
    Posts
    559

    Default Re: An Expression a day keeps a clear mind away

    Not really sure what you're asking, but that set of if statements is entirely unnecessary, replace it with something like

    Plate:applyForce(Plateforward * 100*(Space-Num5))
    Y += 90*(Right-Left)
    R += 45*(RightRoll-LeftRoll)
    P += 45*(PitchForward-PitchBackward)

  5. #5
    Inactive Peruanischer Speckkäfer is on a distinguished road Peruanischer Speckkäfer's Avatar
    Join Date
    Jan 2009
    Posts
    14

    Default Re: An Expression a day keeps a clear mind away

    ok still i want to make it turn like 10° left when i press left but don't want it to stop there, it should go on :/

  6. #6
    Wire Sofaking mjmr89 is on a distinguished road mjmr89's Avatar
    Join Date
    Mar 2008
    Posts
    559

    Default Re: An Expression a day keeps a clear mind away

    Ok I think I got what you're saying - in that case,

    P = Plate:angles()itch()
    Y = Plate:angles():yaw()
    R = Plate:angles():roll()

    take these three lines out.

    P.S. I wouldn't have $Gyro there if I were you - it'd be better done as Plate:angVel(), but also, if Right/Left/Rightroll etc is pressed it will screw that value up.

  7. #7
    Inactive Peruanischer Speckkäfer is on a distinguished road Peruanischer Speckkäfer's Avatar
    Join Date
    Jan 2009
    Posts
    14

    Default Re: An Expression a day keeps a clear mind away

    how is the chair meant to work without knowing it's own pitch roll and yaw?

  8. #8
    Wire Sofaking mjmr89 is on a distinguished road mjmr89's Avatar
    Join Date
    Mar 2008
    Posts
    559

    Default Re: An Expression a day keeps a clear mind away

    Ah, I got you...you only want the yaw to be unrestricted? i.e. not at a specific degree? Then only delete this line

    Y = Plate:angles():yaw()

    and keep the other two in.

  9. #9
    Inactive Peruanischer Speckkäfer is on a distinguished road Peruanischer Speckkäfer's Avatar
    Join Date
    Jan 2009
    Posts
    14

    Default Re: An Expression a day keeps a clear mind away

    hmm, why does something like this not work? if(Right == 1){Y = Y + timer(TimerY,0)}
    i want to add Y to the value of the timer

  10. #10
    E2 Optimizer
    chinoto is on a distinguished road chinoto's Avatar
    Join Date
    Apr 2008
    Location
    In the skybox, lost another contraption...
    Posts
    1,714

    Default Re: An Expression a day keeps a clear mind away

    Code:
    @inputs Numpad Active RightRoll LeftRoll Right Left PitchForward PitchBackward Space Num5
    @outputs Plateforward:vector Ang:angle
    runOnTick(1)
    Plate = entity()
    V = owner():pos() - Plate:massCenter() + vec(0,0,-22)
    Plateforward = Plate:forward()
        
    if (Active) {
        if (Space|Num5){Plate:applyForce((Plateforward * 100 * (Space - Num5)) * Plate:mass())}
        Ang = ang(
            (PitchForward-PitchBackward)*45,
            (Right       -Left         )*90,
            (RightRoll   -LeftRoll     )*45
        )
        Plate:applyAngForce(((-Plate:angles():setYaw(0)-Ang)*25-Plate:angVel()*5) * Plate:inertia():length()/sqrt(3))
    }
    
    if (Numpad) {Plate:applyForce((V*10-Plate:vel())*Plate:mass())}
    
    Validates in E2... Should work

    (\__/) <- Put this bunny in your sig and help him to rule the world!
    (='.'=) PM me code and I'll send it back optimized if possible. (I find it fun dammit!)
    (")_(") Expression Gate 2 Wiki Help us update the wiki! Together we can make it more up to date than the SVN! ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Console Screen Clear
    By grandpapolly in forum Technical Support
    Replies: 12
    Last Post: 05-31-2009, 08:33 PM
  2. i fun E2 (pick thing up wit your mind!!!)
    By steelseeker in forum Finished contraptions
    Replies: 12
    Last Post: 04-27-2009, 04:36 PM
  3. How do I clear an entity
    By SpectreCat in forum Expression 1 & 2
    Replies: 4
    Last Post: 03-31-2009, 12:20 PM
  4. Mind if I use some Wire stuff in a map?
    By Rybec in forum Wiremod General Chat
    Replies: 3
    Last Post: 04-07-2008, 10:09 AM
  5. Mind rover will not work :(
    By George in forum Off-Topic
    Replies: 6
    Last Post: 07-08-2007, 05:49 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