SHOW:
|
|
- or go back to the newest paste.
| 1 | - | print("---Create Mod Train Speed script---")
|
| 1 | + | shell.run("wget https://github.com/9551-Dev/apis/raw/main/graphir.lua")
|
| 2 | - | shell.run("wget https://github.com/9551-Dev/apis/raw/main/graphir.lua")
|
| 2 | + | |
| 3 | - | shell.run("wget https://github.com/9551-Dev/apis/raw/main/pixelbox_lite.lua")
|
| 3 | + | shell.run("wget https://github.com/9551-Dev/apis/raw/main/pixelbox_lite.lua")
|
| 4 | - | local graphir = require("graphir")
|
| 4 | + | |
| 5 | - | local pixelbox = require("pixelbox_lite")
|
| 5 | + | local graphir = require("graphir")
|
| 6 | - | local box = pixelbox.new(term.current()) |
| 6 | + | |
| 7 | - | local graph = graphir.new(box,colors.lightGray,colors.black,true,"normal") |
| 7 | + | local pixelbox = require("pixelbox_lite")
|
| 8 | - | |
| 8 | + | |
| 9 | - | while true==true do |
| 9 | + | local box = pixelbox.new(term.current()) |
| 10 | - | local a_x, a_y, a_z = gps.locate(5) |
| 10 | + | |
| 11 | - | -- print("---FIRST COORD---")
|
| 11 | + | local graph = graphir.new(box,colors.lightGray,colors.black,true,"normal") |
| 12 | - | -- print(a_x) |
| 12 | + | |
| 13 | - | -- print(a_y) |
| 13 | + | |
| 14 | - | -- print(a_z) |
| 14 | + | |
| 15 | - | os.sleep(5) |
| 15 | + | while true do |
| 16 | - | local b_x, b_y, b_z = gps.locate(5) |
| 16 | + | local a_x, a_y, a_z = gps.locate(5) |
| 17 | - | -- print("---SECOND COORD---")
|
| 17 | + | |
| 18 | - | -- print(b_x) |
| 18 | + | os.sleep(0.5) |
| 19 | - | -- print(b_y) |
| 19 | + | |
| 20 | - | -- print(b_z) |
| 20 | + | local b_x, b_y, b_z = gps.locate(5) |
| 21 | - | local delta_x = a_x - b_x |
| 21 | + | |
| 22 | - | local delta_z = a_z - b_z |
| 22 | + | |
| 23 | - | -- print("---DELTA---")
|
| 23 | + | local delta_x = a_x - b_x |
| 24 | - | -- print(delta_x) |
| 24 | + | local delta_z = a_z - b_z |
| 25 | - | -- print(delta_z) |
| 25 | + | |
| 26 | - | |
| 26 | + | local distance = math.sqrt(delta_x^2 + delta_z^2) |
| 27 | - | local distance = math.sqrt(delta_x^2 + delta_z^2) |
| 27 | + | |
| 28 | - | local a_x = nil |
| 28 | + | local a_x = nil |
| 29 | - | local b_x = nil |
| 29 | + | local b_x = nil |
| 30 | - | local b_y = nil |
| 30 | + | local b_y = nil |
| 31 | - | local a_y = nil |
| 31 | + | local a_y = nil |
| 32 | - | local a_z = nil |
| 32 | + | local a_z = nil |
| 33 | - | local b_z = nil |
| 33 | + | local b_z = nil |
| 34 | - | --print(distance) |
| 34 | + | |
| 35 | - | os.sleep(0.5) |
| 35 | + | local speed = distance*2 |
| 36 | - | |
| 36 | + | |
| 37 | - | -- print("Speed")
|
| 37 | + | term.setBackgroundColor(colors.black) |
| 38 | - | local speed = distance/5.5 |
| 38 | + | term.setTextColor(colors.white) |
| 39 | - | -- print(speed) |
| 39 | + | graph:add(speed) |
| 40 | - | |
| 40 | + | graph:push() |
| 41 | - | term.setBackgroundColor(colors.black) |
| 41 | + | box:render() |
| 42 | - | term.setTextColor(colors.white) |
| 42 | + | term.setCursorPos(1, 1) |
| 43 | - | graph:add(speed) |
| 43 | + | term.setBackgroundColor(colors.white) |
| 44 | - | graph:push() |
| 44 | + | term.setTextColor(colors.black) |
| 45 | - | box:render() |
| 45 | + | print(("Current speed: %s meters/second"):format(speed))
|
| 46 | - | term.setCursorPos(1, 1) |
| 46 | + | |
| 47 | - | term.setBackgroundColor(colors.white) |
| 47 | + | end |
| 48 | - | term.setTextColor(colors.black) |
| 48 | + | |
| 49 | - | print("Current speed:"..speed.. " a second")
|
| 49 | + |