Scrit for SL
loop2detect(string szWhy,integer iNum) {
key idKey;
integer iTmp;
for(iTmp=0;iTmp<iNum;iTmp++) {
idKey=llDetectedKey(iTmp);
llOwnerSay(szWhy+" with "+llKey2Name(idKey));
}
}
loopFromCollision(string szWhy,integer iNum) {
key idKey;
integer iTmp;
for(iTmp=0;iTmp<iNum;iTmp++) {
idKey=llDetectedKey(iTmp);
llOwnerSay(szWhy+" with "+llKey2Name(idKey)+" belonging to "+llKey2Name(llGetOwnerKey(idKey)));
}
}
newlocation(string szEvent) {
llOwnerSay("I am now at "+(string)llGetPos()+" with a rot of "+(string)llGetRot()+" because event "+szEvent);
}
rezObject() {
integer iNum=llGetInventoryNumber(INVENTORY_OBJECT);
while(iNum) { // rez by the end to win a variable
string szObject=llGetInventoryName(INVENTORY_OBJECT,--iNum); // match the last object with its pos first
// param is a random number != 0 to make the difference by the 0 from Inventory rezing
llRezObject(szObject, llGetPos() + <0.0, 0.0, 0.5>, ZERO_VECTOR, ZERO_ROTATION,(integer)llFrand(30)+1);
}
}
default
{
state_entry() {
llSay(0, "Hello, Avatar!");
//needed for llAvatarOnSitTarget to work. The vectors components must not all be set to 0
llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
llOwnerSay("I start with the parameter "+(string)llGetStartParameter());
llListen(PUBLIC_CHANNEL,"",llGetOwner(),""); // hear public channel to trigger listen event
}
moving_start() { newlocation("moving_start"); }
moving_end() { newlocation("moving_end"); }
on_rez(integer iParam) {
llOwnerSay("on_rez with param="+(string)iParam);
llOwnerSay("Be care I act it the state of the object is when taken");
}
listen(integer iChan,string szName,key id,string szMsg) {
llOwnerSay("Listen Event:"+(string)iChan+" "+szName+" id="+(string)id+" says "+szMsg);
}
touch_start(integer iNum) { loop2detect("Touch_start",iNum); }
touch(integer iNum) { loop2detect("Touch",iNum); }
touch_end(integer iNum) { loop2detect("Touch_end",iNum); }
collision_start( integer iNum ) { loopFromCollision("collision_start",iNum); }
collision( integer iNum ) { loopFromCollision("collision",iNum); }
collision_end( integer iNum ) { loopFromCollision("collision_end",iNum); }
changed(integer iFlag) //reset script if inventory iFlags
{
llOwnerSay("Change event with "+(string)iFlag);
//note that it's & and not &&... it's bitwise!
if (iFlag & CHANGED_INVENTORY) {
llOwnerSay("The inventory has changed.");
rezObject();
}
if (iFlag & CHANGED_COLOR) llOwnerSay("The color or alpha changed.");
if (iFlag & CHANGED_SHAPE) llOwnerSay("The prims shape has changed.");
if (iFlag & CHANGED_SCALE) llOwnerSay("The prims size has changed.");
if (iFlag & CHANGED_TEXTURE) llOwnerSay("The prims texture or texture attributes have changed.");
if (iFlag & CHANGED_LINK) {
key idAvatar;
idAvatar=llAvatarOnSitTarget();
llOwnerSay("The number of links have changed.");
llOwnerSay("The avatar sitting is "+llKey2Name(idAvatar)+" with id="+(string)idAvatar);
}
if (iFlag & CHANGED_ALLOWED_DROP)
llOwnerSay("The inventory has iFlagd as a result of a user without mod permissions dropping an item on the prim and it being allowed by the script.");
if (iFlag & CHANGED_OWNER) llOwnerSay("The owner of the object has changed.");
if (iFlag & CHANGED_REGION) llOwnerSay("The region the object is in has changed.");
if (iFlag & CHANGED_TELEPORT) llOwnerSay("The object has been teleported while attached.");
}
attach(key idUser) { llOwnerSay("Attach on "+llKey2Name(idUser)); }
money(key id,integer iAmount) {
llOwnerSay("Get "+(string)iAmount+" L$ from "+llKey2Name(id));
llOwnerSay("Fictive refund of "+(string)iAmount+" L$ from "+llKey2Name(id));
llOwnerSay("Put this script twice in the box to see how funny it is");
}
state_exit() { llOwnerSay("State exit. Seems I cancel all running llListen() llSetTimerEvent"); }
object_rez(key id) { llOwnerSay("I create the object with id="+(string)id); }
}
I comment all that is not working
loop2detect(string szWhy,integer iNum) {
key idKey;
integer iTmp;
for(iTmp=0;iTmp<iNum;iTmp++) {
idKey=llDetectedKey(iTmp);
llOwnerSay(szWhy+" with "+llKey2Name(idKey));
}
}
loopFromCollision(string szWhy,integer iNum) {
key idKey;
integer iTmp;
for(iTmp=0;iTmp<iNum;iTmp++) {
idKey=llDetectedKey(iTmp);
llOwnerSay(szWhy+" with "+llKey2Name(idKey)+" belonging to "+llKey2Name(llGetOwnerKey(idKey)));
}
}
newlocation(string szEvent) {
llOwnerSay("I am now at "+(string)llGetPos()+" with a rot of "+(string)llGetRot()+" because event "+szEvent);
}
//rezObject() {
// integer iNum=llGetInventoryNumber(INVENTORY_OBJECT);
// while(iNum!=0) { // rez by the end to win a variable
// string szObject=llGetInventoryName(INVENTORY_OBJECT,--iNum); // match the last object with its pos first
// // param is a random number != 0 to make the difference by the 0 from Inventory rezing
// llRezObject(szObject, llGetPos() + <0.0, 0.0, 0.5>, ZERO_VECTOR, ZERO_ROTATION,(integer)16);
// }
//}
integer And(integer iA,integer iB) {
integer iTmp;
for(iTmp=0;iTmp<32;iTmp+=1) {
integer iBitA=iA%2;
integer iBitB=iB%2;
if(iBitA==iBitB) {
if(iBitA!=0) return(TRUE);
}
iA/=2; // remove the bit for next check
iB/=2; // remove the bit for next check
}
return(FALSE);
}
default
{
state_entry() {
llSay(0, "Hello, Avatar!");
//needed for llAvatarOnSitTarget to work. The vectors components must not all be set to 0
llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
//llOwnerSay("I start with the parameter "+(string)llGetStartParameter());
llListen(PUBLIC_CHANNEL,"",llGetOwner(),""); // hear public channel to trigger listen event
}
//moving_start() { newlocation("moving_start"); }
//moving_end() { newlocation("moving_end"); }
//on_rez(integer iParam) {
// llOwnerSay("on_rez with param="+(string)iParam);
// llOwnerSay("Be care I act it the state of the object is when taken");
//}
listen(integer iChan,string szName,key id,string szMsg) {
llOwnerSay("Listen Event:"+(string)iChan+" "+szName+" id="+(string)id+" says "+szMsg);
}
touch_start(integer iNum) { loop2detect("Touch_start",iNum); }
touch(integer iNum) { loop2detect("Touch",iNum); }
touch_end(integer iNum) { loop2detect("Touch_end",iNum); }
//collision_start( integer iNum ) { loopFromCollision("collision_start",iNum); }
//collision( integer iNum ) { loopFromCollision("collision",iNum); }
//collision_end( integer iNum ) { loopFromCollision("collision_end",iNum); }
changed(integer iFlag) //reset script if inventory iFlags
{
llOwnerSay("Change event with "+(string)iFlag);
//note that it's & and not &&... it's bitwise!
if (And(iFlag,CHANGED_INVENTORY)!=0) {
llOwnerSay("The inventory has changed.");
// rezObject();
}
//if (And(iFlag,CHANGED_COLOR)!=0) llOwnerSay("The color or alpha changed.");
//if (And(iFlag,CHANGED_SHAPE)!=0) llOwnerSay("The prims shape has changed.");
//if (And(iFlag,CHANGED_SCALE)!=0) llOwnerSay("The prims size has changed.");
if (And(iFlag,CHANGED_TEXTURE)!=0) llOwnerSay("The prims texture or texture attributes have changed.");
if (And(iFlag,CHANGED_LINK)!=0) {
key idAvatar;
idAvatar=llAvatarOnSitTarget();
llOwnerSay("The number of links have changed.");
llOwnerSay("The avatar sitting is "+llKey2Name(idAvatar)+" with id="+(string)idAvatar);
}
if (And(iFlag,CHANGED_ALLOWED_DROP)!=0)
llOwnerSay("The inventory has iFlagd as a result of a user without mod permissions dropping an item on the prim and it being allowed by the script.");
if (And(iFlag,CHANGED_OWNER)!=0) llOwnerSay("The owner of the object has changed.");
// if (And(iFlag,CHANGED_REGION)) llOwnerSay("The region the object is in has changed.");
// if (And(iFlag,CHANGED_TELEPORT)) llOwnerSay("The object has been teleported while attached.");
}
//attach(key idUser) { llOwnerSay("Attach on "+llKey2Name(idUser)); }
//money(key id,integer iAmount) {
// llOwnerSay("Get "+(string)iAmount+" L$ from "+llKey2Name(id));
// llOwnerSay("Fictive refund of "+(string)iAmount+" L$ from "+llKey2Name(id));
// llOwnerSay("Put this script twice in the box to see how funny it is");
//}
state_exit() { llOwnerSay("State exit. Seems I cancel all running llListen() llSetTimerEvent"); }
//object_rez(key id) { llOwnerSay("I create the object with id="+(string)id); }
}
[/quote]