Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //at this point only a switch to pivot blocks around a point
- //comparable to igob rotation
- package pivotswitch {
- function portculyswitch::onPickup(%this,%obj,%user,%amount) {
- parent::onPickup(%this,%obj,%user,%amount);
- if(%obj.type==13) {
- doPivot(%obj);
- }
- }
- };
- activatepackage(pivotswitch);
- function testexec() {
- exec("tbm/server/scripts/proswitches.cs");
- }
- function doPivot(%obj) {
- %doorset=%obj.doorset;
- echo(%doorset);
- if (!%doorset)
- return;
- %count = MissionCleanup.getCount();
- for (%i = 0; %i < %count; %i++) {
- %block = MissionCleanup.getObject(%i);
- if (%block.port == %doorset)
- schedule(0,%block,pivot,%block,%obj.rotsav, %obj.direction, %obj.delay, %obj.times);
- }
- }
- function pivot(%obj,%rotation,%origin,%delay,%times) { //mostly taken from igob
- if (!%times) {
- echo("countdown finished");
- return;
- }
- if (isobject(%obj)) {
- echo(%rotation@" "@%origin);
- if (getwords(%rotation,0,1) $= "0 0") {
- echo("rotation done");
- %obj.rotsav = rotaddup(%obj.rotsav, %rotation);
- %theta = (360 - getword(%rotation,2))/90/2*$pi;
- %pos = vectoradd(%obj.position ,vectorscale(%origin, -1));
- %rx = getWord(%pos,0);
- %ry = getWord(%pos,1);
- %rz = getWord(%pos,2);
- %newpos = %rx * mcos(%theta) - %ry * msin(%theta);
- %newpos = %newpos SPC %rx * msin(%theta) + %ry * mcos(%theta);
- %newpos = %newpos SPC %rz;
- }
- %newpos = vectoradd(%newpos, %origin);
- %obj.settransform(%newpos@" "@rotconv(%obj.rotsav));
- }
- schedule(%delay,%obj,pivot,%obj,%rotation,%origin,%delay,%times--);
- }
- //schedule(%delay,%port,rsetport,%port,%direction,%delay,%times--);
Add Comment
Please, Sign In to add comment