1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

How can I get the height of different blocks?

Discussion in 'Programming Questions and Suggestions' started by Kezeslabas, Aug 9, 2019.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Kezeslabas

    Kezeslabas Trainee Engineer

    Messages:
    7
    I would need the height of pistons for a script, to control rotating arms made out of pistons of different types, like modded pistons and such.

    I want to adjust the rotation speed automatically and I need this information to do that.
    It's easy to get that how much a piston is extended, but I'm struggling to figure out how to get the base height of the individual pistons.

    Anyone can help?
     
  2. mojomann71

    mojomann71 Senior Engineer

    Messages:
    2,005
    One large block = 2.5M. I am currently at work and I think a large piston is 2 blocks in length so that would be 5M (not extended of course). If it is 3 blocks in length then, of course, it would be 7.5M (not extended).

    Small Block is 0.5M a block. Same rule applies as above to figure out the length of a non-extended piston.

    I am assuming that is what you were looking for??
     
  3. Kezeslabas

    Kezeslabas Trainee Engineer

    Messages:
    7
    No, I know this, what I'm looking for is to how get this information trough programming.

    Like let's say that there are random pistons with different heights, placed on top of each other, and I want to know, how tall that Piston tower is, without counting it with my eyes.
    Like is there a way to get their individual heights in a script without manual input?
     
  4. Mollymawk

    Mollymawk Apprentice Engineer

    Messages:
    124
    Two ideas:
    GetPosition() of a block at the top and another at the bottom then calc the distance. control panels are very small and hopefully would not impact the design of the machine.

    Vector3D.DistanceSquared(Vector3D, Vector3D) is quicker than Vector3D.Distance(Vector3D, Vector3D) if you using it many times in a loop.

    Also Camera looking up or down could work. but if things are rotating and stretching all over the place getting it to point in the right direction could be an issue.

    if the pistons are all in line though, and are the only things affecting height. i would use the pistons CurrentPosition and MaxPosition
     
    Last edited: Aug 19, 2019
  5. Kezeslabas

    Kezeslabas Trainee Engineer

    Messages:
    7
    I have figured it out recently, and your comment helped, thanks.

    My script uses Drills at the end of the Pistons, and I ended up predicting the length of the Rotating Arm, by projecting the difference Vector of the Rotor's Position and the Furthest Drill's Position to the right plane, then measuring it with the Vector3D.Distance().
     
    • Like Like x 1
Thread Status:
This last post in this thread was made more than 31 days old.