Jump to content

Need help combining these 2 scripts please


ChantellexMarie
 Share

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

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

Recommended Posts

Greetings Scripters

OK, I've got the following 2 scripts, both work but need 1 put into the other, and to be used as a hud.

1st is Anti No Script with Controls

2nd is Warp to cam

Anti No Script

//Makes scripts work in no script zones
default
{

 state_entry()
        {
            //This line of code goes into state_entry, or simply make sure it's triggered before you enter a no-script zone.
            llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
        }
 
    //This is the run time permissions event, this is why it works. Put this event anywhere in your script, before, between or after all your other events..
    run_time_permissions(integer perms)
        {
            llTakeControls(CONTROL_BACK, FALSE, TRUE);
        }
}

Warp To Cam

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(),PERMISSION_TRACK_CAMERA);
    }
    touch_start(integer total_number)
    {
        llSetStatus(STATUS_PHYSICS,TRUE);
        llMoveToTarget(llGetCameraPos()+<0,0,1>,0.1);
        llSleep(2);
        llStopMoveToTarget();
        llSetStatus(STATUS_PHYSICS,FALSE);
    }
}

I've been trying to figure it out for weeks now but just can't get it to work, so if anyone could help it would be deeply appreciated.

Merry Christmas

Chantelle xx

Link to comment
Share on other sites

Let's see if you can't fix this one yourself with a couple hints:

  • A script can only use one instance of each type of event handler, but luckily the only event handler common to these scripts is state_entry(), so your new script can simply include the old scripts' run_time_permissions and touch_start handlers as-is.
  • Even luckier, both scripts' state_entry handlers simply call llRequestPermissions, only requesting different permissions. You can instead ask for both permissions at the same time by combining them with a logical OR (" | "), like this:
llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA | PERMISSION_TAKE_CONTROLS);

That should get you a working script combining both the others. As described, it'll consist of a single default state with the combined state_entry handler plus the run_time_permissions and touch_start handlers of the old scripts.

Now... the original scripts could have been improved, so you shouldn't put this combined script in a product for distribution without making some improvements first. (Notably, there's no provision for getting new permissions when a new owner attaches the script, and anyway it's not completely safe to assume permissions have been granted as that touch_start handler does.) We can tackle those problems later if you want other people to use the script inside an object you distribute.

  • Like 2
Link to comment
Share on other sites

8 hours ago, Qie Niangao said:

llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA | PERMISSION_TAKE_CONTROLS);

Hi Qie Niangao,

I really appreciate you giving me the hint to help teach me, figured out where I went wrong.

I had very similar to you, but instead of the | for the or command, I was using a comma, then had 1 too many } at end after the combining of the permissions.

But eventually I followed the syntac errors to correct it all, and finally it saved.

The script is just for myself, but for anyone that wants it, here it is.

Again thank you so much for the lessons, and more so being on christmas day too.

Blessed Be

Chantelle xxx

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA | PERMISSION_TAKE_CONTROLS);
    }
run_time_permissions(integer perms)
    {
            llTakeControls(CONTROL_BACK, FALSE, TRUE);
    }
    touch_start(integer total_number)
    {
        llSetStatus(STATUS_PHYSICS,TRUE);
        llMoveToTarget(llGetCameraPos()+<0,0,1>,0.1);
        llSleep(2);
        llStopMoveToTarget();
        llSetStatus(STATUS_PHYSICS,FALSE);
    }
}

If the above one not work, try this modded one, seems to work better, though a bit hit and miss still.

default
{
    state_entry()
    {
        llReleaseControls();
        llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRACK_CAMERA);
    }
run_time_permissions(integer perms)
    {
            integer hasPerms = llGetPermissions();
            llTakeControls(CONTROL_BACK, TRUE, TRUE);
    }
     touch_start(integer total_number)
    {
        llSetStatus(STATUS_PHYSICS,TRUE);
        llMoveToTarget(llGetCameraPos()+<0,0,1>,0.1);
        llSleep(2);
        llStopMoveToTarget();
        llSetStatus(STATUS_PHYSICS,FALSE);
    }
}

 

Edited by ChantellexMarie
  • Like 1
Link to comment
Share on other sites

Since you mention that it doesn't always work:

It only works if you are wearing the hud BEFORE you enter a no script zone. If you attach it while you are already in a no script zone - it will not work.

To make it work in  a no script zone - fly up 100m - attach it - fly down. The no script zone only goes from ground to about 80m above ground.

Edited by Nova Convair
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1576 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...