Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multi-Level Parsing Invnetory Menu

Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
02-24-2008 13:56
Hi all, I've been thrown yet another curve-ball. At least I'm really learning some things here I guess. I need some pointers to tell me if I'm on the right track before I even begin to code this as I'm scratching my head a bit.

Current code for grabbing inventory and making a list:

CODE

create_menus()
{
gIntObjTotal = llGetInventoryNumber( INVENTORY_OBJECT );
for (i = gIntObjTotal; i > 0; --i)
{
if (llGetInventoryName( INVENTORY_OBJECT, i - 1) != "tp" && llGetInventoryName( INVENTORY_OBJECT, i - 1) != "screen")
{
choiceList = [llGetInventoryName( INVENTORY_OBJECT, i - 1 )] + choiceList;
menuList = [llGetInventoryName( INVENTORY_OBJECT, i - 1 )] + "\n" + menuList;
main_buttons = [(string)i] + main_buttons;
}
}
main_buttons = main_buttons + ["Cancel"];
}


This creates a list used as a string in the menu content, a list used to pick a chioce via position in the list, and a string of numbered buttons that corrospond to the listed inventory. (including a cancel button).

Now then here is the curve ball: Now I've been asked to add a "top menu" that goes something like

"kittens, puppies, misc"

and still be able to drag and drop inventory items labeled as such into the object and auto-populate the menu.

So... should I just read in the list pretty much the same, then attempt to parse one of the lists and search for "kittens" and turn that into a list, then search for "puppies", etc. etc.?

Or is there a nice compressed way to do this I am just not advanced enough yet to know? Or am I even going about this whole process entirely wrong and I'm striking a golf-ball with a bat?

I apologize for asking so many questions as of late, but I am suddenly on a spurt and seem to be really doing well on some projects so I'm really wanting to get my scripting to the point not just so it works, but as efficient as possible also. My goal is not to just be a good scripter but a really good and low-lag scripter.

Thanks again everyone.

- Hap
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-24-2008 22:38
are the categories preset? if so you could just detect and place them into the correct list when you build it...

if it's dynamic I'd go with some naming scheme that breaks up the list, and then maintain a second list that tracks categories indexes.... you could update the tracking list each time a new category is found.

both add to the complexity of reading, but once read it's not going to hurt much.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
02-24-2008 22:53
Okay thanks. I went ahead and read them in as lists like before and then parsed them off on the fly as there are only 3 categories and 11 possibilities (plus cancel) each keeping it within the one page of 12 buttons.

It worked out great although I had to beat my head against the wall forever to get it to work, I still consider myself a noob at what I consider the more advanced things...

I know that although everything now works perfectly as I need it.. my code is HUGE and I'm certain it could be halved or at least reduced.

I think I did a good job with the menus, but in the listen statement and doing all the comparissons I needed to do the things I needed with the data involved.. I'm thinking it's a total mess. LOL

Thank you very much for the direction assist. Now I just need to try and figure out better ways to code my things.

My best,
Haplo
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-24-2008 23:13
you could post it and let all the bored forumites tear it apart... we have the technology, blah blah blah =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
02-24-2008 23:52
You have no idea how bad I want to... but my client would probably get a little ticked off if I did. LOL :)

That's the bad part about it... It's really weird, I've suddenly got people coming to me with custom scripting jobs all because I've helped people out a few times. Now I'm writing more and more complicated things and I like it, especially since I had to give up programming years ago due to epilepsy - now controlled via meds.

However, it's putting pressure on me to learn a bit faster than I'd like. I'm using logic from my past that would be better served if I understood LSL better.

I'm falling back on using too many variable comparrisons when I've seen really cool shortcuts that sometimes I work out and other times I don't.

I'll try to get a large hulky script worked up that's similar sometime soon and post it for everyone to enjoy and use after they've torn it up and made it better :)

Thanks again and sorry I can't post it yet. I will after the initial vendor split and perms agreement between us has expired. Great person to deal with too. He gave me a bit over half up front, and vendor split the rest. I'm allowed to hard-code the vendor.

It's not like it's something many people on these forums couldn't write themselves, however many trolls could probably take it and run. Many, many apologies.

- Haplo

(To be honest, even thought it's not as perfectly coded as it could be, I'm pretty proud of myself that I made such a professional looking and working resale product for someone! My first one of this type! It's basically a room / scene rezzor tailored for his target customers with some very nifty special features built in. ;)
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-25-2008 00:06
q1: does it do what it's supposed to?
q2: does it NOT crash the sim it's on?
q3: does the client pay for it?

if yes, then you have success to be proud of (assuming q1 and q2 aren't at odds =x)

I know what you mean about helping then all the sudden people want to pay for more and more complex things, I think that happens with everyone here.

as for not posting the code, no worries, business is business, I have several scripts languishing on my HD for that very reason.

and you might be surprised, often it's faster to use variable comparisons than some of the built-in functions (how you do the comparisons can make huge differences). just takes more memorry =/
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
02-25-2008 00:19
That's cool, thanks for the positives. Yes it compiles rather quickly and isn't much of a memory hog. Only slow down it really has is using llInstantMessage for instruction transactions and there's only 3 of those per use.

Doesn't use any timers, and really, I have 3 extra variables I used as switches because I was getting too many nested if-then-else loops driving me nuts so it became easier to have about 4-5 basic blocks and just qualify them using something like:

if (switch1 == TRUE && (integer)msg != 0 && switch3 == FALSE)
blah blah blah...

then basically I defined the blocks under listen channels per dialog and it all got a lot less confusing. So I think I did a good job of cutting down as such, but it could still be much better ;)

And as always thanks again. You're one of the people on here that always has some positive input and cut and dried information. You've helped me out a lot directly and indirectly via posts I've found in searches as well.

Take care,
Haplo
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-25-2008 07:17
yay I did something right!!!...

er I meant to say "I'm glad it helped" ;)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -