01-09-2006 06:41
Hi,

I have been trying to position an attachment via scripting and for the hell of me cant see why its not working.

Basically all I do is, when its attached I get the local pos and store it. Then via llSetPos, after a certain command has been typed in chat, set a new position of the attachment and then have it reset back to its original position after a few seconds.

It doesnt seem to change the position, although when i detach and attach it again, the position has changed.

What bothers me is, if i right click edit the object while attached and type the commands, it changes its position in edit mode, once i exit edit mode it doesnt change the position... but it changes in the world, not on the client viewer.

Here is the code :

vector origPos;
integer CMD_CHANNEL = 3;
default {
state_entry() {
integer perms = llGetPermissions() | PERMISSION_ATTACH;
llRequestPermissions(llGetOwner(), perms);
llListen(CMD_CHANNEL,"",llGetOwner(),"";);
}

run_time_permissions(integer perm) {
if (perm & (PERMISSION_ATTACH)) {
llAttachToAvatar(ATTACH_HEAD);
origPos = llGetLocalPos();
llOwnerSay("Original Position";);
}
}

listen(integer channel, string name, key id, string message) {
if(channel == CMD_CHANNEL)
{
// raise object
if(message== "rd1";)
{
llSetPos(origPos + <0.00,0,0.03>;);
}
// reset position
if(message == "rs";) {
llSetPos(origPos);
}
}
}
}

It works sometimes...

I dont know whats up! Anyone who knows please respond.

Regards,
Ewen Troughton