Advertisement
salahzar

dom_nav.js

Aug 3rd, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     //Alezia Kurdis, July 2018.
  3.     var APP_NAME = "DOM NAV";
  4.     var APP_URL = "http://mpassets.highfidelity.com/7aa9e823-1f3a-4001-b36a-8a51081f7990-v1/dom_nav.html";
  5.     var APP_ICON = "http://mpassets.highfidelity.com/7aa9e823-1f3a-4001-b36a-8a51081f7990-v1/dom_nav_icon.png";
  6.  
  7.    
  8.     var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
  9.     var button = tablet.addButton({
  10.         text: APP_NAME,
  11.         icon: APP_ICON
  12.     });
  13.    
  14.     function clicked(){
  15.         var AvatarPosition = MyAvatar.position;
  16.        
  17.         tablet.gotoWebScreen(APP_URL + "?x=" + Math.round(AvatarPosition.x) + "&y=" + Math.round(AvatarPosition.y) + "&z=" + Math.round(AvatarPosition.z));
  18.     }
  19.     button.clicked.connect(clicked);
  20.    
  21.     function onWebEventReceivedz(eventz){
  22.  
  23.         if(typeof eventz === "string"){
  24.             eventzget = JSON.parse(eventz);
  25.        
  26.    
  27.             if(eventzget.type === "give_tp_coor"){
  28.                
  29.                 //print("X: " + eventzget.x);
  30.                 //print("Y: " + eventzget.y);
  31.                 //print("Z: " + eventzget.z);
  32.                 var myVec = {
  33.                     x: parseFloat(eventzget.x),
  34.                     y: parseFloat(eventzget.y),
  35.                     z: parseFloat(eventzget.z)
  36.                 };
  37.                
  38.                 MyAvatar.goToLocation(myVec, false);
  39.                
  40.             }
  41.            
  42.             if(eventzget.type === "look_to_north"){
  43.                 //print("Look at North!")
  44.                
  45.                 MyAvatar.goToLocation(MyAvatar.position, true,{ x: 0, y: 0, z: 0, w:1 },false);
  46.             }
  47.  
  48.             if(eventzget.type === "look_to_south"){
  49.                 //print("Look at South!")
  50.                 MyAvatar.goToLocation(MyAvatar.position, true,{ x: 0, y: 1, z: 0, w:0 },false);
  51.             }
  52.            
  53.             if(eventzget.type === "look_to_west"){
  54.                 //print("Look at West!")
  55.                 MyAvatar.goToLocation(MyAvatar.position, true,{ x: 0, y: 0.7071068, z: 0, w:0.7071068 },false);
  56.             }
  57.  
  58.             if(eventzget.type === "look_to_east"){
  59.                 //print("Look at East!")
  60.                 MyAvatar.goToLocation(MyAvatar.position, true,{ x: 0, y: 0.7071068, z: 0, w:-0.7071068 },false);
  61.             }          
  62.            
  63.         }
  64.        
  65.     }
  66.    
  67.     tablet.webEventReceived.connect(onWebEventReceivedz);
  68.    
  69.     function cleanup() {
  70.         tablet.removeButton(button);
  71.     }
  72.    
  73.     Script.scriptEnding.connect(cleanup);
  74. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement