Advertisement
i_makes_stuff

Scriptcraft functions - Minecraft Christmas Tree

Feb 10th, 2015
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var lastHttp = 0;
  2.  
  3. exports.bulbcontrolHttp = function( rest ) {
  4.  
  5. var t = server.getWorld('world').getFullTime();
  6. var delta = t - lastHttp;
  7.  
  8.         if (delta > 60 ){
  9.             lastHttp = t;
  10.             console.log( 'HttpCommand');
  11.             var jsResponse;
  12.             var http = require('../modules/http/request');
  13.             http.request("http://#####################/" + rest,function(responseCode, responseBody){
  14.             jsResponse = eval("(" + responseBody +  ")");
  15.             console.log(jsResponse.return_value);
  16.             });
  17.         }else{
  18.             console.log("too soon");
  19.             server.broadcastMessage("slow down");
  20.             }
  21.    
  22.  
  23. }
  24.  
  25. exports.updatergbHttp = function( msg ) {
  26.     var http = require('../modules/http/request');
  27.     http.request(
  28.     {
  29.         url: "http://########################/updatergb",
  30.         method: 'GET',
  31.         params: {script: msg}
  32.     },
  33.     function( responseCode, responseBody ) {
  34.         var jsObj = eval('(' + responseBody + ')');
  35.         console.log(jsObj.return_value);
  36.     });
  37. }
  38.  
  39.  
  40. exports.pushmsgHttp = function( rest,msg ) {
  41.     var http = require('../modules/http/request');
  42.     http.request(
  43.     {
  44.         url: "http://##############################/" + rest,
  45.         method: 'GET',
  46.         params: {script: msg}
  47.     },
  48.     function( responseCode, responseBody ) {
  49.         var jsObj = eval('(' + responseBody + ')');
  50.         console.log(jsObj.status);
  51.     });
  52. }
  53.  
  54. events.on('player.PlayerJoinEvent', function ( event ) {
  55.    
  56.     if (!event.player.hasPlayedBefore()){
  57.         console.log("New Player Detected");
  58.         pushmsgHttp('pushnotify','New Player Joined - ' + event.player.name);
  59.     }else{
  60.         console.log("Same old folks 3- " + event.player.name);
  61.     }
  62.    
  63.    
  64. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement