forked from rohimma/du-atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lua-v2-0.json
1 lines (1 loc) · 14.1 KB
/
lua-v2-0.json
1
{"slots":{"0":{"name":"screen","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":[]}},"-2":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"library","type":{"events":[],"methods":[]}}},"handlers":[{"code":"screen.activate()\nsystem.print(\"Starting DU Destinations. Type a search term.\")\nlocal r = 225 --export: red between 0 and 1\nlocal g = 0 --export: green between 0 and 1\nlocal b = 0 --export: blue between 0 and 1\nsearch = nil\nwait = false\nfunction handleTextCommand(t) \n wait = false\n if t == \"clear\" then\n search = nil\n sendData()\n return\n end\n search = t \n system.print(\"Searching for: \\\"\"..t..\"\\\"\")\n sendData()\nend\n\n\n\nunit.hide()\nsystem.createWidgetPanel('DU-Atlas v1.2')\n\n\n\nscreen.setRenderScript([[\n\n\n\nfunction dump(o)\n if type(o) == 'table' then\n local s = '{ '\n for k,v in pairs(o) do\n if type(k) ~= 'number' then k = '\"'..k..'\"' end\n s = s .. '['..k..'] = ' .. dump(v) .. ','\n end\n return s .. '} '\n else\n return tostring(o)\n end\nend\n\n\nlocal json = require('dkjson') \n local rslib=require('rslib')\n\n local speed = 3 --export\n local cornerRadius = 5 --export\n local rd = cornerRadius\n \n rslib.drawQuickImage(\"assets.prod.novaquark.com/74927/4caa44d4-757f-4fe8-b52e-f0021ae4693d.png\")\n \n local l = createLayer()\n local l2 = createLayer()\nlocal l4 = createLayer()\n local rx, ry = getResolution()\n\n \n setNextFillColor(l,0,0,0,0.5)\n addBox(l,0,0,rx,ry)\n\n setDefaultShadow(l2,Shape_BoxRounded,10,0,0,0,0.5)\n setDefaultShadow(l2,Shape_Box,10,0,0,0,0.5)\n \n\n local fontSize = 20 --export: List font size\n local font = loadFont(\"Montserrat-Light\", fontSize)\n local fontB = loadFont(\"Montserrat-Bold\", fontSize)\n local fontC = loadFont(\"Play\",25)\n local fma, fmd = getFontMetrics(font)\n local params = json.decode(getInput()) or {}\n local cx, ch = getCursor()\n\n\n local r = params[1]\n local g = params[2]\n local b = params[3]\n local list = params[4]\n local search = params[5]\n \n\n if not iteration then\n iteration = 0\n end\n\n if not tab then\n tab = 1\n end\n \n \n\n headerH = (ry / 100) * 10\n \n \n aantalHeaders = #list\n headerW = rx / aantalHeaders\n\n for i=1, #list do\n local locationgroup = list[i]\n local name = locationgroup.n\n \n local x = (i-1)*headerW\n local y = 0\n local nextFont = font\n if cx > x and cx < x + headerW and ch > y and ch < y + headerH then\n setNextFillColor(l2, r, g, b, 1)\n \n if getCursorDown() then\n tab = i\n iteration = 0\n end\n nextFont = fontB\n elseif tab == i then\n setNextFillColor(l2, r, g, b, 1)\n nextFont = fontB\n else \n setNextFillColor(l2, r/500, g/500, b/500, 1)\n end\n setNextStrokeWidth(l2,3)\n setNextStrokeColor(l2,0,0,0,0.7)\n addBox(l2, x, y, headerW, headerH)\n local tbw, tbh = getTextBounds(font, name)\n addText(l2, nextFont, name, x + (headerW / 2) - (tbw / 2), headerH/2 + tbh/2)\n end\n\n --\n -- End top\n --\n\t\n\t\n\tfunction displayList(list, tab )\n\t\tfor y=1, #list do\n\t\t\tlocal item = list[y]\n\t\t\n\t\t\tlocal boxStartH = listOffset\n\n\t\t\tif ch > boxStartH-animationOffset and ch < boxStartH + boxH - animationOffset and cx < boxW then\n\t\t\t\tsetNextFillColor(l, r, g, b, 0.5)\n\t\t\t if tab then\n specialTab = tab\n else\n specialTab = list[y].tab\n end\n\t\t\t\tif getCursorDown() then\n\t\t\t\t\tsetOutput(json.encode({\n\t\t\t\t\t\taction = \"setLocation\",\n\t\t\t\t\t\tgroup = specialTab,\n\t\t\t\t\t\tlocation = y\n\t\t\t\t\t}))\n\t\t\t\t\tsetNextFillColor(l, r, g, b, 0.7)\n\t\t\t\tend\n\t\t\t\n\t\t\t\tsetNextStrokeColor(l, 1, 1, 1, 1)\n\t\t\telse\n\t\t\t\tsetNextFillColor(l,0,0,0,0.8)\n\t\t\t\tsetNextStrokeColor(l, r, g, b, 0.3)\n\t\t\tend\n\t\t\t\n\t\t\tsetNextStrokeWidth(l, 2)\n\t\t\t\n\t\t\taddBoxRounded(l, 10, boxStartH - animationOffset, boxW-20, boxH, rd)\n\t\t\t\n\t\t\tlocal text = item\n\t\t\tlocal tbw, tbh = getTextBounds(font, text)\n\t\t\taddText(l, font, text, boxW/2-tbw/2, boxStartH + boxH/2 + tbh/2 - animationOffset)\n\t\t\t\n\t\t\tlistOffset = listOffset + boxH + padding\t\n\t\tend\n\tend\n\t\n\t\n\t--\n\t-- Search\n\t-- \n\t\n\t\n\n\tfunction displayMatches(matches,s) \n\t\t\n\t\tsetNextFillColor(l4,1,1,1,0.8)\n\t\taddBoxRounded(l4, rx* 8/10, ry * 8/10, rx*1/5, ry * 1/5,5)\n\t\tfontSearchTitle = loadFont(\"Monserrat-Light\", 30)\n setNextTextAlign(l4, AlignH_Center, AlignV_middle)\n\t\taddText(l4,fontSearchTitle,\"Searching for: \\\"\"..s..\"\\\"\", rx/2,headerH*2)\n\t\t\n\t\tfor j=1, matches do\n\t\t\t--\n\t\tend\n\tend\n\t\n\tfunction findMatches(list, s)\n\t\tlocal matches = {}\n\t\tfor x=1, #list do\n\t\t\tfor y=1, #list[x].l do\n\t\t\t\tlocal item = list[x].l[y]\n\t\t\t\tlocal i = 0\n\t\t\t\twhile true do\n\t\t\t\t\ti = string.find(item:lower(), s:lower(), i+1)\n\t\t\t\t\t\n\t\t\t\t\tif i == nil then \n\t\t\t\t\t\tbreak \n end\n\t\t\t\t\t\t\n\t\t\t\t\ttable.insert(matches,{x,y,item})\n\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend \n\t end\n return matches\n\tend\n\n if search then\n matches = findMatches(list, search)\n \n if #matches == 1 then \n\t\t\t--found\n\t\t\t setOutput(json.encode({\n\t\t\t\t\t\taction = \"setLocation\",\n\t\t\t\t\t\tgroup = matches[1][1],\n\t\t\t\t\t\tlocation = matches[1][2]\n\t\t\t\t\t}))\t\t\n search = nil\n \n \n\t\telseif #matches > 1 then\t\n\t\t\t--display them\n\t\t\tsetOutput(json.encode({\n\t\t\t\t\t\taction = \"showOptions\",\n\t\t\t\t\t\tmatch = matches\n\t\t\t\t\t}))\n\t\t\trequestAnimationFrame(1)\n\t\t\t\n\t\telse\n setOutput(json.encode({\n\t\t\t\t\t\taction = \"404\"\n\t\t\t\t\t}))\t\t\n end\n \n\tend\n\t\n\t\n\t \n \n \n\t--\n\t--End Search\n\t--\n\n\n boxH = (ry / 100) * 8\n boxW = rx * 9/10\n padding = (ry / 100) * 2\n listOffset = headerH + padding \n \n setNextFillColor(l2,r/500,g/500,b/500,1)\n buttonH = headerH\n buttonW = rx/10-padding*2\n buttonX = rx-(rx/10)+padding\n buttonY = headerH+padding\n if ch > buttonY and ch < buttonY+buttonH and cx > buttonX and cx < buttonX+buttonW then\n if getCursorDown() then\n iteration = iteration -1\n setNextFillColor(l2,1,1,1,0.5)\n end\n setNextStrokeColor(l2,1,1,1,0.5)\n setNextStrokeWidth(l2,2)\n end\n addBoxRounded(l2,buttonX,buttonY,buttonW,buttonH,rd)\n setNextTextAlign(l2,AlignH_Center, AlignV_Middle)\n addText(l2, fontC, \"UP\",buttonX+buttonW/2,buttonY+buttonH/2)\n \n buttonY = buttonY+headerH+padding\n\n setNextFillColor(l2,r/500,g/500,b/500,1)\n if ch > buttonY and ch < buttonY+buttonH and cx > buttonX and cx < buttonX+buttonW then\n if getCursorDown() then\n iteration = iteration +1\n setNextFillColor(l2,1,1,1,0.5)\n end\n setNextStrokeColor(l2,1,1,1,0.5)\n setNextStrokeWidth(l2,2)\n end\n\n \n addBoxRounded(l2,buttonX,buttonY,buttonW,buttonH,rd)\n setNextTextAlign(l2,AlignH_Center, AlignV_Middle)\n addText(l2, fontC, \"DOWN\",buttonX+buttonW/2,buttonY+buttonH/2)\n \n \n \n allBoxes = boxH * #list[tab].l\n \n animationOffset = speed * iteration\n if animationOffset < 0 then\n animationOffset = 0\n iteration = 0\n end\n -- list\n displayList(list[tab].l,tab)\n \n \n requestAnimationFrame(1)\n\n\n\n\n]])\n\nfunction sendData()\nlocal screenInput = {};\nfor i=1, #locations do\n local _loc = {}\n for y=1, #locations[i].list do\n table.insert(_loc, locations[i].list[y].name)\n end \n table.insert(screenInput, {\n n = locations[i].name,\n l = _loc\n })\nend \n\nscreen.setScriptInput(json.encode({r,g,b,screenInput,search}))\n end\nsendData()","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"0"},{"code":"screen.setRenderScript([[\nlocal rx, ry = getResolution()\nlocal dt = 100 * getDeltaTime()\nlocal l = createLayer()\nlocal font = loadFont(\"FiraMono-Bold\", 85)\n\nif not init then \n init = true\n text = {}\n text.header = \"DU-Atlas\"\n \n local tbw, tbh = getTextBounds(font, text.header)\n \n text.w = tbw\n text.h = tbh\n \n text.x = math.random(tbw, rx-tbw)\n text.y = math.random(tbh, ry-tbh)\n text.vx = 0.75\n text.vy = 0.5\nend\n\n \n \ntext.x = text.x + text.vx * dt\ntext.y = text.y + text.vy * dt\n\nif text.x < 0 or text.x > rx - text.w then\n text.x = text.x - text.vx * dt\n text.vx = -text.vx\nend\n\nif text.y < text.h or text.y > ry then\n text.y = text.y - text.vy * dt\n text.vy = -text.vy\nend\n\naddText(l, font, text.header, text.x, text.y)\n\nrequestAnimationFrame(1)\n]])","filter":{"args":[],"signature":"stop()","slotKey":"-1"},"key":"1"},{"code":"local output = screen.getScriptOutput()\nlocal shutoff_distance = 50 --export\n\n\nif #output > 0 then\n screen.clearScriptOutput()\n \n _o = json.decode(output)\n if _o.action == 'clearSearch' then\n search = nil\n sendData()\n end\n if _o.action == '404' then\n system.print(\"No matches found.\")\n search = nil\n sendData()\n end\n if _o.action == 'showOptions' then\n local options = \"\"\n for i=1, #_o.match do\n local option = _o.match[i][3]\n options = options..option..\", \"\n end\n if not wait then\n system.print(options)\n wait=true\n end\n \n end\n if _o.action == 'setLocation' then\n system.print(\"Location Found: \"..locations[_o.group].list[_o.location].name)\n system.setWaypoint(locations[_o.group].list[_o.location].location)\n search = nil\n sendData()\n end \nend\n\nlocal pos = unit.getMasterPlayerPosition()\nif vec3(pos):len() > shutoff_distance then\n unit.exit()\nend","filter":{"args":[],"signature":"update()","slotKey":"-2"},"key":"2"},{"code":"handleTextCommand(text)","filter":{"args":[{"variable":"*"}],"signature":"inputText(text)","slotKey":"-2"},"key":"3"},{"code":"locations = {\n {\n name = 'My Spots',\n list = {\n {\n name = 'My Base',\n location = '::pos{0,2,-67.2215,171.6768,83.4687}'\n }\n }\n },\n {\n name = 'Special Locations',\n list = {\n {\n name = 'The Hedronic library',\n location = '::pos{0,8,1.3405,133.7848,55.9334}'\n },\n {\n name = 'Jasper spacebase',\n location = '::pos{0,2,-9.1616,162.6723,621410.9375}'\n },\n {\n name = 'NQ pixel art',\n location = '::pos{0,0,7541779.0000,22300232.0000,6489264.0000}'\n },\n {\n name = 'Metallic Dugo and Fonds',\n location = '::pos{0,26,7.9501,-19.0057,10.3428}'\n },\n {\n name = 'TicTacs Ship Shop',\n location = '::pos{0,2,-66.2150,156.4984,-0.0000}'\n },\n {\n name = 'Snowhex Sanc',\n location = '::pos{0,26,88.4855,-30.5057,143.2993}'\n },\n {\n name = 'd4nkknight Showroom',\n location = '::pos{0,2,6.6084,80.3590,2.3621}'\n },\n {\n name = 'Infinity Spaceport',\n location = '::pos{0,2,7.9912,79.3320,0.0004}'\n },\n {\n name = 'Utopia Space Center',\n location = '::pos{0,0,13662322.5694,7547220.7030,-215970.4049}'\n }\n }\n },\n {\n name = 'Markets',\n list = {\n {\n name = 'Disctrict market 6',\n location = '::pos{0,2,36.0044,101.3503,220.0897}'\n }\n }\n },\n {\n name = 'My Mining Units',\n list = {\n {\n name = 'Ore 1',\n location = 'Enter Coordinates'\n }\n }\n },\n {\n name = 'Race tracks',\n list = {\n {\n name = 'Obsidian Race Area',\n location = '::pos{0,2,-14.5771,-12.0537,-0.0008}'\n },\n {\n name = 'PINTDeathBlossom',\n location = '::pos{0,2,-9.7257,-166.9100,4.1896}'\n },\n {\n name = 'GWNC',\n location = '::pos{0,2,0.3699,-178.1286,45.0133}'\n },\n {\n name = 'Melanuma',\n location = '::pos{0,2,0.2342,108.8616,62.4634}'\n },\n {\n name = 'Anvilworks ',\n location = '::pos{0,2,-4.9108,94.8415,1.2653}'\n },\n {\n name = 'Pure Velocity Raceway',\n location = '::pos{0,2,4.9829,147.5784,594.0582}'\n },\n {\n name = 'DesertOasis',\n location = '::pos{0,2,-4.1999,117.2064,55.3775}'\n },\n {\n name = 'GTFOval',\n location = '::pos{0,2,0.2342,108.8616,62.4634}'\n }\n }\n }\n}\n\n","filter":{"args":[],"signature":"start()","slotKey":"-3"},"key":"4"}],"methods":[],"events":[]}