Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help with Linking and scripting

GunCock Boozehound
Registered User
Join date: 23 Sep 2007
Posts: 2
09-24-2007 00:48
I'm working on scripting a piece of pelvis armor with a revolver attached. My goal is to have to be able to command it in chat to position the revolver either in a straight out (erect and ready to fire) or pointed down position (reload). Also, I want to add actual gun scripting to it to make it a firing weapon, but this isn't my primary question here.

My (noobish) approach has been to attach two coppies of the revolver object, one in each position. Then place a script in each prim of the appropriat revolver that either set the alpha to zero or one per my chat command. This works, crudly, and if I want to update the scrips (like say if I want to change the listen channel) I have to redrop them into eact of the 89 primes that make up EACH revolver. This makes me want to pull my hair out.

I found out about the SetLinkAlpha() function and have been trying to get it to do the job. With this approach I hope I can place the script in one parent object and specefy the link numbers (with flow controll) ( like 0-20 for the pelvis piece, 21-109 for the erect revolver, and 110-199 for the reload revolver) to set the alpha.

The problem I'm having is that when I link the 3 main objects, the assigned link numbers are all out of whack and the prims dissapear all hodgepodge like. I mean I have three previously linked objects, I thought that if I link two of these together one of the original objects would contain the beginning of the link set numbers and the second object would continue from there etc. I'm guessing it doesn't work that way.

I'm currently testing posible solutions from these forums, but the learning curve is steep.

Any help would be greatly appreciated solving this problem, or if another approach altogether (like using rotation) seems like a better way to do what I want please explain.

Thanks!
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
09-24-2007 04:19
Unfortunately, since you have armor with the gun attached to it, there really isn't a simple way other than to use alpha to go about this.

What you described as far as linking two linksets together and having the numbers get all jumbled is sadly one of the lovely quirky annoyances of SL. You won't be able to tell what numbers they will have prior to linking them unless you unlink both linksets and select the prims one by one before linking them again.
Buffy Wilder
Registered User
Join date: 12 Jan 2007
Posts: 16
09-24-2007 07:17
Heres a suggestion to hopefully help you. Instead of having a script in each prim have just one script in the root prim that runs through all the prims in the link set and then looks at what the name for that prim is (hint use llGetLinkName)

You can change the names of the prims for the gun in the up position to "up" for example, and the prims for the gun in the down position to "down"

When the script finds a prim named either "up" or "down" it changes the alpha to whatever is required (either shown or hidden) hint use llSetLinkAlpha

This means only one script to worry about, the rest is just getting the names on the prims correct :-)

Buffy

p.s. you can even optimise this further by scanning the prims for there names when the script is started so that it keeps 2 seperate list of prim id's for the prims making up the 2 states of the gun. It is then just a simple case of walking down the lists and using the id's to show one set and hide the other.
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
09-24-2007 10:31
To expand on Buffy's suggestion to use a scripted approach to find this information out...

Really trying to have it poll each time you switch would be slow. The best thing would be to have it output the link #'s for Up and the link #'s for Down so that you can script them with llSetLinkAlpha manually. It will be a lot of work...160 calls of the command each time, but it would be a good bit faster in the end.
GunCock Boozehound
Registered User
Join date: 23 Sep 2007
Posts: 2
09-24-2007 14:05
Thanks for the suggestions guys. Naming the prims seems like an excellent solution. Now I just have to create a script the automatically rename them for me =(. (or perhaps just doing it manually will be faster in the end).

I will probably experiment with both Buffy's and Tiarnalalon's suggestions to speed up the alpha change. Having a fast switch is deffinatly desirable.

I'll post again when with the outcome when I get it figured out.

Thanks again.