-
Notifications
You must be signed in to change notification settings - Fork 0
/
PB Script
1 lines (1 loc) · 21.9 KB
/
PB Script
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":"dist = 0\nmeasureCount = 0\n\nfunction GetPosString(px,py,pz)\n Atlas={\n [0] = {\n [1]={\n GM=6930729684,\n bodyId=1,\n center={x=17465536.000,y=22665536.000,z=-34464.000},\n name='Madis',\n planetarySystemId=0,\n radius=44300\n },\n [2]={\n GM=157470826617,\n bodyId=2,\n center={x=-8.000,y=-8.000,z=-126303.000},\n name='Alioth',\n planetarySystemId=0,\n radius=126068\n },\n [3]={\n GM=11776905000,\n bodyId=3,\n center={x=29165536.000,y=10865536.000,z=65536.000},\n name='Thades',\n planetarySystemId=0,\n radius=49000\n },\n [4]={\n GM=14893847582,\n bodyId=4,\n center={x=-13234464.000,y=55765536.000,z=465536.000},\n name='Talemai',\n planetarySystemId=0,\n radius=57450\n },\n [5]={\n GM=16951680000,\n bodyId=5,\n center={x=-43534464.000,y=22565536.000,z=-48934464.000},\n name='Feli',\n planetarySystemId=0,\n radius=41800\n },\n [6]={\n GM=10502547741,\n bodyId=6,\n center={x=52765536.000,y=27165538.000,z=52065535.000},\n name='Sicari',\n planetarySystemId=0,\n radius=51100\n },\n [7]={\n GM=13033380591,\n bodyId=7,\n center={x=58665538.000,y=29665535.000,z=58165535.000},\n name='Sinnen',\n planetarySystemId=0,\n radius=54950\n },\n [8]={\n GM=18477723600,\n bodyId=8,\n center={x=80865538.000,y=54665536.000,z=-934463.940},\n name='Teoma',\n planetarySystemId=0,\n radius=62000\n },\n [9]={\n GM=18606274330,\n bodyId=9,\n center={x=-94134462.000,y=12765534.000,z=-3634464.000},\n name='Jago',\n planetarySystemId=0,\n radius=61590\n },\n [10]={\n GM=78480000,\n bodyId=10,\n center={x=17448118.224,y=22966846.286,z=143078.820},\n name='Madis Moon 1',\n planetarySystemId=0,\n radius=10000\n },\n [11]={\n GM=237402000,\n bodyId=11,\n center={x=17194626.000,y=22243633.880,z=-214962.810},\n name='Madis Moon 2',\n planetarySystemId=0,\n radius=11000\n },\n [12]={\n GM=265046609,\n bodyId=12,\n center={x=17520614.000,y=22184730.000,z=-309989.990},\n name='Madis Moon 3',\n planetarySystemId=0,\n radius=15005\n },\n [21]={\n GM=2118960000,\n bodyId=21,\n center={x=457933.000,y=-1509011.000,z=115524.000},\n name='Alioth Moon 1',\n planetarySystemId=0,\n radius=30000\n },\n [22]={\n GM=2165833514,\n bodyId=22,\n center={x=-1692694.000,y=729681.000,z=-411464.000},\n name='Alioth Moon 4',\n planetarySystemId=0,\n radius=30330\n },\n [26]={\n GM=68234043600,\n bodyId=26,\n center={x=-1404835.000,y=562655.000,z=-285074.000},\n name='Sanctuary',\n planetarySystemId=0,\n radius=83400\n },\n [30]={\n GM=211564034,\n bodyId=30,\n center={x=29214402.000,y=10907080.695,z=433858.200},\n name='Thades Moon 1',\n planetarySystemId=0,\n radius=14002\n },\n [31]={\n GM=264870000,\n bodyId=31,\n center={x=29404193.000,y=10432768.000,z=19554.131},\n name='Thades Moon 2',\n planetarySystemId=0,\n radius=15000\n },\n [40]={\n GM=141264000,\n bodyId=40,\n center={x=-13503090.000,y=55594325.000,z=769838.640},\n name='Talemai Moon 2',\n planetarySystemId=0,\n radius=12000\n },\n [41]={\n GM=106830900,\n bodyId=41,\n center={x=-12800515.000,y=55700259.000,z=325207.840},\n name='Talemai Moon 3',\n planetarySystemId=0,\n radius=11000\n },\n [42]={\n GM=264870000,\n bodyId=42,\n center={x=-13058408.000,y=55781856.000,z=740177.760},\n name='Talemai Moon 1',\n planetarySystemId=0,\n radius=15000\n },\n [50]={\n GM=499917600,\n bodyId=50,\n center={x=-43902841.780,y=22261034.700,z=-48862386.000},\n name='Feli Moon 1',\n planetarySystemId=0,\n radius=14000\n },\n [70]={\n GM=396912600,\n bodyId=70,\n center={x=58969616.000,y=29797945.000,z=57969449.000},\n name='Sinnen Moon 1',\n planetarySystemId=0,\n radius=17000\n },\n [100]={\n GM=13975172474,\n bodyId=100,\n center={x=98865536.000,y=-13534464.000,z=-934461.990},\n name='Lacobus',\n planetarySystemId=0,\n radius=55650\n },\n [101]={\n GM=264870000,\n bodyId=101,\n center={x=98905288.170,y=-13950921.100,z=-647589.530},\n name='Lacobus Moon 3',\n planetarySystemId=0,\n radius=15000\n },\n [102]={\n GM=444981600,\n bodyId=102,\n center={x=99180968.000,y=-13783862.000,z=-926156.400},\n name='Lacobus Moon 1',\n planetarySystemId=0,\n radius=18000\n },\n [103]={\n GM=211503600,\n bodyId=103,\n center={x=99250052.000,y=-13629215.000,z=-1059341.400},\n name='Lacobus Moon 2',\n planetarySystemId=0,\n radius=14000\n },\n [110]={\n GM=9204742375,\n bodyId=110,\n center={x=14165536.000,y=-85634465.000,z=-934464.300},\n name='Symeon',\n planetarySystemId=0,\n radius=49050\n },\n [120]={\n GM=7135606629,\n bodyId=120,\n center={x=2865536.700,y=-99034464.000,z=-934462.020},\n name='Ion',\n planetarySystemId=0,\n radius=44950\n },\n [121]={\n GM=106830900,\n bodyId=121,\n center={x=2472916.800,y=-99133747.000,z=-1133582.800},\n name='Ion Moon 1',\n planetarySystemId=0,\n radius=11000\n },\n [122]={\n GM=176580000,\n bodyId=122,\n center={x=2995424.500,y=-99275010.000,z=-1378480.700},\n name='Ion Moon 2',\n planetarySystemId=0,\n radius=15000\n } \n }\n }\n mindist2=nil\n for index,data in pairs(Atlas[0]) do\n r=data.radius\n center=data.center\n cx=center.x\n cy=center.y\n cz=center.z\n dist2=(px-cx)^2+(py-cy)^2+(pz-cz)^2\n if mindist2==nil then\n mindist2=dist2\n mincx=cx\n mincy=cy\n mincz=cz\n minr=r\n minindex=index\n elseif dist2<mindist2 then\n mindist2=dist2\n mincx=cx\n mincy=cy\n mincz=cz\n minr=r\n minindex=index\n end\n end\n cx=mincx\n cy=mincy\n cz=mincz\n r=minr\n rad2deg=180/math.pi\n x=px-cx\n y=py-cy\n z=pz-cz\n d=math.sqrt(x^2+y^2+z^2)\n alt=d-r\n phi=math.atan(y,x)\n lon= phi>=0 and phi or (2*math.pi+phi)\n lat= math.pi/2 - math.acos(z/d)\n \n alt_str=string.format('%.4f',alt)\n lon_str=string.format('%.4f',lon*rad2deg)\n lat_str=string.format('%.4f',lat*rad2deg)\n\n pos_str='::pos{0,'..minindex..','..lat_str..','..lon_str..','..alt_str..'}'\n return pos_str\nend\n\ndistance_list={400,375,350,325,300,275,250,225,200,175,150,125,100,75,50,45,40,35,30,25,20,15,10,5}\nbutton_r=25\ndx=5\ncurrent_di=1\nmargin=0.10\n\nhudHTML=\n[[\n<div style=\"font-size:2vh;position:absolute;left:0;top:20%;\">\nAlt+1: Decrease Distance -25<br>\nAlt+2: Incrase Distance -5<br>\nAlt+3: Lock Distance at ]]..dist..[[m<br>\nAlt+4: Decrease Distance +5<br>\nAlt+5: Incrase Distance +25<br><br>\nCurrent Locks: ]]..measureCount..[[<br><br>\nAlt+9: Reset\n</div>\n]]\n\nsystem.setScreen(hudHTML)\nsystem.showScreen(1)","filter":{"args":[],"signature":"start()","slotKey":"-1"},"key":"0"},{"code":"dist = dist-25\n\nif dist <= 100 then indicatorX = 70-dist/80 indicatorY = 86.25-dist/13\nelseif dist > 100 and dist <= 200 then indicatorX = 68.8-(dist-100)/85 indicatorY = 78.5-(dist-100)/14.7\nelseif dist > 2 and dist <= 300 then indicatorX = 67.8-(dist-200)/93 indicatorY = 71.6-(dist-200)/16.3\nelse indicatorX = 66.8-(dist-300)/100 indicatorY = 65.5-(dist-300)/17.9 end\n\n\nhudHTML=\n[[\n<div style=\"font-size:2vh;position:absolute;left:0;top:20%;\">\nAlt+1: Decrease Distance -25<br>\nAlt+2: Incrase Distance -5<br>\nAlt+3: Lock Distance at ]]..dist..[[m<br>\nAlt+4: Decrease Distance +5<br>\nAlt+5: Incrase Distance +25<br><br>\nCurrent Locks: ]]..measureCount..[[<br><br>\n]]\nif measureCount >= 3 then\n hudHTML=hudHTML..[[Possible Ore Vein Location Found.<br>Set Waypoint From LUA Chatbox.<br>]]\nend\nhudHTML=hudHTML..[[Alt+9: Reset\n</div>\n<svg width=100% height=100%>\n\n<rect x=]].. indicatorX ..[[% y=]].. indicatorY ..[[% width=1vw height=.3vh style=\"fill:white;\"/>\n</svg>\n]]\n\nsystem.setScreen(hudHTML)","filter":{"args":[{"value":"option1"}],"signature":"actionStart(action)","slotKey":"-2"},"key":"1"},{"code":"dist = dist-5\n\nif dist <= 100 then indicatorX = 70-dist/80 indicatorY = 86.25-dist/13\nelseif dist > 100 and dist <= 200 then indicatorX = 68.8-(dist-100)/85 indicatorY = 78.5-(dist-100)/14.7\nelseif dist > 2 and dist <= 300 then indicatorX = 67.8-(dist-200)/93 indicatorY = 71.6-(dist-200)/16.3\nelse indicatorX = 66.8-(dist-300)/100 indicatorY = 65.5-(dist-300)/17.9 end\n\n\nhudHTML=\n[[\n<div style=\"font-size:2vh;position:absolute;left:0;top:20%;\">\nAlt+1: Decrease Distance -25<br>\nAlt+2: Incrase Distance -5<br>\nAlt+3: Lock Distance at ]]..dist..[[m<br>\nAlt+4: Decrease Distance +5<br>\nAlt+5: Incrase Distance +25<br><br>\nCurrent Locks: ]]..measureCount..[[<br><br>\n]]\nif measureCount >= 3 then\n hudHTML=hudHTML..[[Possible Ore Vein Location Found.<br>Set Waypoint From LUA Chatbox.<br>]]\nend\nhudHTML=hudHTML..[[Alt+9: Reset\n</div>\n<svg width=100% height=100%>\n\n<rect x=]].. indicatorX ..[[% y=]].. indicatorY ..[[% width=1vw height=.3vh style=\"fill:white;\"/>\n</svg>\n]]\n\nsystem.setScreen(hudHTML)","filter":{"args":[{"value":"option2"}],"signature":"actionStart(action)","slotKey":"-2"},"key":"2"},{"code":"--dist=distance_list[current_di]\n--dist=distance\nif dist>=50 then\n margin=12.5\nelse\n margin=2.5\nend\nplayer_id=unit.getMasterPlayerId()\nplayer_pos=vec3(system.getPlayerWorldPos(player_id))\nplayer_marker=GetPosString(player_pos.x,player_pos.y,player_pos.z)\nsystem.print(\"You are here:\")\nsystem.print(player_marker)\nmeasureCount=measureCount+1\nif measureCount==1 then\n measureList={}\n table.insert(measureList,{player_pos.x,player_pos.y,player_pos.z,dist^2})\n boxXmin=player_pos.x-(dist+margin)\n boxXmax=player_pos.x+(dist+margin)\n boxYmin=player_pos.y-(dist+margin)\n boxYmax=player_pos.y+(dist+margin)\n boxZmin=player_pos.z-(dist+margin)\n boxZmax=player_pos.z+(dist+margin)\n \n start_x=player_pos.x\n start_y=player_pos.y\n start_z=player_pos.z\n start_d2=(1.25*dist)^2\nelse\n table.insert(measureList,{player_pos.x,player_pos.y,player_pos.z,dist^2})\n \n dist_from_start=(player_pos.x-start_x)^2+(player_pos.y-start_y)^2+(player_pos.z-start_z)^2\n if dist_from_start>start_d2 then\n system.print(\"ERROR: location out of bounds\")\n system.print(\"ignoring measure, submit a new one\")\n system.print(\"that is within range of first measurement\")\n measureCount=measureCount-1\n else\n box2Xmin=player_pos.x-(dist+margin)\n box2Xmax=player_pos.x+(dist+margin)\n box2Ymin=player_pos.y-(dist+margin)\n box2Ymax=player_pos.y+(dist+margin)\n box2Zmin=player_pos.z-(dist+margin)\n box2Zmax=player_pos.z+(dist+margin)\n\n boxXmin=math.max(boxXmin,box2Xmin)\n boxXmax=math.min(boxXmax,box2Xmax)\n boxYmin=math.max(boxYmin,box2Ymin)\n boxYmax=math.min(boxYmax,box2Ymax)\n boxZmin=math.max(boxZmin,box2Zmin)\n boxZmax=math.min(boxZmax,box2Zmax)\n \n \n\n if boxXmin>=boxXmax or boxYmin>=boxYmax or boxZmin>=boxZmax then\n system.print(\"ERROR: unable to define bounding box\")\n system.print(\"Please start over\")\n measureCount=0\n elseif measureCount>2 then\n \n\n chunks=5\n xdelta=(boxXmax-boxXmin)/chunks\n ydelta=(boxYmax-boxYmin)/chunks\n zdelta=(boxZmax-boxZmin)/chunks\n \n found_marker=0\n\n minError=1000000000\n x=boxXmin\n while x<=boxXmax do\n y=boxYmin\n while y<=boxYmax do\n z=boxZmin\n while z<=boxZmax do\n curError=0\n out_of_bounds=0\n for i=1,#measureList do\n measure=measureList[i]\n mx=measure[1]\n my=measure[2]\n mz=measure[3]\n m2=measure[4]\n d2=(mx-x)^2+(my-y)^2+(mz-z)^2\n e=math.abs(d2-m2)\n if e>1.5625*m2 then\n out_of_bounds=1\n break\n end\n curError=curError+e\n end\n if curError<minError and out_of_bounds==0 then\n minError=curError\n marker_x=x\n marker_y=y\n marker_z=z\n found_marker=1\n end\n z=z+zdelta\n end\n y=y+ydelta\n end\n x=x+xdelta\n end\n \n if found_marker==1 then\n\n vol=(boxXmax-boxXmin)*(boxYmax-boxYmin)*(boxZmax-boxZmin)\n\n marker_pos=GetPosString(marker_x,marker_y,marker_z)\n \n dist_to_player=math.sqrt((player_pos.x-marker_x)^2+(player_pos.y-marker_y)^2+(player_pos.z-marker_z)^2)\n \n \n system.print(\"This location is my best guess for the node:\")\n system.print(marker_pos)\n system.print(\"(\"..marker_x..\",\"..marker_y..\",\"..marker_z..\")\")\n system.print(\"distance from player: \"..dist_to_player)\n else\n system.print(\"Unable to find a suitable best guess location\")\n system.print(\"submit another measurement or restart\")\n end\n else\n end\n end\nend\n\nhudHTML=\n[[\n<div style=\"font-size:2vh;position:absolute;left:0;top:20%;\">\nAlt+1: Decrease Distance -25<br>\nAlt+2: Incrase Distance -5<br>\nAlt+3: Lock Distance at ]]..dist..[[m<br>\nAlt+4: Decrease Distance +5<br>\nAlt+5: Incrase Distance +25<br><br>\nCurrent Locks: ]]..measureCount..[[<br><br>\n]]\nif measureCount >= 3 then\n if dist - dist_to_player > 20 or dist - dist_to_player < -20 then\n hudHTML=hudHTML..[[Additional data required. Please lock additional markers.<br>]]\n else \n hudHTML=hudHTML..[[Possible Ore Vein Location Found.<br>Set Waypoint From LUA Chatbox.<br>]]\n end\nend\nhudHTML=hudHTML..[[Alt+9: Reset\n</div>\n]]\n\n\n\nsystem.setScreen(hudHTML)","filter":{"args":[{"value":"option3"}],"signature":"actionStart(action)","slotKey":"-2"},"key":"3"},{"code":"measureCount=0\nsystem.print(\"system restarted\")\nsystem.print(\"submit a first measurement\")\n\nhudHTML=\n[[\n<div style=\"font-size:2vh;position:absolute;left:0;top:20%;\">\nAlt+1: Decrease Distance<br>\nAlt+2: Incrase Distance<br>\nAlt+3: Lock Distance at ]]..dist..[[<br>\nCurrent Locks: ]]..measureCount..[[<br>\n]]\nif measureCount >= 3 then\n hudHTML=hudHTML..[[Ore triangulation complete.<br>Check LUA chatbox for waypoint.<br>]]\nend\nhudHTML=hudHTML..[[Alt+9: Reset\n</div>\n]]\nsystem.setScreen(hudHTML)","filter":{"args":[{"value":"option9"}],"signature":"actionStart(action)","slotKey":"-2"},"key":"4"},{"code":"dist = dist+5\n\nif dist <= 100 then indicatorX = 70-dist/80 indicatorY = 86.25-dist/13\nelseif dist > 100 and dist <= 200 then indicatorX = 68.8-(dist-100)/85 indicatorY = 78.5-(dist-100)/14.7\nelseif dist > 2 and dist <= 300 then indicatorX = 67.8-(dist-200)/93 indicatorY = 71.6-(dist-200)/16.3\nelse indicatorX = 66.8-(dist-300)/100 indicatorY = 65.5-(dist-300)/17.9 end\n\n\nhudHTML=\n[[\n<div style=\"font-size:2vh;position:absolute;left:0;top:20%;\">\nAlt+1: Decrease Distance -25<br>\nAlt+2: Incrase Distance -5<br>\nAlt+3: Lock Distance at ]]..dist..[[m<br>\nAlt+4: Decrease Distance +5<br>\nAlt+5: Incrase Distance +25<br><br>\nCurrent Locks: ]]..measureCount..[[<br><br>\n]]\nif measureCount >= 3 then\n hudHTML=hudHTML..[[Possible Ore Vein Location Found.<br>Set Waypoint From LUA Chatbox.<br>]]\nend\nhudHTML=hudHTML..[[Alt+9: Reset\n</div>\n<svg width=100% height=100%>\n\n<rect x=]].. indicatorX ..[[% y=]].. indicatorY ..[[% width=1vw height=.3vh style=\"fill:white;\"/>\n</svg>\n]]\n\nsystem.setScreen(hudHTML)","filter":{"args":[{"value":"option4"}],"signature":"actionStart(action)","slotKey":"-2"},"key":"5"},{"code":"dist = dist+25\n\nif dist <= 100 then indicatorX = 70-dist/80 indicatorY = 86.25-dist/13\nelseif dist > 100 and dist <= 200 then indicatorX = 68.8-(dist-100)/85 indicatorY = 78.5-(dist-100)/14.7\nelseif dist > 2 and dist <= 300 then indicatorX = 67.8-(dist-200)/93 indicatorY = 71.6-(dist-200)/16.3\nelse indicatorX = 66.8-(dist-300)/100 indicatorY = 65.5-(dist-300)/17.9 end\n\n\nhudHTML=\n[[\n<div style=\"font-size:2vh;position:absolute;left:0;top:20%;\">\nAlt+1: Decrease Distance -25<br>\nAlt+2: Incrase Distance -5<br>\nAlt+3: Lock Distance at ]]..dist..[[m<br>\nAlt+4: Decrease Distance +5<br>\nAlt+5: Incrase Distance +25<br><br>\nCurrent Locks: ]]..measureCount..[[<br><br>\n]]\nif measureCount >= 3 then\n hudHTML=hudHTML..[[Possible Ore Vein Location Found.<br>Set Waypoint From LUA Chatbox.<br>]]\nend\nhudHTML=hudHTML..[[Alt+9: Reset\n</div>\n<svg width=100% height=100%>\n\n<rect x=]].. indicatorX ..[[% y=]].. indicatorY ..[[% width=1vw height=.3vh style=\"fill:white;\"/>\n</svg>\n]]\n\nsystem.setScreen(hudHTML)","filter":{"args":[{"value":"option5"}],"signature":"actionStart(action)","slotKey":"-2"},"key":"6"}],"methods":[],"events":[]}