{"slots":{"0":{"name":"slot1","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}},"-3":{"name":"player","type":{"events":[],"methods":[]}},"-2":{"name":"construct","type":{"events":[],"methods":[]}},"-4":{"name":"system","type":{"events":[],"methods":[]}},"-5":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"evaluateButtons(x, y, false, slot4)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseUp(x,y)","slotKey":"3"},"key":"0"},{"code":"evaluateButtons(x, y, true, slot4)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"3"},"key":"1"},{"code":"evaluateButtons(x, y, false, slot5)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseUp(x,y)","slotKey":"4"},"key":"2"},{"code":"evaluateButtons(x, y, true, slot5)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"4"},"key":"3"},{"code":"evaluateButtons(x, y, false, slot6)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseUp(x,y)","slotKey":"5"},"key":"4"},{"code":"evaluateButtons(x, y, true, slot6)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"mouseDown(x,y)","slotKey":"5"},"key":"5"},{"code":"update3d(true)\nupdateButtons(true)","filter":{"args":[{"value":"spacemap"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"6"},{"code":"mapRotate()","filter":{"args":[{"value":"maprotate"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"7"},{"code":"\nbuttonHeight = 35\n\n-- buttonWidth = 333\n\nbuttonSpacing = 3\nbuttonStroke = 2\nbuttonStrokeHalf = buttonStroke / 2\n\nscreenHeight = 612\nscreenWidth = 1024\n\nbuttonsPerLine = 4\nbuttonWidth = (screenWidth / buttonsPerLine) - (buttonSpacing * (buttonsPerLine-1))+ (buttonStrokeHalf * buttonsPerLine)\n\nradarScale = 110\nradarFullScreenScale = 50\n\nscreens = {}\ndatabank = nill\nwarpdrive = nill\n\nwarpDriveDestinationPlanet = nill\n\nupdateInterval = 1\nupdateMouseInterval = 0.05\nupdateHoverInterval = 0.05\n\nshipWeight = 0\n\natlas = require(\"atlas\")\nlocal coreAtlas = atlas[0]\n\ntonum = tonumber\nstringmatch = string.match\n\nlocal internalScale = 400000\n\nlocal customWarp = nil\n\nlocal customWarpName = \"WarpBeacon\"\n\nlocal function zeroConvertToWorldCoordinates(pos)\n\tlocal num = ' *([+-]?%d+%.?%d*e?[+-]?%d*)'\n\tlocal posPattern = '::pos{' .. num .. ',' .. num .. ',' .. num .. ',' .. num .. ',' .. num .. '}'\n\tlocal systemId, id, latitude, longitude, altitude = stringmatch(pos, posPattern)\n\tif (systemId == \"0\" and id == \"0\") then\n\t\treturn vec3(tonum(latitude),\n\t\t\ttonum(longitude),\n\t\t\ttonum(altitude))\n\tend\n\tlongitude = math.rad(longitude)\n\tlatitude = math.rad(latitude)\n\tlocal planet = atlas[tonum(systemId)][tonum(id)]\n\tlocal xproj = math.cos(latitude);\n\tlocal planetxyz = vec3(xproj*math.cos(longitude),\n\t\txproj*math.sin(longitude),\n\t\tmath.sin(latitude));\n\tlocal pcenter = {x = planet.center[1], y = planet.center[2], z = planet.center[3]}\n\treturn pcenter + ((planet.radius + altitude) * planetxyz)\nend\n\nfunction luaChatEnter(text)\n\tlocal position = zeroConvertToWorldCoordinates(text)\n\n\tlocal button = {id = 66, planet = nill, name = customWarpName, x=100, y=500}\n\n\tcustomWarp = {fullname = customWarpName, name = customWarpName, center = position, mapCoords = {x = position.x/internalScale,y = position.y/internalScale, z = position.z/internalScale}, moons = {}, button = button}\n\tfor _,screenObject in ipairs(screens) do\n\t\tscreenObject.selectedPlanet = nil\n\tend\n\tupdate3d(false)\n\tupdateButtons(false)\nend\n\nfunction initializeScreen(key, screenUnit)\n\treturn {\n\t\tscreen = screenUnit,\n\t\tid = screenUnit.getLocalId(),\n\t\tslot = key,\n\t\tangle = -1,\n\t\tpitch = 0,\n\t\tyaw = 0,\n\t\tscale = 1,\n\t\tmapCenterPoint = {x = 0, y = 0, z = 0},\n\t\tscreenCenterX = screenWidth / 2,\n\t\tscreenCenterY = screenHeight - (screenHeight / 3),\n\t\tmapViewState = 1,\n\t\textraWeight = 0,\n\t\tweightButtonClicked = nill,\n\t\ttimer = 0,\n\t\tchangeView = true,\n\t\tmouseDown = false,\n\t\tselectedPlanet = nill,\n\t\thover = nill,\n\t\tzoomScale = 1.5,\n\t\ttargetZoomScale = 1.5}\nend\n\nfor key, value in pairs(unit) do\n\tif type(value) == \"table\" and type(value.export) == \"table\" then\n\t\tif value.getClass then\n\t\t\tif value.getClass() == \"ScreenUnit\" then\n\t\t\t\tscreens[#screens + 1] = initializeScreen(key, value)\n\t\t\telseif value.getClass() == \"DataBankUnit\" then\n\t\t\t\tdatabank = value\n\t\t\telseif value.getClass() == \"WarpDriveUnit\" then\n\t\t\t\twarpdrive = value\n\t\t\tend\n\t\tend\n\tend\nend\n\npresets = {}\n\nfunction addPreset(preset)\n\tpresets[#presets+1] = preset\nend\n\n\n-- #1\naddPreset({\n\tbackGroundColor = \"0c0f09\",\n\tpathColor = \"999999\",\n\tplanetOffsetColor = \"ffffff\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"ffffff\",\n\tbuttonBInactiveColor = \"ff6700\",\n\tbuttonTInactiveColor = \"d2d1d1\",\n\tbuttonBActiveColor = \"fc7b24\",\n\tbuttonTActiveColor = \"b1b1b1\",\n\tbuttonTWarpInactiveColor = \"D0AF40\",\n\tbuttonTWarpActiveColor = \"b1b1b1\",\n\tmapCircleColor = \"9e9e9e\",\n\tmapBCircleColor = \"a08787\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"ffffff\",\n\tplanetEdgeColor = \"ffffff\",\n\tplanetNameColor = \"ff6700\",\n\tminiTextColor = \"ff6700\",\n\twarpCostColor = \"fc7b24\"})\n\n-- #2\naddPreset({\n\tbackGroundColor = \"DFDFDF\",\n\tpathColor = \"999999\",\n\tplanetOffsetColor = \"2c2c2c\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"ffffff\",\n\tbuttonBInactiveColor = \"4B4B4B\",\n\tbuttonTInactiveColor = \"d2d1d1\",\n\tbuttonBActiveColor = \"c5c5c5\",\n\tbuttonTActiveColor = \"515151\",\n\tbuttonTWarpInactiveColor = \"D0AF40\",\n\tbuttonTWarpActiveColor = \"756326\",\n\tmapCircleColor = \"2c2c2c\",\n\tmapBCircleColor = \"2c2c2c\",\n\tmapConstructColor = \"6f6f6f\",\n\tmapConstructSColor = \"404040\",\n\tplanetColor = \"424242\",\n\tplanetEdgeColor = \"4b4b4b\",\n\tplanetNameColor = \"2c2c2c\",\n\tminiTextColor = \"161616\",\n\twarpCostColor = \"161616\"})\n\n-- #3\naddPreset({\n\tbackGroundColor = \"031333\",\n\tpathColor = \"999999\",\n\tplanetOffsetColor = \"82e0ff\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"68b3cc\",\n\tbuttonBInactiveColor = \"68b3cc\",\n\tbuttonTInactiveColor = \"5d3c00\",\n\tbuttonBActiveColor = \"335c69\",\n\tbuttonTActiveColor = \"a66c02\",\n\tbuttonTWarpInactiveColor = \"595601\",\n\tbuttonTWarpActiveColor = \"bdb603\",\n\tmapCircleColor = \"9e9e9e\",\n\tmapBCircleColor = \"a08787\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"1b708c\",\n\tplanetEdgeColor = \"000000\",\n\tplanetNameColor = \"82e0ff\",\n\tminiTextColor = \"82e0ff\",\n\twarpCostColor = \"5fd6fd\"})\n\n-- #4\naddPreset({\n\tbackGroundColor = \"000000\",\n\tpathColor = \"ffffff\",\n\tplanetOffsetColor = \"ffffff\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"ffffff\",\n\tbuttonBInactiveColor = \"151515\",\n\tbuttonTInactiveColor = \"ffffff\",\n\tbuttonBActiveColor = \"232323\",\n\tbuttonTActiveColor = \"ffffff\",\n\tbuttonTWarpInactiveColor = \"909090\",\n\tbuttonTWarpActiveColor = \"909090\",\n\tmapCircleColor = \"ffffff\",\n\tmapBCircleColor = \"cfcfcf\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"4a4ed7\",\n\tplanetEdgeColor = \"ffffff\",\n\tplanetNameColor = \"ffffff\",\n\tminiTextColor = \"ffffff\",\n\twarpCostColor = \"ffffff\"})\n-- #5\naddPreset({\n\tbackGroundColor = \"000000\",\n\tpathColor = \"ffffff\",\n\tplanetOffsetColor = \"ffffff\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"4a4ed7\",\n\tbuttonBInactiveColor = \"ffffff\",\n\tbuttonTInactiveColor = \"151515\",\n\tbuttonBActiveColor = \"ffffff\",\n\tbuttonTActiveColor = \"232323\",\n\tbuttonTWarpInactiveColor = \"1d1c1c\",\n\tbuttonTWarpActiveColor = \"373030\",\n\tmapCircleColor = \"ffffff\",\n\tmapBCircleColor = \"cfcfcf\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"4a4ed7\",\n\tplanetEdgeColor = \"ffffff\",\n\tplanetNameColor = \"ffffff\",\n\tminiTextColor = \"ffffff\",\n\twarpCostColor = \"ffffff\"})\n-- #6\naddPreset({\n\tbackGroundColor = \"3c6553\",\n\tpathColor = \"ffffff\",\n\tplanetOffsetColor = \"2c2c2c\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"ffffff\",\n\tbuttonBInactiveColor = \"070b0a\",\n\tbuttonTInactiveColor = \"3c6553\",\n\tbuttonBActiveColor = \"3c6553\",\n\tbuttonTActiveColor = \"070b0a\",\n\tbuttonTWarpInactiveColor = \"1d1c1c\",\n\tbuttonTWarpActiveColor = \"1d1c1c\",\n\tmapCircleColor = \"ffffff\",\n\tmapBCircleColor = \"cfcfcf\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"3c6553\",\n\tplanetEdgeColor = \"ffffff\",\n\tplanetNameColor = \"0d1311\",\n\tminiTextColor = \"0d1311\",\n\twarpCostColor = \"0d1311\"})\n-- #7\naddPreset({\n\tbackGroundColor = \"070b0a\",\n\tpathColor = \"ffffff\",\n\tplanetOffsetColor = \"ffffff\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"ffffff\",\n\tbuttonBInactiveColor = \"3c6553\",\n\tbuttonTInactiveColor = \"070b0a\",\n\tbuttonBActiveColor = \"070b0a\",\n\tbuttonTActiveColor = \"3c6553\",\n\tbuttonTWarpInactiveColor = \"1d1c1c\",\n\tbuttonTWarpActiveColor = \"808080\",\n\tmapCircleColor = \"ffffff\",\n\tmapBCircleColor = \"cfcfcf\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"ffffff\",\n\tplanetEdgeColor = \"ffffff\",\n\tplanetNameColor = \"3c6553\",\n\tminiTextColor = \"3c6553\",\n\twarpCostColor = \"3c6553\"})\n-- #8\naddPreset({\n\tbackGroundColor = \"00001e\",\n\tpathColor = \"ffffff\",\n\tplanetOffsetColor = \"025a6e\",\n\tbuttonBorderColor = \"2c2c2c\",\n\tbuttonBorderHoverColor = \"ffffff\",\n\tbuttonBInactiveColor = \"025a6e\",\n\tbuttonTInactiveColor = \"fba71d\",\n\tbuttonBActiveColor = \"fba71d\",\n\tbuttonTActiveColor = \"025a6e\",\n\tbuttonTWarpInactiveColor = \"1d1c1c\",\n\tbuttonTWarpActiveColor = \"04d8d7\",\n\tmapCircleColor = \"ffffff\",\n\tmapBCircleColor = \"cfcfcf\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"0d71d3\",\n\tplanetEdgeColor = \"ffffff\",\n\tplanetNameColor = \"816d32\",\n\tminiTextColor = \"816d32\",\n\twarpCostColor = \"816d32\"})\n-- #9\naddPreset({\n\tbackGroundColor = \"060000\",\n\tpathColor = \"ff4b00\",\n\tplanetOffsetColor = \"025a6e\",\n\tbuttonBorderColor = \"b20000\",\n\tbuttonBorderHoverColor = \"ffffff\",\n\tbuttonBInactiveColor = \"100000\",\n\tbuttonTInactiveColor = \"aa0000\",\n\tbuttonBActiveColor = \"280101\",\n\tbuttonTActiveColor = \"aa0000\",\n\tbuttonTWarpInactiveColor = \"c51d1d\",\n\tbuttonTWarpActiveColor = \"c51d1d\",\n\tmapCircleColor = \"ff0000\",\n\tmapBCircleColor = \"ff0000\",\n\tmapConstructColor = \"00ff00\",\n\tmapConstructSColor = \"440044\",\n\tplanetColor = \"001aff\",\n\tplanetEdgeColor = \"ffffff\",\n\tplanetNameColor = \"ff0000\",\n\tminiTextColor = \"ff0000\",\n\twarpCostColor = \"ff0000\"})\n\n-- #10\naddPreset({\n\tbackGroundColor = \"000006\",\n\tpathColor = \"41a1e4\",\n\tplanetOffsetColor = \"3a77a2\",\n\tbuttonBorderColor = \"0047b2\",\n\tbuttonBorderHoverColor = \"4fb6fd\",\n\tbuttonBInactiveColor = \"012459\",\n\tbuttonTInactiveColor = \"294f89\",\n\tbuttonBActiveColor = \"0a5ca1\",\n\tbuttonTActiveColor = \"5acbff\",\n\tbuttonTWarpInactiveColor = \"1d1dc5\",\n\tbuttonTWarpActiveColor = \"1d1dc5\",\n\tmapCircleColor = \"0c3650\",\n\tmapBCircleColor = \"0c3650\",\n\tmapConstructColor = \"A8e6fd\",\n\tmapConstructSColor = \"97d5fc\",\n\tplanetColor = \"012459\",\n\tplanetEdgeColor = \"0a5ca1\",\n\tplanetNameColor = \"294f89\",\n\tminiTextColor = \"0a5ca1\",\n\twarpCostColor = \"0a5ca1\"})\n\n\nmapCircleThickness = 0.8 --export: Defines circle thickness. Default: 0.8\nmapCircleThickness = mapCircleThickness..\"vh\"\n\nshowSafeZone = false --export: Shows or hides safe zone bubble\n\n\n\n\nlocal presetButton = {width = buttonHeight, height = buttonHeight, y = buttonSpacing + ((buttonHeight+buttonSpacing+buttonStrokeHalf) * (math.floor(12 / buttonsPerLine) + 1)), x=buttonSpacing, preset = 1}\n\n\nfunction saveAll()\n\tif databank then\n\t\tsavepreset()\n\t\tfor _,screenObject in ipairs(screens) do\n\t\t\tsave(screenObject)\n\t\tend\n\t\tif (construct.getMass() / 1000 > 3) then\n\t\t\tdatabank.setFloatValue(\"shipWeight\", math.floor(construct.getMass() / 1000))\n\t\tend\n\tend\nend\n\nfunction savepreset()\n\tif databank then\n\t\tdatabank.setIntValue(\"warpPreset\", presetButton.preset)\n\tend\nend\n\n\n\nfunction split(s, delimiter)\n\tresult = {};\n\tfor match in (s..delimiter):gmatch(\"(.-)\"..delimiter) do\n\t\ttable.insert(result, match);\n\tend\n\treturn result;\nend\n\nif databank then\n\tfor _,key in ipairs(databank.getKeyList()) do\n\t\tvalue = databank.getFloatValue(key)\n\n\t\tfor _,screenObject in ipairs(screens) do\n\t\t\tif string.match(key, screenObject.slot) then\n\t\t\t\tsplitted = split(key, \"_\")\n\t\t\t\tlastPart = splitted[#splitted]\n\n\t\t\t\tif lastPart == \"angle\" then\n\t\t\t\t\tscreenObject.angle = value\n\t\t\t\telseif lastPart == \"pitch\" then\n\t\t\t\t\tscreenObject.pitch = value\n\t\t\t\telseif lastPart == \"zoomScale\" then\n\t\t\t\t\tscreenObject.zoomScale = value\n\t\t\t\telseif lastPart == \"yaw\" then\n\t\t\t\t\tscreenObject.yaw = value\n\t\t\t\telseif lastPart == \"state\" then\n\t\t\t\t\tscreenObject.mapViewState = value\n\t\t\t\telseif lastPart == \"weight\" then\n\t\t\t\t\tshipWeight = value\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\n\tif databank.hasKey(\"shipWeight\") then\n\t\tshipWeight = math.floor(databank.getFloatValue(\"shipWeight\"))\n\tend\n\n\tif databank.hasKey(\"warpPreset\") then\n\t\tpresetButton.preset = databank.getIntValue(\"warpPreset\")\n\t\tif presetButton.preset < 1 then\n\t\t\tpresetButton.preset = 1\n\t\tend\n\tend\nend\n\npreset = presets[1]\n\nfunction updatePreset()\n\tif #presets < presetButton.preset or presetButton.preset < 1 then\n\t\tpreset = presets[1]\n\t\treturn\n\tend\n\tpreset = presets[presetButton.preset]\nend\nupdatePreset()\n\nfunction Split(s, delimiter)\n\tresult = {};\n\tfor match in (s..delimiter):gmatch(\"(.-)\"..delimiter) do\n\t\ttable.insert(result, match);\n\tend\n\treturn result;\nend\n\n\n\nfunction save(screenObject)\n\tif databank then\n\t\tdatabank.setFloatValue(screenObject.slot..\"_angle\", screenObject.angle)\n\t\tdatabank.setFloatValue(screenObject.slot..\"_pitch\", screenObject.pitch)\n\t\tdatabank.setFloatValue(screenObject.slot..\"_yaw\", screenObject.yaw)\n\t\tdatabank.setFloatValue(screenObject.slot..\"_zoomScale\", screenObject.zoomScale)\n\t\tdatabank.setFloatValue(screenObject.slot..\"_state\", screenObject.mapViewState)\n\tend\nend\n\n\nweightScreenButtons = {}\n\nlocal amountButton = {id = #weightScreenButtons, width = 80, y=screenHeight-buttonHeight-buttonSpacing, x=screenWidth - 80 -10, change = 100}\ntable.insert(weightScreenButtons, amountButton)\nlocal amountButton = {id = #weightScreenButtons, width = 60, y=amountButton.y, x=amountButton.x- 60 -3, change = 10}\ntable.insert(weightScreenButtons, amountButton)\nlocal amountButton = {id = #weightScreenButtons, width = 50, y=amountButton.y, x=amountButton.x- 50 -3, change = -10}\ntable.insert(weightScreenButtons, amountButton)\nlocal amountButton = {id = #weightScreenButtons, width = 70, y=amountButton.y, x=amountButton.x- 70 -3, change = -100}\ntable.insert(weightScreenButtons, amountButton)\n\nfunction getMoonsCount(planet)\n\tcounter = \"\"\n\tif (planet.satellites == nil) then\n\t\treturn counter\n\tend\n\tfor index in pairs(planet.satellites) do\n\tif index > 5 then\n\treturn counter\n\tend\n\t\tcounter = counter..\"*\"\n\tend\n\treturn counter\nend\n\nfunction formatPlanetName(planet)\n\treturn planet.name[1]..getMoonsCount(planet)\nend\n\nfunction mapX(planet)\n\treturn planet.center[1]/internalScale\nend\n\nfunction mapY(planet)\n\treturn (planet.center[2]/internalScale)\nend\n\nfunction mapZ(planet)\n\treturn planet.center[3]/internalScale\nend\n\nplanets = {}\n\n---- creating planet button and assingning it to planet object\n--function addPlanetButton(planet)\n--\n--\tlocal x = 0\n--\tlocal y = 0\n--\n--\n--\tlocal line = math.floor(#planets / buttonsPerLine)\n--\tlocal place = #planets % buttonsPerLine\n--\n--\tbuttonX = buttonSpacing + ((buttonWidth+buttonSpacing+buttonStrokeHalf) * place)\n--\tbuttonY = buttonSpacing + ((buttonHeight+buttonSpacing+buttonStrokeHalf) * line)\n--\n--\tbutton = {id = #planets + 1, planet = planet, name = formatPlanetName(planet), x=buttonX, y=buttonY}\n--\tplanet.button = button\n--\tplanet.mapCoords = {x = mapX(planet),y = mapY(planet), z = mapZ(planet)}\n--\tplanet.fullname = planet.name\n--\ttable.insert(planets, planet)\n--end\n\n-- creating planet button and assingning it to planet object\nfunction addPlanets()\n\n\t_planets = {}\n\n\tfor _,b in pairs(coreAtlas) do\n\t\tif b.systemId == 0 then\n\t\t\tif b.satellites then\n\t\t\t\ttable.sort (b.satellites, function (b1, b2) return coreAtlas[b1].positionInSystem < coreAtlas[b1].positionInSystem end )\n\t\t\tend\n\n\t\t\t_planets[#_planets+1] = b\n\t\tend\n\tend\n\ttable.sort (_planets, function (b1, b2) return b1.positionInSystem < b2.positionInSystem end )\n\n\n\tfor _,p in pairs(_planets) do\n\n\t\tlocal x = 0\n\t\tlocal y = 0\n\n\t\tlocal line = math.floor(#planets / buttonsPerLine)\n\t\tlocal place = #planets % buttonsPerLine\n\n\t\tbuttonX = buttonSpacing + ((buttonWidth + buttonSpacing + buttonStrokeHalf) * place)\n\t\tbuttonY = buttonSpacing + ((buttonHeight + buttonSpacing + buttonStrokeHalf) * line)\n\n\t\tplanet = {name = p.name[1], color = \"#4d5861\", center = vec3(p.center)}\n\n\t\tbutton = {id = #planets + 1, planet = p, name = formatPlanetName(p), x= buttonX, y= buttonY}\n\t\tplanet.button = button\n\t\tplanet.satellites = p.satellites\n\t\tplanet.icon = p.iconPath\n\t\tplanet.mapCoords = {x = mapX(p),y = mapY(p), z = mapZ(p)}\n\t\tplanet.fullname = p.name[1]\n\t\ttable.insert(planets, planet)\n\n\tend\nend\n\n--::pos{0,0,13855453,7385167,-38337}\n--::pos{0,0,13771471,7435803,-128971}\nsafeZoneCenter = vec3(13771471 / internalScale, 7435803 / internalScale, -128971 / internalScale)\n\n--edge = vec3(-2630938.1075 / 400000, 22487.5022 / 400000, -190192.7468 / 400000)\n\n-- safe zone edge ::pos{0,0,-2630938.1075,22487.5022,-190192.7468}\n-- Safe zone radius 90SU\n\nsafeZoneSize = 27.3*2\n\nSU100 = 30*2\n\n\n\n---- Moons\n---- Madis\n--local MadisMoon1 = {id = 10, name = \"Moon 1\", center = vec3(17448118.224,22966846.286,143078.820), radius = 10000}\n--local MadisMoon2 = {id = 11, name = \"Moon 2\", center = vec3(17194626.000,22243633.880,-214962.810), radius = 11000}\n--local MadisMoon3 = {id = 12, name = \"Moon 3\", center = vec3(17520614.000,22184730.000,-309989.990), radius = 15005}\n--\n---- Alioth\n--local AliothMoon1 = {name = \"Moon 1\", center = vec3(457933.000,-1509011.000,115524.000), radius = 30000}\n--local AliothMoon4 = {name = \"Moon 4\", center = vec3(-1692694.000,729681.000,-411464.000), radius = 30330}\n--local Sanctuary = {name = \"Sanctuary\", center = vec3(-1404835.000,562655.000,-285074.000), radius = 83400}\n--local Haven = {name = \"Haven\", center = vec3(-1205152.02, 1124841.79, -2638867.62), radius = 83443}\n--\n---- Thades\n--local ThadesMoon1 = {name = \"Moon 1\",center = vec3(29214402.000,10907080.695,433858.200), radius = 14002}\n--local ThadesMoon2 = {name = \"Moon 2\",center = vec3(29404193.000,10432768.000,19554.131), radius = 15000}\n--\n---- Talemai\n--local TalemaiMoon1 = {name = \"Moon 1\",center = vec3(-13058408.000,55781856.000,740177.760), radius = 15000}\n--local TalemaiMoon2 = {name = \"Moon 2\",center = vec3(-13503090.000,55594325.000,769838.640), radius = 12000}\n--local TalemaiMoon3 = {name = \"Moon 3\",center = vec3(-12800515.000,55700259.000,325207.840), radius = 11000}\n--\n---- Feli\n--local FeliMoon1 = {name = \"Moon 1\",center = vec3(-43902841.780,22261034.700,-48862386.000), radius = 14000}\n--\n---- Sinnen\n--local SinnenMoon1 = {name = \"Moon 1\",center = vec3(58969616.000,29797945.000,57969449.000), radius = 17000}\n--\n---- Lacobus\n--local LacobusMoon1 = {name = \"Moon 1\",center = vec3(99180968.000,-13783862.000,-926156.400), radius = 18000}\n--local LacobusMoon2 = {name = \"Moon 2\",center = vec3(99250052.000,-13629215.000,-1059341.400), radius = 14000}\n--local LacobusMoon3 = {name = \"Moon 3\",center = vec3(98905288.170,-13950921.100,-647589.530), radius = 15000}\n--\n---- Ion\n--local IonMoon1 = {name = \"Moon 1\",center = vec3(2472916.800,-99133747.000,-1133582.800), radius = 11000}\n--local IonMoon2 = {name = \"Moon 2\",center = vec3(2995424.500,-99275010.000,-1378480.700), radius = 15000}\n--\n-- Planets\n--addPlanetButton({id = 2, name = \"Alioth\", center = vec3(-8.000, -8.000, -126303.000), radius = 126068, color = \"#4d5861\", moons = {AliothMoon1, AliothMoon4, Sanctuary, Haven}})\n--addPlanetButton({id = 1, name = \"Madis\", center = vec3(17465536.000, 22665536.000, -34464.000), radius = 44300, color = \"#777bbf\", moons = {MadisMoon1, MadisMoon2, MadisMoon3}})\n--addPlanetButton({name = \"Thades\", center = vec3(29165536.000, 10865536.000, 65536.000), radius = 49000, color = \"#da985f\", moons = {ThadesMoon1, ThadesMoon2}})\n--addPlanetButton({name = \"Ion\", center = vec3(2995424.500,-99275010.000,-1378480.700), radius = 44950, color = \"#9fc1df\", moons = {IonMoon1, IonMoon2}})\n--addPlanetButton({name = \"Sinnen\", center = vec3(58665536.000, 29665536.000, 58165536.000), radius = 54950, color = \"#d0885b\", moons = {SinnenMoon1}, drawZero = true})\n--addPlanetButton({name = \"Jago\", center = vec3(-94134464.000, 12765536.000, -3634464.000), radius = 61590, color = \"#36444f\", moons = {}})\n--addPlanetButton({name = \"Symeon\", center = vec3(14165536.000, -85634464.000, -934464.000), radius = 49050, color = \"#cad1d9\", moons = {}})\n--addPlanetButton({name = \"Lacobus\", center = vec3(98865536.000, -13534464.000, -934464.000), radius = 55650, color = \"#deedf9\", moons = {LacobusMoon1, LacobusMoon2, LacobusMoon3}})\n--addPlanetButton({name = \"Teoma\", center = vec3(80865536.000, 54665536.000, -934464.000), radius = 62000, color = \"#3e5268\", moons = {}})\n--addPlanetButton({name = \"Feli\", center = vec3(-43534464.000, 22565536.000, -48934464.000), radius = 60000, color = \"#928370\", moons = {FeliMoon1}, drawZero = true})\n--addPlanetButton({name = \"Talemai\", center = vec3(-13234464.000, 55765536.000, 465536.000), radius = 57450, color = \"#929482\", moons = {TalemaiMoon1, TalemaiMoon2, TalemaiMoon3}})\n--addPlanetButton({name = \"Sicari\", center = vec3(52765536.000, 27165536.000, 52065536.000), radius = 51100, color = \"#b78a64\", moons = {}, drawZero = true})\n\naddPlanets()\n\nbuttonLowY = button.y\n\n-- creating moon buttons\nplace = 1\nlocal middle = screenWidth / 2\n\nfor i, planet in ipairs(planets) do\n\tif planet.satellites ~= nil and #planet.satellites > 0 then\n\t\tlocal shift = 1\n\n\t\tys = buttonLowY + (buttonHeight + buttonSpacing + buttonStrokeHalf)\n\n\t\tlocal moons = {}\n\n\t\tfor y, moonID in ipairs(planet.satellites) do\n\n\t\t\txs = middle - ((buttonWidth / 2) * #planet.satellites) + ((y-1) * (buttonWidth + buttonSpacing + buttonStrokeHalf) - buttonSpacing)\n\n\t\t\tif #planet.satellites == 4 then\n\t\t\t\txs = xs - buttonSpacing - buttonStrokeHalf\n\t\t\tend\n\n\t\t\tm = coreAtlas[moonID]\n\n\t\t\tif m.type[0] ~= \"Asteroid\" then\n\t\t\t\tlocal moon = {name = m.name[1]:gsub(planet.name, \"\"), center =vec3( m.center), radius = m.radius}\n\n\t\t\t\tlocal button = {id = y, planet = moon, name = planet.name..\" \"..moon.name, y=ys, x=xs}\n\t\t\t\tmoon.button = button\n\t\t\t\tmoon.sourcePlanet = planet\n\t\t\t\tmoon.mapCoords = {x = mapX(m),y = mapY(m), z = mapZ(m)}\n\t\t\t\tmoon.fullname = planet.fullname..\" \"..moon.name\n\n\t\t\t\tmoon.icon = m.iconPath\n\n\t\t\t\tmoons[y] = moon\n\n\t\t\t\tshift = shift + 1\n\t\t\tend\n\t\tend\n\n\t\tplanet.moons = moons\n\telse\n\t\tplanet.moons = {}\n\n\tend\nend\n\nmapSize = 100\n\nfunction updateStyle()\n\tstyle = [[]]\nend\n\nupdateStyle()\n\nfunction matmul(projection, vector)\n\tx = (projection[1][1] * vector.x) + (projection[1][2] * vector.y) + (projection[1][3] * vector.z)\n\ty = (projection[2][1] * vector.x) + (projection[2][2] * vector.y) + (projection[2][3] * vector.z)\n\tz = (projection[3][1] * vector.x) + (projection[3][2] * vector.y) + (projection[3][3] * vector.z)\n\treturn {x = x, y = y, z = z}\nend\n\nfunction compare(a,b)\n\treturn a.z > b.z\nend\n\norDistance = 200\n\nfunction toScreenCordsX(value)\n\tif value == nill then\n\t\treturn 0\n\tend\n\treturn value * 100 / screenWidth\nend\n\nfunction toScreenCordsY(value)\n\tif value == nill then\n\t\treturn 0\n\tend\n\treturn value * 100 / screenHeight\nend\n\nfunction toScreenCords(value)\n\tif value == nill then\n\t\treturn 0\n\tend\n\treturn value * 100 / screenWidth\nend\n\nfunction planetByName(name)\n\tfor i, planet in ipairs(planets) do\n\t\tif planet.name == name then\n\t\t\treturn planet\n\t\tend\n\t\tif planet.moons ~= nill then\n\t\t\tfor y, moon in ipairs(planet.moons) do\n\t\t\t\t-- checking by formatted moon name which includes planet name\n\t\t\t\tif moon.button.name == name then\n\t\t\t\t\treturn moon\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn nill\nend\n\nfunction getSuDistance(center)\n\treturn tonumber(string.format(\"%.2f\", math.sqrt((globalLoc.x-center.x)^2+(globalLoc.y-center.y)^2+(globalLoc.z-center.z)^2)/200000))\nend\n\nfunction getSuDistancePoints(fromVector, center)\n\treturn tonumber(string.format(\"%.2f\", math.sqrt((fromVector.x-center.x)^2+(fromVector.y-center.y)^2+(fromVector.z-center.z)^2)/200000))\nend\n\nfunction getRoute(toPlanet)\n\n\tdistance = getSuDistance(toPlanet.center)\n\tif distance <= 500 then\n\t\treturn {toPlanet}\n\tend\n\n\tprimary = {}\n\n\tfor i, planet in ipairs(planets) do\n\t\tdistance = getSuDistance(planet.center)\n\t\tif distance <= 500 then\n\t\t\ttable.insert(primary, planet)\n\t\tend\n\n\t\tfor i, moon in ipairs(planet.moons) do\n\t\t\tdistance = getSuDistance(moon.center)\n\t\t\tif distance <= 500 then\n\t\t\t\ttable.insert(primary, moon)\n\t\t\tend\n\t\tend\n\tend\n\n\n\n\tlocal newDistance = internalScale\n\tlocal endPlanets = {}\n\n\tfor i, primaryPlanet in ipairs(primary) do\n\t\tdistance = getSuDistancePoints(primaryPlanet.center, toPlanet.center)\n\t\tif distance <= 500 then\n\t\t\ttotal = (getSuDistance(primaryPlanet.center)+distance)\n\t\t\tif total < newDistance then\n\t\t\t\tnewDistance = total\n\t\t\t\tendPlanets[1] = primaryPlanet\n\t\t\t\tendPlanets[2] = toPlanet\n\t\t\tend\n\t\tend\n\tend\n\treturn endPlanets, newDistance\nend\n\nfunction convertTime(t)\n\tif t == nil then\n\t\treturn \"\"\n\tend\n\thours = 0\n\tminutes = t\n\tseconds = 0\n\tif t > 60 then\n\t\thours = math.floor(t / 60)\n\tend\n\n\tif (hours > 24) then\n\t\treturn \"-\"\n\tend\n\n\n\tif hours > 0 then\n\t\tminutes = math.floor(t - (hours * 60))\n\telse\n\t\tminutes = math.floor(t)\n\tend\n\n\tseconds = (t - (hours * 60) - minutes)\n\tseconds = math.floor(seconds * 60)\n\n\tendText = minutes..\"min \"..seconds..\"sec\"\n\tif hours > 0 then\n\t\tendText = hours..\"h \"..endText\n\tend\n\treturn endText\nend\n\nupdateCounter = 30\n\nfunction update(auto)\n\tupdateCounter = updateCounter + 1\n\tif auto and updateCounter < 1 / updateInterval then\n\t\treturn\n\tend\nend\n\nfunction getMass()\n\treturn math.ceil(construct.getMass() / 1000)\nend\n\nfunction getBoardedShipsMass()\n\tlocal dockedMass = 0\n\tlocal constructIds = construct.getDockedConstructs()\n\tfor i, cid in ipairs(constructIds) do\n\t\tdockedMass = dockedMass + math.ceil(construct.getDockedConstructMass(cid) / 1000)\n\tend\n\treturn dockedMass\nend\n\nfunction getBoardedPlayerMass()\n\tlocal dockedMass = 0\n\tlocal playerIds = construct.getPlayersOnBoard()\n\tfor i, pid in ipairs(playerIds) do\n\n\n\t\tlocal ms = math.ceil(construct.getBoardedPlayerMass(pid) / 1000)\n\n\t\tif ms > 20 then\n\t\t\tdockedMass = dockedMass + (ms - 20)\n\t\tend\n\tend\n\treturn dockedMass\nend\n\nfunction updateButtons(auto)\n\n\tupdateCounter = updateCounter + 1\n\n\tif auto and updateCounter < 1 / updateInterval then\n\t\treturn\n\tend\n\n\tupdateCounter = 0\n\n\tif warpdrive then\n\t\tlocal decoded = json.decode(warpdrive.getWidgetData())\n\t\tlocal warpDriveDestination = decoded.destination\n\n\t\tif warpDriveDestination == \"Sanctuary\" then\n\t\t\twarpDriveDestination = \"Alioth \"..warpDriveDestination;\n\t\tend\n\n\t\tif warpDriveDestinationPlanet == nill or warpDriveDestinationPlanet.fullname ~= warpDriveDestination then\n\t\t\twarpDriveDestinationPlanet = planetByName(warpDriveDestination)\n\t\t\tif warpDriveDestinationPlanet ~= nill then\n\t\t\t\tfor _,screenObject in ipairs(screens) do\n\t\t\t\t\tscreenObject.selectedPlanet = warpDriveDestinationPlanet\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif customWarp ~= nil then\n\t\t\t\t\twarpDriveDestinationPlanet = customWarp\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tif decoded.destination ~= \"Unknown\" then\n\t\t\twarpDriveMath = tonumber(Split(decoded.cellCount, \" / \")[2])\n\t\t\twarpDriveCells = tonumber(Split(decoded.cellCount, \" / \")[1])\n\t\telse\n\t\t\twarpDriveMath = nil\n\t\t\twarpDriveCells = nil\n\t\tend\n\tend\n\n\tshipVelocity = vec3(construct.getVelocity()):len() * 3.6\n\n\tboardedWeight = getBoardedShipsMass() + getBoardedPlayerMass()\n\n\tconstructWeight = getMass()\n\n\tif constructWeight < 2 and shipWeight > 2 then\n\t\tconstructWeight = shipWeight\n\telse\n\t\tconstructWeight = getMass() + boardedWeight\n\tend\n\n\n\tfor _,screenObject in ipairs(screens) do\n\n\t\tlocal selectedPlanet = screenObject.selectedPlanet\n\n\t\tif selectedPlanet == nill and warpDriveDestinationPlanet ~= nill then\n\t\t\tscreenObject.selectedPlanet = warpDriveDestinationPlanet\n\t\t\tselectedPlanet = warpDriveDestinationPlanet\n\t\tend\n\n\t\tif selectedPlanet == nill then\n\t\t\tcalculatedDist = 0\n\t\telse\n\t\t\tcalculatedDist = getSuDistance(selectedPlanet.center)\n\t\tend\n\n\n\t\tif calculatedDist > 500 then\n\t\t\tscreenObject.route, calculatedDist = getRoute(selectedPlanet)\n\t\t\tnewDistance = calculatedDist\n\t\telse\n\t\t\tscreenObject.route = {selectedPlanet}\n\t\tend\n\n\t\t--\t\t\taepx = 0.0002466\n\t\taepx = 0.00025\n\t\tif warpDriveMath ~=nill and (screenObject.selectedPlanet == warpDriveDestinationPlanet or screenObject.selectedPlanet == customWarp) then\n\t\t\twarpmath = warpDriveMath\n\t\t\twarpmathBack = math.floor((screenObject.extraWeight) * calculatedDist * aepx)\n\t\t\twarpmathBack = warpmath + warpmathBack\n\t\telse\n\t\t\t--24.5 = 1000 * (100-2) * 0.00025\n\t\t\t-- (100-2) = 24.5 / 1000 / 0.00025\n\n\t\t\twarpmath = math.floor((constructWeight) * (calculatedDist-2) * aepx)\n\t\t\twarpmathBack = math.floor((constructWeight+screenObject.extraWeight) * (calculatedDist-2) * aepx)\n\t\tend\n\t\tif constructWeight+screenObject.extraWeight < 0 then\n\t\t\tscreenObject.extraWeight = -constructWeight\n\t\tend\n\n\n\n\t\tif warpmath < 1 then\n\t\t\twarpmath = 1\n\t\tend\n\n\t\tif warpmathBack < 1 then\n\t\t\twarpmathBack = 1\n\t\tend\n\n\t\tapproxSpeed = \"\"\n\t\tpredictedSpeed = shipVelocity\n\n\t\tif shipVelocity <= 10 then\n\t\t\tapproxSpeed = \"*\"\n\t\t\tif calculatedDist < 3 then\n\t\t\t\tpredictedSpeed = 8000\n\t\t\telseif calculatedDist < 10 then\n\t\t\t\tpredictedSpeed = 10000\n\t\t\telseif calculatedDist < 20 then\n\t\t\t\tpredictedSpeed = 20000\n\t\t\telse\n\t\t\t\tpredictedSpeed = 29900\n\t\t\tend\n\t\tend\n\n\t\tshipVelocityFormat = string.format(\"%.0f\", predictedSpeed)\n\n\t\tlessWarpDistance = (warpmath - 1) / constructWeight / aepx\n\t\tlessWarpWeight = (warpmath - 1) / (calculatedDist-2) / aepx\n\n\t\ttime_to_distance = string.format(\"%.2f\", calculatedDist * 200 / ( predictedSpeed ) * 60)\n\t\tdist = string.format(\"%.0f\", calculatedDist * 200)\n\n\n\n\t\thtml = [[]]\n\n\t\tif screenObject.mapViewState == 1 then\n\t\t\tfor i, planet in ipairs(planets) do\n\t\t\t\ttextColor = preset.buttonTInactiveColor\n\t\t\t\tbackColor = preset.buttonBInactiveColor\n\n\t\t\t\tif (screenObject.selectedPlanet == planet or screenObject.selectedPlanet ~=nill and screenObject.selectedPlanet.sourcePlanet == planet) then\n\t\t\t\t\ttextColor = preset.buttonTActiveColor\n\t\t\t\t\tbackColor = preset.buttonBActiveColor\n\t\t\t\tend\n\n\n\n\t\t\t\tif (warpDriveDestinationPlanet ~= nill and (warpDriveDestinationPlanet == planet or warpDriveDestinationPlanet.sourcePlanet == planet)) then\n\t\t\t\t\ttextColor = preset.buttonTWarpInactiveColor\n\t\t\t\t\tif (screenObject.selectedPlanet == planet or screenObject.selectedPlanet.sourcePlanet == planet) then\n\t\t\t\t\t\ttextColor = preset.buttonTWarpActiveColor\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tdistanceToPlanet = getSuDistance(planet.center)\n\n\t\t\t\tborderColor = preset.buttonBorderColor\n\n\t\t\t\tif screenObject.hover == planet.button then\n\t\t\t\t\tborderColor = preset.buttonBorderHoverColor\n\t\t\t\tend\n\n\t\t\t\thtml = html..[[]]\n\n\t\t\t\t--\t\t\t\thtml = html..[[]]\n\t\t\t\t--\t\t\t\thtml = html..[[]]..planet.button.name..[[]]\n\n\n\t\t\t\thtml = html..[[]]..planet.button.name..[[]]\n\t\t\t\thtml = html..[[]]..string.format(\"%.1f\", distanceToPlanet)..[[]]\n\t\t\tend\n\n\t\t\tif screenObject.selectedPlanet ~= nill then\n\n\t\t\t\tmoons = screenObject.selectedPlanet.moons\n\n\t\t\t\tif screenObject.selectedPlanet.sourcePlanet ~= nill then\n\t\t\t\t\tmoons = screenObject.selectedPlanet.sourcePlanet.moons\n\t\t\t\telse\n\t\t\t\t\tmoons = screenObject.selectedPlanet.moons\n\t\t\t\tend\n\n\t\t\t\tfor i, moon in ipairs(moons) do\n\n\t\t\t\t\ttextColor = preset.buttonTInactiveColor\n\t\t\t\t\tbackColor = preset.buttonBInactiveColor\n\t\t\t\t\tif (screenObject.selectedPlanet == moon) then\n\t\t\t\t\t\ttextColor = preset.buttonTActiveColor\n\t\t\t\t\t\tbackColor = preset.buttonBActiveColor\n\t\t\t\t\tend\n\n\t\t\t\t\tif (warpDriveDestinationPlanet == moon) then\n\t\t\t\t\t\ttextColor = preset.buttonTWarpInactiveColor\n\t\t\t\t\t\tif (screenObject.selectedPlanet == moon) then\n\t\t\t\t\t\t\ttextColor = preset.buttonTWarpActiveColor\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tcalculatedDist = getSuDistance(moon.center)\n\n\n\t\t\t\t\tborderColor = preset.buttonBorderColor\n\n\t\t\t\t\tif screenObject.hover == moon.button then\n\t\t\t\t\t\tborderColor = preset.buttonBorderHoverColor\n\t\t\t\t\tend\n\n\t\t\t\t\thtml = html..[[]]\n\t\t\t\t\thtml = html..[[]]..moon.name..[[]]\n\t\t\t\t\thtml = html..[[]]..string.format(\"%.1f\", calculatedDist)..[[]]\n\t\t\t\tend\n\t\t\tend\n\n\n\t\t\ttextColor = preset.buttonTInactiveColor\n\n\t\t\tfor i, button in ipairs(weightScreenButtons) do\n\n\t\t\t\tbackColor = preset.buttonBInactiveColor\n\t\t\t\tif screenObject.weightButtonClicked == button and screenObject.mouseDown then\n\t\t\t\t\tbackColor = \"30786B\"\n\t\t\t\tend\n\n\t\t\t\tborderColor = preset.buttonBorderColor\n\n\t\t\t\tif screenObject.hover == button then\n\t\t\t\t\tborderColor = preset.buttonBorderHoverColor\n\t\t\t\tend\n\n\t\t\t\thtml = html..[[]]\n\n\t\t\t\tchange = button.change\n\t\t\t\tif change > 0 then\n\t\t\t\t\tchange = \"+\"..change\n\t\t\t\tend\n\t\t\t\thtml = html..[[]]..change..[[]]\n\t\t\tend\n\n\n\n\t\t\tborderColor = preset.buttonBorderColor\n\n\t\t\tif screenObject.hover == presetButton then\n\t\t\t\tborderColor = preset.buttonBorderHoverColor\n\t\t\tend\n\n\t\t\thtml = html..[[]]\n\t\t\thtml = html..[[]]..presetButton.preset..[[]]\n\n\t\tend\n\n\t\ttotalCells = warpmath+warpmathBack\n\n\n\t\t--\t\tif string.len(warpCostColor) < 3 then\n\t\t--\t\t\twrpCostColor = \"#9cfd80\"\n\t\t--\n\t\t--\t\t\tif warpDriveCells ~= nill then\n\t\t--\t\t\t\tif totalCells <= warpDriveCells - 10 then\n\t\t--\t\t\t\t\twrpCostColor = \"#08f600\"\n\t\t--\t\t\t\telseif totalCells >= warpDriveCells - 2 and totalCells < warpDriveCells then\n\t\t--\t\t\t\t\twrpCostColor = \"#ceffc0\"\n\t\t--\t\t\t\telseif totalCells == warpDriveCells then\n\t\t--\t\t\t\t\twrpCostColor = \"#fcfd80\"\n\t\t--\t\t\t\telseif totalCells > warpDriveCells then\n\t\t--\t\t\t\t\twrpCostColor = \"#ff0000\"\n\t\t--\t\t\t\tend\n\t\t--\t\t\tend\n\t\t--\t\telse\n\t\twrpCostColor = preset.warpCostColor\n\t\t--\t\tend\n\n\n\t\tif warpDriveCells ~= nill then\n\t\t\ttotalCells = warpDriveCells..\" / \"..totalCells\n\t\telse\n\t\t\ttotalCells = totalCells\n\t\tend\n\n\n\t\tif screenObject.mapViewState ~= 2 then\n\t\t\tif screenObject.route ~= nill and #screenObject.route > 1 then\n\t\t\t\trouteY = buttonLowY + buttonHeight*3+buttonSpacing\n\t\t\t\trouteX = \"1%\"\n\t\t\t\trouteAnchor = \"start\"\n\n\t\t\t\tif screenObject.mapViewState == 3 or screenObject.mapViewState == 4 then\n\t\t\t\t\trouteX = \"99%\"\n\t\t\t\t\trouteY = screenHeight-70\n\t\t\t\t\trouteAnchor = \"end\"\n\t\t\t\tend\n\n\t\t\t\thtml = html..[[New Su: ]]..newDistance..[[]]\n\t\t\t\tfromName = screenObject.route[1].button.name\n\t\t\t\tif screenObject.route[1].sourcePlanet == nill then\n\t\t\t\t\tfromName = screenObject.route[1].name\n\t\t\t\tend\n\t\t\t\ttoName = screenObject.route[2].button.name\n\t\t\t\tif screenObject.route[2].sourcePlanet == nill then\n\t\t\t\t\ttoName = screenObject.route[2].name\n\t\t\t\tend\n\t\t\t\thtml = html..[[]]..fromName..[[]]\n\t\t\t\thtml = html..[[]]..toName..[[]]\n\t\t\tend\n\n\t\t\thtml = html..[[Dist: ]]..dist..\n\t\t\t\t[[ kmVel: ]]..approxSpeed..shipVelocityFormat..\n\t\t\t\t[[ km/hTTD: ]]..approxSpeed..convertTime(tonumber(time_to_distance))..\n\t\t\t\t[[]]\n\t\tend\n\n\n\n\t\tif screenObject.mapViewState == 1 then\n\n\t\t\tlocal aditionalWeight = \"\"\n\t\t\tif boardedWeight > 1 then\n\t\t\t\taditionalWeight = [[Boarded: ]]..boardedWeight.. [[T]]\n\t\t\tend\n\n\t\t\thtml = html..[[Warp Cost: ]]..warpmath..\n\t\t\t\t[[Back Cost: ]]..warpmathBack..\n\t\t\t\t[[Total: ]]..totalCells..[[]]..\n\n\t\t\t\t[[TLOC]]..\n\t\t\t\t[[]]..string.format(\"%.2f\", calculatedDist-lessWarpDistance)..[[SU]]..\n\t\t\t\t[[]]..string.format(\"%.2f\",constructWeight-lessWarpWeight)..[[T]]..\n\n\t\t\t\taditionalWeight..\n\t\t\t\t[[Weight: ]]..constructWeight..\n\t\t\t\t[[ TBack Weight: ]]..math.floor(constructWeight+screenObject.extraWeight)..\n\t\t\t\t[[ T]]\n\t\telseif screenObject.mapViewState == 4 then\n\n\t\t\tlocal aditionalWeight = \"\"\n\t\t\tif boardedWeight > 1 then\n\t\t\t\taditionalWeight = [[Boarded: ]]..boardedWeight.. [[T]]\n\t\t\tend\n\n\t\t\thtml = html..[[Warp Cost: ]]..warpmath..[[]]..\n\t\t\t\t[[Back Cost: ]]..warpmathBack..[[]]..\n\t\t\t\t[[Total: ]]..totalCells..[[]]..\n\n\t\t\t\taditionalWeight..\n\t\t\t\t[[Weight: ]]..constructWeight..[[ T]]..\n\t\t\t\t[[Back Weight: ]]..math.floor(constructWeight+screenObject.extraWeight)..[[ T]]\n\n\n\t\t\thtml = html..[[TLOC]]..\n\t\t\t\t[[]]..string.format(\"%.2f\", calculatedDist-lessWarpDistance)..[[SU]]..\n\t\t\t\t[[]]..string.format(\"%.2f\",constructWeight-lessWarpWeight)..[[T]]\n\n\n\t\tend\n\n\t\thtml = html ..[[]]\n\t\tif screenObject.mapButtonContentId == nill then\n\t\t\tscreenObject.mapButtonContentId = screenObject.screen.addContent(0, 0, html)\n\t\telse\n\t\t\tscreenObject.screen.resetContent(screenObject.mapButtonContentId, html)\n\t\tend\n\tend\nend\n\nfunction getPointOnMap(rotationX, rotationY, rotationZ, screenObject, vector)\n\tpoint = {x = vector.x*screenObject.scale - screenObject.mapCenterPoint.x*screenObject.scale, y = vector.y*screenObject.scale - screenObject.mapCenterPoint.y*screenObject.scale, z = vector.z*screenObject.scale - screenObject.mapCenterPoint.z*screenObject.scale}\n\n\tpoint = matmul(rotationZ, point)\n\tpoint = matmul(rotationY, point)\n\tpoint = matmul(rotationX, point)\n\tdistance = distance * screenObject.scale\n\tz = 1 - (point.z)/400\n\t-- if z < 0.2 then\n\t-- z = 0.2\n\t-- end\n\t-- if z > 1 then\n\t-- z = 1\n\t-- end\n\tprojection = {\n\t\t{1, 0, 0},\n\t\t{0, 1, 0},\n\t\t{0, 0, 1}\n\t}\n\tpoint = matmul(projection, point)\n\treturn {x = point.x + screenObject.screenCenterX, y = point.y + screenObject.screenCenterY, z = point.z, planet = planet, r = 5}\nend\n\nfunction updateScreen3d(screenObject, auto)\n\n\tglobalLoc = vec3(construct.getWorldPosition())\n\t-- globalLoc = vec3(-94134464.000, 12765536.000, -3634464.000)\n\tconstructLoc = {x = globalLoc.x/internalScale, y = (globalLoc.y/internalScale), z = globalLoc.z/internalScale}\n\n\tupdateSC3d(screenObject, auto)\n\nend\n\nfunction update3d(auto)\n\n\tglobalLoc = vec3(construct.getWorldPosition())\n\t-- globalLoc = vec3(-94134464.000, 12765536.000, -3634464.000)\n\tconstructLoc = {x = globalLoc.x/internalScale, y = (globalLoc.y/internalScale), z = globalLoc.z/internalScale}\n\n\tfor _,screenObject in ipairs(screens) do\n\t\tupdateSC3d(screenObject, auto)\n\tend\nend\n\nfunction updateSC3d(screenObject, auto)\n\n\t--\t\t screenObject.mapCenterPoint = {x = globalLoc.x/400000, y = (globalLoc.y/400000), z = globalLoc.z/400000}\n\n\tif screenObject.mapViewState ~= 1 then\n\t\tscreenObject.screenCenterX = screenWidth / 2\n\t\tscreenObject.screenCenterY = screenHeight / 2\n\t\tscreenObject.scale = screenObject.zoomScale\n\telse\n\t\tscreenObject.screenCenterX = screenWidth / 2\n\t\tscreenObject.screenCenterY = screenHeight - (screenHeight / 2.7)\n\t\tscreenObject.scale = 1\n\tend\n\n\t-- if auto then\n\t-- screenObject.angle = screenObject.angle + 0.01\n\t-- screenObject.pitch = screenObject.pitch + 0.01\n\t-- screenObject.yaw = screenObject.yaw + 0.01\n\t-- end\n\n\t-- screenObject.scale = screenObject.scale + 0.05\n\n\tcosX = math.cos(screenObject.angle)\n\tsinX = math.sin(screenObject.angle)\n\trotationX = {\n\t\t{1, 0, 0},\n\t\t{0, cosX, -sinX},\n\t\t{0, sinX, cosX}\n\t}\n\n\tcosY = math.cos(screenObject.pitch)\n\tsinY = math.sin(screenObject.pitch)\n\trotationY = {\n\t\t{cosY, 0, -sinY},\n\t\t{0, 1, 0},\n\t\t{sinY, 0, cosY}\n\t}\n\n\tcosZ = math.cos(screenObject.yaw)\n\tsinZ = math.sin(screenObject.yaw)\n\trotationZ = {\n\t\t{cosZ, -sinZ, 0},\n\t\t{sinZ, cosZ, 0},\n\t\t{0, 0, 1}\n\t}\n\n\thtml = style..[[]]\n\n\n\n\thtml = html..[[]]\n\n\tnewPoints = {}\n\n\tscreenObject.planetScreen = {}\n\n\tfor i, planet in ipairs(planets) do\n\n\t\tpoint = {x = planet.mapCoords.x*screenObject.scale - screenObject.mapCenterPoint.x*screenObject.scale, y = planet.mapCoords.y*screenObject.scale - screenObject.mapCenterPoint.y*screenObject.scale, z = planet.mapCoords.z*screenObject.scale - screenObject.mapCenterPoint.z*screenObject.scale}\n\n\n\t\t-- point = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, point)\n\n\t\tpoint = matmul(rotationZ, point)\n\t\tpoint = matmul(rotationY, point)\n\t\tpoint = matmul(rotationX, point)\n\n\t\tdistance = orDistance*screenObject.scale\n\n\t\tz = 1 - (point.z)/400\n\n\t\tprojection = {\n\t\t\t{1, 0, 0},\n\t\t\t{0, 1, 0},\n\t\t\t{0, 0, 1}\n\t\t}\n\t\tpoint = matmul(projection, point)\n\n\t\tr = 10 - point.z/50\n\t\tfont = 6 - (0.8 * (point.z/10 + mapSize*(screenObject.scale+1)) / distance)\n\n\t\tif r < 5 then\n\t\t\tr = 5\n\t\tend\n\t\tif r > 15 then\n\t\t\tr = 15\n\t\tend\n\n\t\t-- if font < 2 then\n\t\t-- font = 3\n\t\t-- end\n\n\n\t\tnewPoints[i] = {x = point.x + screenObject.screenCenterX, y = point.y + screenObject.screenCenterY, z = point.z, planet = planet, r = r, font = font}\n\n\n\t\ttable.insert(screenObject.planetScreen,planet.button.id, {x = newPoints[i].x, y = newPoints[i].y})\n\n\n\t\tif planet.drawZero then\n\t\t\tnewPoints[i].zeroPoint = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, {x = planet.mapCoords.x, y = planet.mapCoords.y, z = 0})\n\t\tend\n\n\tend\n\n\ttable.sort(newPoints, compare)\n\n\tdegreeY = -(screenObject.pitch * (180/math.pi))\n\tdegreeX = screenObject.angle * (180/math.pi)\n\tdegreeZ = -(screenObject.yaw * (180/math.pi))\n\n\tif degreeY < -360 then\n\t\tscreenObject.pitch = 0\n\tend\n\n\tif degreeX > 360 then\n\t\tscreenObject.angle = 0\n\tend\n\n\tif degreeZ > 360 then\n\t\tscreenObject.yaw = 0\n\tend\n\n\trotationSide = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, {x=0, y = 0, z= 10})\n\n\tmapStrokeColor = preset.mapCircleColor\n\n\tif rotationSide.z < 0 then\n\t\tmapStrokeColor = preset.mapBCircleColor\n\tend\n\n\n\topacity = 0.3\n\n\tif screenObject.hover == \"circle\" then\n\t\t--\t\t\tmapStrokeColor = preset.buttonBorderHoverColor\n\t\topacity = 0.6\n\tend\n\n\thtml = html..[[]]\n\thtml = html..[[]]\n\thtml = html..[[]]\n\thtml = html..[[]]\n\thtml = html..[[]]\n\thtml = html..[[]]\n\thtml = html..[[]]\n\thtml = html..[[]]\n\n\t-- degreeY = degreeY -45\n\t-- html = html..[[]]\n\n\n\tif showSafeZone then\n\t\tconstructPoint = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, safeZoneCenter)\n\t\thtml = html..[[]]\n\tend\n\n\t--\t\tconstructPoint = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, edge)\n\t--\t\thtml = html..[[]]\n\n\n\n\tif screenObject.route ~= nill then\n\t\tpreviousPoint = constructLoc\n\t\tfor i, planet in ipairs(screenObject.route) do\n\t\t\tif planet ~= nill then\n\n\t\t\t\toriginPoint = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, previousPoint)\n\t\t\t\tdistinationPoint = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, planet.mapCoords)\n\n\t\t\t\tdashArray = \"10 10\"\n\t\t\t\tif screenObject.timer > 2 then\n\t\t\t\t\tscreenObject.timer = 0\n\t\t\t\tend\n\t\t\t\tscreenObject.timer = screenObject.timer + 1\n\n\t\t\t\thtml = html..[[]]\n\t\t\tend\n\t\t\tpreviousPoint = planet.mapCoords\n\t\tend\n\tend\n\n\tfor i, planetPoint in ipairs(newPoints) do\n\t\tif planetPoint.planet ~= nill then\n\n\t\t\tif planetPoint.zeroPoint ~= nill then\n\t\t\t\thtml = html..[[]]\n\t\t\tend\n\n\t\t\tplColor = planetPoint.planet.color\n\n\t\t\tif string.len(preset.planetColor) > 2 then\n\t\t\t\tplColor = preset.planetColor;\n\t\t\tend\n\n\t\t\tlocal planetSize = planetPoint.r\n\n\t\t\tif screenObject.mapViewState ~= 1 then\n\t\t\t\tplanetSize = planetSize*screenObject.zoomScale\n\t\t\tend\n\n\t\t\tlocal fontSize = planetPoint.font\n\t\t\tif screenObject.hover ~= nill and screenObject.hover == planetPoint.planet then\n\t\t\t\tplanetSize = planetSize * 1.5\n\t\t\t\tfontSize = fontSize * 1.5\n\t\t\tend\n\t\t\thtml = html..[[]]\n\t\t\thtml = html..[[]]..planetPoint.planet.name..[[]]\n\t\tend\n\tend\n\n\n\n\n\t-- Custom warp beacon point on screen\n\tif screenObject.selectedPlanet ~= nil and screenObject.selectedPlanet.name == customWarpName then\n\t\tconstructPoint = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, screenObject.selectedPlanet.mapCoords)\n\t\thtml = html..[[]]\n\tend\n\n\tconstructPoint = getPointOnMap(rotationX, rotationY, rotationZ, screenObject, constructLoc)\n\thtml = html..[[]]\n\n\thtml = html ..[[]]\n\tif screenObject.mapContentId == nill then\n\t\tscreenObject.mapContentId = screenObject.screen.addContent(0, 0, html)\n\telse\n\t\tscreenObject.screen.resetContent(screenObject.mapContentId, html)\n\tend\nend\n\nfunction evaluateButtons(x, y, pressDown, screen)\n\tfor _,screenObject in ipairs(screens) do\n\t\tif screenObject.screen.getLocalId() == screen.getLocalId() then\n\n\t\t\tscreenObject.mouseDown = pressDown\n\n\n\t\t\tif pressDown then\n\t\t\t\tunit.setTimer(\"maprotate\", updateMouseInterval)\n\t\t\tend\n\n\t\t\tclickCoordX = x * screenWidth\n\t\t\tclickCoordY = y * screenHeight\n\n\t\t\tif not pressDown then\n\t\t\t\tscreenObject.weightButtonClicked = nill\n\t\t\tend\n\n\t\t\t-- if screenObject.mapViewState ~= 1 then\n\t\t\tfor i, planet in ipairs(planets) do\n\n\t\t\t\tdpd = screenObject.planetScreen[planet.button.id]\n\n\t\t\t\tif clickCoordX > dpd.x-20 and clickCoordX < dpd.x+20 and clickCoordY > dpd.y-20 and clickCoordY < dpd.y+20 and pressDown then\n\t\t\t\t\tif screenObject.selectedPlanet == planet and pressDown then\n\t\t\t\t\t\tscreenObject.selectedPlanet = nill\n\t\t\t\t\telseif pressDown then\n\t\t\t\t\t\tscreenObject.selectedPlanet = planet\n\t\t\t\t\tend\n\t\t\t\t\tscreenObject.changeView = false\n\t\t\t\t\tupdate3d(false)\n\t\t\t\t\tupdateButtons(false)\n\t\t\t\t\treturn\n\t\t\t\tend\n\t\t\tend\n\t\t\t-- end\n\n\t\t\tif screenObject.mapViewState == 1 then\n\t\t\t\t-- for i, v in ipairs(activeMoons) do activeMoons[i] = nil end\n\t\t\t\tfor i, planet in ipairs(planets) do\n\t\t\t\t\tif clickCoordX > planet.button.x-buttonStrokeHalf and clickCoordX < planet.button.x + buttonWidth+buttonStrokeHalf and clickCoordY > planet.button.y-buttonStrokeHalf and clickCoordY < planet.button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\tif screenObject.selectedPlanet == planet and pressDown then\n\t\t\t\t\t\t\tscreenObject.selectedPlanet = nill\n\t\t\t\t\t\telseif pressDown then\n\t\t\t\t\t\t\tscreenObject.selectedPlanet = planet\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif screenObject.selectedPlanet ~= nill then\n\t\t\t\t\tif screenObject.selectedPlanet.moons ~= nill then\n\t\t\t\t\t\tfor i, moon in ipairs(screenObject.selectedPlanet.moons) do\n\t\t\t\t\t\t\tif clickCoordX > moon.button.x-buttonStrokeHalf and clickCoordX < moon.button.x + buttonWidth+buttonStrokeHalf and clickCoordY > moon.button.y-buttonStrokeHalf and clickCoordY < moon.button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\t\t\tscreenObject.selectedPlanet = moon\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tfor i, moon in ipairs(screenObject.selectedPlanet.sourcePlanet.moons) do\n\t\t\t\t\t\t\tif clickCoordX > moon.button.x-buttonStrokeHalf and clickCoordX < moon.button.x + buttonWidth+buttonStrokeHalf and clickCoordY > moon.button.y-buttonStrokeHalf and clickCoordY < moon.button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\t\t\tscreenObject.selectedPlanet = moon\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif #weightScreenButtons >= 1 then\n\t\t\t\t\tfor i, button in ipairs(weightScreenButtons) do\n\t\t\t\t\t\tif clickCoordX > button.x-buttonStrokeHalf and clickCoordX < button.x + button.width+buttonStrokeHalf and clickCoordY > button.y-buttonStrokeHalf and clickCoordY < button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\t\tif not pressDown then\n\t\t\t\t\t\t\t\tscreenObject.extraWeight = screenObject.extraWeight + button.change\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tscreenObject.weightButtonClicked = button\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif clickCoordX > presetButton.x-buttonStrokeHalf and clickCoordX < presetButton.x + presetButton.width+buttonStrokeHalf and clickCoordY > presetButton.y-buttonStrokeHalf and clickCoordY < presetButton.y + presetButton.height+buttonStrokeHalf then\n\t\t\t\t\tif not pressDown then\n\t\t\t\t\t\tpresetButton.preset = presetButton.preset + 1\n\t\t\t\t\t\tif presetButton.preset > #presets then\n\t\t\t\t\t\t\tpresetButton.preset = 1\n\t\t\t\t\t\tend\n\t\t\t\t\t\tsavepreset()\n\t\t\t\t\t\tupdatePreset()\n\t\t\t\t\t\tupdateStyle()\n\t\t\t\t\t\tupdate3d(false)\n\t\t\t\t\t\tupdateButtons(false)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\n\t\t\tend\n\n\t\t\tif screenObject.changeView and not pressDown then\n\t\t\t\tif screenObject.mapViewState ~= 1 then\n\t\t\t\t\tscreenObject.mapViewState = screenObject.mapViewState + 1\n\t\t\t\t\tif screenObject.mapViewState > 4 then\n\t\t\t\t\t\tscreenObject.mapViewState = 1\n\t\t\t\t\tend\n\t\t\t\telse\n\n\t\t\t\t\tif clickCoordX > (screenWidth / 2) - 400 and clickCoordX < (screenWidth / 2) + 400 and clickCoordY > (screenHeight / 3) and clickCoordY < (screenHeight / 2) + 200 then\n\t\t\t\t\t\tscreenObject.mapViewState = 2\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tsave(screenObject)\n\t\t\tend\n\n\t\t\tupdate3d(false)\n\t\t\tupdateButtons(false)\n\n\t\t\treturn\n\t\tend\n\tend\nend\n\nrotatelimit = 2\n\nfunction mapRotate()\n\n\tlocal someOneHolding = false\n\n\tfor _,screenObject in ipairs(screens) do\n\t\tif screenObject.mouseDown then\n\t\t\tsomeOneHolding = true\n\t\t\tchanged = false;\n\t\t\tif (screenObject.screen.prevMouseX ~= nil and screenObject.screen.getMouseX() > 0 and screenObject.screen.getMouseY() > 0) then\n\n\t\t\t\tdifX = (screenObject.screen.prevMouseX - screenObject.screen.getMouseX()*screenWidth)\n\t\t\t\tdifY = (screenObject.screen.prevMouseY - screenObject.screen.getMouseY()*screenHeight)\n\n\t\t\t\tscreenObject.screen.difX = difX\n\t\t\t\tscreenObject.screen.difY = difY\n\n\t\t\t\tif (screenObject.screen.getMouseY() > 0.85 and screenObject.mapViewState ~= 1) then\n\t\t\t\t\tif (difX < 20 or difX > -20) then\n\t\t\t\t\t\tscreenObject.yaw = screenObject.yaw + (difX / 100)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\tend\n\t\t\t\t\tif changed then\n\t\t\t\t\t\tupdate3d(false)\n\t\t\t\t\tend\n\t\t\t\telseif (screenObject.screen.getMouseX() < 0.15 and screenObject.mapViewState ~= 1) then\n\t\t\t\t\tif ((difY < 20 or difY > -20) and (difY > 0.8 or difY < -0.8)) then\n\t\t\t\t\t\tscreenObject.angle = screenObject.angle - (difY / 200)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\tend\n\t\t\t\t\tif changed then\n\t\t\t\t\t\tupdate3d(false)\n\t\t\t\t\tend\n\t\t\t\telseif (screenObject.screen.getMouseY() < 0.15 and screenObject.mapViewState ~= 1) then\n\t\t\t\t\tif (difX < 20 or difX > -20) and (difX > 0.8 or difX < -0.8) then\n\t\t\t\t\t\tscreenObject.pitch = screenObject.pitch - (difX / 200)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\tend\n\t\t\t\t\tif changed then\n\t\t\t\t\t\tupdate3d(false)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tif (difX < 20 or difX > -20) and (difX > 1 or difX < -1) then\n\t\t\t\t\t\tscreenObject.pitch = screenObject.pitch - (difX / 200)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\tend\n\n\t\t\t\t\tif ((difY < 20 or difY > -20) and (difY > 1 or difY < -1)) then\n\t\t\t\t\t\tscreenObject.angle = screenObject.angle - (difY / 200)\n\t\t\t\t\t\tchanged = true\n\t\t\t\t\tend\n\t\t\t\t\tif changed then\n\t\t\t\t\t\tscreenObject.changeView = false\n\t\t\t\t\t\tupdate3d(false)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\n\t\t\tif (screenObject.screen.getMouseX() > 0 and screenObject.screen.getMouseY() > 0)then\n\t\t\t\tscreenObject.screen.prevMouseX = screenObject.screen.getMouseX()*screenWidth\n\t\t\t\tscreenObject.screen.prevMouseY = screenObject.screen.getMouseY()*screenHeight\n\t\t\t\tif (changed) then\n\t\t\t\t\tscreenObject.changeView = false\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tscreenObject.changeView = true\n\t\t\t\tscreenObject.mouseDown = false\n\t\t\t\tscreenObject.screen.prevMouseX = nill\n\t\t\t\tscreenObject.screen.prevMouseY = nill\n\t\t\tend\n\t\telse\n\n\t\t\tscreenObject.screen.prevMouseX = nill\n\t\t\tscreenObject.screen.prevMouseY = nill\n\n\t\t\tif (screenObject.screen.difX ~= 0 or screenObject.screen.difY ~= 0) and screenObject.screen.difX ~= nill and screenObject.screen.difY ~= nill\n\t\t\t\tand (screenObject.screen.difX < -rotatelimit or screenObject.screen.difX > rotatelimit\n\t\t\t\tor (screenObject.screen.difY < -rotatelimit or screenObject.screen.difY > rotatelimit))\n\t\t\tthen\n\n\t\t\t\tsomeOneHolding = true\n\t\t\t\tscreenObject.screen.difX = screenObject.screen.difX / 1.2\n\t\t\t\t--\t\t\t\tscreenObject.screen.prevMouseX =screenObject.screen.prevMouseX+screenObject.screen.difX\n\n\t\t\t\tif screenObject.screen.difX > -rotatelimit and screenObject.screen.difX < rotatelimit then\n\t\t\t\t\tscreenObject.screen.difX = 0\n\t\t\t\tend\n\t\t\t\tscreenObject.screen.difY = screenObject.screen.difY / 1.2\n\t\t\t\t-- screenObject.screen.prevMouseY =screenObject.screen.prevMouseY+screenObject.screen.difY\n\t\t\t\tif screenObject.screen.difY > -rotatelimit and screenObject.screen.difY < rotatelimit then\n\t\t\t\t\tscreenObject.screen.difY = 0\n\t\t\t\tend\n\n\t\t\t\tif screenObject.screen.difX == 0 and screenObject.screen.difY == 0 then\n\t\t\t\t\tsomeOneHolding = false\n\t\t\t\tend\n\n\t\t\t\tif (screenObject.screen.difX < 20 or screenObject.screen.difX > -20) and (screenObject.screen.difX > rotatelimit or screenObject.screen.difX < -rotatelimit) then\n\t\t\t\t\tscreenObject.pitch = screenObject.pitch - (screenObject.screen.difX / 200)\n\t\t\t\t\tchanged = true\n\t\t\t\tend\n\n\t\t\t\tif ((screenObject.screen.difY < 20 or screenObject.screen.difY > -20) and (screenObject.screen.difY > rotatelimit or screenObject.screen.difY < -rotatelimit)) then\n\t\t\t\t\tscreenObject.angle = screenObject.angle - (screenObject.screen.difY / 200)\n\t\t\t\t\tchanged = true\n\t\t\t\tend\n\t\t\t\tif changed then\n\t\t\t\t\tupdate3d(false)\n\t\t\t\tend\n\n\n\n\t\t\telse\n\t\t\t\tsave(screenObject)\n\t\t\t\tscreenObject.changeView = true\n\t\t\tend\n\t\tend\n\tend\n\n\tif not someOneHolding then\n\t\tsaveAll()\n\t\tunit.stopTimer(\"maprotate\")\n\tend\nend\n\nhovertimer = 1\n\nzoomMax = 5\nzoomMin = 0.8\n\nfunction checkhover()\n\tlooking = false\n\tfor _,screenObject in ipairs(screens) do\n\t\tscreenLooking = false\n\t\tlocal x = screenObject.screen.getMouseX()\n\t\tif x ~= -1 then\n\t\t\tlocal y = screenObject.screen.getMouseY()\n\t\t\tif y ~= -1 then\n\n\n\t\t\t\tif system.getMouseWheel() ~= 0 then\n\t\t\t\t\tscreenObject.targetZoomScale = screenObject.targetZoomScale+(system.getMouseWheel()/10)\n\t\t\t\t\tif screenObject.targetZoomScale < zoomMin then\n\t\t\t\t\t\tscreenObject.targetZoomScale = zoomMin\n\t\t\t\t\tend\n\t\t\t\t\tif screenObject.targetZoomScale > zoomMax then\n\t\t\t\t\t\tscreenObject.targetZoomScale = zoomMax\n\t\t\t\t\tend\n\t\t\t\t\tupdate3d(screenObject, false)\n\t\t\t\t\tsave(screenObject)\n\t\t\t\tend\n\n\n\t\t\t\tif screenObject.targetZoomScale ~= screenObject.zoomScale then\n\t\t\t\t\tzoomDif = screenObject.targetZoomScale - screenObject.zoomScale\n\n\t\t\t\t\tif zoomDif < 0.01 and zoomDif > -0.01 then\n\t\t\t\t\t\tscreenObject.zoomScale = screenObject.targetZoomScale\n\t\t\t\t\telse\n\t\t\t\t\t\tzoomDif =zoomDif - ( zoomDif * 0.5)\n\t\t\t\t\t\tscreenObject.zoomScale = screenObject.zoomScale + zoomDif\n\t\t\t\t\t\tupdateScreen3d(screenObject, false)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\n\t\t\t\tlooking = true\n\t\t\t\tclickCoordX = x * screenWidth\n\t\t\t\tclickCoordY = y * screenHeight\n\t\t\t\tif hovertimer == 1 then\n\t\t\t\t\tunit.setTimer(\"hoverdetect\", updateHoverInterval)\n\t\t\t\t\thovertimer = updateHoverInterval\n\t\t\t\tend\n\t\t\t\tfor i, planet in ipairs(planets) do\n\t\t\t\t\tdpd = screenObject.planetScreen[planet.button.id]\n\t\t\t\t\tif clickCoordX > dpd.x-20 and clickCoordX < dpd.x+20 and clickCoordY > dpd.y-20 and clickCoordY < dpd.y+20 then\n\t\t\t\t\t\tscreenObject.hover = planet\n\t\t\t\t\t\tscreenLooking = true\n\t\t\t\t\t\tupdate3d(false)\n\t\t\t\t\t\treturn\n\t\t\t\t\tend\n\t\t\t\tend\n\n\n\n\t\t\t\tif screenObject.mapViewState == 1 then\n\t\t\t\t\t-- for i, v in ipairs(activeMoons) do activeMoons[i] = nil end\n\t\t\t\t\tfor i, planet in ipairs(planets) do\n\t\t\t\t\t\tif clickCoordX > planet.button.x-buttonStrokeHalf and clickCoordX < planet.button.x + buttonWidth+buttonStrokeHalf and clickCoordY > planet.button.y-buttonStrokeHalf and clickCoordY < planet.button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\t\tscreenObject.hover = planet.button\n\t\t\t\t\t\t\tscreenLooking = true\n\t\t\t\t\t\t\tupdateButtons(false)\n\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tif screenObject.selectedPlanet ~= nill then\n\t\t\t\t\t\tif screenObject.selectedPlanet.moons ~= nill then\n\t\t\t\t\t\t\tfor i, moon in ipairs(screenObject.selectedPlanet.moons) do\n\t\t\t\t\t\t\t\tif clickCoordX > moon.button.x-buttonStrokeHalf and clickCoordX < moon.button.x + buttonWidth+buttonStrokeHalf and clickCoordY > moon.button.y-buttonStrokeHalf and clickCoordY < moon.button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\t\t\t\tscreenObject.hover = moon.button\n\t\t\t\t\t\t\t\t\tscreenLooking = true\n\t\t\t\t\t\t\t\t\tupdateButtons(false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tfor i, moon in ipairs(screenObject.selectedPlanet.sourcePlanet.moons) do\n\t\t\t\t\t\t\t\tif clickCoordX > moon.button.x-buttonStrokeHalf and clickCoordX < moon.button.x + buttonWidth+buttonStrokeHalf and clickCoordY > moon.button.y-buttonStrokeHalf and clickCoordY < moon.button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\t\t\t\tscreenObject.hover = moon.button\n\t\t\t\t\t\t\t\t\tscreenLooking = true\n\t\t\t\t\t\t\t\t\tupdateButtons(false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tif #weightScreenButtons >= 1 then\n\t\t\t\t\t\tfor i, button in ipairs(weightScreenButtons) do\n\t\t\t\t\t\t\tif clickCoordX > button.x-buttonStrokeHalf and clickCoordX < button.x + button.width+buttonStrokeHalf and clickCoordY > button.y-buttonStrokeHalf and clickCoordY < button.y + buttonHeight+buttonStrokeHalf then\n\t\t\t\t\t\t\t\tscreenObject.hover = button\n\t\t\t\t\t\t\t\tscreenLooking = true\n\t\t\t\t\t\t\t\tupdateButtons(false)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tif clickCoordX > presetButton.x-buttonStrokeHalf and clickCoordX < presetButton.x + presetButton.width+buttonStrokeHalf and clickCoordY > presetButton.y-buttonStrokeHalf and clickCoordY < presetButton.y + presetButton.height+buttonStrokeHalf then\n\t\t\t\t\t\tif not pressDown then\n\t\t\t\t\t\t\tscreenObject.hover = presetButton\n\t\t\t\t\t\t\tscreenLooking = true\n\t\t\t\t\t\t\tupdateButtons(false)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif screenObject.mapViewState ~= 1 then\n\n\t\t\t\telseif clickCoordX > (screenWidth / 2) - 400 and clickCoordX < (screenWidth / 2) + 400 and clickCoordY > (screenHeight / 3) and clickCoordY < (screenHeight / 2) + 200 then\n\t\t\t\t\tscreenObject.hover = \"circle\"\n\t\t\t\t\tscreenLooking = true\n\t\t\t\t\tupdate3d(false)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tif screenObject.hover ~= nill and not screenLooking then\n\t\t\tscreenObject.hover = nill\n\t\t\tupdate3d(false)\n\t\t\tupdateButtons(false)\n\t\tend\n\n\t\tif not screenLooking then\n\t\t\tscreenObject.hover = nill\n\t\tend\n\n\tend\n\tif not looking then\n\t\tunit.setTimer(\"hoverdetect\", 1)\n\t\thovertimer = 1\n\tend\nend\n\nfor _,screenObject in ipairs(screens) do\n\tscreenObject.screen.clear()\nend\nupdate3d(false)\nupdateButtons(false)\nunit.setTimer(\"spacemap\", updateInterval)\nunit.setTimer(\"hoverdetect\", 1)\nunit.hideWidget()\n","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"8"},{"code":"for _,screenObject in ipairs(screens) do\n -- screenObject.screen.clear() \nend\nsaveAll()","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"9"},{"code":"checkhover()","filter":{"args":[{"value":"hoverdetect"}],"signature":"tick(timerId)","slotKey":"-1"},"key":"10"}],"methods":[],"events":[]}