Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dance Balls

Cordelia Schwarz
Registered User
Join date: 18 Jun 2008
Posts: 14
08-03-2008 10:53
Hi everyone! This is my first post here (and, with my scripting abilities, it probably won't be the last time lol)

My question is this: I am making a dance ball using the freebie "Dance Script". Unfortunately it will only hold 11 dances (as far as I can see). Is there a way I can get it to hold more dances - say about 20?

Thanx in advance.
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
re
08-03-2008 14:40
if its like the solop dance ball open the server script you should see some thing like

integer danceslots = #;

change integer danceslots = 10;

then copy mainanim to your inventory then back into the dance ball till you get

mainanim 1
mainanim 2
mainanim 3
mainanim 4
mainanim 5
mainanim 6
mainanim 7
mainanim 8
mainanim 9
mainanim 10
Cordelia Schwarz
Registered User
Join date: 18 Jun 2008
Posts: 14
Re:
08-03-2008 16:05
Sorry - I'm a little bit thick! I don't quite understand what you mean.
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
08-03-2008 18:01
There are lots of dance scripts out there, where might one find the one you are trying to use? It would be easier if we could see it.

Is it only able to do 11 dances because the menu only has 12 buttons, or something like that? That kind of thing can be fixed, we'd have to see how it is doing things now.
_____________________
Cordelia Schwarz
Registered User
Join date: 18 Jun 2008
Posts: 14
Re:
08-04-2008 02:32
This is the Dance Script I am trying to use. The dance balls allows me to load as many dances as I like but, when Touched, the menu will only show 11 dances.



// Just add this script into a prim with up to 11 dances and touch the prim to start

string dances;
list dance_buttons;
integer chat_channel = -468;
integer dance_number;

stopAllDances()
{
integer total_dances = llGetInventoryNumber(INVENTORY_ANIMATION);
integer i = 0;
while(i < total_dances)
{
llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, i++));
}
}

default
{
state_entry()
{
integer total_dances = llGetInventoryNumber(INVENTORY_ANIMATION);
if(total_dances > 11) total_dances = 11;
integer i = 0;
while(i < total_dances)
{
dances = (dances = "";) + dances + (string)(++i) + " " + llGetInventoryName(INVENTORY_ANIMATION, i) + "\n";
dance_buttons = (dance_buttons = []) + dance_buttons + (string)i;
}
dance_buttons = (dance_buttons = []) + dance_buttons + "STOP";
llListen(chat_channel, "", NULL_KEY, "";);
}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), dances, dance_buttons, chat_channel);
}

listen(integer channel, string name, key id, string message)
{
if(message == "STOP";)
dance_number = -1;
else
dance_number = (integer)message - 1;
llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
}

changed(integer change)
{
if(change & CHANGED_INVENTORY)
llResetScript();
}

run_time_permissions(integer perms)
{
if(perms & PERMISSION_TRIGGER_ANIMATION)
{
stopAllDances();
if(dance_number > -1)
{
llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, dance_number));
}
}
}
}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
08-04-2008 03:55
A llDialog has 12 buttons at the most, that makes room for 11 dances and a "Stop" button.
The only way to apply llDialog for more dances is by introducing sub-menus
_____________________
From Studio Dora
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
08-04-2008 03:56
you could have two dance balls?
_____________________
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
08-04-2008 09:52
This script is a little eh, sort of works with multiple people but will ask for permission an awful lot. Here it is with more dances and possibly a little less naggy about those perms.

CODE

// Add this script into a prim with dances and touch the prim to start.
//
// You can put as many dances as will fit into memory. If you put in too many,
// you will get a nice friendly stack/heap collision error. If that happens, take
// out some dances and reset the script. Isn't that fun?

list dances;
list danceButtons;
integer danceNumber;

// Stuff for the menu
integer dlgSlots = 9; // available buttons in a multipage dialog
integer dlgMax = 12; // number of buttons in a plain old dialog
integer dlgLength; // size of the button list
integer dlgLastPage; // how many pages do we have?
integer dlgChannel = -468;


// Stop dances and play the next, if any.
PlayDance() {
integer totalDances = llGetInventoryNumber(INVENTORY_ANIMATION);
integer i = 0;
while(i < totalDances)
llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, i++));

if(danceNumber > -1) {
llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, danceNumber));
}
}


// Hunt through inventory and load any animiations found.
LoadDances() {
integer totalDances = llGetInventoryNumber(INVENTORY_ANIMATION);
dances = [];
danceButtons = [];
integer i = 0;
while(i < totalDances){
dances = (dances = []) + dances
+ [(string)(++i) + " " + llGetInventoryName(INVENTORY_ANIMATION, i)];
danceButtons = (danceButtons = []) + danceButtons + (string)i;
}

dlgLength = llGetListLength(danceButtons);

// Add a stop button if we won't need a paged menu.
if (dlgLength > 0 && dlgLength < dlgMax) {
danceButtons = (danceButtons = []) + "[STOP]" + danceButtons;
dlgLength++;
}

dlgLastPage = (dlgLength - 1) / dlgSlots;
}


Dialog(key id, integer page) {
if (danceButtons == []) {
llInstantMessage(id, "No dances to play, feed me!");
return;
}

if (llList2String(danceButtons, 0) == "[STOP]") {
// plain old dialog
llDialog(id, llDumpList2String(dances, "\n"), danceButtons, dlgChannel);
}
else {
// paged dialog
integer firstButton = page * dlgSlots;
list allButtons = llList2List(danceButtons, firstButton, firstButton + dlgSlots - 1);


// figure out what the next and previous page are.
integer nextPage = page + 1;
if (nextPage > dlgLastPage)
nextPage = 0;
integer prevPage = page - 1;
if (prevPage < 0)
prevPage = dlgLastPage;

allButtons = (allButtons=[])
+ ["<< " + (string) prevPage, "[STOP]", ">> " + (string) nextPage] + allButtons;
llDialog(
id,
llDumpList2String(llList2List(dances, firstButton, firstButton + dlgSlots - 1), "\n"),
allButtons,
dlgChannel
);
}
}

default {
state_entry() {
LoadDances();
llListen(dlgChannel, "", NULL_KEY, "");
}

changed (integer change) {
if (change & CHANGED_INVENTORY)
LoadDances();
}

touch_start(integer total_number) {
Dialog(llDetectedKey(0), 0);
}

listen(integer channel, string name, key id, string message) {
string pageCheck = llGetSubString(message, 0, 2);
if (pageCheck == "<< " || pageCheck == ">> ") {
if (message != pageCheck) // actually more than the arrow markers?
Dialog(id, (integer) llGetSubString(message, 3, -1));
return; // no need to mess with animations this time
}
else if (message == "[STOP]") {
danceNumber = -1;
}
else {
danceNumber = (integer)message - 1;
}

// If we still hold animation permission for this avatar, we don't
// need to ask again.
if ((id == llGetPermissionsKey()) && (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
PlayDance();
else
llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perms) {
if(perms & PERMISSION_TRIGGER_ANIMATION)
PlayDance();
}
}
_____________________
Cordelia Schwarz
Registered User
Join date: 18 Jun 2008
Posts: 14
Re:
08-04-2008 13:32
Viktoria - you are amazing!! This script works perfectly. Thank you SO much. :)
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
08-04-2008 14:22
Oop, not perfectly! This line

dlgLastPage = dlgLength / dlgSlots;

should have been

dlgLastPage = (dlgLength - 1) / dlgSlots;

It would choke if the number of anims happened to be a multiple of 9. That one gets me every time :p
_____________________