daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //at this point only a switch to pivot blocks around a point
  2. //comparable to igob rotation
  3.  
  4. package pivotswitch {
  5.  
  6. function portculyswitch::onPickup(%this,%obj,%user,%amount) {
  7.     parent::onPickup(%this,%obj,%user,%amount);
  8.     if(%obj.type==13) {
  9.         doPivot(%obj);
  10.     }
  11.    
  12.     }
  13.  
  14. };
  15.  
  16. activatepackage(pivotswitch);
  17.  
  18. function testexec() {
  19.     exec("tbm/server/scripts/proswitches.cs");
  20. }
  21.  
  22. function doPivot(%obj) {
  23.   %doorset=%obj.doorset;
  24.   echo(%doorset);
  25.   if (!%doorset)
  26.     return;
  27.   %count = MissionCleanup.getCount();
  28.   for (%i = 0; %i < %count; %i++) {
  29.     %block = MissionCleanup.getObject(%i);
  30.     if (%block.port == %doorset)
  31.       schedule(0,%block,pivot,%block,%obj.rotsav, %obj.direction, %obj.delay, %obj.times);
  32.     }
  33. }
  34.  
  35. function pivot(%obj,%rotation,%origin,%delay,%times) {  //mostly taken from igob
  36.    
  37.     if (!%times) {
  38.         echo("countdown finished");
  39.         return;
  40.     }
  41.     if (isobject(%obj)) {
  42.         echo(%rotation@" "@%origin);
  43.         if (getwords(%rotation,0,1) $= "0 0") {
  44.             echo("rotation done");
  45.             %obj.rotsav = rotaddup(%obj.rotsav, %rotation);
  46.             %theta = (360 - getword(%rotation,2))/90/2*$pi;
  47.             %pos = vectoradd(%obj.position ,vectorscale(%origin, -1));
  48.             %rx = getWord(%pos,0);
  49.             %ry = getWord(%pos,1);
  50.             %rz = getWord(%pos,2);
  51.             %newpos = %rx * mcos(%theta) - %ry * msin(%theta);
  52.             %newpos = %newpos SPC %rx * msin(%theta) + %ry * mcos(%theta);
  53.             %newpos = %newpos SPC %rz;
  54.         }
  55.         %newpos = vectoradd(%newpos, %origin);
  56.         %obj.settransform(%newpos@" "@rotconv(%obj.rotsav));
  57.     }
  58.     schedule(%delay,%obj,pivot,%obj,%rotation,%origin,%delay,%times--);
  59. }
  60.  
  61. //schedule(%delay,%port,rsetport,%port,%direction,%delay,%times--);
RAW Paste Data
Top