+ Reply to Thread
Page 38 of 40 FirstFirst ... 283637383940 LastLast
Results 371 to 380 of 399

Thread: Expression Gate Documentation

  1. #371
    Wire Noob _Snake?Eye^_|Marsh's Avatar
    Join Date
    Dec 2008
    Location
    Denmark
    Posts
    6

    Default Re: Expression Gate Documentation

    Quote Originally Posted by taz_doh View Post
    the modulo do something like:
    4/5=2+1/5
    so it only give you the value that they cant divide whitout using fraction(1 in this equation)
    Thanks, I actually realized that while testing it, but i thought it might had some further actions :P.. Usefull i guess, once i get some good ideas.^_^

  2. #372
    Wire Amateur hexpunK's Avatar
    Join Date
    Sep 2008
    Location
    Thetford, England
    Posts
    45

    Default Re: Expression Gate Documentation

    Sorry for the bump, but this is useful after all. Anyway, I have a slight problem with Expression, I am trying to make a simple little Tank Controlling expression, problem is I can get the wheels to turn how I need, but they don't stop, then when i add something to make them stop, they don't turn. I know I am probably missing something important, I just can't figure out what it is.

    Code:
    N@Tank Controls
    I@W A S D
    O@Left Right
    W == 1 -> Left=1 Right=1;
    W == 0 -> Left=0 Right=0;
    A == 1 -> Left=-1 Right=1;
    A == 0 -> Left=0 Right=0;
    S == 1 -> Left=-1 Right=-1;
    S == 0 -> Left=0 Right=0;
    D == 1 -> Left=-1 Right=1;
    D == 0 -> Left=0 Right=0;
    Any help is appreciated.

  3. #373
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: Expression Gate Documentation

    Quote Originally Posted by hexpunK View Post
    Sorry for the bump, but this is useful after all. Anyway, I have a slight problem with Expression, I am trying to make a simple little Tank Controlling expression, problem is I can get the wheels to turn how I need, but they don't stop, then when i add something to make them stop, they don't turn. I know I am probably missing something important, I just can't figure out what it is.

    Code:
    N@Tank Controls
    I@W A S D
    O@Left Right
    W == 1 -> Left=1 Right=1;
    W == 0 -> Left=0 Right=0;
    A == 1 -> Left=-1 Right=1;
    A == 0 -> Left=0 Right=0;
    S == 1 -> Left=-1 Right=-1;
    S == 0 -> Left=0 Right=0;
    D == 1 -> Left=-1 Right=1;
    D == 0 -> Left=0 Right=0;
    Any help is appreciated.
    Absolutely, this thread is intended to help people so ask as much as you want.

    Your problem is quite common actually, if you look closely at each of your keys, you'll notice they are either PRESSED or NOT PRESSED. And depending on which it is, you set _ALL_ the parameters. Meaning, that any previous changes will have no effect.

    This is one way of fixing it: (Also, note that you don't have to write == 1)
    Code:
    N@Tank Controls
    I@W A S D
    O@Left Right
    Left = Right = 0
    W -> Left=1, Right=1;
    A -> Left=-1, Right=1;
    S -> Left=-1, Right=-1;
    D -> Left=1, Right=-1;
    EDIT: And I could recommend switching to Expression2, it is superiour in every way, your code would look like this in E2 if you want to try it out (it also support if-else-statements which are really handy):

    Code:
    @name Tank Controls
    @inputs W A S D
    @outputs Left Right
    Left = Right = 0
    if(W) { Left=1, Right=1 }
    if(A) { Left=-1, Right=1 }
    if(S) { Left=-1, Right=-1 }
    if(D) { Left=1, Right=-1 }

  4. #374
    Wire Sofaking Jimlad's Avatar
    Join Date
    Dec 2008
    Posts
    941

    Default Re: Expression Gate Documentation

    Quote Originally Posted by Syranide View Post
    And I could recommend switching to Expression2, it is superiour in every way, your code would look like this in E2 if you want to try it out (it also support if-else-statements which are really handy):
    I'm going to echo what Syranide said just to reinforce the point: I can't see much reason to use E1, when E2 is much more refined, easier to read and write, and more powerful in many ways. I would strongly advise immediately forgetting about E1 and switching over. It really surprises me that people still write in E1. Maybe they think it'll be easier because of the name? I don't know.

  5. #375
    Wire Amateur hexpunK's Avatar
    Join Date
    Sep 2008
    Location
    Thetford, England
    Posts
    45

    Default Re: Expression Gate Documentation

    Thanks for the reply Syranide, that helped me a lot, I haven't had tome to test it due to reformatting my PC (evil virus that ate almost everything suddenly, I was sure I quarantined it...). I thought I had gone wrong with something like that, i was using Zeos Panteras Dual input steering as a base, and I was thinking about the E2 equivalent, but couldn't quite figure it out while I was playing.

    EDIT: Normally I do try and use E2, but as I am still learning it a bit, I thought I might try E1 due to the slightly more simple way to do things like this, and that I had used it before.

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

    Default Re: Expression Gate Documentation

    They are exactly the same as far as simple math. Heres my version of the code:
    Code:
    N@Tank Controls
    I@W A S D
    O@Left Right
    Left =sgn(W-A-S+D)
    Right=sgn(W+A-S-D)
    (\__/) 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."

  7. #377
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: Expression Gate Documentation

    Quote Originally Posted by chinoto View Post
    They are exactly the same as far as simple math. Heres my version of the code:
    Code:
    N@Tank Controls
    I@W A S D
    O@Left Right
    Left =sgn(W-A-S+D)
    Right=sgn(W+A-S-D)
    Not the same, with that you can control the tracks individually (e.g. turn the left track but not the right), the initial codes does not allow that.

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

    Default Re: Expression Gate Documentation

    I was talking about E1 and E2 being the same as far as simple math.
    (\__/) 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."

  9. #379
    Wire Noob mooserider12's Avatar
    Join Date
    Mar 2009
    Location
    on a cat
    Posts
    4

    Default Re: Expression Gate Documentation

    im trying to make it so when a round wired to a timer is 1, a hydraulic is zero. i enterd this code:
    length = 117 (example)
    timer == 1 -> length = 0

    so yeah.. when i do I cant spawn it and it says "expected symbol (() near (==) at line 1". help! i might just add i have gmod 10 if that affects anything.

  10. #380
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: Expression Gate Documentation

    you can't write "(example)" in your code, if that's a comment then use "... #example".
    Otherwise, if what you posted is what you really wrote as an expression, it looks fine, except that you forgot a ; after "length = 0".

+ Reply to Thread
Page 38 of 40 FirstFirst ... 283637383940 LastLast

Similar Threads

  1. !!!OLD!!! Documentation of hi-speed devices
    By Black Phoenix in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 98
    Last Post: 02-10-2011, 07:41 PM
  2. !!!OLD!!! ZGPU Documentation
    By Black Phoenix in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 38
    Last Post: 11-29-2010, 04:54 PM
  3. !!!OLD!!! ZCPU Documentation
    By Black Phoenix in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 144
    Last Post: 09-05-2010, 03:46 AM
  4. Moongate Documentation
    By BlackNecro in forum Wiremod Addons & Coding
    Replies: 24
    Last Post: 04-22-2009, 01:32 AM

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