Jump to content
Sylvia Wasp

Idiot proof product box script - criticism wanted

Recommended Posts

Hello, 

I'm a very, very, sloooowwww novice scripter but after months of work (literally ... months!) I finally came up with what I think is a perfect script for product boxes.  So before I actually load up the product I'm posting it here in case anyone else needs to use it, and also to see if any of the script kiddies that hang out here can find some egregious flaw that I missed.  :)  Seriously, criticise away!  

The basic idea is that you rez a prim, put a texture in the inventory (the box art), then chuck this script in and it formats the box and sets it up for sale.  The box would be sold in a vendor and in MP.  Obvs. you would add some product as well.  Changing the box art in inventory leads to it automatically being put on the outside of the box.  

The intent is that it can be rezzed on the ground or attached to the HUD, and in either case, it gives you a folder of the prim inventory (minus the script itself).  Mostly, this is to avoid that annoying "(ADD)" that most folks end up putting at the end of the title so that n00bs know what to do.  Every default action that the user is likely to take would lead to them getting the folder full of inventory without any hassle or knowledge required.  

The only thing I'd (maybe) like to do, but couldn't figure out, is that it would be nice if the box when it's rezzed  on the ground was a different size (larger) than the box when it's attached, but I couldn't' see a way to do it without some nausea inducing prim transformations after it's attached or rezzed.  It didn't seem worth it (or very elegant)

code below (hopefully, lol)

Sylvia

 

//==============================
//  Sylvia's box "Magic" (2018)
//==============================

list    boxContents;
string  itemName;
string  folderName;

box_SETUP()
{
        llSetLinkPrimitiveParamsFast(LINK_THIS,[
            PRIM_SIZE,<0.05, 1.0, 1.0>,
            PRIM_TEXTURE, ALL_SIDES,TEXTURE_BLANK, <1.0, 0.5, 0.5>,<0.0, 0.0, 0.0>,0.0,
            PRIM_TEXTURE, 2, llGetInventoryName(INVENTORY_TEXTURE, 0), <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, 
            PRIM_TEXTURE, 4, llGetInventoryName(INVENTORY_TEXTURE, 0), <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0, 
            PRIM_FULLBRIGHT,ALL_SIDES,FALSE,
            PRIM_FULLBRIGHT,2,TRUE,
            PRIM_FULLBRIGHT,4,TRUE
            ]);    
}

box_TEXTURE()
{
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, 0), 2);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, 0), 4);
}

default
{
    state_entry()
    {
        box_SETUP();
        folderName = llGetSubString(llGetObjectName(),0,(llStringLength(llGetObjectName())-6));
        integer count = llGetInventoryNumber(INVENTORY_ALL);
        while (count--) {
            itemName = llGetInventoryName(INVENTORY_ALL, count);
            if (itemName != llGetScriptName() ) {
                boxContents += itemName;
            }
        }
    }

    changed(integer change)
    {
        if (change & CHANGED_INVENTORY){
        box_TEXTURE();
            }
    }
    
    on_rez(integer rez)
    {
        box_SETUP();
        folderName = llGetSubString(llGetObjectName(),0,(llStringLength(llGetObjectName())-6));
        llGiveInventoryList(llGetOwner(), folderName, boxContents);
    }
    
    attach(key id)
        {
            if (id) {
                llSleep(5.0);
                llOwnerSay("right-click to detach");
                }
        }
    
}

 

Share this post


Link to post
Share on other sites

as the script is being dropped into the box Contents after all the items, including the face texture, have been loaded then box_TEXTURE() and changed() are not necessary as the face texturing is also being done in box_SETUP()

Share this post


Link to post
Share on other sites
2 hours ago, ellestones said:

as the script is being dropped into the box Contents after all the items, including the face texture, have been loaded then box_TEXTURE() and changed() are not necessary as the face texturing is also being done in box_SETUP()

very good point.  

I do change the box texture about a dozen times before I'm finished though.  so it helps for that

Share this post


Link to post
Share on other sites

depends on your workflow I suppose

another workflow when we are often changing the box texture for visual appearance evaluation, is to drop the evaluation textures onto the face of the prim directly, rather than into Contents. And when the texture appearance is as wanted then drop everything into Contents and reset the script

Share this post


Link to post
Share on other sites
7 hours ago, ellestones said:

depends on your workflow I suppose

another workflow when we are often changing the box texture for visual appearance evaluation, is to drop the evaluation textures onto the face of the prim directly, rather than into Contents. And when the texture appearance is as wanted then drop everything into Contents and reset the script

Interesting.  That would work too.  Very old-school to drop textures that way, lol. 

I tend to get confused over which version of "Product_name (box)" I uploaded last. :) 

At the end of the day I find that you pretty much need the product shot in the folder that the user gets anyway, which is probably why I ended up with this solution.  

Not related to this at all, but in the spirit of self-criticism, I think I may change this part: 

Quote

    attach(key id)
        {
            if (id) {
                llSleep(5.0);
                llOwnerSay("right-click to detach");
                }
        }

To:

Quote

    attach(key id)
        {
            if (id) {
                llSleep(5.0);
                llOwnerSay("right-click to detach " & folderName);
                }
        }

Sylvia

Share this post


Link to post
Share on other sites

What about the no-copy objects? My boss and I currently face a very annoying problem where the unpacker she uses never unpacks items that are no copy. Which means her gacha boxes have to be rezzed instead of added to worn since if you add it, it'll only give you an error.

Share this post


Link to post
Share on other sites
1 hour ago, Sylvannas Zulaman said:

What about the no-copy objects? My boss and I currently face a very annoying problem where the unpacker she uses never unpacks items that are no copy. Which means her gacha boxes have to be rezzed instead of added to worn since if you add it, it'll only give you an error.

Well that's another interesting point, and you're right about that.  I guess I don't see this as a problem for me in that I don't intend to sell no-copy objects.  

I want to sell mostly clothing & accessories and I can't think of any situation (other than Gacha) where a no-copy item would be appropriate in that scenario.     

Even though it's wildly popular I have to say that for me personally ... I don't really like Gacha.  I think it's a bit of a scam in that it sells a false sense of uniqueness. The "secondary market" it supposedly creates is also a bit illusory IMO.  To me, Gacha machines are similar to "one armed bandit" gambling machines and I assume the scripts for those have been worked out by people more talented than I am.  

This script is just about getting the shoes and dresses out of the box and giving them to the user with minimal interaction, and as automatically as possible, but yes it *does* rely on copyable objects for sure. 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...