Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Probably easy, but...

Tsukasa Karuna
Master of all things desu
Join date: 30 Jun 2004
Posts: 370
07-19-2007 03:10
This is driving me batty. I'm not sure if i'm tired or just not seeing something horribly obvious, but here goes. This script's pupose is to get a list of an object's contents, then rez them, sequentially, one by one each time you click on it.

Anyways:

touch_start(integer f)
{
integer i;
integer len = llGetListLength(gInventoryList);
string whatobj = llList2String(gInventoryList,i);
llSay(0, whatobj);
llRezObject(whatobj, llGetPos() + <0, 0, 2>, ZERO_VECTOR, ZERO_ROTATION, 1);
llSay(0, (string)i);
i = i + 1;
}

Yeah, i know it's wrong right now. The result is that i get the same object and number and i is never touched. I think the reason for this is that i gets re-initialized every time that touch_start occurs (on the first line.) The thing i can't figure out is how to write this so that it works. I'm positive this is right under my nose... anyone care to clue me in?

**edit

Yup. Knew it was easy and that i'd figure it out after posting. Just needed to declare the variable globally instead of in the same codeblock. :/
_____________________
".. who as of 5 seconds ago is no longer the deliverator.."
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
07-19-2007 10:11
Make i a global variable by declaring it befor the default state. Declaring it inside the touch event makes it local and basically a new i every time it is touched. Remember to reset i to 0 once it reaches the last object to rez.
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
Learjeff Innis
musician & coder
Join date: 27 Nov 2006
Posts: 817
07-19-2007 10:48
Please do us all a favor and post a subject that indicates the subject, next time. Thanks!