GetItemCount

Post » Tue Feb 23, 2010 5:23 am

I have a result script for a piece of dialogue, which involves removing stealth boys from the player's inventory.

The script looks something like this (with some displays to see what's going on):

float SCountprinttoconsole "aaa"set SCount to player.GetItemCount Stealthboyprinttoconsole "Count %f" SCountprinttoconsole "yyy"player.removeitem Stealthboy SCount


The result is:

aaa
yyy

In other words, no display of the SCount line, presumably because SCount is being set to some invalid value. No stealth boys are removed.

Am I completely misunderstanding how GetItemCount works? Is GetItemCount not allowed in a dialogue result script? Or is it just another bugged function?

Note that GetItemCount is working perfectly in the conditions for the dialogue entry.
User avatar
ZzZz
 
Posts: 3396
Joined: Sat Jul 08, 2006 9:56 pm

Post » Tue Feb 23, 2010 4:01 am

Try a short variable, not a float.
User avatar
Aman Bhattal
 
Posts: 3424
Joined: Sun Dec 17, 2006 12:01 am

Post » Tue Feb 23, 2010 3:48 am

Try a short variable, not a float.

Already thought of that one - same result I'm afraid!
User avatar
TASTY TRACY
 
Posts: 3282
Joined: Thu Jun 22, 2006 7:11 pm

Post » Mon Feb 22, 2010 9:57 pm

Is GetItemCount not allowed in a dialogue result script?
It is, but variable declarations aren't- make a global like TempVar or something and use that instead.
User avatar
Greg Cavaliere
 
Posts: 3514
Joined: Thu Nov 01, 2007 6:31 am

Post » Tue Feb 23, 2010 4:40 am

Removed as the answer is above.
User avatar
Megan Stabler
 
Posts: 3420
Joined: Mon Sep 18, 2006 2:03 pm

Post » Tue Feb 23, 2010 12:36 am

It is, but variable declarations aren't- make a global like TempVar or something and use that instead.


Thanks! A Quest variable worked fine. The odd thing is, you can declare a reference variable in those scripts. Oh for a bit of consistency!
User avatar
Jennifer May
 
Posts: 3376
Joined: Thu Aug 16, 2007 3:51 pm

Post » Tue Feb 23, 2010 3:52 am

I didn't think you could pass non-OBSE functions quest vars. Did it accept Removeitem MyItem MyQuest.Count?

In any case, you'll find it's perfectly consistent that results scripts (quest stage scripts, perk activate scripts, dialogue ones, package end etc.), those not attached to an in-game thing can't store variables. Quest/object/effect ones can.
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am

Post » Tue Feb 23, 2010 7:47 am

Haha I totally missed that.

It is as they say - you cannot use variables that you define in a result script. You can code for them and it will compile, but it won't actually work. You have to stash the variable somewhere else, like in a quest script, and then call it explicitly (MyHappyQuest.CountStuff).
User avatar
Siobhan Wallis-McRobert
 
Posts: 3449
Joined: Fri Dec 08, 2006 4:09 pm

Post » Mon Feb 22, 2010 9:13 pm

I didn't think you could pass non-OBSE functions quest vars. Did it accept Removeitem MyItem MyQuest.Count?

Yes, it's working exactly as I intended.
User avatar
Vera Maslar
 
Posts: 3468
Joined: Wed Sep 27, 2006 2:32 pm

Post » Mon Feb 22, 2010 10:43 pm

Some types of result script will allow you to use local "ref" variables, but other types of variable will never work when declared in result scripts.

Cipscis
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am

Post » Tue Feb 23, 2010 1:51 pm

I will add that you can use variables (even declared in the result script) on terminals in a Menu Item Result Scripts with no problem.
User avatar
kat no x
 
Posts: 3247
Joined: Mon Apr 16, 2007 5:39 pm


Return to Fallout 3