Jump to content

Conflicting scripts issue


BEGOCER Lehmann
 Share

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

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

Recommended Posts

So I've got a real strange one of a doozy for y'all.

I've got a truck with a bed mounted turret, each controlled by a different person.  The turret spins and tracks the operators camera, the truck...is a truck nothing too advanced.

The end game is that both should be operated without interference... but that isn't happening.

Somehow, some way the turret operator can drive the truck- the trucks script's are listening to the command inputs of the turret operator. I have a highly talented scripter friend who looked into it, using a script that shows the UUID of the people inputting the commands.

That script showed when the turret operator hit forward (a command not needed in the gun's operation) the truck's script is receiving a command as if the driver was the one who told the truck to go forward.

I really have no literal idea what is going on. The turret script has no conflicting channels, no lines to take control of the arrow keys. Only way I've been able to prevent this is by removing the llTakeControls line which expectedly cut off the controls for whichever script the line was removed from.

I'm not a talented scripter which is a given considering my car script is a horrendous mishmash that in itself shouldn't cause issues but.... scripting...

Not sure if anyones had this arise before as I know of tons of cars with driver/turret combos that can be used together.

Link to comment
Share on other sites

A script can only hold permissions for one person at a time.  If you are using the same script to manage actions by two people, then the permissions for the first person are being lost when the second person gives permission. If that's what is happening -- as I suspect -- then the solution is to separate the two sets of actions into two scripts, preferably in two different prims.  As long as they are in the same linkset, you can pass messages from one to the other as link messages if you need them to share information.

Another way to approach this, if the turret operator does not need to use the arrow keys or WASD to control the turret, is to take care to prevent him from ever being asked for PERMISSION_TAKE_CONTROLS.  The llRequestPermissions function expects the UUID of a specific person.  Just be sure that it's never asking for the turret operator's UUID and that should solve the problem without needing to to divide your script into two.

Link to comment
Share on other sites

In theory 2 scripts can take controls for 2 avatars (one per script) on an object.

But forget about it, it doesnt work. The control inputs become confused.

Another nice bug is in the camera controls which you probably need for the turret. With multiple sitters on an object: if one avatar unsits - all others loose camera controls.

 

Link to comment
Share on other sites

I agree with Rolig's diagnosis.   I'm willing to bet the problem is that the script is requesting permissions from llAvatarOnSitTarget(), which means that if the driver sits first and then the turret operator sits, the turret operator then becomes llAvatarOnSitTarget(), and thus also becomes llGetPermissionsKey() -- the avatar whose permissions the script holds.

You might try playing round llAvatarOnLinkSitTarget() in a single script instead.  

However, it's almost certainly going to be simpler, and probably necessary, to have two scripts, each one holding the correct set of permissions for the appropriate avatar, so the driver can drive and the turret operator can operate the turret.

ETA:  I cannot, however, agree with Nova that having two scripts wouldn't work in practice.   It works perfectly well if the scripts are written correctly.   I think you should be OK if you simply place the appropriate scripts in the driver's seat and the turret operator's seat respectively, and have each script set a sit target for the prim.    It's a couple of months since I last made something like this, so I'd have to check what I did, but I'm pretty sure that's all I needed to do.   You might need to use llAvatarOnLinkSitTarget() to make sure you're getting the perms for the appropriate avatar.

After that, each script  just needs to check in the control event  if the avatar whose control inputs it's receiving is llGetPermissionsKey() before it processes them.

Link to comment
Share on other sites

I gotta read stuff before I post...WOOPS

I meant to add that there are two separate objects, the drivers seat contains the driving script and assorted mod controllers.

And the turret is in the bed that the gunner can sit on which in itself contains the firing script.

I have a friends truck that when you drop the turret script onto it, it works just fine though which is why I'm a little lost at why mine is being a bugger.

But the vehicle it works fine with is a hodgepodge of way more advanced scripts to what I'm using (it uses raycast and what not but still has the permission requests and take control areas).

I've seen it work in similar cases which is comforting to know its possible but it's just beyond what I'm capable of with scripting (It requires talent).

I do know that the PERMISSIONS for the camera are different as there is PERMISSION_CONTROL_CAMERA for the truck and PERMISSION_TRACK_CAMERA as the object you sit on rotates to track your camera, whilst making a second part tilt up and down separately, creating a hinged turret effect.

I bloody hate scripting... I spent about 8 hours reworking a new car script that's a better update as I thought the turret worked fine with it but IT DON'T!

 

 

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...