User:Jesse Barnett/SandBox Blox

From Second Life Wiki
Jump to navigation Jump to search



//////////////////////////////////////////////////////////////////////////////////////////////////////
//				SandBox Blox Rezzer 1.0
// 				"Dec  4 2008", "22:01:49"
// 				Creator: Jesse Barnett
//				Released into the Public Domain
//////////////////////////////////////////////////////////////////////////////////////////////////////

//Highly addictive and fun to play with
//Inspired by a script by Pedro Mcmillan
//Pedro's script can be found at
//http://www.avid-insight.co.uk/dev/stackable_graph_cube_1.2.lsl

//Drop this script in a 1/2 meter cube prim along with
//a white SandBox Blox
//To use: Touch the red blox to activate
//A white Sandbox Blox will rez above this cube and another will
//rezz a short distance away.
//Touch the white blox that is on top of the rezzor and then touch
//the face of the other white blox where you want this blox to go.
//When blox are active they will turn green
//A new prim will rez whenever one is used
//When you are tired of playing, just touch the red blox
//and all of the white blox will disappear

vector rezOffset = <0,0,1>;
integer dieChan = -7912374;
//The dieChan must be the same as in the SandBlox script
//Please pick your own channels
integer On = 1;

rezObj() {
	llRezObject("SandBox Blox", llGetPos() + rezOffset, ZERO_VECTOR, ZERO_ROTATION, 42);
}

default {
	state_entry() {
		llSetObjectName("SandBox Blox Rezzer");
		llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, "5748decc-f629-461c-9a36-a35a221fe21f",
			<1,1,1>, <0,0,0>, 0, PRIM_COLOR, ALL_SIDES, <1, 0, 0>, 1]);
	}
	touch_start(integer n) {
		if (On) {
			rezObj();
			llSensorRepeat("SandBox Blox", NULL_KEY, SCRIPTED | PASSIVE , 1.1, PI, 1.0);
		}
		else {
			llRegionSay(dieChan, "die");
			llSensorRemove();
		}
		On = !On;
	}
	sensor(integer n) {
	}
	no_sensor() {
		rezObj();
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//				SandBox Blox 2.0
// 				"Dec  4 2008", "20:45:46"
// 				Creator: Jesse Barnett
//				Released into the Public Domain
//////////////////////////////////////////////////////////////////////////////////////////////////////

//Drop this script in a cube prim
//Take it into inventory and then place inside the SandBox Blox Rezzor prim

integer dieChan = -7912374;
//The dieChan must be the same as in the SandBlox Rezzor script
//Please pick your own channels
integer posChan = -6641118;
integer chanRem;
integer faceInt;
vector faceVec;

reset() {
	llSetColor(<1, 1, 1 >, ALL_SIDES);
	llListenRemove(chanRem);
	llSetTimerEvent(0.0);
}

default {
	state_entry() {
		llSetObjectName("SandBox Blox");
		llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f", ALL_SIDES);
		llListen(dieChan, "", "", "die");
	}
	touch_start(integer n) {
		integer i = 0;
		for (; i < n; ++i) {
			faceVec = llDetectedTouchNormal(i);
			faceInt = llDetectedTouchFace(i);
		}
		faceVec *= .5;
		vector setPos = llGetPos() + faceVec;
		llSay(posChan, (string) setPos);
		llSetTimerEvent(5.0);
		llSetColor(<0, 1, 0 >, faceInt);
		chanRem = llListen(posChan, "SandBox Blox", "", "");
	}
	listen(integer channel, string name, key id, string msg) {
		if (channel == dieChan) {
			llDie();
		}
		else if ("stop" != msg) {
			llSetPos((vector)msg);
			llRegionSay(posChan, "stop");
		}
		reset();
	}
	timer() {
		reset();
	}
}