Jump to content

If inventory_dropped object is this, then do this issue


Artorius Constantine
 Share

You are about to reply to a thread that has been inactive for 2805 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm stumped. I have a Troll guarding a bridge, he wants a Fairy for dinner or you won't cross..

Got everything working except the testing of the Fairy to make sure it is a Fairy and not just any old object.

Any clues what I'm doing wrong? It's definitely leaving the default state but then nothing.

 

default
{
    state_entry()
    {
        llAllowInventoryDrop(TRUE);
    }                           
    changed(integer change)
    {
        if (change & CHANGED_ALLOWED_DROP);

        state test;
    }
}
state test
{
    state_entry()
    {
        string  ItemName;
        ItemName = llGetInventoryName(INVENTORY_OBJECT, 1);
         if (ItemName == "NaS-T Fairy") {
            llSay(0, "Thanks for the dinner!");
            llSleep(2);
            llSay(0, "You are a Winner!");
            llSleep(2);
            llSay(0, "The bridge is now clear");
            llSleep(2);
            llSay(0, "You may pass with no fear.");
      }
}

 

Link to comment
Share on other sites

Hi Artorius,

It's been ages since I've scripted, but I think your script should respond to the first object dropped into it, but it'll be dead after that. Your test state has no change event handler, so it'll execute on entry, handle the first dropped object, then go idle forever after.

Why not put your test code inside the change event and do away with the test state entirely? Also, the script will only test the identity of the first object dropped into it. A second person dropping something into the prim will, even if you fix the error I've mentioned, get whatever response the first dropper got. I think you want to test the name of the last object dropped into the prim, which you'd get using...

 

integer count = llGetInventoryNumber(INVENTORY_OBJECT);ItemName = llGetInventoryName(INVENTORY_OBJECT, count);

 

Or, better yet (because your bridge will eventually fill with objects), toss the object as soon as you get its name...

ItemName = llGetInventoryName(INVENTORY_OBJECT, 1);llRemoveInventory(ItemName);

 

ETA: I also recommend the liberal use of llOwnerSay() to print progress messages, so you know what's going on. You can comment them out once things are working, or make them conditional on a global variable you set/clear. Like this

if (debug){llOwnerSay("message");}

if you set debug = 1, every debug message will print, if you set debug = 0, everything goes quiet.

 

Link to comment
Share on other sites


Artorius Constantine wrote:

Thx! I'll go at it again. Took a dinner break.

The rezzing object is a temp rezz object itself.

The Bridge rezzes the Troll on collision. The troll just delivers the chat message and then waits for the Fairy.

Once it gets a Fairy it will open the bridge then die and a new one will rezz for the next person.

Ah, kk. That solves the filling inventory problem. I still think the test state is unneeded, but can't explain why it doesn't work. The first (and only) object dropped on the thing should flip states and the test should work. Use llOwnerSay(ItemName) to make sure of the ItemName your capturing. (I added to my original post, reread it).

  • Like 1
Link to comment
Share on other sites

 

ItemName = llGetInventoryName(INVENTORY_OBJECT, 1);

Indexing inventory items starts at zero. So if the dropped Fairy is the only object in the trolls inventory, it should look like this:

 

 

ItemName = llGetInventoryName(INVENTORY_OBJECT, 0);

Or for the last object:

ItemName = llGetInventoryName(INVENTORY_OBJECT, llGetInventoryNumber(INVENTORY_OBJECT) -1);

 

 

Link to comment
Share on other sites


arton Rotaru wrote:

 
ItemName = llGetInventoryName(INVENTORY_OBJECT, 1);

Indexing inventory items starts at zero. So if the dropped Fairy is the only object in the trolls inventory, it should look like this:

 

 
ItemName = llGetInventoryName(INVENTORY_OBJECT, 0);

Or for the last object:
ItemName = llGetInventoryName(INVENTORY_OBJECT, llGetInventoryNumber(INVENTORY_OBJECT) -1);

 

 

Oops, that's the answer, Arton. I should have caught that.

Link to comment
Share on other sites

Yes that was the final answer. Got it done just before 2 AM lol

It worked, then it didn't then it did, bleeh.

After a long struggle I finally changed that 1 to a 0 an it works.

Using OnwerSay as a flow test worked a treat too. I forgot to do that too.

I think I was in to big a hurry.

Not sure how or why I messed that up but that was the issue. 1 instead of 0 that is.

I also changed the handler to INVENTORY_CHANGE instead of allowed drop.

I think because I am the owner it was ignoring my drops.

Either way it works a charm now! I'll drop you both a copy today when I get it packed up =)

Link to comment
Share on other sites

another suggestion would be llGetInventoryType

changed(integer change)    {        if(change & CHANGED_INVENTORY)        {            if(llGetInventoryType("NaS-T Fairy") == INVENTORY_OBJECT)            {                //do something            }        }    }

or add even more of a test, to make sure someone's not cheating llGetInventoryCreator

changed(integer change)    {        if(change & CHANGED_INVENTORY)        {            if(llGetInventoryType("NaS-T Fairy") == INVENTORY_OBJECT)            {                key objcreator = llGetInventoryCreator("NaS-T Fairy");//creator of the object                key scriptcreator = llGetInventoryCreator(llGetScriptName());//creator of this script                if(objcreator == scriptcreator)//they both have the same creator, so this person was not cheating                {                    //do something                }            }        }    }
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2805 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...