-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlua.json
1 lines (1 loc) · 8.08 KB
/
lua.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()\n\nlocal r = 1 --export: red between 0 and 1\nlocal g = 0 --export: green between 0 and 1\nlocal b = 0 --export: blue between 0 and 1\n\nunit.hide()\nsystem.createWidgetPanel('DU-Atlas v1.2')\n\nscreen.setRenderScript([[\n local json = require('dkjson') \n \n local l = createLayer()\n local rx, ry = getResolution()\n local fontSize = 20\n local font = loadFont(\"Play\", fontSize)\n local fma, fmd = getFontMetrics(font)\n local params = json.decode(getInput()) or {}\n local cx, ch = getCursor()\n\n local r = params[1]\n local g = params[2]\n local b = params[3]\n local list = params[4]\n\n if not tab then\n tab = 1\n end\n \n headerH = (ry / 100) * 10\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 \n if cx > x and cx < x + headerW and ch > y and ch < y + headerH then\n setNextFillColor(l, r, g, b, 1)\n \n if getCursorDown() then\n tab = i\n end\n else\n setNextFillColor(l, r, g, b, 0.5)\n end\n \n addBox(l, x, y, headerW, headerH)\n local tbw, tbh = getTextBounds(font, name)\n addText(l, font, name, x + (headerW / 2) - (tbw / 2), headerH/2 + tbh/2)\n end\n \n \n local boxH = (ry / 100) * 5\n local boxW = rx\n local padding = (ry / 100) * 2\n local listOffset = headerH + padding\n \n -- list\n for y=1, #list[tab].l do\n local item = list[tab].l[y]\n \n local boxStartH = listOffset\n if ch > boxStartH and ch < boxStartH + boxH then\n setNextFillColor(l, r, g, b, 0.5)\n \n if getCursorDown() then\n setOutput(json.encode({\n action = \"setLocation\",\n group = tab,\n location = y\n }))\n setNextFillColor(l, r, g, b, 1)\n end\n else\n setNextFillColor(l, 0.054, 1, 0.007, 0)\n end\n \n setNextStrokeColor(l, r, g, b, 1)\n setNextStrokeWidth(l, 2)\n addBoxRounded(l, 10, boxStartH, boxW-20, boxH, 30)\n \n local text = item\n local tbw, tbh = getTextBounds(font, text)\n addText(l, font, text, boxW/2-tbw/2, boxStartH + boxH/2 + tbh/2)\n \n listOffset = listOffset + boxH + padding\n end\n \n requestAnimationFrame(1)\n\n\n]])\n\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}))","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()\nif #output > 0 then\n screen.clearScriptOutput()\n \n _o = json.decode(output)\n if _o.action == 'setLocation' then\n system.setWaypoint(locations[_o.group].list[_o.location].location)\n end \nend\n\nlocal pos = unit.getMasterPlayerPosition()\nif vec3(pos):len() > 15 then\n unit.exit()\nend","filter":{"args":[],"signature":"update()","slotKey":"-2"},"key":"2"},{"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 = '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":"3"}],"methods":[],"events":[]}