Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Page Up/Down In-order commands

JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
07-25-2008 00:13
I'm sorry for the lack in the title description. I'm not sure how to word it. I have been trouble shooting (I quite don't understand how these kind of complex operations work) and I cannot figure it out.

Basically here is what I would like the script to do.
Each time you press page up, it changes the instructions for what is to happen (play a sound, rez an object, whatever I wish for it to do.

Page up = 1st set of commands
Page up = 2nd set of commands
page up = 3rd set of commands
It needs to work in order. Then it needs to also work in reverse operation.

Page down will reverse the set of commands back down to the 1st set of commands.

For example;

Avatar pushes PAGE UP 5 times. The script is now in the 5th set of script instructions (playing a sound, animation, pose, whatever I choose to have run in the 5th set). Now the avatar wishes to return to 3rd set of commands, so they hit PAGE DOWN 2 times to return to the 3rd set of script instructions.

If there is any advanced scripters out there willing to give this a try or even just give me some tips or advice? I would great appreciate it. Thank you so much for reading. :)
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
07-25-2008 00:40
would the prim/object containing this script be attached or rezzed in world? In any case u need to get permisions to take controls. and then the other stuff is easy. Just put in counter for states and check what state it is each time PG UP or PG DN is pressed.
JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
07-25-2008 00:56
Thank you for replying.

Yes, I have the permissions and take controls already in the script.

It would be rezzed. Not attached.

And Im sorry but I dont know what you mean without some kind of an example.
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
07-25-2008 01:30
my idea is generally like

From: someone

// Related global variables and function

integer NUMBER_OF_CHOICES = 3;

integer choice;

DoTheAppropriateThing()
{
while(choice < 0) choice += NUMBER_OF_CHOICES;
while(choice >= NUMBER_OF_CHOICES) choice -= NUMBER_OF_CHOICES;

if(choice == 0)
{
llOwnerSay("Thing 0";);
}
else if(choice == 1)
{
llOwnerSay("Thing 1";);
}
else if(choice == 2)
{
llOwnerSay("Thing 2";);
}

}


From: someone

// Related control event

control(key id, integer level, integer edge)
{
if(level & edge & CONTROL_UP)
{
++choice;
DoTheAppropriateThing();
}
else if(level & edge & CONTROL_DOWN)
{
--choice;
DoTheAppropriateThing();
}
}
_____________________
JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
07-25-2008 14:50
This works great. Its exactly what I had explained. As I tested it out it worked good. Thank you so much.

Unfortunately, I left out some key details in my explanation.

When hitting page up, it needs to stop at the last set of instructions, and hitting page down needs to stop at the first set of instructions.

This was probably the most important key factor I didn't explain and I apologize. My lack of experience asking for such help in these cases.

Pressing CONTROL_FWD and CONTROL_BACK will execute the set of instructions.

-----------------------------------------------------------------------------------------------

I really hope I'm making sense here. Thank you so much again for your help. I will study this formula you've provided and see if I cant figure out what you've already given to work with what exactly I'm looking for, but in the mean time I still would greatly appreciate any more help with what more I'm looking for. Thank you so much again.
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
07-25-2008 17:31
Maybe this script is what u are looking for:

CODE

//start
integer counter = 1;
integer MaxChoices = 3;

integer Choice(integer num)
{
if(num > MaxChoices)
{
num = MaxChoices;
}
else if(num <= 0)
{
num = 1;
}
return num;
}

Function(integer num2, integer fwd_bck)
{
if((num2 == 1) && (fwd_bck == 1))
{
llSay(0, "Functioin 1. Pressed Forward.");
}
else if((num2 == 1) && (fwd_bck == 0))
{
llSay(0, "Functioin 1. Pressed Back.");
}
else if((num2 == 2) && (fwd_bck == 1))
{
llSay(0, "Functioin 2. Pressed Forward.");
}
else if((num2 == 2) && (fwd_bck == 0))
{
llSay(0, "Functioin 2. Pressed Back.");
}
else if((num2 == 3) && (fwd_bck == 1))
{
llSay(0, "I guess it is all working. Pressed Forward.");
}
else if((num2 == 3) && (fwd_bck == 0))
{
llSay(0, "I am working. Pressed Back.");
}

}

default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
}

touch_start(integer num)
{
llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS);
}

run_time_permissions(integer perm)
{
if(perm & PERMISSION_TAKE_CONTROLS)
{
llTakeControls(CONTROL_UP | CONTROL_DOWN | CONTROL_FWD | CONTROL_BACK, TRUE, FALSE);
}
}

control(key id,integer level, integer edge)
{
if(level & edge & CONTROL_UP)
{
counter += 1;
Choice(counter);
}
else if(level & edge & CONTROL_DOWN)
{
counter -= 1;
Choice(counter);
}
else if(level & edge & CONTROL_FWD)
{
Function(Choice(counter), 1);
}
else if(level & edge & CONTROL_BACK)
{
Function(Choice(counter), 0);
}
}
}
//end