Author Topic: Looking for a script to identify an item when put into a container.  (Read 347 times)

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0


               

Greetings,


Anyone have a script like this they would be willing to share? I am guessing it would need to check first if the item(s) is(are) identified, and if not ID it(them).


Laz



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #1 on: July 27, 2014, 08:40:18 pm »


               Everything nwnscript is event based.
So you have identified that the event / trigger you want is when an item is added to a container.

This event is specifically referred to as the OnDisturbed event of a container.
 
// put this OnDisturbed of a container.
void main()
{
     object oItem=GetInventoryDisturbItem();
     object oPC=GetLastDisturbed();
     int nType=GetInventoryDisturbType();
 
     switch (nType)
     {
     case INVENTORY_DISTURB_TYPE_ADDED:
            //Put your identify code here
            SetIdentified(oItem,TRUE);
           //End of Identify code
        break;
     case INVENTORY_DISTURB_TYPE_REMOVED:

        break;
     case INVENTORY_DISTURB_TYPE_STOLEN:
 
       
         break;
    }
}
So there is 3 main ways inventories can be disturbed.
items added, removed, or stolen.
I've assumed you wanted this to fire when items are added- as seen above.

Because identification is a single routine/function call, I wouldn't really worry about the checking to see if the item is identified already or not.
If its already identified, is it really so bad that we re-identify it?

http://www.nwnlexico...e=SetIdentified

nwnlexicon might be slightly out dated, but its still your friend.
I recommend it for reference.
Even people who are script guru's refer to it, as the nwnscript language is much to large for anyone person to remember it all.
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #2 on: July 27, 2014, 10:30:36 pm »


               

Thank you very much Baaelos. I will give this a try.



               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #3 on: July 29, 2014, 04:32:38 am »


               

This worked perfectly. TYVM Baaleos. I recommend to anyone using omega forges to add this to the ondisturbed event.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #4 on: July 29, 2014, 08:10:49 am »


               For a fee, obviously ':devil:'
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #5 on: July 30, 2014, 03:38:29 am »


               

Umm... what?


 


I asked the community to help with an issue, which I didn't elaborate on. Baaleos presented a solution which I verified as working, and I gave a heads up to anyone else using the system we found could benefit from this.


 


If you want my version of the script I would love to post it if these damn forums would allow me to paste (It's nothing special, I just added the code Baaleos provided to dm_forge_ondist).


               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #6 on: July 30, 2014, 03:40:03 am »


               

P.S. how the hell do you paste things on these boards anyways? I tried more reply options, paste, paste simple text, paste from word. Nothing works...



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #7 on: July 30, 2014, 07:05:25 am »


               If you mean the code tags it's

The words code inside square brackets


[ code].  And [/code ]


Hope that displayed correctly
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #8 on: July 30, 2014, 08:48:58 am »


               Regarding the "fee", I simply meant that omega forge in-game normally requires the player to pay for the upgrade, so you'd expect them to pay extra for identification. No RL implication intended!

Regarding "paste", are you using IE? For a long time, I could't get the editor to work on this site (or neverwintervault.org, for that matter) without reverting to plain text and bbcode. Then I read that IE is massively incompatible with editors like Drupal. I've switched to Firefox, no more problems. I hear that just about any browser except IE will work.
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #9 on: July 30, 2014, 09:41:32 am »


               

P.S. Sometimes you have to use CTRL C / X  / V to copy / cut / paste these sites. Seems like a conspiracy to regress to the 1970s...  ':rolleyes:'  Scary for me, as CTRL C was also the code for crashing programs on many systems... ':wacko:'



               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Looking for a script to identify an item when put into a container.
« Reply #10 on: July 31, 2014, 02:16:26 am »


               

#include "dm_forge_config"

void main()

{

    object oItemPlot = GetLastDisturbed();

    object oPC = GetLastUsedBy();


    if(!PLOT_UNFORGEABLE) return;


    if(GetPlotFlag(oItemPlot))

    {

        CopyItem(oItemPlot,oPC,TRUE);

        DestroyObject(oItemPlot,0.5);

        SendMessageToPC(oPC,"You cannot forge that item");

    }

//ID item

{

object oItem=GetInventoryDisturbItem();

     object oPC=GetLastDisturbed();

     int nType=GetInventoryDisturbType();


     switch (nType)

     {

     case INVENTORY_DISTURB_TYPE_ADDED:

            //Put your identify code here

            SetIdentified(oItem,TRUE);

           //End of Identify code

        break;

     case INVENTORY_DISTURB_TYPE_REMOVED:


        break;

     case INVENTORY_DISTURB_TYPE_STOLEN:



         break;

    }


}

}


 


 


I was using IE11. Firefox seems to handle it no problems. Thanks much. That's the code we used for the omega forge ondisturbed event.