Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need a very simple script....

Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-02-2006 13:21
I apologise if this is the wrong place to request a script, but i cant see anywhere to ask.

Basically, i am trying to make a simple laptop pc, so far i have got it so it is always in the open state, but i want to be able to click it to close.

Can anyone give me any help in finding the script or any other help in making this possible.

I am very new to building and i have never ever scripted before.

Thankyou for any help
jrrdraco Oe
Insanity Fair
Join date: 28 Oct 2005
Posts: 372
05-02-2006 13:40
Welcome to Second Life,


The simplest way I see to solve this problem is making two covers for the laptop, and one base. One cover is the open state, the other cover is the closed state, everytime you click in it it will hide one and reveal the other.

In the main object you set a state variable, and everytime Touch event is called you change the switch the state and send a linkmessage to all other LINK_SET, put a script in each object that is cover part, everytime Linkmessage event is called check the message and set its alpha to 0 or 1 depending if you want it be visile or not.

You can find exemples searching for Open/close wing scripts freely available inworld, or if you need some extra help, feel free to drop me a message.
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-02-2006 13:43
thanks for that, that sounds exactly like what i want.

If it okay i will drop you a message in about an hour when i can get on SL because like i said i am new to building/scripting.

thankyou for your help :)
jrrdraco Oe
Insanity Fair
Join date: 28 Oct 2005
Posts: 372
05-02-2006 13:45
Its ok, just that I might reply you only when Im back at home, since Im at the office now and I cant get inworld here.
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-02-2006 13:52
okay no problem, does this involve any scripting or can it be done all from the build menu? sorry for the stupid questions :)
Inanna Assia
Registered User
Join date: 18 Jul 2005
Posts: 30
05-02-2006 13:53
you might want to look at a freebie swinging door script to get an idea of what's involved.
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-02-2006 14:35
thanks i will look now
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
05-02-2006 15:04
From: Dean Knight
im struggling to find a rotating door script :(

i have done a search and also looked through the library script


Script Link

This should do what you're looking for.

Either way you do it, Dean, you'll need a script. You can do it by actually moving the laptop screen(see the link to the script above), or by having 2 prims, one showing open, one showing closed, and toggling visibility.

Since you're new to scripting, here, I'll make it as easy as I can for you. Take the script below at put it in the "Root Prim" of your laptop.(as you select a linked object, the one that appears outlined in yellow is your root prim; it is always the last prim you select before you click "link" to join objects, incase you want/need to change it) Anyways, this is the script you'll put in your root prim:

CODE


default
{
state_entry()
{
state close;
}
}

state close
{
touch_start(integer total_number)
{
llMessageLinked(LINK_SET, 0, "", "");
state open;
}
}

state open
{
touch_start(integer total_number)
{
llMessageLinked(LINK_SET, 1, "", "");
state close;
}
}




Then, using the edit tools you'll want to click the little "edit linked parts" box and we're going to put this script into your open-laptop-screen prim and your closed-laptop-top prim, 2 copies. And then finally we'll make a minor change to just one copy of the script.

CODE

default
{

link_message(integer send, integer num, string str, key id)
{
if ( num == 1 )
{
llSetAlpha(0,ALL_SIDES);
}
else
{
llSetAlpha(1,ALL_SIDES);
}
}
}


And then just one more step - if you click now you'll see that it toggles between both pieces being visible, then both pieces being invisible! You'll want to pick _one_ of the scripts we just pasted above and alter it. See the two occurances of the line "llSetAlpha(0,ALL_SIDES);"? One has "1" and the other has "0", just switch these numbers with eachother, and you should be set.
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-02-2006 17:00
Logan thankyou very much for your time and effort, you are what makes SL so brilliant!!
thanks again

:)
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-03-2006 09:12
Well i dont know what i have done wrong here, i am sure i have followed those instructions word for word.

Basically, everything is working and the 'open' state of the laptop does appear and disappear on clicking.
However the 'closed' state of the laptop always remains visible.

I have put the the first script in the root prim (which i have as the base of the laptop) and the first script also in the 'closed' prim.

Then i put the second script in the 'open' prim and changed the alpha values.

can anyone please tell me if they can see what i have done wrong.

thanks alot for your help so far :)
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
05-03-2006 13:07
Dean--

"and the first script also in the 'closed' prim"

Sounds like you have the wrong script in the "closed" prim.

From the instructions, both the "closed" and "open" prim should have the 2nd script, with the only difference between the two, being the alternating of the Alpha '1' and '0'.
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-04-2006 03:51
woooooot!!

works a treat, thankyou so much for all your help!!

thanks again, that is just what i wanted :)
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-04-2006 03:54
now, at the risk of pushing my luck, can anyone tell me how to put in a startup sound when the laptop is opened?

say, for instance, the windows startup sound?? :)
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
05-04-2006 04:46
the function you're looking for is llPlaySound
http://secondlife.com/badgeo/wakka.php?wakka=llPlaySound

llPlaySound(string sound, float volume);
where sound is either the UUID of the sound file (in your inventory right click an item and choose copy UUID) or the file name of a sound in the objects contents folder. I've never played much with the volume value, it's just a number from 0.0 to 1.0 so I'm guessing 1.0 is full volume.


finally, where to put the function:
CODE

default
{
state_entry()
{
state close;
}
}

state close
{
touch_start(integer total_number)
{
llMessageLinked(LINK_SET, 0, "", "");
state open;
}
}

state open
{
touch_start(integer total_number)
{
llMessageLinked(LINK_SET, 1, "", "");
llPlaySound("WindowsStartup",1.0); // here is your sound clip
// (the file "WindowsStartup" should be dragged into the contents of this prim)
state close;
}
}


hope that helps.
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-04-2006 07:21
Thankyou very much, this is exactly how i want it now.

All you people have been a great help and are a credit to SL!!
Dean Knight
Registered User
Join date: 13 Apr 2006
Posts: 13
05-05-2006 08:41
any of you great people know of any other scripts i can add to this laptop to make it better?

it currently just opens and closes and makes the apple mac startup noise.

i dont know if its possible (or needs to) do anything else, as people obviously have their usual pc's to do other stuff.

any ideas would be great :)
Les White
sombish
Join date: 7 Oct 2004
Posts: 163
05-05-2006 11:42
You can get right silly with it. Look up some of the llDetected and llGet functions.
Read about scanners. Play around :)
_____________________