Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

New Scripter needs a little help

Cyrus Odets
Registered User
Join date: 5 Oct 2005
Posts: 51
10-14-2005 10:04
Hi,

I'm new to scripting in SL (ugh) and have been reading and reading and reading...trying to get my feet wet and get started and I have a few questions I was hoping someone could help me with or lend me some pointers. My situation is that in my 'first' life I actually am a programmer. I know Java, C++, etc. So programming conventions I'm familiar with. However, my job the past few years has been a COBOL programmer so its rare that I mess with Java/C type stuff. So aside from 'concepts'....my 'practical' knowledge of LSL style coding is pretty sparse. Moreso, I'm a business programmer so the idea of the type of 'stuff' you are scripting in SL is often pretty foreign concepts for me. As such, as I learn, its often more difficult for me as I have to often 'unlearn' what I know to learn the new stuff. Its pretty hard when you code one way (structured) 8 hours a day and then mess with coding another way (OO, event-driven) for 'fun'. hehe.

Anyway, now ya know my situation...on to my questions.

1) If you have an item in SL created by someone else and marked No Copy, No Trans, etc...can you still write scripts that will affect it? I'm a bit confused on this as all the tutorials I've been reading seem to involve placing your script into the object that the script will affect. However, if you can't put something 'in' that object because of its permissions....can you write a script somewhere ELSE to still affect it?

For example. I purchased a 'gun' from a vendor in SL. When I 'wear' the gun it places it in my avatar's hand. What I'd LIKE to be able to do is to build myself a 'holster' and write a script for the gun that would put the gun in the holster as its default attachment point when I 'wear' the gun...and then 'draw' the gun when I activate the script. Could I write the script and place it in the holster instead, and then interract with the holster? Say...for example...in my inventory choose 'wear' for the gun and it places it snug in its holster on my avatar's leg...then....when I want to 'draw' the gun....click on the holster and have the gun pop into my avatar's hand.

2) That same gun I purchased above....has a few custom animations attached to it. I couldn't figure out though, how to actually 'activate' those animations in the game....as they are part of the gun and that gun is no-copy no-modify. I IM'd the seller and asked him how I could activate those animations and he said that I need a special script to activate the animations that are a part of the gun, and I could get that script from another scripter. Any idea what he's talking about, what I need to do, or where I can get it? Can anyone explain this to me?

3) If you have say 10 custom built animations, let say for example...you have 10 custom built dancing animations. Is it possible to write a script that will allow the user to 'fire off' those animations using a menu based interface? For example...in the upper right of the screen you'd get a menu that had a button for each of the 10 dance moves...and the user could then simply 'click' on the move they'd like to perform and it would fire off that animation...or...perhaps hit a 'random' buttom that would randomly cycle through the animations.

4) Similar question to #1 above. If I bought...say...a flamethrower from someone else that is marked no-copy, no-modify....but that flamethrower doesn't have a particle effect and I'd like to create a 'stream of flame' that shoots out from the tip. I can't 'add' a script to the flamethrower because it is no-mod/no-copy....is there a way I can write a script to make the flame effect, store it somewhere else (Like my inventory) and somehow make it know to operate on the flamethrower and make flames shoot from the tip?

5) Is it possible to script the movement/actions of your own avatar? For example...say I want to script my avatar to perform some actions based on scripted decisions. I want my avatar to, depending on his 'state' of 'tired', 'hungry', or 'bored', either A) If tired, Approach and activate a pose ball which puts him in a sleeping pose on his bed, lay down and go to sleep or B) If hungry, Approach and activate a pose ball at his dinner table which makes him animate eating his food or C) If bored, Go to the living room and approach and activate a pose ball which sits him on the couch in front of his TV and turns it on.

Maybe those are some 'odd' questions, but please bear with me as I'm still learning and figuring out what can and cannot be done :)

Thanks!!!!
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
10-14-2005 10:39
1) As far as writing scripts that will affect something... as long as you have modify permissions on the object, you can drop new scripts into it. Even if you don't have mod-rights, you should still be able to see it with a sensor, get it's key, and use some commands on it (I.E make particles target and move towards it, if it's physical you can apply impulse)... For the gun you mention here, I think your best bet would be to make a holster with an invisible, transparent gun in it and an invisible transparent gun that you attach to your hand - and then just make one visible and the other invisible... AFAIK there is no way to make an attachment jump/move to another position, or automatically make something attach unless it's rezzed in world...

2) Check llStartAnimation and llStopAnimation in the wiki - Check in the gun's inventory and see if the animations there have copy enabled... Even though the gun may be no mod, no copy, no transfer, the animations and scripts and anything else inside it may have entirely different permissions.

3) Soitenly. Jah. By all means. Actually, IM me in game and if I can find it I'll toss you an example script that does just this - lets you see the default built-in animations for SL using the menu interface...

4) Hmm, possibly, I think unless someone else has a good solution for this, if I were you, I'd just make my own flamethrower. I mean, you can only attach the flamethrower to one point, and you'd have to attach your "flame thrower detector" item to say, your shoulder, and then make it something invisible that extends into where the actual flamethrower is (so the particles look like they're coming from your purchased flamethrower)... Any way I look at it you'd save yourself a headache by IM'ing the creator and asking them, and if they aren't eager to help you make the modification your looking for I'd recommend trying to make your own.

5) No, because that would be way too much like "The Sims". Heheh, seriously, I don't see why not - your AV would have to be wearing a "bracelet" or attachment of some sort that would check whatever variables, then decide, "Ok, I'm hungry"... Since there's no real way I know of to "force" your AV to walk over to a poseball, you'd have to make the script actually push your AV towards the poseball, and run the "walking" animation... And once you got to the poseball, since there's no script command to force your AV to sit there, you'd have to do away with the poseball and maybe have a sensor or collision detection routine that says, "Am I in range of the bed? Is my AV tired?" and then instead the poseball animating you, the bracelet would move you to the bed and make you run the sleep animation.

In other words, everything you mention in #5 seems doable to me EXCEPT the 'activate poseball' part - I think you'd need to work around that by putting the actual animation into the bracelet.
Arito Cotton
Still Addicted
Join date: 25 Aug 2003
Posts: 131
10-14-2005 10:57
From: Cyrus Odets

1) If you have an item in SL created by someone else and marked No Copy, No Trans, etc...can you still write scripts that will affect it?


I believe so. Unless the object is locked (which most items aren't), you should be able to drop your custom scripts in it (or pull the existing ones out).

From: Cyrus Odets

(snip)...build myself a 'holster' and write a script for the gun that would put the gun in the holster as its default attachment point when I 'wear' the gun...and then 'draw' the gun when I activate the script.


You can't really have an attachment jump attachment points, so you might have to go about that like so:

Make two guns. Build one into a holster. Attach the other gun to your hand. Attached the holstered gun to your hip. Basically, you'll make one gun or the other invisible when you want to draw it or put it away. You'll pretty much need a script in every part of the gun that will become transparent, and also a controller script that tells them all when dissapear or appear. llSetTexture is the main command you'll use here.

From: Cyrus Odets

2) That same gun I purchased above....has a few custom animations attached to it. I couldn't figure out though, how to actually 'activate' those animations in the game....as they are part of the gun and that gun is no-copy no-modify.


If they are custom animations:

The llStartAnimation command is going to be your friend here. Just make sure that the custom animations are in the same prim as whatever script that's calling llStartAnimation. You might have to pull them out of the gun if you want to use them elsewhere.

If they are built-in SL animations:

Here's an example script that should let you play with the built-in animations:

http://secondlife.com/badgeo/wakka.php?wakka=ExampleAnimationScript

From: Cyrus Odets

3) If you have say 10 custom built animations, let say for example...you have 10 custom built dancing animations. Is it possible to write a script that will allow the user to 'fire off' those animations using a menu based interface?


I'm assuming since you're an experienced programmer I can just point you at some functions and you'll be okay. Let me know if I need to elaborate. ^_^

llStartAnimation
llDialog

From: Cyrus Odets

4) Similar question to #1 above. If I bought...say...a fl(amethrower from someone else that is marked no-copy, no-modify....but that flamethrower doesn't have a particle effect and I'd like to create a 'stream of flame' that shoots out from the tip. I can't 'add' a script to the flamethrower because it is no-mod/no-copy....is there a way I can write a script to make the flame effect, store it somewhere else (Like my inventory) and somehow make it know to operate on the flamethrower and make flames shoot from the tip?


You may be able to create a small prim (texture it with an invisible texture if you'd like), put your custom script in it, position it at the tip of the gun, and link it in with the rest of the gun. I'm not 100% sure you can do that to a no modify object, but that's your best bet. Otherwise, you might be out of luck unless you made a separate (invisible) attachment on the lower arm or something (containing your particle script) that just lined up with the end of the gun most of the time.

From: Cyrus Odets

5) Is it possible to script the movement/actions of your own avatar?


Great idea. Should be able to do that easily with llListen on a channel other than 0 and llStartAnimation. Make some custom gestures in your gesture folder that issue the right commands to your channel, and bind them to the function keys at the top of the keyboard for ease of use. ^_^ If you want something to happen if you sit on it (like laying on a bed), the poseball is your best bet.

From: Cyrus Odets

Maybe those are some 'odd' questions, but please bear with me as I'm still learning and figuring out what can and cannot be done :)


Great questions, not odd at all. Let me know if I need to elaborate on any of my answers.

The wiki that I linked to above is a great informational source.

LSL is a pretty interesting language that forces you to think in unconventional ways at times. Once you get rolling though, it's not bad. Best of luck! ^_^
Kitty Rees
Registered User
Join date: 15 Oct 2006
Posts: 2
Draw / Holster
10-02-2007 11:03
I am kinda in the same boat I created my own guns, animations and bullets. They are dual holstered and draw guns this is my prob. I know that show / hide is a way that I can get my guns to be hidden in the hands and look like they are in the holsters when drawn they are in my hands and not in the holsters, issue I am having I need to figure out how do I make it so that when I draw ,it draws from both left and right side at the same time this way it only works on one side at a time. the show / hide that I am using doesnt link all 4 pieces( two holsters and 2 hand guns so that all 4 pieces work togeather, is there something I am missing or not doing right? here is an example of the script I am using.
this is my main scipt:( tells the link scipts when to draw and holster or show and hide but again only works form one side at a time)
(MAIN)
key target;
integer lid;
float chann;
integer chan;
list List;
integer listener; key owner;
default
{
state_entry()
{


llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
llMessageLinked(LINK_SET,0,"db",NULL_KEY);
}

on_rez(integer start_param)
{

List = [];


chan = (integer)llFrand(1000.0) + 5; // starts listening on channel 5
owner = llGetOwner(); llListenRemove(listener); listener = llListen(chan,"",owner,"";);
llListen(chan,"",NULL_KEY,"";);
llMessageLinked(LINK_SET,0,"db",NULL_KEY);
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
}

touch_start(integer total_number)
{if ( llDetectedKey(0) == llGetOwner() )
{
llDialog(llGetOwner(),"Dread 9mm",["Holster", "Draw"], chan);
}
}

listen(integer channel, string name, key id, string message)
{

if (message == "Holster";)
{
llPlaySound("18f6d98d-8a76-be6f-f219-9271fbcdbc95",1.0);
llMessageLinked(LINK_SET,0,"son",NULL_KEY);

}

if (message == "Draw";)
{
llPlaySound("18f6d98d-8a76-be6f-f219-9271fbcdbc95",1.0);
llMessageLinked(LINK_SET,0,"soff",NULL_KEY);



}
}
}
and this is what I am using on the guns in my hands to disappar and appear oppisite of the holsters although the other prob I am experiancing is the animations when holstered are still playing so that I need to figure out when they are holstered even though they are really stil in my hands how to start and stop aniamtions based on draw / holster commands

(Link Script foreach prim that I want hidden and then shown on touch Show / Hide, Draw /Holster )

default
{
state_entry()
{

}

link_message(integer sender, integer num, string message, key id)
{
if (message=="Holster";)
{
llSetAlpha(1.0, ALL_SIDES);
}
if (message=="Draw";)
{
llSetAlpha(0.0, ALL_SIDES);
}
}
}
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
10-02-2007 15:50
From: Cyrus Odets
Hi,

I'm new to scripting in SL (ugh) and have been reading and reading and reading...trying to get my feet wet and get started and I have a few questions I was hoping someone could help me with or lend me some pointers. My situation is that in my 'first' life I actually am a programmer. I know Java, C++, etc. So programming conventions I'm familiar with. However, my job the past few years has been a COBOL programmer so its rare that I mess with Java/C type stuff. So aside from 'concepts'....my 'practical' knowledge of LSL style coding is pretty sparse. Moreso, I'm a business programmer so the idea of the type of 'stuff' you are scripting in SL is often pretty foreign concepts for me. As such, as I learn, its often more difficult for me as I have to often 'unlearn' what I know to learn the new stuff. Its pretty hard when you code one way (structured) 8 hours a day and then mess with coding another way (OO, event-driven) for 'fun'. hehe.

Anyway, now ya know my situation...on to my questions.

1) If you have an item in SL created by someone else and marked No Copy, No Trans, etc...can you still write scripts that will affect it? I'm a bit confused on this as all the tutorials I've been reading seem to involve placing your script into the object that the script will affect. However, if you can't put something 'in' that object because of its permissions....can you write a script somewhere ELSE to still affect it?

For example. I purchased a 'gun' from a vendor in SL. When I 'wear' the gun it places it in my avatar's hand. What I'd LIKE to be able to do is to build myself a 'holster' and write a script for the gun that would put the gun in the holster as its default attachment point when I 'wear' the gun...and then 'draw' the gun when I activate the script. Could I write the script and place it in the holster instead, and then interract with the holster? Say...for example...in my inventory choose 'wear' for the gun and it places it snug in its holster on my avatar's leg...then....when I want to 'draw' the gun....click on the holster and have the gun pop into my avatar's hand.

2) That same gun I purchased above....has a few custom animations attached to it. I couldn't figure out though, how to actually 'activate' those animations in the game....as they are part of the gun and that gun is no-copy no-modify. I IM'd the seller and asked him how I could activate those animations and he said that I need a special script to activate the animations that are a part of the gun, and I could get that script from another scripter. Any idea what he's talking about, what I need to do, or where I can get it? Can anyone explain this to me?

3) If you have say 10 custom built animations, let say for example...you have 10 custom built dancing animations. Is it possible to write a script that will allow the user to 'fire off' those animations using a menu based interface? For example...in the upper right of the screen you'd get a menu that had a button for each of the 10 dance moves...and the user could then simply 'click' on the move they'd like to perform and it would fire off that animation...or...perhaps hit a 'random' buttom that would randomly cycle through the animations.

4) Similar question to #1 above. If I bought...say...a flamethrower from someone else that is marked no-copy, no-modify....but that flamethrower doesn't have a particle effect and I'd like to create a 'stream of flame' that shoots out from the tip. I can't 'add' a script to the flamethrower because it is no-mod/no-copy....is there a way I can write a script to make the flame effect, store it somewhere else (Like my inventory) and somehow make it know to operate on the flamethrower and make flames shoot from the tip?

5) Is it possible to script the movement/actions of your own avatar? For example...say I want to script my avatar to perform some actions based on scripted decisions. I want my avatar to, depending on his 'state' of 'tired', 'hungry', or 'bored', either A) If tired, Approach and activate a pose ball which puts him in a sleeping pose on his bed, lay down and go to sleep or B) If hungry, Approach and activate a pose ball at his dinner table which makes him animate eating his food or C) If bored, Go to the living room and approach and activate a pose ball which sits him on the couch in front of his TV and turns it on.

Maybe those are some 'odd' questions, but please bear with me as I'm still learning and figuring out what can and cannot be done :)

Thanks!!!!



1)It depends what you mean by "affect". If you own the object, regardless of permissions, you can take the scripts out to your inventory and put them in another object which you have full perms to, and play around with it. Even if its no mod,you could still send link messages and reset/start/stop the script. As for remotely you can still affect it through email, http, and simply saying stuff.

2)He simply lied to you. What you need to do is get another copy of the gun.

3)Its absolutely possible and there are dozens of such products for sale ingame, on SLX and Onrez. If want, I'd script them for you.

4)You could write a script and place it in an object adjacent to your flame thrower, but it simply isn't worth the time. For a few bucks, you could much rather buy a new, fully functional flame thrower.

5) It's fully possible to script the action's of your avatar and there are many products which do so, known as AO's (animation overiders).

I hope I helped and if you still have questions, continue to post them.