Author Topic: GetNumItems  (Read 337 times)

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
GetNumItems
« on: January 12, 2014, 08:54:52 pm »


               Hello Everybody,
This is a simple one. Well, maybe for you guys anyway. I created an Item from Misc Thin (GoldBars). I gave it a tag, and placed three of them in an area. In a convo with an NPC, I wanted to check to see if the player had all three.

Text appears of the first node I placed this Script.

#include "nw_i0_plot"
int StartingConditional()
{
 object oPC = GetFirstPC();
 string sTag = "RoyalGoldBars";
 if(GetNumItems(oPC,sTag) == 3)
 return TRUE;
 return FALSE;
}

seemed simple enough, yet in testing, the fist node is returning TRUE, when the player only has one of the Items.
The Item props show a stack size of 1-1.
What am I doing wrong this time ?

My monitors been flickering for the past couple of days. I think it's going to die.
Ed
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
GetNumItems
« Reply #1 on: January 12, 2014, 09:33:59 pm »


               Stack size shouldn't be an issue, since GetNumItems() counts items in a stack, too.

Perhaps I'm missing something obvious here, but the things that occur to me are: (1) the script is on the wrong node or on the Actions Taken tab instead of the Text Appears When tab or (2) you're testing with more than one PC in the module. What happens if you switch out GetFirstPC() with GetPCSpeaker()?
               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
GetNumItems
« Reply #2 on: January 13, 2014, 02:17:47 am »


               Squatting Monk ,
Checked the convo. Text Appears is correct
Modified oPC

#include "nw_i0_plot"
int StartingConditional()
{
object oPC = GetPCSpeaker();
string sTag = "RoyalGoldBars";

if(GetNumItems(oPC,sTag) == 3)
return TRUE;
return FALSE;
}

Verified Tags on all three items and script.
RoyalGoldBars
RoyalGoldBars
RoyalGoldBars
RoyalGoldBars

Stripped test PC's inventory to make sure there were not other Items with same Tag.
Tested again. Same result.
When Testing I never save the testing PCs. I use a chest with all the plot items in it, and an NPC to set variables and the like. I do this so that a tester never has anything on them unless I need them to have it.

Thank you for verifing that the script should work as writen. Now all I have to do is figure out why it is not.

If it helps. The PC enters a room. The NPC is sitting with his back to him. A trigger on the floor starts a convo with an invisible object. That convo offers the PC the choice of starting a convo with the NPC. The NPC stands and starts his convo.

[Owner] Are you So and So ? Text Appears(TA) A local variable that sets the convo to this node
  [Player] <>Lie<> Yes I am.
   [Ow] Did you get it ?  (TA) Bluff Check
     [Pl] Yes.
        [Ow]  Do you have it ?
           [Pl] It's in my pack  (TA) checks to see if player has any of the gold bars
              [Ow] Can I see it?
                 [Pl] <> You open your pack<>  
                   [Ow] Where are the rest ? (TA) The above script
                   [Ow] Good job.

There are other branches for the Player and the NPC, but this is the path a 40lvl Rouge goes through it.
The problem is the [Ow] Good job appears rather than the node above it.

There's always a line.
Ed
               
               

               


                     Modifié par Ed Venture, 13 janvier 2014 - 03:26 .
                     
                  


            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
GetNumItems
« Reply #3 on: January 13, 2014, 03:45:05 am »


               Yeah, the script is on the wrong node. Starting Conditional scripts return TRUE if the node should display and FALSE if it should not. The script you presented returns TRUE if the PC has all three bars, but since it's on the "Where are the rest" node, it tells the conversation to display "Where are the rest" only if the PC has all the bars and "Good job" if there are still some to find. It should be the other way around.
               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
GetNumItems
« Reply #4 on: January 13, 2014, 04:28:56 am »


               Squatting Monk,
Wow I can't believe I  did that. I should make alot of excuses so you won't think I'm stupid. Yeah I know, Toooo late. You would think after a couple hundred thousand words of dialogue, a guy could learn a thing or two.

Well thanks for saying, "Look stupid, you got it in the wrong place ! "
The help is always appreciated,

Ed

They say you can't teach an old dog new tricks, but you can't teach a dumb one nothin !
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
GetNumItems
« Reply #5 on: January 13, 2014, 05:24:48 am »


               Don't sweat it. I do stuff like that all the time and tear my hair out trying to figure out the problem. Having a fresh set of eyes is great.
               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
GetNumItems
« Reply #6 on: January 13, 2014, 05:34:01 pm »


               BTW, very small thing, but you may want the script to use <= or >=  instead of ==, in case the speaker doesn't have enough bars or has too many.

E.g.

// Returns true of the speaker has 3 or fewer bars
#include "nw_i0_plot"
int StartingConditional()
    {
    object oPC = GetPCSpeaker();
    string sTag = "RoyalGoldBars";

    return ( GetNumItems(oPC,sTag) <= 3 );
    }

               
               

               


                     Modifié par MrZork, 13 janvier 2014 - 05:36 .
                     
                  


            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
GetNumItems
« Reply #7 on: January 17, 2014, 04:17:20 am »


               MrZork ,
Sorry it took so long for the reply. Had to take a break.
Thanks for the script. I have said this to others before, and I'll say it again. I can read other peoples scripts and wind up like a deer in the head lights waiting for the truck to hit me. When some one gives you an example to compare to your own, it makes sense. Your version is much cleaner,and easier to type. I have been using the return FALSE; return TRUE: all this time. I think I like the
return ( GetNumItems(oPC,sTag) <= 3 ); much better.
I may never be worth a crap at this, but I'll keep at it as long as I'm learning.
Thanks again,
Ed