Jump to content

Confused needs help with HUD script


Gregory McLeod
 Share

You are about to reply to a thread that has been inactive for 3796 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have a big favor to ask. I need some help to find out why the attached scripts do not work.

Put all three scripts in a single prim they should co-operate and ask for permission to attach as HUD bottom right and end with message from each that the runtime state is doing other things.

integer    ChecksComplete        = FALSE;
integer    M3ChecksComplete    = FALSE;
integer    U3ChecksComplete    = FALSE;
integer AllChecksComplete    = FALSE;
integer AllChecksCount        = 0;
key     gkPlayer            = NULL_KEY;
float   gfTimeOut            = 60.0;
integer giTimer                = FALSE;

default {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " S3:default state_entry event");
		llSetScriptState("MultiScriptM3",FALSE);
		llSetScriptState("MultiScriptU3",FALSE);
        llOwnerSay((string)llGetUnixTime() + " S3:default "+(string)llGetFreeMemory());
        gkPlayer = llGetOwner();
        llSetTimerEvent(gfTimeOut);
        giTimer = TRUE;
        llRequestPermissions(gkPlayer,PERMISSION_ATTACH);
    }
    run_time_permissions(integer piPerm) {
        if (piPerm & PERMISSION_ATTACH) {
            llOwnerSay((string)llGetUnixTime() + " S3:default r_t_p Permission granted");
            llAttachToAvatar(ATTACH_HUD_BOTTOM_RIGHT);
        }
        else {
            llOwnerSay("Permission not granted.  - DIE");
            llSleep(5.0);
            llDie();
        }
    }
    attach(key pkOwner) {
        llOwnerSay((string)llGetUnixTime() + " S3:default attach event");
        llSetScriptState("MultiScriptM3",FALSE);
        llSetScriptState("MultiScriptU3",FALSE);
        gkPlayer = pkOwner;
        if (pkOwner != NULL_KEY) {
            llOwnerSay((string)llGetUnixTime() + " S3:default:attach S3 OK");
            llSetTimerEvent(gfTimeOut);
            giTimer = TRUE;
            llSetScriptState("MultiScriptM3",TRUE);
            llSetScriptState("MultiScriptU3",TRUE);
            state Runtime;
        }
        else {
            llOwnerSay((string)llGetUnixTime() + " S3:default:attach S3 FAIL");
            state Detach;
        }
    }
    timer() {
        if (giTimer) {
            llOwnerSay((string)llGetUnixTime() + " S3:default timed out waiting on " 
                + "permission to attach");
            llDie();
        }
    }
}
state Runtime {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " S3:Runtime state_entry event");
        llMessageLinked(LINK_THIS,0,"S3ChecksComplete",gkPlayer);
    }
    attach(key pkOwner) {
        llOwnerSay((string)llGetUnixTime() + " S3:Runtime attach event");
        if (pkOwner == NULL_KEY) {
            llOwnerSay((string)llGetUnixTime() + " S3:Runtime attach null-key");
            state Detach;
        }
        else {
            gkPlayer = pkOwner;
            llOwnerSay((string)llGetUnixTime() + " S3:Runtime waiting");
        }
    }
    link_message(integer piSender, integer piData, string psData, key pkID) {
        llOwnerSay((string)llGetUnixTime() + " S3:Runtime link_message-event");
        llOwnerSay((string)llGetUnixTime() + " S3:Runtime link_message data " + psData);
        if (psData == "DETACH") {
            llOwnerSay((string)llGetUnixTime() + " S3:Runtime DETACH message received");
            state Detach;
        }
        if (psData == "M3ChecksComplete") {
            llOwnerSay((string)llGetUnixTime() + " S3:Runtime M3ChecksComplete message received");
            M3ChecksComplete = TRUE;
        }
        if (psData == "U3ChecksComplete") {
            llOwnerSay((string)llGetUnixTime() + " S3:Runtime U3ChecksComplete message received");
            U3ChecksComplete = TRUE;
        }
        if (M3ChecksComplete & U3ChecksComplete) {
            AllChecksComplete = TRUE;
            AllChecksCount++;
            if (AllChecksComplete & (AllChecksCount < 2)) {
                llMessageLinked(LINK_THIS,0,"AllChecksComplete",gkPlayer);
            }
        }
        else llOwnerSay((string)llGetUnixTime() + " S3:Runtime doing other things");
    }
    touch_start(integer number) {
        llOwnerSay((string)llGetUnixTime() + " S3: touched in Runtime state");
    }
}
state Detach {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " S3:Detach state_entry event");
        llSetTimerEvent(0.0);
        integer liPerms = llGetPermissions();
        if (liPerms & PERMISSION_ATTACH) {
            llOwnerSay((string)llGetUnixTime() + " S3:Detach s_e liPerms " + (string)liPerms);
            llSetForce(ZERO_VECTOR,TRUE);
            llOwnerSay((string)llGetUnixTime() + " S3:Detach s_e Detaching!");
            llDetachFromAvatar();
        }
		else llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);
    }
    run_time_permissions(integer piPermissions) {
        if ((piPermissions & PERMISSION_ATTACH) != 0) {
            llOwnerSay((string)llGetUnixTime() + " S3:Detach r_t_p Detaching");
            llDetachFromAvatar();
        }
    }
    attach(key pkOwner) {
        llOwnerSay((string)llGetUnixTime() + " S3:Detach attach event");
        if (pkOwner == NULL_KEY) {
            llOwnerSay((string)llGetUnixTime() + " S3:Detach attach null-key resetting script");
            llResetScript();
        }
		else state default;
    }
}

 

integer	S3ChecksComplete    = FALSE;
integer	AllChecksComplete	= FALSE;
key		gkPlayer            = NULL_KEY;
float	gfTimeOut           = 60.0;
integer	giTimer             = FALSE;

default {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " M3:default state_entry event");
        llOwnerSay((string)llGetUnixTime() + " M3:default "+(string)llGetFreeMemory());
        gkPlayer = llGetOwner();
        llOwnerSay((string)llGetUnixTime() + " M3:default Game data set up!");
    }
    attach(key pkOwner) {
        llOwnerSay((string)llGetUnixTime() + " M3:default attach event");
        if (pkOwner != NULL_KEY) {
            llOwnerSay((string)llGetUnixTime() + " M3:default Game data set up!");
            llSetTimerEvent(gfTimeOut);
            giTimer = TRUE;
        }
        else {
            llOwnerSay((string)llGetUnixTime() + " M3:default Invalid game data!");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
    link_message(integer piSender, integer piData, string psData, key pkID) {
        llOwnerSay((string)llGetUnixTime() + " M3:default link_message-event");
        llOwnerSay((string)llGetUnixTime() + " M3:default link_message data " + psData);
        if (psData == "S3ChecksComplete") {
            llOwnerSay((string)llGetUnixTime() + " M3:default S3ChecksComplete message received");
            S3ChecksComplete = TRUE;
            llSetTimerEvent(0.0);
            state Initialize;
        }
        else llOwnerSay((string)llGetUnixTime() + " M3:default waiting for S3ChecksComplete message");
    }
    timer() {
        if (giTimer) {
            llOwnerSay((string)llGetUnixTime() + " M3:default timed out waiting on " 
                + "S3CheckComplete message");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
}
state Initialize {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " M3:Initialize state_entry event");
        llOwnerSay((string)llGetUnixTime() + " M3:Initialize doing other things");
        llMessageLinked(LINK_THIS,0,"M3ChecksComplete",gkPlayer);
    }
    link_message(integer piSender, integer piData, string psData, key pkID) {
        llOwnerSay((string)llGetUnixTime() + " M3:Initialize link_message-event");
        llOwnerSay((string)llGetUnixTime() + " M3:Initialize link_message data " + psData);
        if (psData == "AllChecksComplete") {
            llOwnerSay((string)llGetUnixTime() + " M3:Initialize AllChecksComplete message received");
            AllChecksComplete = TRUE;
            state Runtime;
        }
        else llOwnerSay((string)llGetUnixTime() + " M3:Initialize waiting for AllChecksComplete message");
    }
    timer() {
        if (giTimer) {
            llOwnerSay((string)llGetUnixTime() + " M3:Initialize timed out waiting on " 
                + "AllCheckComplete message");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
}
state Runtime {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " M3:Runtime state_entry event");
        llOwnerSay((string)llGetUnixTime() + " M3:Runtime doing other things");
    }
    attach(key pkAvatar) {
        llOwnerSay((string)llGetUnixTime() + " M3:Runtime attach event");
        if (pkAvatar == NULL_KEY) {
            llOwnerSay((string)llGetUnixTime() + " M3:Runtime attach null-key");
        }
        else {
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
    touch_start(integer number) {
        llOwnerSay((string)llGetUnixTime() + " M3: touched in Runtime state");
    }
    timer() {
        if (giTimer) {
            llOwnerSay((string)llGetUnixTime() + " M3:default timed out waiting on " 
                + "S3CheckComplete message");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
}

 

integer	S3ChecksComplete    = FALSE;
integer	AllChecksComplete	= FALSE;
key		gkPlayer            = NULL_KEY;
float	gfTimeOut           = 60.0;
integer	giTimer             = FALSE;

default {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " U3:default state_entry event");
        llOwnerSay((string)llGetUnixTime() + " U3:default "+(string)llGetFreeMemory());
        gkPlayer = llGetOwner();
        llOwnerSay((string)llGetUnixTime() + " U3:default Game data set up!");
    }
    attach(key pkOwner) {
        llOwnerSay((string)llGetUnixTime() + " U3:default attach event");
        if (pkOwner != NULL_KEY) {
            llOwnerSay((string)llGetUnixTime() + " U3:default Game data set up!");
            llSetTimerEvent(gfTimeOut);
            giTimer = TRUE;
        }
        else {
            llOwnerSay((string)llGetUnixTime() + " U3:default Invalid game data!");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
    link_message(integer piSender, integer piData, string psData, key pkID) {
        llOwnerSay((string)llGetUnixTime() + " U3:default link_message-event");
        llOwnerSay((string)llGetUnixTime() + " U3:default link_message data " + psData);
        if (psData == "S3ChecksComplete") {
            llOwnerSay((string)llGetUnixTime() + " U3:default S3ChecksComplete message received");
            S3ChecksComplete = TRUE;
            llSetTimerEvent(0.0);
            state Initialize;
        }
        else llOwnerSay((string)llGetUnixTime() + " U3:default waiting for S3ChecksComplete message");
    }
    timer() {
        if (giTimer) {
            llOwnerSay((string)llGetUnixTime() + " U3:default timed out waiting on " 
                + "S3CheckComplete message");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
}
state Initialize {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " U3:Initialize state_entry event");
        llOwnerSay((string)llGetUnixTime() + " U3:Initialize doing other things");
        llMessageLinked(LINK_THIS,0,"U3ChecksComplete",gkPlayer);
    }
    link_message(integer piSender, integer piData, string psData, key pkID) {
        llOwnerSay((string)llGetUnixTime() + " U3:Initialize link_message-event");
        llOwnerSay((string)llGetUnixTime() + " U3:Initialize link_message data " + psData);
        if (psData == "AllChecksComplete") {
            llOwnerSay((string)llGetUnixTime() + " U3:Initialize AllChecksComplete message received");
            AllChecksComplete = TRUE;
            state Runtime;
        }
        else llOwnerSay((string)llGetUnixTime() + " U3:Initialize waiting for AllChecksComplete message");
    }
    timer() {
        if (giTimer) {
            llOwnerSay((string)llGetUnixTime() + " U3:Initialize timed out waiting on " 
                + "AllCheckComplete message");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
}
state Runtime {
    state_entry() {
        llOwnerSay((string)llGetUnixTime() + " U3:Runtime state_entry event");
        llOwnerSay((string)llGetUnixTime() + " U3:Runtime doing other things");
    }
    attach(key pkAvatar) {
        llOwnerSay((string)llGetUnixTime() + " U3:Runtime attach event");
        if (pkAvatar == NULL_KEY) {
            llOwnerSay((string)llGetUnixTime() + " U3:Runtime attach null-key");
        }
        else {
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
    touch_start(integer number) {
        llOwnerSay((string)llGetUnixTime() + " U3: touched in Runtime state");
    }
    timer() {
        if (giTimer) {
            llOwnerSay((string)llGetUnixTime() + " U3:default timed out waiting on " 
                + "S3CheckComplete message");
            llMessageLinked(LINK_THIS,0,"DETACH",gkPlayer);
        }
    }
}

 the scripts are MultiScriptS3, MultiScriptM3, and MultiScriptU3.

Thanks in advance for any help

Link to comment
Share on other sites

If permission to attach is not given you are correct it dies - expected action.

The script S3 is meant to attach the prim to the HUD position bottom right and then signal to the other scripts that it has completed that. It initially stops the other two scripts until this has been done.

The other two scripts are then started before the message to them is sent.

They then will 'do other things' meaning that part of the script is not yet coded but they will eventually have sections which in M3 will get permissions to animate and or control the avatar and in U3 will manage the user interface send and receive messages and commands to and from the Avatar.

I expected the scripts initially to run asynchronously which is why the stopping and restarting of the scripts was coded.

What I observe happening is the following

If the prim is rezzed on the ground and the scripts recompiled they seem to be compiled ok but never in the same oreder twice.

If the prim is reszzed on the ground and the scripts initially compiled in the non running state and then reset the S3 script asks for permission to ATTACh and if given OK continues as do the others but I never get the message from the S3 script that it is 'doing other things' which should be the same as the other two.

However if I then detach from self and try to 'wear' it it stops I think because it is not being attached as HUD. If instead I attach as HUD borttom right it seems to work except it does not repeat a second time. I cannot get a consistent execution to enable me to debug the code.

I hope that helps you to help me further

Thanks for your input.

Link to comment
Share on other sites

After resetting the "allow attachment dialog" pops up.

Clicking 'yes' results in a lot of ownersay spam, a couple of "Could not find script MultiScriptxx" and a attached box.
Touching the attached box gives this:

[12:50] Object: 1389387016 M3: touched in Runtime state
[12:50] Object: 1389387016 U3: touched in Runtime state
[12:50] Object: 1389387016 S3: touched in Runtime state

 

Link to comment
Share on other sites

After finally having read what you are trying to do, or atleast what I think it is that you are trying to do, I have to ask this: why not keep it simple?

Have 1 script to handle the attaching, checcking and 'touch interacting' stuff.
Have another to do the animation stuff.
And the last for the avatar communications.

Use link messages to communicat between the scripts.

Kinda like this is what I mean: 

Script 1

default {    state_entry() {        llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);        llSetTimerEvent(10.0);    }    run_time_permissions(integer perm) {        llSetTimerEvent(.0);        if (perm & PERMISSION_ATTACH) llAttachToAvatar(38);        else llDie();    }        attach(key id) {        if (id) llMessageLinked(LINK_SET, 1, "ATTACHED", "");        else {            llMessageLinked(LINK_SET, 1, "DETACHED", "");            llSetTimerEvent(5.0);        }        }        touch_end(integer num) {        llMessageLinked(LINK_SET, 1, "TOUCHED", "");    }            timer() {        llDie();    }                on_rez(integer rez) {        if (!llGetAttached()) llResetScript();    }      }

 

Script 2 and 3

default {    link_message(integer linknum, integer num, string message, key id) {        if (message == "ATTACHED") {            // do stuff        }        if (message == "DETACHED") {            // do some cleanup stuff        }        if (message == "TOUCHED") {            // do stuff        }    }}

 

I think the above scripts do what you want without all the confusing multiple events and states.

Link to comment
Share on other sites

Not sure where to start on this one except to agree with both Steph and Ron and say your initial start is so overly complex it's nearly impossible to proceed. So, the first thing we need to do is simplify everything. At least to the point that one can follow the programs' execution without having to go through a lot of clutter not related to the logic flow. Only then can we actually begin to check the logic of it all.

First thing, get rid of all those debugging lines with "llOwnerSay()" in them. Though it can be a very useful tool to track what is happening, when 50% of your code is devoted to them, you're not going to be able to effectively read the code itself. Also, you'll spend way too much time sorting through all those chat messages you generate each time you run things. I never use more than 3 such debug lines in my code, moving them around to different places as needed. 

Next, examine the use of your global variables. Though you have quite a handful in each of your programs, only 3 are needed- gfTimeOut throughout all of the programs (but only as a convenience in case you decide to change the timer() at some point) and, in S3, the variables M3ChecksComplete and U3ChecksComplete. But even those last 2 shouldn't be globally declared, they're both only used once within S3 > Runtime > link_message and should be local to that event handler.

Now, by its use, I do see why you have giTimer- you figure that the timer() will be used at some point for other reasons as well and you'll need a way to distinguish what triggered it. However, this is actually the wrong approach, you're prematurely declaring variables. As a general rule, you'll write much tighter code if you write the action first, see what variables were required and then write the declarations of any new ones. This keeps you focused on what is being accomplished right now instead of trying to anticipate what may happen later as well as keeping unnecessary clutter out of what you're having to deal with at any given time. And you really must de-clutter things here to see where things are going astray.

But get rid of ChecksComplete (never used anyway), gkPlayer (though set twice, plays no real role), AllChecksCount (incremented once, unnecessarily) and both S3ChecksComplete and AllChecksComplete (which, though set to TRUE, never are checked).

Now observe the two lines in S3 that inactivate the other two scripts. They appear twice, once in state_entry() and again in attach(). But one can't get to that second spot without having gone through the first, which makes the second occurrence redundant clutter, so remove them as well.

Still unsatisfied, I next POOF! as many solitary curly braces as possible, the empty event handlers left over without a llOwnerSay() to fill them and tighten things up a bit more. You really want to get things to the point so at least a state can be entirely visible to the reader without having to scroll.

And then add comments to the de-cluttered version on what you're expecting to happen at each point. Without this documentation, you'll never figure out where it's taking the wrong turn(s). Keep your code tight, be loose with comments.

Let me show the result of this de-cluttering, to which I've added some comments of things that immediately pop out on a first scan through.

 

// MultiScriptS3float   gfTimeOut            = 60.0;default {    state_entry() {        // This does NOT reset the other scripts.	llSetScriptState("MultiScriptM3",FALSE);	llSetScriptState("MultiScriptU3",FALSE);        llSetTimerEvent(gfTimeOut);        llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);    }    run_time_permissions(integer piPerm) {        if (piPerm & PERMISSION_ATTACH)            llAttachToAvatar(ATTACH_HUD_BOTTOM_RIGHT);        else             llDie();    }    attach(key pkOwner) {        if (pkOwner != NULL_KEY) { // you've been attached            llSetTimerEvent(gfTimeOut);     // No idea why you'd want to do this???            llSetScriptState("MultiScriptM3",TRUE);            llSetScriptState("MultiScriptU3",TRUE);            state Runtime;        }        else            state Detach;    }    timer() { // No permission granted within time limit, so...            llDie();    }}state Runtime {    state_entry() {        llMessageLinked(LINK_THIS,0,"S3ChecksComplete",NULL_KEY);    }    attach(key pkOwner) {        if (pkOwner == NULL_KEY) // you've been detached            state Detach;    }    link_message(integer piSender, integer piData, string psData, key pkID) {        integer    M3ChecksComplete    = FALSE;        integer    U3ChecksComplete    = FALSE;                if (psData == "DETACH")            state Detach;        else if (psData == "M3ChecksComplete")            M3ChecksComplete = TRUE;        else if (psData == "U3ChecksComplete")            U3ChecksComplete = TRUE;                    if (M3ChecksComplete & U3ChecksComplete)             llMessageLinked(LINK_THIS,0,"AllChecksComplete",NULL_KEY);    }}// You'll arrive here if you've either been detached or if a "DETACH" link_message has been received.state Detach {    state_entry() {        llSetTimerEvent(0.0);        if (llGetPermissions() & PERMISSION_ATTACH) {            llSetForce(ZERO_VECTOR,TRUE);            llDetachFromAvatar();        }		else llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);    }    run_time_permissions(integer piPermissions) {        // hmmm, if you're given permissions then you're going to detach from the avatar???        if ((piPermissions & PERMISSION_ATTACH) != 0)            llDetachFromAvatar();    }    attach(key pkOwner) {        if (pkOwner == NULL_KEY) // you've been detached            llResetScript();		else            state default;    // No difference to llResetScript(); at this stage    }}

 

// MultiScriptM3float	gfTimeOut           = 60.0;default {    /* HUH??? I thought you said this script was meant to      "get permissions to animate and or control the avatar".    Are you certain you also want it to be involved with the attaching    and detaching of the object as well? And what's with all the "DETACH"     I see here. Are you certain it's messaging that correctly each time? */    attach(key pkOwner) {        if (pkOwner != NULL_KEY) // you've been attached            llSetTimerEvent(gfTimeOut);        else            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }        link_message(integer piSender, integer piData, string psData, key pkID) {        if (psData == "S3ChecksComplete") {            llSetTimerEvent(0.0);           // NOTE: timer() is turned OFF here!            state Initialize;        }    }        timer() {            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }}state Initialize {    state_entry() {        llMessageLinked(LINK_THIS,0,"M3ChecksComplete",NULL_KEY);    }    link_message(integer piSender, integer piData, string psData, key pkID) {        if (psData == "AllChecksComplete")            state Runtime;    }    timer() {                       // this event will never be triggered        llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }}state Runtime {    attach(key pkAvatar) {        if (pkAvatar != NULL_KEY) // you've been attached            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }    timer() {                       // this event will never be triggered        llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }}

 

// MultiScriptU3float	gfTimeOut           = 60.0;default {    /* HUH??? I thought you said this script was meant to      "manage the user interface send and receive messages and commands".    Are you certain you also want it to be involved with the attaching    and detaching of the object as well? And what's with all the "DETACH"     I see here. Are you certain it's messaging that correctly each time? */    attach(key pkOwner) {        if (pkOwner != NULL_KEY) // you've been attached            llSetTimerEvent(gfTimeOut);        else            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }    link_message(integer piSender, integer piData, string psData, key pkID) {        if (psData == "S3ChecksComplete") {            llSetTimerEvent(0.0);           // NOTE: timer() is turned OFF here!            state Initialize;        }    }    timer() {            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }}state Initialize {    state_entry() {        llMessageLinked(LINK_THIS,0,"U3ChecksComplete",NULL_KEY);    }    link_message(integer piSender, integer piData, string psData, key pkID) {        if (psData == "AllChecksComplete")            state Runtime;    }    timer() {                       // this event will never be triggered            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }}state Runtime {    attach(key pkAvatar) {        if (pkAvatar != NULL_KEY) // you've been attached            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }    timer() {                       // this event will never be triggered            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);    }}

 

 

Link to comment
Share on other sites

I still can not get my head around all these state changes. 

added: tried to get some were with one script, but dam hard when not know what it inteded to do. The more it compressed, the more 1/2 of it has no use.

ADDED: Unless i thick, this is what all those scripts are doing.

// MultiScriptS3float   gfTimeOut            = 60.0;default{	state_entry()	{		llSetTimerEvent(gfTimeOut);		llRequestPermissions(llGetOwner(),PERMISSION_ATTACH);	}	run_time_permissions(integer piPerm)	{		if (piPerm & PERMISSION_ATTACH)		{			llAttachToAvatar(ATTACH_HUD_BOTTOM_RIGHT);		}		else		{			llDie();		}	}	attach(key pkOwner)	{		if (pkOwner)		{			integer test = llGetAttached();			if(test)			{ // you've been attached				llOwnerSay("OBJECT ATTACHED");			}			else//not attached anyway			{				return;			}		}	}	link_message(integer piSender, integer piData, string psData, key pkID)	{		if (psData == "DETACH")		{			llSetTimerEvent(0.0);			llDetachFromAvatar();			llSleep(1.0);			llResetScript();		}		else		{			return;		}	}	timer()	{ // No permission granted within time limit, so...		llDie();	}}

 

 

 

 

 

 

Link to comment
Share on other sites

@Ron Khondji

Thank you for your thoughts and reply.

In fact the three scripts set out to do exactly what you suggested.

MultiScriptS3 is the one that does the attaching and detachs if permission is not granted. It also communicates with a website to confirm that the version of the HUD is the correct one and detach if not after sending a new one of the latest version. It also performs a check that the player(user) is registered by further communication with the website it checks that the player is known what functions they can perform and that they are not using an 'alt' by reference to a table held on the website.

MultiscriptM3 is the one that will do all the animating and control functions. As such it needs to request permission to animate and control the avatar detaching if permission not granted.

MultiScriptU3 is the one that will do the interfacing with the user.

A problem arises if the user does not permit the animation and control functions. This must cause detaching.

The same problem exists to a lesser extent in the the third script.

Now examine the effect of the following scenario.

1. All the scripts execute correctly.

2. The player does what they came to do and then detachs the HUD from themselves. This will leave the HUD in the state that it reached, the running state.

3. When the HUD is again 'worn' or 'attached' it must redo the checks that were done the firast time by Script S3

 

It is the problem of ensuring that the other scripts are in a  compatible state to restart. Remembering that the second script M3 may have to cause a detach event.

My work on this leads me to believe that with all the possibilities of which state the scripts are in when detached they must be reset so that the crosschecking can be done again.

I hope this might help to explain my problem and confusion.

Link to comment
Share on other sites

@LepreKhaun

Thank you for your help and input.

Points on your content

1. The many too many llOwnerSay lines weree put in after I was having a terrible time determining why it wasn't working. I agree 90% or more of them could be eliminated.

2. <quote>Now observe the two lines in S3 that inactivate the other two scripts. They appear twice, once in state_entry() and again in attach(). But one can't get to that second spot without having gone through the first, which makes the second occurrence redundant clutter, so remove them as well.</quote>

This has been done in the version I have now which is working as expected withe help received earlier.

3. <quote>/* HUH??? I thought you said this script was meant to 
    "get permissions to animate and or control the avatar".
    Are you certain you also want it to be involved with the attaching
    and detaching of the object as well? And what's with all the "DETACH"
    I see here. Are you certain it's messaging that correctly each time? */ </quote>

These have been working correctly but have all now been removed. I was under the wrong impression that should not request permission to attach in any other script than the first. It seems that is wrong. My bad.

 4. <quote> timer() {                       // this event will never be triggered
            llMessageLinked(LINK_THIS,0,"DETACH",NULL_KEY);</quote>

Absolutely correct I forgot to remove it when I changed the approach. With so much happeneing at different time and different sequences each time I try the scripts I felt it was necessary to stop timer events happening willy-nilly so cut a lot of them out but forgot to remove the timer event.

 

Thanks again for your patience and help.

Link to comment
Share on other sites

@LeprKhan reply timed at 1-10-2014 7.21 pm

I tried your version of the scripts which run but after I had added something to let me see which scripts were running I found only the MultiScriptS3 was running. This is not a criticism but a fact to prevent others trying it.

I have a version which works but it still has all the documenting llOwnerSay s in it so I wount burden you all with re-pasting it.

I have now moved on to modifications to implement the actual tasks that the scripts are meant to do. Also modification of my one is necessary to overcome a failing 'it does restart correctly'.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3796 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...