llPushObject() - Impulse - Avatar weight
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
04-02-2007 10:04
I'm currently building a bed, and i have done the duvet movable... It brakes free from the link and scales and moves back or forth on push and then links with the bed again at it's new position... Only problem was (is), when someone was (are) standing in the bed the whole bed would (will) move and get out of position because of the moving duvet colliding with the avatar (and setting the duvet to phantom while moving it did not work good all). I have now tried to "solve" this by gently pushing detected avatar up in Z-axis a bit. llPushObject(llDetectedKey(0), <0,0,40.0>, <0,0,0>, FALSE); This works oki for me (it just lifts me a bit over the duvet while it moves), but does it push all avatars with the same force regardless of how big or small they are? The Wiki seems a bit unclear on this matter (it talks about object mass, but not avatar mass). Allso, how do i restrict the push so that it only occurs if the avatar is actually standing/lying on the duvet ifself? As of now, it pushes me a bit even if i stand close beside the bed (not on the duvet).
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|
|
Learjeff Innis
musician & coder
Join date: 27 Nov 2006
Posts: 817
|
04-02-2007 10:59
You might avoid this by making sure the duvet doesn't accept the sit.
First, make sure it's not the root prim (which no doubt you're doing, or the whole bed would move). Second, make sure there IS an explicit (non-default) sit target in the bed somewhere.
This is off the top of my head, and I may have some of the details wrong, but I'm pretty sure you can use the sit target rules to your benefit here.
Also, you might want to consider putting an invisible prim just above the duvet, so folks simply standing on top of the whole bed will be above the duvet. Actually, you could have two of these, one for each side of the bed, for easy sit targets for the default laying position, on a bed big enough.
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
04-02-2007 12:12
From: Learjeff Innis You might avoid this by making sure the duvet doesn't accept the sit. Yes, that would work when the avatar sits on it, but not when the avatar just stands on it. From: Learjeff Innis First, make sure it's not the root prim (which no doubt you're doing, or the whole bed would move). Second, make sure there IS an explicit (non-default) sit target in the bed somewhere.
This is off the top of my head, and I may have some of the details wrong, but I'm pretty sure you can use the sit target rules to your benefit here.
*blush* I had it as root prim in the beginning, but i quickly changed that...  Allso, explicit sit tagets i have, it's two poseballs. From: Learjeff Innis Also, you might want to consider putting an invisible prim just above the duvet, so folks simply standing on top of the whole bed will be above the duvet. Actually, you could have two of these, one for each side of the bed, for easy sit targets for the default laying position, on a bed big enough. That's a very good idea, but i dont think i can do that because i have to have the duvet on top because it has touch script to make/unmake the bed. :| I propably could make the invisible prim whisper to duvet on touch, but i think that it must be another solution available because there's alot of whispering back and fourth between the poseballs and duvet allready. On the other hand, with the invisible prim i can propably eliminate much of the conversation between the poseballs and duvet when the poseball tells the duvet that the bed is in use and the duvet therefor are not allowed to move. Many thanks, i will try this! 
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
04-02-2007 16:25
I dont understand what i do wrong here. This script listen to two messages. One message is the posball that whispers "occupied" if someone sits on it, and "unoccupied" if someone unsits on it (default state sets it to "unoccupied" because i take for granted that noone can sit on an object when it rezzes). The other message is from the invisible prim that i placed over the bed and that prim whispers "move" if touched. (all OwnerSay()'s is only there to make it easier for me to follow what happens.) But it does not work, it moves the duvet one time, in one direction, and if i change the "integer duvet = FALSE;" to "integer duvet = TRUE;" it works one time again when i restart the script. I do get the message "I have instructions to move and have permission to move!" so the conditions must be met. integer duvet = FALSE; integer move; string message;
default{ state_entry(){ occupied = FALSE; move = TRUE; llListen(2, "", NULL_KEY, ""); llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS); }
listen(integer channel, string name, key id, string message){ if(message == "move"){ llOwnerSay("I have instructions to move!"); state moveDuvet; }
}
}
state moveDuvet{ state_entry(){ llListen(2, "", NULL_KEY, ""); vector RootPos = llGetRootPosition(); key ParentKey = llGetLinkKey(1);
if(duvet == FALSE && move == TRUE){ duvet = TRUE; llBreakLink(llGetLinkNumber()); llSetScale(<0.400, 2.082, 0.198>); llSetPos(RootPos + <1.348, 0.000, 0.000> * llGetRot()); llCreateLink(ParentKey, FALSE); llWhisper(2, "show"); }else if(duvet == TRUE && move == TRUE){ duvet =FALSE; llBreakLink(llGetLinkNumber()); llSetScale(<2.200, 2.082, 0.198>); llSetPos(RootPos + <0.448, 0.000, 0.000> * llGetRot()); llCreateLink(ParentKey, FALSE); llWhisper(2, "hide"); }
}
listen(integer channel, string name, key id, string message){ if(message == "unoccupied"){ llOwnerSay("I have instructions to move and have permission to move!"); move = TRUE; }else if(message == "occupied"){ llOwnerSay("I have instructions to move but lack permission to move!"); move = FALSE; } }
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
04-03-2007 07:32
If I'm understanding your intent, and reading the code rght, shouldn't all that code you have in the state_entry of the moveDuvet state actually be in the listen event of the moveDuvet state? Otherwise, once the listen event is fired, I don't see how any other code ever executes.
Rj
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-03-2007 08:05
The code as it stands ties itself in a few knots. Its first listening for a command to move and changes state to moveDuvet where it moves once. After that it stalls as none of the dynamic code is being re-executed. I think what you meant to do was have it only move when in the unoccupied condition? integer duvet = FALSE; integer Move = TRUE; string message;
default { state_entry() { llListen(2, "", NULL_KEY, ""); llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS); }
listen(integer channel, string name, key id, string message) { if("move" == message) { if(MOVE) { llOwnerSay("I have instructions to move and have permission to move!"); vector RootPos = llGetRootPosition(); key ParentKey = llGetLinkKey(1); if(duvet == TRUE) { duvet = FALSE; llBreakLink(llGetLinkNumber()); llSetScale(<2.200, 2.082, 0.198>); llSetPos(RootPos + <0.448, 0.000, 0.000> * llGetRot()); llCreateLink(ParentKey, FALSE); llWhisper(2, "hide"); } else { duvet = TRUE; llBreakLink(llGetLinkNumber()); llSetScale(<0.400, 2.082, 0.198>); llSetPos(RootPos + <1.348, 0.000, 0.000> * llGetRot()); llCreateLink(ParentKey, FALSE); llWhisper(2, "show"); } } else { llOwnerSay("I have instructions to move but lack permission to move!"); } } else if("unoccupied" == message)Move = TRUE; else if("occupied" == message)Move = FALSE; } }
|
|
Margot Schnyder
Generalsekretärin
Join date: 20 Feb 2007
Posts: 14
|
04-03-2007 15:12
Many, many thanks guys!  I tested Newgate's code and it works perfect with some minor modifications.  I had to make the poseballs whisper separate messages otherwise the previously occupied now unoccupied poseball's message about being "unoccupied" overrided the later occupied poseball's "occupied" message ( *phew*  ). I post it here with changes for reference if anyone is interested: integer duvet = FALSE; integer f_Move = TRUE; integer m_Move = TRUE; string message;
default { state_entry() { llListen(2, "", NULL_KEY, ""); llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS); }
listen(integer channel, string name, key id, string message) { if("move" == message) { if(f_Move && m_Move) // Added "&& m_Move { llOwnerSay("I have instructions to move and have permission to move!"); vector RootPos = llGetRootPosition(); key ParentKey = llGetLinkKey(1); if(duvet == TRUE) { duvet = FALSE; llBreakLink(llGetLinkNumber()); llSetScale(<2.200, 2.082, 0.198>); llSetPos(RootPos + <0.448, 0.000, 0.000> * llGetRot()); llCreateLink(ParentKey, FALSE); llWhisper(2, "hide"); } else { duvet = TRUE; llBreakLink(llGetLinkNumber()); llSetScale(<0.400, 2.082, 0.198>); llSetPos(RootPos + <1.348, 0.000, 0.000> * llGetRot()); llCreateLink(ParentKey, FALSE); llWhisper(2, "show"); } } else { llOwnerSay("I have instructions to move but lack permission to move!"); } } else if("f_unoccupied" == message)f_Move = TRUE; else if("f_occupied" == message)f_Move = FALSE; else if("m_unoccupied" == message)m_Move = TRUE; //Added these two conditions else if("m_occupied" == message)m_Move = FALSE; } }
_____________________
"Wir kennen nur ein Ziel, das die gesamte Politik unserer Partei durchdringt: alles zu tun für das Wohl des Menschen, für das Glück des Volkes, für die Interessen der Arbeiterklasse und aller Werktätigen. Das ist der Sinn des Sozialismus. Dafür arbeiten und kämpfen wir."
|