Oddy's OpenSim Script tip #2: Going up?

Creating scripts
Post Reply
User avatar
oddball otoole
Posts: 7
Joined: Sat Mar 08, 2014 9:02 pm
Has thanked: 7 times
Been thanked: 35 times
Contact:

Oddy's OpenSim Script tip #2: Going up?

Post by oddball otoole »

Howdy folks!

Here's a little script tip for you! (Well, it's more like a small tutorial which I have plenty on my website (Oddy.nl) but here we go!)

Let's build a very simple elevator!
I provide the scripts, you provide the hard work (and a animation. You definitely need an animation!)

Le scripts
The header of the main script says this:
// From the book
//
// Scripting Recipes for Second Life
// by Jeff Heaton (Encog Dod in SL)
// ISBN: 160439000X
// Copyright 2007 by Heaton Research, Inc.
//
// This script may be freely copied and modified so long as this header
// remains unmodified.
//
// For more information about this book visit the following web site:
//
// http://www.heatonresearch.com/articles/series/22/
So I think it's safe to use these scripts here ;)

First thing you want to do is to download these set of scripts.
elevator scripts.zip
Le scripts..
(3.63 KiB) Downloaded 473 times
Unpack them to a convenient place on your PC.

Go ahead, download that shizzle and unpack it on your nizzle...
The files inside the Zip file are 6 scripts. You can open them with any text editor, but I prefer notepad++ (http://notepad-plus-plus.org/download/v6.5.5.html)

Le building of ze elevateur <=Say this with an Inspector Clouseau voice...

Un: Build a floor for your elevator (2x2 meters is fine.)

Deux: Build a poseball above this floor, add an animation and the 'Poseball Script' from the zip file. Make sure the animation plays correct (Rotation, height, etc) so you stand or sit on the right spot. Link this prim to the floor. (In Edit mode, hold shift key on your keyboard and touch the floor. Then hit CTRL-L to link the poseball to the floor.)

Trois: Create 2 buttons, name one button up, and the other button down. Place the "elevator button up" script in the Up button, and the "elevator button down" script in the down button. Link these 2 buttons to the floor.

Quatre: Place your elevator on the lowest floor. (Tip: try to place it on a round number, something like 22.0000 meters.) Open the "Elevator Main Script" with a text-editor and look for the line:

Code: Select all

float BOTTOM = 23.02081;
Change the 23.02081 to the lowest point of your elevator. The floor will go to this point when somebody touches a down button.
Now raise the elevator to the next floor, again, try to keep the numbers round, e.g. 32.0000 meters (=10 meters higher then floor 1)

Search in the "Main Elevator Script" for the next line:

Code: Select all

float FLOOR_HEIGHT = 23.79401;
This line moves the elevator floor 23.79401 meters up. So if your floor 1 is at 22.0000 meters, floor 2 is at 22.0000+23.79401 meters.
Sooooooo, if your elevator floor has 22m as floor 1 and you want it to move up to 32m change float_HEIGTH to 10.

Happy with the numbers?
OK, since we were working in notepad (or any other text editor (Don't use wordpad though, that might give errors!)) copy the script from notepad to a new script in your inv. Place this new script in the elevator floor.

Cinq: It really sucks when you are standing on floor 1 and the elevator is on floor 2! You want a button to press so the darn thing goes down! (or up if you happen to stand on floor 2 and the elevator is on on floor 1)
Create 2 buttons, don't link them to the elevator.
Place one button on floor 1 and put the "elevator call button down" script in it.
place one button on floor 2 and put the "elevator call button up" script in it.

Et voilà, we ave un elevateur..
Sit on the poseball, touch a button and off you go!

Good luck!
These users thanked the author oddball otoole for the post (total 6):
Constance PeregrineDot Matrixoopsee joseppeGraham MillsZuza RittMarstol Nitely
User avatar
Constance Peregrine
Posts: 2349
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1482 times

Re: Oddy's OpenSim Script tip #2: Going up?

Post by Constance Peregrine »

lol...I love the way you do tuts-))

Animation? well, dunno if this one will be the right one, but it is awful fun anyways.

From Linda Kellie who emailed it to me personally a bit back, upload in priority 4 and looped, for possible use in this, or making your own tiny-))

https://drive.google.com/file/d/0B6pQoe ... sp=sharing
These users thanked the author Constance Peregrine for the post:
oddball otoole
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Oddy's OpenSim Script tip #2: Going up?

Post by Graham Mills »

Thanks for this, Oddy. I need an elevator script and this sounds like a good place to start. In the meantime I've been using a rather hackish approach based on llSetKeyframedMotion to create a paternoster-type elevator that moves up and down continuously. You sit on the lift and stand on arrival. The benefit of this approach is the really smooth ride. You can see an example at a stalled build called Microbeum (a virtual Microbiology Museum) where the idea is that different levels in the building reflect levels of detail (in a microbiological sense). The elevator is eventually intended to be part of the educational experience. I'm surprised we don't see more use of llSetKeyframedMotion.
User avatar
Keith Selmes
Posts: 175
Joined: Fri Jan 04, 2013 1:13 pm
Location: Devon, UK
Has thanked: 174 times
Been thanked: 153 times
Contact:

Re: Oddy's OpenSim Script tip #2: Going up?

Post by Keith Selmes »

I had the impression that llSetKeyframedMotion was a later addition to lsl,so there aren't as many sample scripts and code fragments for it.
I noticed it in a script which I think was by Kayaker Magic and probably at OSgrid, and then again possibly the same one here. So it's lodged in the back of my mind, but I don't recall seeing it anywhere else. It looks extremely useful, and I keep meaning to have a good look at it .
I picked up an idea that it was introduced as an alternative to other functions, like setpos, which have undesirable system overheads.
I think of using it for unmanned aircraft. The Kayaker sample script works with my aircraft, although not quite how I'd want it to. That is, needs some time allocated to work it through.

But there are so many easy little things you can do with setpos,(like the elevator script) it's difficult to give it up.
These users thanked the author Keith Selmes for the post:
Graham Mills
User avatar
Handy Low
Posts: 231
Joined: Fri Nov 08, 2013 3:38 pm
Location: Yorkshire, England
Has thanked: 207 times
Been thanked: 140 times
Contact:

Re: Oddy's OpenSim Script tip #2: Going up?

Post by Handy Low »

Keith Selmes wrote:I had the impression that llSetKeyframedMotion was a later addition to lsl,so there aren't as many sample scripts and code fragments for it.
That's correct - I think it was introduced into SL in 2011. I don't know when it was incorporated into OpenSim.
Handy Low
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Oddy's OpenSim Script tip #2: Going up?

Post by Graham Mills »

June 2013: http://justincc.org/blog/2013/06/13/thi ... june-2013/

The problem I have with it is that movements are relative rather than absolute.
Handy Low wrote:
Keith Selmes wrote:I had the impression that llSetKeyframedMotion was a later addition to lsl,so there aren't as many sample scripts and code fragments for it.
That's correct - I think it was introduced into SL in 2011. I don't know when it was incorporated into OpenSim.
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1142 times

Re: Oddy's OpenSim Script tip #2: Going up?

Post by Graham Mills »

My first thoughts were that Oddy was going to teach us some Dutch and was starting off with faux French (Franglais) by way of a gentle introduction.

My second thoughts were that having a tour of worlds with small prim builds that represent the countries where we live IRL would be a nice grid-wide activity? :)
Minethere Always wrote:lol...I love the way you do tuts-))
Post Reply