+ Reply to Thread
Results 1 to 4 of 4

Thread: need some help with EXP2

  1. #1
    Lurker KustoM is on a distinguished road KustoM's Avatar
    Join Date
    Jun 2008
    Location
    Sydney
    Posts
    12

    Default need some help with EXP2

    okay so i am trying to make a completely automated factory using EXP2 but i am having some troubles with EXP2 not recognizing 2 different length inputs for one hydraulic.
    here is some of the code to illustrate:

    Code:
    @name Automated Factory Grabber
    @inputs Equal2 Ranger2 Ranger3 Grab2 Hyd5
    @outputs Hyd3 Spawn2 Hyd4 Grab2 Hyd5
    @persist
    
    if (Hyd5==130)
        {
            Hyd3=20
        }
    
    else { Hyd3=3 }
    
    if (Ranger2<14)
        {
            Grab2=1
        }
    
    else { Grab2=0 }
    
    if (Hyd5==130)
        {
            Hyd4=130
        }
    
    if (Hyd2==435)
        {
            Hyd4=50
         }
    
    else { Hyd4=1 }
    
    if (Ranger3<50)
        {
            Hyd5=130
        }
    
    else { Hyd5=0 }
    
    so take the lines for Hydraulic 4 for example. in one situation i want the hydraulic to lower a pickup plate to a certain level to pick up and object. i then the crane transports it down to another station to place it on the base requiring the hydraulic to extend to a different amount. the problem i am having is that EXP2 is only recognizing one of these lines at the best of times.

    so my question is is there something i am doing wrong or not doing at all that will let me use multiple lentgh triggers to multiple lengths on one hydraulic?

    P.S i kno my code sucks im a nub

  2. #2
    Lurker lucasmontec is on a distinguished road lucasmontec's Avatar
    Join Date
    Dec 2007
    Posts
    104

    Default Re: need some help with EXP2

    your not a nub! since you are using expression you are better than a lot of guys that I know!
    your code is right but you need to specify which hydraulic is what...and I'm missing a timer there since your arm is a mechanic thing. Try to implement a timer for timed actions or a smoother. This way you wont "kill" your hydraulic system.

  3. #3
    Spucatum Tauri Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    4,702

    Default Re: need some help with EXP2

    You are not a noob since:
    You tried to do it yourself first and posted the code.
    You give a description of what you want to do.

    Okay, that was the noob issue. Now the code.

    You need to be more clear for yourself.
    Hyd1 to 5 isn't very descriptive. Names as UpDownHyd ForwBackHyd are better to use.

    Don't use the same variable name as input and output anyway.

    How to fix it?
    Just write down a simple list on what happens and what triggers it.
    But you need to make sure that it is triggered on the right moment. A good way to achieve that is to use Fase or Stage variable. This one keeps everything working in the right order.

    Code:
    @name Automated Factory Grabber
    @inputs Start RangerFront
    @outputs LiftHyd ForwardHyd Grabber
    @persist Fase First
    interval(100)
    if (!First) #This makes sure your hydraulics start at the right value when you spawn the gate
        {
        LiftHyd=50
        ForwardHyd=10
        Grabber=0
        First=1
        }
    
    if (Start&Fase==0) #If the button is on it will continue processing the fases. Otherwise it just waits.
        {
            Fase=1
        }
    
    if (Fase==1)
       {
        LiftHyd-=1  #Every clk 1 is taken of the LiftHydr
        if (Fase==1&LiftHyd<10) #Until is 10 or less, then it continues to fase 2
            {
            Fase=2
            }
        }
    
    
    if (Fase==2)
       {
        ForwHyd+=1
        if (Fase==2&RangerFront) #Stay in fase 2 until something hits the ranger. (Assuming you set it to default to zero)
            {
            Fase=3
            }
        }
    
    if (Fase==3)
       {
        LiftHyd+=1
        if (Fase==3 & LiftHyd>30) #When the lift hydraulic has extended to 30 or more then  
            {
            Grabber=1  #Activate the grabber
            Fase=0  #And return to the start of the program
            }
        }
    
    Obviously this code is not complete, just to give you an idea.

    I hope it helps!

    @Lucas
    A timer is a way to keep things in track, but it's very unreliable.
    Whenever there is a slight problem everything is affected.
    Last edited by Bull; 12-10-2008 at 08:25 AM.
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

  4. #4
    Lurker KustoM is on a distinguished road KustoM's Avatar
    Join Date
    Jun 2008
    Location
    Sydney
    Posts
    12

    Default Re: need some help with EXP2

    sweet thanks for the help. currently i have three expressions running this whole thing but with this i might be able to put it all on one. ill go try it now and post back if it works

+ Reply to Thread

Similar Threads

  1. Calculations and Exp2 question
    By jayg20769 in forum Technical Support
    Replies: 9
    Last Post: 02-22-2009, 02:13 PM
  2. Where I have a mistake? [Exp2]
    By Klask in forum Technical Support
    Replies: 4
    Last Post: 02-21-2009, 04:58 PM
  3. exp2 strings using star trek
    By LimEJET in forum Expression 1 & 2
    Replies: 5
    Last Post: 01-13-2009, 01:28 PM
  4. Wirelinks in exp2
    By Hitman271 in forum Technical Support
    Replies: 5
    Last Post: 11-23-2008, 10:11 AM
  5. Questions about Exp2 (Functionality)
    By Pyro-Fire in forum Technical Support
    Replies: 1
    Last Post: 11-09-2008, 01:18 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