Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitorSide = "top";
- --local serverID = 6;
- local m = peripheral.wrap(monitorSide)
- m.setTextScale(0.5)
- --
- term.redirect(m)
- --Monitor Width and Length
- local mW, mL = term.getSize()
- --rednet.open("top")
- local function round(num)
- return math.floor(num + 0.5)
- end
- --Getting The Track Layout Data
- local packet = {
- ["type"] = "railwayDisplayRequestAllData"
- }
- local type = ""
- local message = {
- type = "railwayDisplayAllData",
- signals = {
- W1 = {
- connectsTo = {
- W2 = {
- trackSpine = {},
- },
- },
- x = 562,
- z = -551,
- },
- N1 = {
- connectsTo = {
- S1 = {
- trackSpine = {},
- },
- },
- x = 568,
- z = -555,
- },
- E1 = {
- connectsTo = {
- W1 = {
- trackSpine = {},
- },
- },
- x = 561,
- z = -547,
- },
- W2 = {
- connectsTo = {
- E2 = {
- trackSpine = {},
- },
- },
- x = 581,
- z = -551,
- },
- S1 = {
- connectsTo = {
- W2 = {
- trackSpine = {},
- },
- },
- x = 573,
- z = -554,
- },
- E2 = {
- connectsTo = {
- E1 = {
- trackSpine = {},
- },
- N1 = {
- trackSpine = {},
- },
- },
- x = 580,
- z = -547,
- },
- },
- }
- --[[
- while false and type ~= "railwayDisplayAllData" do
- rednet.send(serverID, packet, "railwayDisplay")
- local id, m = rednet.receive("railwayDisplay")
- type = m["type"]
- message = m
- os.sleep(1)
- end
- ]]--
- local xRange = 0;
- local zRange = 0;
- local smallestX = nil
- local largestX = nil
- local smallestZ = nil
- local largestZ = nil
- for k,v in pairs(message["signals"]) do
- if(smallestX == nil or v.x < smallestX) then
- smallestX = v.x
- elseif(largestX == nil or v.x > largestX) then
- largestX = v.x
- end
- if(smallestZ == nil or v.z < smallestZ) then
- smallestZ = v.z
- elseif(largestZ == nil or v.z > largestZ) then
- largestZ = v.z
- end
- end
- xRange = math.abs(largestX - smallestX)
- zRange = math.abs(largestZ - smallestZ)
- print("monitor width: " .. mW)
- print("monitor height: " .. mL)
- print("X Range: " .. xRange)
- print("Z Range: " .. zRange)
- local xScale = mW / xRange
- local zScale = mL / zRange
- print("X Scale: " .. xScale)
- print("Z Scale: " .. zScale)
- --textutils.slowPrint(textutils.serialise(message),10)
- local function worldToScreenPos(x, z)
- return {
- ["x"] = round(((x - smallestX) * xScale)),
- ["z"] = round(((z - smallestZ) * zScale))
- }
- end
- term.clear()
- for k,v in pairs(message["signals"]) do
- local pixel = worldToScreenPos(v.x, v.z)
- --print(k .. ": " .. textutils.serialize(pixel))
- paintutils.drawPixel(pixel.x, pixel.z, colors.red)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement