Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Script: Pose ball (with optional notecard support)

CrystalShard Foo
1+1=10
Join date: 6 Feb 2004
Posts: 682
11-16-2004 05:48
I kept hearing complaints from friends that they cant find a decent poseball script that is both:
a. free
b. easy to configure (for the technicly challenged)

So I decided to make one. :P

You can get it either from this very post, or by just being lazy and fetching a copy I made from this location:

Script-Foo! - Apukohai (167, 22)

This poseball script has the following features:
1)Everything (well, almost everything) can be configured via a notecard.
2)Has voice commands or touch support. You toggle.
3)Will always listen to link_message commands, letting you combine it in a link-set for various evil hackish purposes. (a script that toggle on and off certain balls, or using them to turn the balls on and off using touch on a root prim, etc)
4)There's enough error-handling to feed an army, and it has default settings to use incase something goes borked (bad notecard syntax, missing notecard, missing pose/animation).
5)It doesnt make coffee.

So, without further comments, here it is. Enjoy.

2 scripts, 2 notecards:

NOTECARD: Pose ball - INSTRUCTIONS
CODE

Opensource switchable-mode pose-ball script (version 4.3)
By CrystalShard Foo // Script-Foo!

NOTE: Please dont contact me with problems. This is a free, open script. If you need help, just hand it to a geek you know and ask for assistance.

Index:
1.The Basic, Simple Way.
2.The advanced way
3.Using link messages
4.Conclusion

HOW TO USE THIS SCRIPT
----------------------------

1)The Basic, Simple Way:
Just drop the script "poseball 4" into a poseball. Then, drop a pose inside (NOT a gesture!!), and you're done.
The poseball with appear or disappear when clicked.

You do NOT need to put ANYTHING else in the ball, other then the single Poseball script and the animation.

What is the Click Broadcaster script for, then? Read part 3 to find out...

2)The advanced way:
The notecard that comes with the poseball (Pose ball - CONFIGURATION) gives you access to afew more intresting functions:

- You can change the offset of the sit position using X,Y,Z coordinates. (that is, changing where you will be positioned when you sit.)
- You can change the floating text title above the ball.
- You can change the name of the "Sit Here" button when right-clicking on the ball.
- You can decide if you want to use a click to make the ball hide and show, or use the commands "hide" and "show" in chat text.

The way for doing this is pretty straight forward: Just open the notecard and change the values after each name.

If "voice" is set to Yes, a listener will be activated and the ball will show or hide when the command "show" or "hide" is given.
If "voice" is set to No, any opened listener will be shut down, and the ball will wait to be clicked instead.

When changing "offset", make sure to keep the < and > signs when changing the numbers. This function will fail if you do not.

3)Using link_messages
Link messages are very useful when you want to put a whole bunch of pose balls in a single linked set object. For example, a chair or a bed with more then one poseball. This way you can turn the balls on and off by a single click anywhere on the object, and without using the evil Voice command option. Remember: Every ball that listens for voice commands = lag. This is why the clicking option is the default.

How to do it: Just link your poseballs with the furniture piece as you always do. Then, once done, put the click-broadcaster script in the ROOT PRIM of the furniture. It will handle the rest.

You do NOT NEED to put any other copy of the click broadcaster anywhere else. This includes the poseballs.

Technical bits:
This poseball script always listens for incoming link messages. These will make the ball show or hide regardless of the setting of using Voice commands or not.

The "integer" value (num) must be 99.
The "string" value (str) can be either "show" to show, or "hide" to hide.

Always put the script that senses for the click and transmit the hide/show link_message in the ROOT PRIM of the linked set.

That should do it. =)

4. Conclusion
And that should sum it up. Hope you find this little script useful. Again, please dont IM me for support on this - i'm flooded with messages allready. Just hand this script and manual to a geek friend who will surely manage to figure it out.

Happy posing!

- CrystalShard Foo


SCRIPT: Pose Ball 4

CODE

//Pose Ball script, Revision 4.3
//Notecard configuration enabled, switchable link_message/touch_start/llListen support, sit_text, floating text, alpha.
//Version 4.3 fixs link_set hide/show and permission sensing issues.

//By CrystalShard Foo.
//Work started - October 10th.
//Last compile - November 7th.

//This script will let you choose if you want to turn the ball visible on CLICK, or by using a SHOW/HIDE voice command.
//You can also set the offset and the title of the ball, as well as the sit button text - all with a notecard.

//This script is free and comes without support. Dont contact me. Ask a local geek for help if it gets messy.

// ** This script is NOT FOR SALE **
//You can use it in commercial products as long as you give this script to anyone who asks for it.
//You can use this source, distribute it and modify it freely, but leave the credits intact!
//(You can add your own name to the list, ofcourse. Like, "Modified by John Doe")



string TITLE="Sit here"; //This text will appear in the floating title above the ball
string ANIMATION=""; //Put the name of the pose/animation here!
vector offset=<0,0,0.5>; //You can play with these numbers to adjust how far the person sits from the ball. ( <X,Y,Z> )
integer use_voice = FALSE;

string gNotecard = "Pose ball - CONFIGURATION";
integer gLine = 0;

integer listenHandle = -1;
integer masterswitch = TRUE;
integer visible = TRUE;
float base_alpha = 1.0;
key avatar;

key dataserver_key = NULL_KEY;

show()
{
visible = TRUE;
llSetText(TITLE, <1,1,1>,1);
llSetAlpha(base_alpha, ALL_SIDES);
}

hide()
{
visible = FALSE;
llSetText("", <1,1,1>,1);
llSetAlpha(0, ALL_SIDES);
}

next_line()
{
gLine++;
dataserver_key = llGetNotecardLine(gNotecard,gLine);
}

use_defaults()
{
llSetSitText("Sit Here");
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}

init()
{

if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) //Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.");
ANIMATION = "sit";
}
else
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION,0);

if(llGetInventoryNumber(INVENTORY_NOTECARD) != 0) //If the notecard is present, use it for configuration.
{
integer i;
for(i=0;i<llGetInventoryNumber(INVENTORY_NOTECARD);i++)
if(llGetInventoryName(INVENTORY_NOTECARD,i) == gNotecard)
{
gLine = 0;
dataserver_key = llGetNotecardLine(gNotecard, 0);
return;
}
use_defaults();
}
else //No configuration notecard found... lets use the defaults.
use_defaults();
}

default
{
state_entry()
{
llSetText("Starting up", <1,1,1>,1);
llSitTarget(offset,ZERO_ROTATION);
init();
}

link_message(integer sender_num, integer num, string str, key id)
{
if(num == 99)
{
if(str == "show")
{
masterswitch = FALSE;
hide();
return;
}

if(str == "hide");
{
masterswitch = TRUE;
show();
}
}
}

touch_start(integer detected)
{
if(use_voice == FALSE)
{
if(visible == TRUE)
hide();
else
show();
}
else
llSay(0,llDetectedName(0)+", say '/1 Hide' to hide me, or '/1 Show' to make me show. Or just right-click and sit on me to use me.");
}

changed(integer change)
{
if(change == CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY)
{
hide();
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
else
{
if (llGetPermissionsKey() != NULL_KEY)
llStopAnimation(ANIMATION);
if(masterswitch == TRUE)
{
llSetAlpha(base_alpha,ALL_SIDES);
llSetText(TITLE,<1,1,1>,1);
}
}
}

if(change == CHANGED_INVENTORY)
{
llSetText("Reloading configuration...",<1,1,1>,1);
init();
}
}

run_time_permissions(integer perm)
{
if(perm == PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStartAnimation(ANIMATION);
if(visible == TRUE)
base_alpha = llGetAlpha(ALL_SIDES);
else
base_alpha = 1.0;
llSetAlpha(0.0,ALL_SIDES);
llSetText("",<1,1,1>,1);
}
}


listen(integer channel, string name, key id, string message)
{
if(llStringLength(message)!=4)
return;

message = llToLower(message);

if(message == "show")
{
show();
return;
}
if(message == "hide")
hide();
}

dataserver(key queryid, string data)
{
if(queryid != dataserver_key)
return;

if(data != EOF)
{
if(llGetSubString(data,0,0) != ";")
{
if(llGetSubString(data,0,5) == "title:")
{
TITLE = llGetSubString(data,7,-1);
next_line();
return;
}
if(llGetSubString(data,0,6) == "offset:")
{
integer length = llStringLength(data);
if(llGetSubString(data,8,8) != "<" || llGetSubString(data,length - 1,length) != ">")
{
llSay(0,"Error: The numbers in the offset value lack the '<' and '>' signs. (Should be something like <3,1,6> )");
offset = <0,0,0.5>;
}
else
offset = (vector)llGetSubString(data,8,-1);

if(offset == <0,0,0>)
offset = <0,0,0.01>;
llSitTarget(offset,ZERO_ROTATION);
next_line();
return;
}
if(llGetSubString(data,0,5) == "voice:")
{
string value = llGetSubString(data,7,-1);
value = llToLower(value);

if(listenHandle != -1)
{
llListenRemove(listenHandle);
listenHandle = -1;
}

if(value !="no" && value != "yes" && value != "true" && value != "false")
use_voice = FALSE;
else
if(value == "no" || value == "false")
use_voice = FALSE;
else
{
use_voice = TRUE;
listenHandle = llListen(1,"","","");
}
next_line();
return;
}
if(llGetSubString(data,0,10) == "sit_button:")
{
llSetSitText(llGetSubString(data,12,-1));
next_line();
return;
}
next_line();
}
}
else
{
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}
}
}


SCRIPT: Pose ball 4 - Click Broadcaster
CODE

//Pose Ball script, Revision 4.3
//Click Broadcaster

// ** This script is NOT FOR SALE **
//You can use it in commercial products as long as you give this script to anyone who asks for it.
//You can use this source, distribute it and modify it freely. Please leave the credits intact!

integer visible = TRUE;

default
{
touch_start(integer total_number)
{
if(visible == TRUE)
{
llMessageLinked(LINK_SET,99,"hide",NULL_KEY);
visible = FALSE;
}
else
{
llMessageLinked(LINK_SET,99,"show",NULL_KEY);
visible = TRUE;
}
}
}


NOTECARD: Pose ball - CONFIGURATION
CODE

title: Sit on me!

offset: <0,0,1>

voice: No

sit_button: Sit Here
Hiro Pendragon
bye bye f0rums!
Join date: 22 Jan 2004
Posts: 5,905
11-18-2004 00:55
(big red font removed)

I recommend using PoseCubes instead of poseballs.
_____________________
Hiro Pendragon
------------------
http://www.involve3d.com - Involve - Metaverse / Emerging Media Studio

Visit my SL blog: http://secondtense.blogspot.com
Plaga Fool
Registered User
Join date: 22 Aug 2004
Posts: 26
11-18-2004 08:25
Thank you very much for this, i was searching for that script.

It's not working as i expected tho, when i drop the notecard with the modified information (along with the script and the pose) on the object, it seems to load the configuration but ignore it. So even when i change the title and voice commands on the notecard, it just ignores it on the script.

I tried to figure where on the script is the on/off for voice command, and located some lines but i am not sure how to work with them.

Can someone please help with this?

Thank you very much.
And thanks Crystalshard again, ur mini crystal fooled me, i've talking to her for like 5 minutes lol.
Kat Medici
Amused Beauty
Join date: 31 Dec 2003
Posts: 26
Brilliant CS!
11-18-2004 18:20
Thank you!

Free scripts from my favorite, CS. You rock, baby.
CrystalShard Foo
1+1=10
Join date: 6 Feb 2004
Posts: 682
11-20-2004 22:52
Several replies grouped into this post:

Hiro:
Thank you for your comments. In the future, I will greatly appriciate it if you choose to IM me instead of posting in 72 point font.

On regards to using llListens on channel 1 - I have recently changed all my scripts to use this channel instead of the public channel zero. I am very much aware of the issues and concerns the use of llListen on channel zero causes - unfortunatly, most of the SL population is not yet educated about the use of different channels. And although I can always put instructions of use in products I actively sell, I cannot explain to anyone who gets a new chair that has my script inside that their usual "Show" and "Hide" will be completly ignored because they are using the wrong channel.

My resort for this case was to disable the llListen when "touch" sensing is selected instead of voice commands. Touch is also chosen by default. You must edit the notecard to enable the llListen. The instructions for the poseball script include a warning that allready detail what you posted in the forum so thoughtfuly.

Plaga:
The reason the script ignores your notecard is due to a mistake on my end, sorry.
The sample notecard I released has bad syntax: Each command word needs a column before its parameter. For example:
voice: no
sit_button: Sit on me

I updated the example notecard in this thread and will also update the box I have in my shop shortly.
Ariel Roentgen
Simply Me
Join date: 11 Apr 2004
Posts: 345
11-21-2004 18:12
oooh, TY! :D It is working fabulously!
hehe I do have a question, is there a way to rotate? I see where you can change the position, but how about to roate how your avie sits? The object that I am making has butt pads, so I can put the script in these, hehe but my avie is not sitting in the correct rotation :) Thanks a bunch! And here I was ready to buy a similar script ;)
_____________________
CrystalShard Foo
1+1=10
Join date: 6 Feb 2004
Posts: 682
11-21-2004 23:25
I did not add an easy way to do this in the notecard since I presumed people will use the balls as balls, and not place the script inside the objects themselves. This is also why the script can turn the object visible and invisible.

Normally I would tell you to just rotate the ball. But if you still want this to be inside the script, here's a special version that will let you do this. Still kinda manual, but less.

How to do this:
In the line that says: vector ROTATION = <0,0,0>; //Euler!
change the 3 zeros into the X,Y,Z rotation values that you want to use. These values will be similiar to the ones you have in your Edit window. For example, you can say: 0,0,90, or 20,0,45, etc.

Save, compile, and that'll do it. Happy sitting.

The modified script (with built-in rotation support):
CODE

//Pose Ball script, Revision 4.1 with Rotation
//Notecard configuration enabled, switchable link_message/touch_start/llListen support, sit_text, floating text, alpha.

//By CrystalShard Foo.
//Work started - October 10th.
//Last compile - November 7th.

//This script will let you choose if you want to turn the ball visible on CLICK, or by using a SHOW/HIDE voice command.
//You can also set the offset and the title of the ball, as well as the sit button text - all with a notecard.

//This script is free and comes without support. Dont contact me. Ask a local geek for help if it gets messy.

// ** This script is NOT FOR SALE **
//You can use it in commercial products as long as you give this script to anyone who asks for it.
//You can use this source, distribute it and modify it freely, but leave the credits intact!
//(You can add your own name to the list, ofcourse. Like, "Modified by John Doe")


vector ROTATION = <0,0,0>; //Euler!

string TITLE="Sit here"; //This text will appear in the floating title above the ball
string ANIMATION=""; //Put the name of the pose/animation here!
vector offset=<0,0,0.5>; //You can play with these numbers to adjust how far the person sits from the ball. ( <X,Y,Z> )
integer use_voice = FALSE;

string gNotecard = "Pose ball - CONFIGURATION";
integer gLine = 0;

integer listenHandle = -1;
integer visible = TRUE;
float base_alpha = 1.0;
key avatar;

key dataserver_key = NULL_KEY;

show()
{
visible = TRUE;
llSetText(TITLE, <1,1,1>,1);
llSetAlpha(1, ALL_SIDES);
}

hide()
{
visible = FALSE;
llSetText("", <1,1,1>,1);
llSetAlpha(0, ALL_SIDES);
}

next_line()
{
gLine++;
dataserver_key = llGetNotecardLine(gNotecard,gLine);
}

use_defaults()
{
llSetSitText("Sit Here");
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}

init()
{

if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) //Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.");
ANIMATION = "sit";
}
else
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION,0);

if(llGetInventoryNumber(INVENTORY_NOTECARD) != 0) //If the notecard is present, use it for configuration.
{
integer i;
for(i=0;i<llGetInventoryNumber(INVENTORY_NOTECARD);i++)
if(llGetInventoryName(INVENTORY_NOTECARD,i) == gNotecard)
{
gLine = 0;
dataserver_key = llGetNotecardLine(gNotecard, 0);
return;
}
use_defaults();
}
else //No configuration notecard found... lets use the defaults.
use_defaults();
}

default
{
state_entry()
{
llSetText("Starting up", <1,1,1>,1);
llSitTarget(offset,llEuler2Rot(ROTATION));
init();
}

link_message(integer sender_num, integer num, string str, key id)
{
if(num == 99)
if(str == "show")
hide();
else
if(str == "hide");
show();
}

touch_start(integer detected)
{
if(use_voice == FALSE)
{
if(visible == TRUE)
hide();
else
show();
}
else
llSay(0,llDetectedName(0)+", say 'Hide' to hide me, or 'Show' to make me show. Or just right-click and sit on me to use me.");
}

changed(integer change)
{
if(change == CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY)
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANI MATION);
llStopAnimation("sit");
llStartAnimation(ANIMATION);
if(visible == TRUE)
base_alpha = llGetAlpha(ALL_SIDES);
else
base_alpha = 1.0;
llSetAlpha(0.0,ALL_SIDES);
llSetText("",<1,1,1>,1);
}
else
{
llStopAnimation(ANIMATION);
llSetAlpha(base_alpha,ALL_SIDES);
llSetText(TITLE,<1,1,1>,1);
}
}

if(change == CHANGED_INVENTORY)
{
llSetText("Reloading configuration...",<1,1,1>,1);
init();
}
}

listen(integer channel, string name, key id, string message)
{
if(llStringLength(message)!=4)
return;

message = llToLower(message);

if(message == "show")
{
show();
return;
}
if(message == "hide")
hide();
}

dataserver(key queryid, string data)
{
if(queryid != dataserver_key)
return;

if(data != EOF)
{
if(llGetSubString(data,0,0) != ";")
{
if(llGetSubString(data,0,5) == "title:")
{
TITLE = llGetSubString(data,7,-1);
next_line();
return;
}
if(llGetSubString(data,0,6) == "offset:")
{
integer length = llStringLength(data);
if(llGetSubString(data,8,8) != "<" || llGetSubString(data,length - 1,length) != ">")
{
llSay(0,"Error: The numbers in the offset value lack the '<' and '>' signs. (Should be something like <3,1,6> )");
offset = <0,0,0.5>;

}
else
offset = (vector)llGetSubString(data,8,-1);

llSitTarget(offset,llEuler2Rot(ROTATION));
next_line();
return;
}
if(llGetSubString(data,0,5) == "voice:")
{
string value = llGetSubString(data,7,-1);
value = llToLower(value);

if(listenHandle != -1)
{
llListenRemove(listenHandle);
listenHandle = -1;
}

if(value !="no" && value != "yes" && value != "true" && value != "false")
use_voice = FALSE;
else
if(value == "no" || value == "false")
use_voice = FALSE;
else
{
use_voice = TRUE;
listenHandle = llListen(0,"","","");
}
next_line();
return;
}
if(llGetSubString(data,0,10) == "sit_button:")
{
llSetSitText(llGetSubString(data,12,-1));
next_line();
return;
}
next_line();
}
}
else
{
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}
}
}
Hiro Pendragon
bye bye f0rums!
Join date: 22 Jan 2004
Posts: 5,905
11-22-2004 00:49
From: CrystalShard Foo
Several replies grouped into this post:

Hiro:
Thank you for your comments. In the future, I will greatly appriciate it if you choose to IM me instead of posting in 72 point font.

Sowwy. I picked "3" or "4" and never previewed the post; I didn't think it'd be THAT big, lol! Doh! I think I have actually IMd you about this a while ago, btw...

From: someone

On regards to using llListens on channel 1 - I have recently changed all my scripts to use this channel instead of the public channel zero. I am very much aware of the issues and concerns the use of llListen on channel zero causes - unfortunatly, most of the SL population is not yet educated about the use of different channels. And although I can always put instructions of use in products I actively sell, I cannot explain to anyone who gets a new chair that has my script inside that their usual "Show" and "Hide" will be completly ignored because they are using the wrong channel.

Yes, I agree that more education is needed. However, your product is so widely used that you could be a big factor in this education! =)

Realize also that the warning was also directed at people using your open source script and making their own stuff.

From: someone

My resort for this case was to disable the llListen when "touch" sensing is selected instead of voice commands. Touch is also chosen by default. You must edit the notecard to enable the llListen. The instructions for the poseball script include a warning that allready detail what you posted in the forum so thoughtfuly.

That's another good idea.
_____________________
Hiro Pendragon
------------------
http://www.involve3d.com - Involve - Metaverse / Emerging Media Studio

Visit my SL blog: http://secondtense.blogspot.com
Surreal Farber
Cat Herder
Join date: 5 Feb 2004
Posts: 2,059
01-10-2005 16:23
thanks for posting this!!

Surreal
Tiesto Cooper
Second Life Resident
Join date: 26 Oct 2004
Posts: 7
what a moron
02-02-2005 20:19
u r so not friendly at all in game...i try to give you a LM for a memorial i built for a SL friend of mine who died in Rl and you wanna act like a moron and cant even accept the LM....wow what a selfish person and all i can say to you ...I hope that when someone dies in your family or friends that noone wants to come pay their respect or for your moral support cause undoubtly you have no moral values at all..Computer Geek is right...ANd that came from your mouth...
Annah Zamboni
Banannah Annah
Join date: 2 Jun 2004
Posts: 1,022
02-13-2005 16:42
I switched to this script from the old one I used to use cause I liked the touch hide/show and wanted to switch my hide/show to another channel anyways to save on Sim. The only problem I have is I get errors from time to time and have to reset the script. The error usually looks like this:

Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set
Position 2 (0, 0):

Sure I could set this msg to iggy but I dont really want to have it spamming other people. In fact I was in the same sim as my store and on the opposite corner of the sim and someone was trying on my pose balls and I got the msg spam from farrr away. I keep having to go reset every script. This was after a sim crash not sure thats why but I've seen it before.

Any ideas to keep the script from spamming this when pose balls are used?
Rhaegys Nyak
Blood of the Dragon
Join date: 7 Feb 2005
Posts: 43
02-15-2005 04:49
Hi! I'm a bit new to scripting so apologize if I'm saying something wrong...

So I wonder if in the case you are using the broadcaster, wouldn't it be more efficient to put also here the listener to the channel /1 and broadcast to each ball as in the touch? So in this way you can use the voice command having only one prim listening instead of all the balls...
Annah Zamboni
Banannah Annah
Join date: 2 Jun 2004
Posts: 1,022
02-15-2005 07:28
So far the fixed posted in this thread seems to work. I'll test more when I get home. Maybe Crystalshard could update her thread with the modified script that doesnt give the permissions errors when people sit/stand? I'll post it here later so you dont have to click on the link below. I might call it version 4.4 (at least in my inventory).

Link to thread with fix:
/54/1d/35885/1.html

Edit:
The fix in the link above does appear to work. I tested about 30 - 40 pose balls last night (2/15) on furniture I had already sitting out that were giving the errors when people would sit or stand. After replacing them the night before, everyone of them worked without error. Before at least 75% of them were giving me problems. This is good news. Maybe Cyrstalshard can update the first post with the corrections.
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
08-22-2005 23:24
three thumbs up for CS

be carefull you are becoming too good with the crowd ^_^
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-11-2006 05:05
Woops. Sorry for bothering by my post. Strife Onizuka had already solved this problem. I should have read this thead more carefully. :p Although his version is better than mine, I dare to leave this by way of warning. Read the whole thread more carefully. :p

Someone links balls one another. But I realized this script had the problem to use like that. So I modified this a bit. I'm sorry that I don't test this much enough. Please feel free to point out my defect.
This revision is 4.3l. "l" is not "one" but Link's l. :D
CODE
//Pose Ball script, Revision 4.3l modified by Seagel Neville, Jan 2006.
//Allowed balls to link each other.

//Pose Ball script, Revision 4.3
//Notecard configuration enabled, switchable link_message/touch_start/llListen support, sit_text, floating text, alpha.
//Version 4.3 fixs link_set hide/show and permission sensing issues.

//By CrystalShard Foo.
//Work started - October 10th.
//Last compile - November 7th.

//This script will let you choose if you want to turn the ball visible on CLICK, or by using a SHOW/HIDE voice command.
//You can also set the offset and the title of the ball, as well as the sit button text - all with a notecard.

//This script is free and comes without support. Dont contact me. Ask a local geek for help if it gets messy.

// ** This script is NOT FOR SALE **
//You can use it in commercial products as long as you give this script to anyone who asks for it.
//You can use this source, distribute it and modify it freely, but leave the credits intact!
//(You can add your own name to the list, ofcourse. Like, "Modified by John Doe")



integer is_sitting = FALSE; //Ppl's state while others changes linking state (sit or stand up) By SN

string TITLE="Sit here"; //This text will appear in the floating title above the ball
string ANIMATION=""; //Put the name of the pose/animation here!
vector offset=<0,0,0.5>; //You can play with these numbers to adjust how far the person sits from the ball. ( <X,Y,Z> )
integer use_voice = FALSE;

string gNotecard = "Pose ball - CONFIGURATION";
integer gLine = 0;

integer listenHandle = -1;
integer masterswitch = TRUE;
integer visible = TRUE;
float base_alpha = 1.0;
key avatar;

key dataserver_key = NULL_KEY;

show()
{
visible = TRUE;
llSetText(TITLE, <1,1,1>,1);
llSetAlpha(base_alpha, ALL_SIDES);
}

hide()
{
visible = FALSE;
llSetText("", <1,1,1>,1);
llSetAlpha(0, ALL_SIDES);
}

next_line()
{
gLine++;
dataserver_key = llGetNotecardLine(gNotecard,gLine);
}

use_defaults()
{
llSetSitText("Sit Here");
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}

init()
{

if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) //Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.");
ANIMATION = "sit";
}
else
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION,0);

if(llGetInventoryNumber(INVENTORY_NOTECARD) != 0) //If the notecard is present, use it for configuration.
{
integer i;
for(i=0;i<llGetInventoryNumber(INVENTORY_NOTECARD);i++)
if(llGetInventoryName(INVENTORY_NOTECARD,i) == gNotecard)
{
gLine = 0;
dataserver_key = llGetNotecardLine(gNotecard, 0);
return;
}
use_defaults();
}
else //No configuration notecard found... lets use the defaults.
use_defaults();
}

default
{
state_entry()
{
llSetText("Starting up", <1,1,1>,1);
llSitTarget(offset,ZERO_ROTATION);
show(); // Modified by SN
init();
}

link_message(integer sender_num, integer num, string str, key id)
{
if(num == 99)
{
if(str == "show")
{
masterswitch = FALSE;
hide();
return;
}

if(str == "hide");
{
masterswitch = TRUE;
show();
}
}
}

touch_start(integer detected)
{
if(use_voice == FALSE)
{
if(visible == TRUE)
hide();
else
show();
}
else
llSay(0,llDetectedName(0)+", say '/1 Hide' to hide me, or '/1 Show' to make me show. Or just right-click and sit on me to use me.");
}

changed(integer change)
{
if(change == CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY)
{
if(!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && is_sitting == FALSE) //Modified by SN
{
hide();
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
}
else
{
if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && is_sitting == TRUE) //Modified by SN
{
if (llGetPermissionsKey() != NULL_KEY)
llStopAnimation(ANIMATION);
llResetScript(); //Modified by SN
// if(masterswitch == TRUE)
// {
// llSetAlpha(base_alpha,ALL_SIDES);
// llSetText(TITLE,<1,1,1>,1);
// }
}
}
}

if(change == CHANGED_INVENTORY)
{
llSetText("Reloading configuration...",<1,1,1>,1);
init();
}
}

run_time_permissions(integer perm)
{
if(perm == PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStartAnimation(ANIMATION);
if(visible == TRUE)
base_alpha = llGetAlpha(ALL_SIDES);
else
base_alpha = 1.0;
llSetAlpha(0.0,ALL_SIDES);
llSetText("",<1,1,1>,1);
is_sitting = TRUE; // Modified by SN
}
}


listen(integer channel, string name, key id, string message)
{
if(llStringLength(message)!=4)
return;

message = llToLower(message);

if(message == "show")
{
show();
return;
}
if(message == "hide")
hide();
}

dataserver(key queryid, string data)
{
if(queryid != dataserver_key)
return;

if(data != EOF)
{
if(llGetSubString(data,0,0) != ";")
{
if(llGetSubString(data,0,5) == "title:")
{
TITLE = llGetSubString(data,7,-1);
next_line();
return;
}
if(llGetSubString(data,0,6) == "offset:")
{
integer length = llStringLength(data);
if(llGetSubString(data,8,8) != "<" || llGetSubString(data,length - 1,length) != ">")
{
llSay(0,"Error: The numbers in the offset value lack the '<' and '>' signs. (Should be something like <3,1,6> )");
offset = <0,0,0.5>;
}
else
offset = (vector)llGetSubString(data,8,-1);

if(offset == <0,0,0>)
offset = <0,0,0.01>;
llSitTarget(offset,ZERO_ROTATION);
next_line();
return;
}
if(llGetSubString(data,0,5) == "voice:")
{
string value = llGetSubString(data,7,-1);
value = llToLower(value);

if(listenHandle != -1)
{
llListenRemove(listenHandle);
listenHandle = -1;
}

if(value !="no" && value != "yes" && value != "true" && value != "false")
use_voice = FALSE;
else
if(value == "no" || value == "false")
use_voice = FALSE;
else
{
use_voice = TRUE;
listenHandle = llListen(1,"","","");
}
next_line();
return;
}
if(llGetSubString(data,0,10) == "sit_button:")
{
llSetSitText(llGetSubString(data,12,-1));
next_line();
return;
}
next_line();
}
}
else
{
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}
}
}

P.S. Why does that PERMISSION_TRIGGER_ANIMATION always turn out be ANI MATION? :confused:
_____________________
:) Seagel Neville :)
Paul Lobo
Registered User
Join date: 3 Dec 2005
Posts: 12
Xcite! Partner program add in
02-06-2006 04:06
Hi Guys,

Thanks for this script, I've been using it in my pose balls with no problems. I've practically no Sripting know how, so this has been a god send.

I've now got Xcite Partnership and want to be able to add in the Message Link commands to get this to work, but I can't get my head around what I would need to do here.

Any suggestions would be greatly appreciated!

Cheers

Paul Lobo
Stephen Psaltery
Registered User
Join date: 4 Jan 2005
Posts: 19
Fix for rotation:
02-09-2006 20:04
CS, it is important to note that your rotation modification will not work as you intend. You cannot input values as high as 90 and get results like you are thinking. eulers in LSL are expressed in radians, not degrees.

Adding this line to the state_entry() will fix it to work as users probably expect it to: ROTATION *= DEG_TO_RAD;

The following is your rotation version, with this update applied. Anyone who wants the rotation to be able to be set within the script so you don't have to rotate the object, use the following script:

CODE

//Pose Ball script, Revision 4.1 with Rotation
//Notecard configuration enabled, switchable link_message/touch_start/llListen support, sit_text, floating text, alpha.

//By CrystalShard Foo.
//Work started - October 10th.
//Last compile - November 7th.

//This script will let you choose if you want to turn the ball visible on CLICK, or by using a SHOW/HIDE voice command.
//You can also set the offset and the title of the ball, as well as the sit button text - all with a notecard.

//This script is free and comes without support. Dont contact me. Ask a local geek for help if it gets messy.

// ** This script is NOT FOR SALE **
//You can use it in commercial products as long as you give this script to anyone who asks for it.
//You can use this source, distribute it and modify it freely, but leave the credits intact!
//(You can add your own name to the list, ofcourse. Like, "Modified by John Doe")


vector ROTATION = <0,0,0>; //Euler!

string TITLE="Sit here"; //This text will appear in the floating title above the ball
string ANIMATION=""; //Put the name of the pose/animation here!
vector offset=<0,0,0.5>; //You can play with these numbers to adjust how far the person sits from the ball. ( <X,Y,Z> )
integer use_voice = FALSE;

string gNotecard = "Pose ball - CONFIGURATION";
integer gLine = 0;

integer listenHandle = -1;
integer visible = TRUE;
float base_alpha = 1.0;
key avatar;

key dataserver_key = NULL_KEY;

show()
{
visible = TRUE;
llSetText(TITLE, <1,1,1>,1);
llSetAlpha(1, ALL_SIDES);
}

hide()
{
visible = FALSE;
llSetText("", <1,1,1>,1);
llSetAlpha(0, ALL_SIDES);
}

next_line()
{
gLine++;
dataserver_key = llGetNotecardLine(gNotecard,gLine);
}

use_defaults()
{
llSetSitText("Sit Here");
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}

init()
{

if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) //Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.");
ANIMATION = "sit";
}
else
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION,0);

if(llGetInventoryNumber(INVENTORY_NOTECARD) != 0) //If the notecard is present, use it for configuration.
{
integer i;
for(i=0;i<llGetInventoryNumber(INVENTORY_NOTECARD);i++)
if(llGetInventoryName(INVENTORY_NOTECARD,i) == gNotecard)
{
gLine = 0;
dataserver_key = llGetNotecardLine(gNotecard, 0);
return;
}
use_defaults();
}
else //No configuration notecard found... lets use the defaults.
use_defaults();
}

default
{
state_entry()
{
llSetText("Starting up", <1,1,1>,1);
ROTATION *= DEG_TO_RAD;
llSitTarget(offset,llEuler2Rot(ROTATION));
init();
}

link_message(integer sender_num, integer num, string str, key id)
{
if(num == 99)
if(str == "show")
hide();
else
if(str == "hide");
show();
}

touch_start(integer detected)
{
if(use_voice == FALSE)
{
if(visible == TRUE)
hide();
else
show();
}
else
llSay(0,llDetectedName(0)+", say 'Hide' to hide me, or 'Show' to make me show. Or just right-click and sit on me to use me.");
}

changed(integer change)
{
if(change == CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY)
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANI MATION);
llStopAnimation("sit");
llStartAnimation(ANIMATION);
if(visible == TRUE)
base_alpha = llGetAlpha(ALL_SIDES);
else
base_alpha = 1.0;
llSetAlpha(0.0,ALL_SIDES);
llSetText("",<1,1,1>,1);
}
else
{
llStopAnimation(ANIMATION);
llSetAlpha(base_alpha,ALL_SIDES);
llSetText(TITLE,<1,1,1>,1);
}
}

if(change == CHANGED_INVENTORY)
{
llSetText("Reloading configuration...",<1,1,1>,1);
init();
}
}

listen(integer channel, string name, key id, string message)
{
if(llStringLength(message)!=4)
return;

message = llToLower(message);

if(message == "show")
{
show();
return;
}
if(message == "hide")
hide();
}

dataserver(key queryid, string data)
{
if(queryid != dataserver_key)
return;

if(data != EOF)
{
if(llGetSubString(data,0,0) != ";")
{
if(llGetSubString(data,0,5) == "title:")
{
TITLE = llGetSubString(data,7,-1);
next_line();
return;
}
if(llGetSubString(data,0,6) == "offset:")
{
integer length = llStringLength(data);
if(llGetSubString(data,8,8) != "<" || llGetSubString(data,length - 1,length) != ">")
{
llSay(0,"Error: The numbers in the offset value lack the '<' and '>' signs. (Should be something like <3,1,6> )");
offset = <0,0,0.5>;

}
else
offset = (vector)llGetSubString(data,8,-1);

llSitTarget(offset,llEuler2Rot(ROTATION));
next_line();
return;
}
if(llGetSubString(data,0,5) == "voice:")
{
string value = llGetSubString(data,7,-1);
value = llToLower(value);

if(listenHandle != -1)
{
llListenRemove(listenHandle);
listenHandle = -1;
}

if(value !="no" && value != "yes" && value != "true" && value != "false")
use_voice = FALSE;
else
if(value == "no" || value == "false")
use_voice = FALSE;
else
{
use_voice = TRUE;
listenHandle = llListen(0,"","","");
}
next_line();
return;
}
if(llGetSubString(data,0,10) == "sit_button:")
{
llSetSitText(llGetSubString(data,12,-1));
next_line();
return;
}
next_line();
}
}
else
{
if(visible == FALSE)
llSetText("",<1,1,1>,1);
else
llSetText(TITLE,<1,1,1>,1);
}
}
}
Jinsar Eponym
Registered User
Join date: 13 Feb 2006
Posts: 127
02-22-2006 08:17
Maybe I'm missing something with this, it SEEMS pretty foolproof, but I guess I'm the fool to prove it. I made a script, put the script into it, dropped it in a sphere, dropped in an animation, and nada.
I tried changing the fields in the script where it says "put the animation name here" (even though basic instructions say thats not necessary) but that doesn't help either. Am I missing something else?
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
02-24-2006 08:19
:eek: Didn't you sit on the ball? :D j/k
You don't have to change the script at all. hmm... make sure if there is the check mark in the left bottom "running" field on your script...
_____________________
:) Seagel Neville :)
Tuber Potato
Registered User
Join date: 26 Jan 2006
Posts: 57
Awesome Script CS Foo!
08-01-2006 08:29
I love this script. It worked right out the box for me. Only problem I had was my own fault. I had a type-o in the name of the notecard so the script wasn't reading it. Once I figured that out, the script read teh notecard just fine. But like I said that was my fault, lol

One question however. How hard would be to allow for multiple animins in the pose ball? For example, I have seen chairs and couchs (By Relic specifically) that have all the fuctionality of this script, but when you press Page Up or Page Down, you can cycle through the multiple anims in the pose ball.

How hard would it be to add the ability to cycle through multiple anims?

I do not have a lot of scripting experience, but I am learning. If someone can point me in the right direction and perhaps help me with this, I'd appreciate it much. And of course, I would post the results.

Thanks in Advance,
Tuber Potato
Tuber Potato
Registered User
Join date: 26 Jan 2006
Posts: 57
Awesome Script CS Foo!
08-01-2006 09:12
***Sorry if this is a double post, I posted it about 30 minutes ago, and it did not show up, nor did a search of the forums reveal that I had posted int eh wrong place (I hate retyping posts, arrrrg).


Anyway, I love this script, and it works perfectly. However, I was wondering if anyone knew a way to make the pose cycle through multiple poses if person sitting in it hits a key, like page up or page down.

I want to put multiple poses in a pose ball and allow the user to choose which pose to sit in.

A perfect example of this funtionality resides in chairs made by Baron Grayson knows as the "RELIC - Fat Little Sofa"

If anyone can help me mod this script for such functionality, I would greatly appreciate it and offer the code here as open source as well.

Thanks!
Tuber

PS I am not a scripter, but I can feel my way around them fairly well.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
08-02-2006 01:12
1. Use list to contain all your animaitons.
2. Use llTakeControls to control them by the keyboard commands.
3. Count controls to change animations in the list every time when you take control under control evet.
For example,
CODE
integer count;
integer NumberOfAnimations;
string ANIMATION;
list ANIM_LIST;
CODE
control(key id, integer held, integer change)
{
if (held & CONTROL_UP)
{
count++;
if(count > NumberOfAnimations)
{
count = 0;
}
llStopAnimation(ANIMATION);
ANIMATION = llList2String(ANIM_LIST, count);
llStartAnimation(ANIMATION);
}
else if (held & CONTROL_DOWN)
{
count--;
if(count < 0)
{
count = NumberOfAnimations);
}
llStopAnimation(ANIMATION);
ANIMATION = llList2String(ANIM_LIST, count);
llStartAnimation(ANIMATION);
}
}
_____________________
:) Seagel Neville :)
LadyLutha Harlow
Registered User
Join date: 9 Sep 2006
Posts: 18
12-08-2006 15:48
Ok, maybe Im being totally stupid - after reading that this script could be dropped into furniture I thought it was the answer to my prayers. (I'm trying to make the one-prim bar stools from tubes sit-on-able).

I cant find a way to have the avi sit on them and then always face the same direction when anyone esle sits on them.

I posted in the building forum but the script offered there also doesnt seem to work.

My prooblem with the script on this post is that, 1. it now makes the chair disappear, and 2. my Avi still sits at 90 degrees from the stool looking at the floor.

Please can anyone help me - Im going totally nuts!!
_____________________
Remember Your Yesterdays, Dream Your Tomorrows, But Live for Today....
Jesse Goulet
Registered User
Join date: 27 Jul 2006
Posts: 1
Thank you!!!
01-15-2007 09:16
This is a lifesaver for me. Thank you so much.
Paul Lobo
Registered User
Join date: 3 Dec 2005
Posts: 12
01-19-2007 08:41
From: LadyLutha Harlow
Ok, maybe Im being totally stupid - after reading that this script could be dropped into furniture I thought it was the answer to my prayers. (I'm trying to make the one-prim bar stools from tubes sit-on-able).

I cant find a way to have the avi sit on them and then always face the same direction when anyone esle sits on them.

I posted in the building forum but the script offered there also doesnt seem to work.

My prooblem with the script on this post is that, 1. it now makes the chair disappear, and 2. my Avi still sits at 90 degrees from the stool looking at the floor.

Please can anyone help me - Im going totally nuts!!


You need to drop the animation script into a pose ball. Attach (link) the pose ball to the furniture. If you have just one pose ball, then make it transparent using a completely clear texture. That should fix it. IM me in world if you are still having problems, I have a training pack that you might find useful, it's a dummies guide for making and adding pose balls to furniture.

Good luck!

Paul Lobo
En:joy animations
1 2