Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $${
- // This script calculates the best possible rail layout between two coordinates.
- // When you execute the script, it will prompt for an input. Enter the destination coordinates in this format: x y z
- // Your current coordinates will be used as the starting coordinates. It will tell you in your chat log how far to go straight, and
- // how far to go angled. Place the first rail next to you (not under you) in the target direction.
- PROMPT(&inputcoords,"$$?","Enter end coordinates as: x y z",true,"%&inputcoords%")
- replace(&inputcoords,"\"","");
- #endcoords[] = split(" ","%&inputcoords%");
- // Get xdif
- if(%#endcoords[0]% >= %XPOS%);
- #xdif = (%#endcoords[0]%) - (%XPOS%)
- &xaxis = "east"
- elseif(%#endcoords[0]% < %XPOS%);
- #xdif = (%XPOS%) - (%#endcoords[0]%)
- &xaxis = "west"
- endif;
- // Get ydif
- if(%#endcoords[1]% >= %YPOS%);
- #ydif = (%#endcoords[1]%) - (%YPOS%)
- elseif(%#endcoords[1]% < %YPOS%);
- #ydif = (%YPOS%) - (%#endcoords[1]%)
- endif;
- // Get zdif
- if(%#endcoords[2]% >= %ZPOS%);
- #zdif = (%#endcoords[2]%) - (%ZPOS%)
- &zaxis = "south"
- elseif(%#endcoords[2]% < %ZPOS%);
- #zdif = (%ZPOS%) - (%#endcoords[2]%)
- &zaxis = "north"
- endif;
- // Calculate angle/straight
- if(%#xdif% > %#zdif%);
- #straight = (%#xdif%) - (%#zdif%)
- // Calculate start of angled
- if(%&xaxis% = "west");
- #xstop = (%XPOS%) - (%#straight%)
- elseif(%&xaxis% = "east");
- #xstop = (%XPOS%) + (%#straight%)
- endif;
- log("%#straight% %&xaxis%, %#zdif% %&zaxis%%&xaxis%. Turn at %#xstop%");
- elseif(%#zdif% > %#xdif%);
- #straight = (%#zdif%) - (%#xdif%)
- // Calculate start of angled
- if(%&zaxis% = "south");
- #zstop = (%ZPOS%) + (%#straight%)
- elseif(%&zaxis% = "north");
- #zstop = (%ZPOS%) - (%#straight%)
- endif;
- log("%#straight% %&zaxis%, %#xdif% %&zaxis%%&xaxis%. Turn at %#zstop%");
- endif;
- stop();
- }$$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement