Advertisement
Guest User

Untitled

a guest
Oct 14th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function interact(event)
  2. {    
  3. var open_today=0;
  4. var hour_correct=0;
  5.  
  6. //what day and time?
  7. var _d=event.block.world.getTempdata().get("day_of_week");
  8. var _h=event.block.world.getTempdata().get("hour");
  9.  
  10. var whichday=1; //tuesday, unless...
  11.  
  12. if (_h==0 || _h==1 || _h==2) //it's after midnight.
  13.   {
  14.   whichday=2; //it's wednesday, since it's after midnight, bruv.
  15.   }
  16.  
  17. open_today = (_d!=whichday); //closed on day 1, Tuesday, and that includes part of Wednesday night.
  18. hour_correct = (_h==0 || _h==1 || _h==2 || _h>=17);
  19.  
  20. if (open_today==1 && hour_correct==1)
  21.   {
  22.   //welcome, everything's cool, use the door or w/e
  23.   }
  24. else
  25.   if (open_today==0)
  26.     {
  27.     event.block.executeCommand('/tellraw @p {"text":"Lil` Nether Tavern is closed on Tuesdays. See you tomorrow."}');
  28.     event.setCanceled(true);
  29.     }
  30.   else //we're open today, but it's the wrong time
  31.     {
  32.     event.block.executeCommand('/tellraw @p {"text":"Lil` Nether Tavern is closed now. Come back between 17:00 and 03:00, excl. Tuesday nights."}');    
  33.     event.setCanceled(true);
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement