Custom Message parameter not displaying correctly

Post » Fri Nov 16, 2012 3:59 pm

Preview Mode "Im trying to display a custom message with a passed in interger value when using a button
to automatically sort and move objects from inventory to containers, interger value is not displaying correctly."

Start of Thread ***
Hello all, Im writing a script that will sort through the players inventory and move certain object types
into thier appropriate Containers throughout my Custom Underground Dwelling.

I had it working just fine before but did some uninstalling/installing of the Game, deleting of saves and
such. After doing most of that i realized I had deleted my .psc files (still learning papyrus and scripting
at this point, and didn't realize the scripts source were in a separate file, I had only backed up my
custom .pex files.) and since my script was not completely finished I had to rewrite it back from scratch.

There is alot of functionality that is currently commented out but i feel it is best not to remove anything from the script so i will put the actual script in spoiler tags.

Spoiler

Scriptname rhodes_Script_SortPlayerInventory extends objectReference
{Script to Sort through the player inventory and move Items to the various chest's in Greylords Sanctum.}

; *** Variables ***

int Max = 100
objectReference BookChest
objectReference DwarvenChest
objectReference EnchantingChest
objectReference FoodChest
objectReference GemChest
objectReference HideChest
objectReference IngotChest
objectReference IngredientChest
objectReference JewelryChest
objectReference LeatherChest
objectReference PotionChest
objectReference RawMaterialChest
objectReference ScrollChest
objectReference ESGChest
objectReference FSGChest
objectReference FrSGChest
objectReference Vault

Formlist BookList
Formlist DwarvenList
Formlist FoodList
Formlist GemList
Formlist HideList
Formlist IngotList
Formlist IngredientList
Formlist JewelryList
Formlist LeatherList
Formlist RawMaterialList
Formlist ESGList
Formlist FSGList
Formlist FrSGList

; *** PROPERTIES ***
; * Containers *
objectReference property rhodes_GreylordSanctum_Chest_Books auto
objectReference property rhodes_GreylordSanctum_Chest_Dwarven auto
objectReference property rhodes_GreylordSanctum_Chest_Food auto
objectReference property rhodes_GreylordSanctum_Chest_Gem auto
objectReference property rhodes_GreylordSanctum_Chest_Hides auto
objectReference property rhodes_GreylordSanctum_Chest_Ingots auto
objectReference property rhodes_GreylordSanctum_Chest_Jewelry auto
objectReference property rhodes_GreylordSanctum_Chest_Leathers auto
objectReference property rhodes_GreylordSanctum_Chest_Potions auto
objectReference property rhodes_GreylordSanctum_Chest_Scrolls auto
objectReference property rhodes_GreylordSanctum_Chest_SmithyRawMaterials auto
objectReference property rhodes_GreylordSanctum_Chest_SoulGemsEmpty auto
objectReference property rhodes_GreylordSanctum_Chest_SoulGemsFilled auto
objectReference property rhodes_GreylordSanctum_Chest_SoulGemsFragments auto
objectReference property rhodes_GreylordSanctum_Satchel_Ingredients auto
objectReference property rhodes_GreylordSanctum_Satchel_Enchanting auto
objectReference property rhodes_GreylordSanctum_Vault auto

; * Vanilla Ingots/forgable resources *
miscObject property IngotCorundum auto
miscObject property IngotDwarven auto
miscObject property IngotEbony auto
miscObject property IngotGold auto
miscObject property IngotIron auto
miscObject property IngotMalachite auto
miscObject property IngotMoonstone auto
miscObject property IngotOrichalcum auto
miscObject property IngotQuicksilver auto
miscObject property ingotSilver auto
miscObject property IngotSteel auto
miscObject property DragonBone auto
miscObject property DragonScales auto
miscObject property ChaurusChitin auto

; * My custom Ingots TODO:: Implement these at some time. *
;miscObject property rhodes_GreylordSanctum_IngotCordite auto
;miscObject property rhodes_GreylordSanctum_IngotTitanium auto

; * Vanilla Ores/smithable resources * TODO: Dwarven
miscObject property OreCorundum auto
miscObject property OreEbony auto
miscObject property OreGold auto
miscObject property OreIron auto
miscObject property OreMalachite auto
miscObject property OreMoonstone auto
miscObject property OreOrichalcum auto
miscObject property OreQuicksilver auto
miscObject property OreSilver auto

; * SoulGemsEmpty *
soulgem property SoulGemBlack auto
soulgem property SoulGemGrand auto
soulgem property SoulGemGreater auto
soulgem property SoulGemCommon auto
soulgem property SoulGemLesser auto
soulgem property SoulGemPetty auto

; * SoulGemsFilled *
soulgem property SoulGemBlackFilled auto
soulgem property SoulGemGrandFilled auto
soulgem property SoulGemGreaterFilled auto
soulgem property SoulGemCommonFilled auto
soulgem property SoulGemLesserFilled auto
soulgem property SoulGemPettyFilled auto

; * SoulGemFragments *
miscObject property SoulGemPiece001 auto
miscObject property SoulGemPiece002 auto
miscObject property SoulGemPiece003 auto
miscObject property SoulGemPiece004 auto
miscObject property SoulGemPiece005 auto

; * FormLists *
Formlist property rhodes_GreylordSanctum_FormList_Books auto
Formlist property rhodes_GreylordSanctum_FormList_Dwarven auto
Formlist property rhodes_GreylordSanctum_FormList_Food auto
Formlist property rhodes_GreylordSanctum_FormList_Gems auto
Formlist property rhodes_GreylordSanctum_FormList_Hides auto
Formlist property rhodes_GreylordSanctum_FormList_Ingots auto
Formlist property rhodes_GreylordSanctum_FormList_Ingredients auto
Formlist property rhodes_GreylordSanctum_FormList_Jewelry auto
Formlist property rhodes_GreylordSanctum_FormList_Leathers auto
Formlist property rhodes_GreylordSanctum_FormList_SmithyRawMaterials auto
Formlist property rhodes_GreylordSanctum_FormList_SoulGems_Empty auto
Formlist property rhodes_GreylordSanctum_FormList_SoulGems_Filled auto
Formlist property rhodes_GreylordSanctum_FormList_SoulGems_Fragments auto

; General Messages
Message property rhodes_GreylordSanctum_BooksSortedMessage auto
Message property rhodes_GreylordSanctum_CraftingSuppliesSortedMessage auto; Ingots ish
Message property rhodes_GreylordSanctum_DwarvenObjectsSortedMessage auto
Message property rhodes_GreylordSanctum_FoodsSortedMessage auto
Message property rhodes_GreylordSanctum_GemsSortedMessage auto
Message property rhodes_GreylordSanctum_HidesSortedMessage auto
Message property rhodes_GreylordSanctum_IngredientsSortedMessage auto
Message property rhodes_GreylordSanctum_JewelrySortedMessage auto
Message property rhodes_GreylordSanctum_LeathersSortedMessage auto
Message property rhodes_GreylordSanctum_SmithySuppliesSortedMessage auto; Raw Materials
Message property rhodes_GreylordSanctum_SoulGemsSortedMessage auto

; Type Item Specific Messages (containing an amount)
Message property rhodes_GreylordSanctum_IngotCorundumMessage auto
Message property rhodes_GreylordSanctum_IngotDwarvenMessage auto
Message property rhodes_GreylordSanctum_IngotEbonyMessage auto
Message property rhodes_GreylordSanctum_IngotGoldMessage auto
Message property rhodes_GreylordSanctum_IngotIronMessage auto
Message property rhodes_GreylordSanctum_IngotOrichalcumMessage auto
Message property rhodes_GreylordSanctum_IngotQuicksilverMessage auto
Message property rhodes_GreylordSanctum_IngotSilverMessage auto
Message property rhodes_GreylordSanctum_IngotSteelMessage auto
Message property rhodes_GreylordSanctum_IngotMalachiteMessage auto
Message property rhodes_GreylordSanctum_IngotMoonstoneMessage auto
Message property rhodes_GreylordSanctum_DragonBoneMessage auto
Message property rhodes_GreylordSanctum_DragonScalesMessage auto
Message property rhodes_GreylordSanctum_ChaurusChitinMessage auto
Message property rhodes_GreylordSanctum_LeatherMessage auto
Message property rhodes_GreylordSanctum_LeatherStripsMessage auto
Message property rhodes_GreylordSanctum_IngredientsMessage auto

; * Keywords *
Keyword property VendorItemBook auto
Keyword property VendorItemFood auto
Keyword property VendorItemFoodRaw auto
Keyword property VendorItemGem auto
Keyword property VendorItemSoulGem auto

Event OnActivate(objectReference player)
Debug.Trace("OnActivate Trace Started, # 01")
;Assign variables
BookChest = rhodes_GreylordSanctum_Chest_Books
;DwarvenChest = rhodes_GreylordSanctum_Chest_Dwarven
;EnchantingChest = rhodes_GreylordSanctum_Satchel_Enchanting
;ESGChest = rhodes_GreylordSanctum_Chest_SoulGemsEmpty
;FSGChest = rhodes_GreylordSanctum_Chest_SoulGemsFilled
;FrSGChest = rhodes_GreylordSanctum_Chest_SoulGemsFragments
;FoodChest = rhodes_GreylordSanctum_Chest_Food
;GemChest = rhodes_GreylordSanctum_Chest_Gem
;HideChest = rhodes_GreylordSanctum_Chest_Hides
;IngotChest = rhodes_GreylordSanctum_Chest_Ingots
;IngredientChest = rhodes_GreylordSanctum_Satchel_Ingredients
;JewelryChest = rhodes_GreylordSanctum_Chest_Jewelry
;LeatherChest = rhodes_GreylordSanctum_Chest_Leathers
;PotionChest = rhodes_GreylordSanctum_Chest_Potions
;RawMaterialChest = rhodes_GreylordSanctum_Chest_SmithyRawMaterials
;ScrollChest = rhodes_GreylordSanctum_Chest_Scrolls
;Vault = rhodes_GreylordSanctum_Vault

Debug.Trace("OnActivate Trace Started, # 02")

BookList = rhodes_GreylordSanctum_FormList_Books
;DwarvenList = rhodes_GreylordSanctum_FormList_Dwarven
;ESGList = rhodes_GreylordSanctum_FormList_SoulGems_Empty
;FSGList = rhodes_GreylordSanctum_FormList_SoulGems_Filled
;FrSGList = rhodes_GreylordSanctum_FormList_SoulGems_Fragments
;FoodList = rhodes_GreylordSanctum_FormList_Food
;GemList = rhodes_GreylordSanctum_FormList_Gems
;HideList = rhodes_GreylordSanctum_FormList_Hides
;IngotList = rhodes_GreylordSanctum_FormList_Ingots
;IngredientList = rhodes_GreylordSanctum_FormList_Ingredients
;JewelryList = rhodes_GreylordSanctum_FormList_Jewelry
;LeatherList = rhodes_GreylordSanctum_FormList_Leathers
;RawMaterialList = rhodes_GreylordSanctum_FormList_SmithyRawMaterials

Debug.Trace("OnActivate Trace Started, # 03")
player = Game.GetPlayer()
Debug.Trace("OnActivate Trace Started, # 04")

CheckBooks(player)
;CheckDwarvenObjects(player)
;CheckSoulGems(player)
;CheckFoodStuffs(player)
;CheckGems(player)
;CheckHides(player)
;CheckIngots(player)
;CheckIngredients(player)
;CheckJewelry(player)
;CheckLeather(player)
;CheckRawMaterials(player)

;player.RemoveItem(BookList, Max, true, BookChest)
;player.RemoveItem(DwarvenList, Max, true, DwarvenChest)
;player.RemoveItem(ESGList, Max, true, ESGChest)
;player.RemoveItem(FSGList, Max, true, FSGChest)
;player.RemoveItem(FrSGList, Max, true, FrSGChest)
;player.RemoveItem(FoodList, Max, true, FoodChest)
;player.RemoveItem(GemList, Max, true, GemChest)
;player.RemoveItem(HideList, Max, true, HideChest)
;player.RemoveItem(IngotList, Max, true, IngotChest)
;player.RemoveItem(IngredientList, Max, true, IngredientChest)
;player.RemoveItem(JewelryList, Max, true, JewelryChest)
;player.RemoveItem(LeatherList, Max, true, LeatherChest)
;player.RemoveItem(RawMaterialList, Max, true, RawMaterialChest)

Debug.Trace("OnActivate Trace Started, # 05")
endEvent

Function CheckBooks(objectReference player)
int totalBooks = 0
if(player.GetItemCount(VendorItemBook) > 0)
totalBooks = player.GetItemCount(VendorItemBook)
rhodes_GreylordSanctum_BooksSortedMessage.Show(totalBooks)
player.RemoveItem(BookList, Max, true, BookChest)
Debug.Trace("CK01: CheckBooks(player) has Completed. " + totalBooks + " Total Books Moved.")
endIf
endFunction

Function CheckDwarvenObjects(objectReference player)
int totalDwarvenArtifacts = 0
rhodes_GreylordSanctum_DwarvenObjectsSortedMessage.Show(totalDwarvenArtifacts)
player.RemoveItem(DwarvenList, Max, true, DwarvenChest)
debug.trace("CK02: CheckDwarvenObjects(player) has Completed.")
endFunction

Function CheckSoulGems(objectReference player)
int soulGems = 0
rhodes_GreylordSanctum_SoulGemsSortedMessage.Show(soulGems)
player.RemoveItem(ESGList, Max, true, ESGChest)
player.RemoveItem(FSGList, Max, true, FSGChest)
player.RemoveItem(FrSGList, Max, true, FrSGChest)
debug.trace("CK03: CheckSoulGems(player) has Completed.")
endFunction

Function CheckFoodStuffs(objectReference player)
int totalFoodStuffs = 0
rhodes_GreylordSanctum_FoodsSortedMessage.Show(totalFoodStuffs)
player.RemoveItem(FoodList, Max, true, FoodChest)
debug.trace("CK04: CheckFoodStuffs(player) has Completed.")
endFunction

Function CheckGems(objectReference player)
int totalGems = 0
rhodes_GreylordSanctum_GemsSortedMessage.Show(totalGems)
player.RemoveItem(GemList, Max, true, GemChest)
debug.trace("CK05: CheckGems(player) has Completed.")
endFunction

Function CheckHides(objectReference player)
int totalhides = 0
rhodes_GreylordSanctum_HidesSortedMessage.Show(totalHides)
player.RemoveItem(HideList, Max, true, HideChest)
debug.trace("CK06: CheckHides(player) has Completed.")
endFunction

Function CheckIngots(objectReference player)
int totalIngots = 0

if(player.getItemCount(IngotCorundum) > 0)
int corundum = player.GetItemCount(IngotCorundum)
totalIngots += corundum
rhodes_GreylordSanctum_IngotCorundumMessage.Show(corundum)
Debug.Trace("Player has Moved " + corundum + " Corundum Ingots!")
endIf

if(player.getItemCount(IngotDwarven) > 0)
int dwarven = player.GetItemCount(IngotDwarven)
totalIngots += dwarven
rhodes_GreylordSanctum_IngotDwarvenMessage.Show(dwarven)
Debug.Trace("Player has Moved " + dwarven + " Dwarven Ingots!")
endIf

if(player.getItemCount(IngotEbony) > 0)
int ebony = player.GetItemCount(IngotEbony)
totalIngots += ebony
rhodes_GreylordSanctum_IngotEbonyMessage.Show(ebony)
Debug.Trace("Player has Moved " + ebony + " Ebony Ingots")
endIf

if(player.getItemCount(IngotGold) > 0)
int gold = player.GetItemCount(IngotGold)
totalIngots += gold
rhodes_GreylordSanctum_IngotGoldMessage.Show()
Debug.Trace("Player has Moved " + gold + " Gold Ingots")
endIf

if(player.getItemCount(IngotMoonstone) > 0)
int moonstone = player.GetItemCount(IngotMoonstone)
totalIngots += moonstone
rhodes_GreylordSanctum_IngotMoonstoneMessage.Show()
Debug.Trace("Player has Moved " + moonstone + " Moonstone Ingots")
endIf

if(player.getItemCount(IngotIron) > 0)
int iron = player.GetItemCount(IngotIron)
totalIngots += iron
rhodes_GreylordSanctum_IngotIronMessage.Show()
Debug.Trace("Player has Moved " + iron + " Iron Ingots")
endIf

if(player.getItemCount(IngotMalachite) > 0)
int malachite = player.GetItemCount(IngotMalachite)
totalIngots += malachite
rhodes_GreylordSanctum_IngotMalachiteMessage.Show()
Debug.Trace("Player has Moved " + malachite + " Malachite Ingots")
endIf

if(player.getItemCount(IngotOrichalcum) > 0)
int orichalcum = player.GetItemCount(IngotOrichalcum)
totalIngots += orichalcum
rhodes_GreylordSanctum_IngotOrichalcumMessage.Show()
Debug.Trace("Player has Moved " + orichalcum + " Orichalcum Ingots")
endIf

if(player.getItemCount(IngotQuicksilver) > 0)
int silver = player.GetItemCount(IngotQuicksilver)
totalIngots += silver
rhodes_GreylordSanctum_IngotQuicksilverMessage.Show()
Debug.Trace("Player has Moved " + silver + " Quicksilver Ingots")
endIf

if(player.getItemCount(IngotSilver) > 0)
int silver = player.GetItemCount(IngotSilver)
totalIngots += silver
rhodes_GreylordSanctum_IngotSilverMessage.Show()
Debug.Trace("Player has Moved " + silver + " Silver Ingots")
endIf

if(player.getItemCount(IngotSteel) > 0)
int steel = player.GetItemCount(IngotSteel)
totalIngots += steel
rhodes_GreylordSanctum_IngotSteelMessage.Show()
Debug.Trace("Player has Moved " + steel + " Steel Ingots")
endIf

if(player.getItemCount(DragonBone) > 0)
int bone = player.GetItemCount(DragonBone)
totalIngots += bone
rhodes_GreylordSanctum_DragonBoneMessage.Show()
Debug.Trace("Player has Moved " + bone + " Dragon Bone")
endIf

if(player.getItemCount(DragonScales) > 0)
int scales = player.GetItemCount(DragonScales)
totalIngots += scales
rhodes_GreylordSanctum_DragonScalesMessage.Show()
Debug.Trace("Player has Moved " + scales + " DragonScales")
endIf

if(player.getItemCount(ChaurusChitin) > 0)
int chitin = player.GetItemCount(ChaurusChitin)
totalIngots += chitin
rhodes_GreylordSanctum_ChaurusChitinMessage.Show()
Debug.Trace("Player has Moved " + chitin + " Chaurus Chitin")
endIf

rhodes_GreylordSanctum_CraftingSuppliesSortedMessage.Show(totalIngots)
player.RemoveItem(IngotList, Max, true, IngotChest)
debug.trace("CK07: CheckIngots(player) has Completed.")

endFunction

Function CheckIngredients(objectReference player)
int totalIngredients = 0
rhodes_GreylordSanctum_IngredientsSortedMessage.Show(totalIngredients)
player.RemoveItem(IngredientList, Max, true, IngredientChest)
debug.trace("CK08: CheckIngredients(player) has Completed.")
endFunction

Function CheckJewelry(objectReference player)
int totalJewelry = 0
rhodes_GreylordSanctum_JewelrySortedMessage.Show(totalJewelry)
player.RemoveItem(JewelryList, Max, true, JewelryChest)
debug.trace("CK09: CheckJewelry(player) has Completed.")
endFunction

Function CheckLeather(objectReference player)
int totalLeather = 0
rhodes_GreylordSanctum_LeathersSortedMessage.Show(totalLeather)
player.RemoveItem(LeatherList, Max, true, LeatherChest)
debug.trace("CK10: CheckLeather(player) has Completed.")
endFunction

Function CheckRawMaterials(objectReference player)
int totalResources = 0
rhodes_GreylordSanctum_SmithySuppliesSortedMessage.Show(totalResources)
player.RemoveItem(RawMaterialList, Max, true, RawMaterialChest)
debug.trace("CK011: CheckRawMaterials(player) has Completed.")
endFunction

;LeveledItem Property pReward Auto
;GlobalVariable Property pCount Auto
;message property DA13VesselClue auto
;MiscObject Property IronIngot Auto
;MiscObject Property LeatherStraps Auto
;MiscObject Property DeerHide Auto
;MiscObject Property LeatherStrips Auto
;MiscObject Property Leather Auto
;Weapon Property IronDagger Auto
;Armor Property ArmorHideHelmet Auto
;MiscObject Property Gold001 Auto
;int Property pDone Auto
;Faction Property pTG02ANP Auto
;Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
;EVENT onItemAdded(form itemAdded, int itemCount, objectReference itemRef, objectReference sourceRef)
;EVENT onItemRemoved(form itemAdded, int itemCount, objectReference itemRef, objectReference sourceRef)
;debug.trace("DA13: Check player for items Kesh requested")
;debug.trace("Silver Ingot: "+gotSilverItem)
;debug.trace("Ruby: "+gotRuby)

Now on to my problem...
In the OnActivate Event I make a call to a custom function, i assign the Player Object to a reference
then pass that player reference into my custom function.

  Debug.Trace("OnActivate Trace Started, # 03")  player = Game.GetPlayer()  Debug.Trace("OnActivate Trace Started, # 04")  CheckBooks(player)

Inside my custom Function i assign a zero value to the Integer variable "totalBooks". I then do a check
to see if the player's inventory contains any Books based on using the Keyword "VendorItemBook". If
the player has any Books then I assign the value of the number of books to the "totalBooks" variable. I
then pass that variable into a custom Message, which promptly displays on the top left corner of the game
screen.

Message Text
  %.0f Books Sorted and Vaulted!

I then use the player.RemoveItem code to look through my List of Books ie.. a FormList and move them
into the appropriate storage Container.

Function CheckBooks(objectReference player)  int totalBooks = 0  if(player.GetItemCount(VendorItemBook) > 0)	totalBooks = player.GetItemCount(VendorItemBook)	rhodes_GreylordSanctum_BooksSortedMessage.Show(totalBooks)	player.RemoveItem(BookList, Max, true, BookChest)	Debug.Trace("CK01: CheckBooks(player) has Completed.  " + totalBooks + " Total Books Moved.")  endIfendFunction

All of this Said, The problem I am having is that no matter what books, or how many books I move, the Message always displays 1 less book than what I am moving, so for instance, I put 2 books in my inventory.

1. Brief History of the Empire v1
2. Brief History of the Empire v2

yet when i activate my button the message that comes back to me only shows 1 book being sorted and vaulted, but when i check both my inventory and the chest where they go both books were actually moved.

can anyone see a problem in my code logic? Is there something zero based that i dont know about? any help would be appreciated.

roadmaster
User avatar
Kevin S
 
Posts: 3457
Joined: Sat Aug 11, 2007 12:50 pm

Post » Sat Nov 17, 2012 12:05 am

Now on to my problem...
In the OnActivate Event I make a call to a custom function, i assign the Player Object to a reference
then pass that player reference into my custom function.
Why not just use a property? It's 'cheaper' and will simplify your code.
Actor Property PlayerREF Auto
Also...
If PlayerREF.GetItemCount(akItem)
...is cheaper than...
If PlayerREF.GetItemCount(akItem) > 0
...but will behave identically as GetItemCount will never return a negative value.

Edit: Never knew Keywords worked like that. Cool! Not sure, however, about your problem.
User avatar
A Lo RIkIton'ton
 
Posts: 3404
Joined: Tue Aug 21, 2007 7:22 pm

Post » Fri Nov 16, 2012 3:38 pm

Roadmaster, maybe the reason the reason the count is different is because it looks like you have one variable for getting the item count, but a different variable for moving the books:

Function CheckBooks(objectReference player)int totalBooks = 0if(player.GetItemCount(VendorItemBook) > 0)totalBooks = player.GetItemCount(VendorItemBook)rhodes_GreylordSanctum_BooksSortedMessage.Show(totalBooks)player.RemoveItem(BookList, Max, true, BookChest)Debug.Trace("CK01: CheckBooks(player) has Completed. " + totalBooks + " Total Books Moved.")endIfendFunction

You're using VendorItemBook for the GetItemCount, but BookList for moving. Maybe one of the books you moved isn't a "vendor" book?
User avatar
Maeva
 
Posts: 3349
Joined: Mon Mar 26, 2007 11:27 pm

Post » Sat Nov 17, 2012 1:52 am

couldn't

PlayerREF.GetItemCount(akItem)

return a value of zero? The purpose of the " > 0 " is to not process anything if the player doesnt have any books.

also

I havent used the Actor Property much yet, I preaty much use what i can find from other scripts, Ill check into this more.
Actor Property PlayerREF Auto

also I used "Keyword" based on

the Creationkit ObjectReference.GetItemCount_(Papyrus) webpage

I will try using a FormList as a property and see if i get the same problem though.

thanks for your reply...

roadmaster
User avatar
suzan
 
Posts: 3329
Joined: Mon Jul 17, 2006 5:32 pm

Post » Fri Nov 16, 2012 2:27 pm

Good call, Sollar. Some of the vanilla forms don't have the keywords you'd expect them to. Same with FormLists and their members.

'> 0': GetItemCount can return 0 if that's the count, but the condition
If PlayerREF.GetItemCount(akItem)
...will still only be true if the count isn't 0.
User avatar
Channing
 
Posts: 3393
Joined: Thu Nov 30, 2006 4:05 pm

Post » Fri Nov 16, 2012 3:20 pm

Roadmaster, maybe the reason the reason the count is different is because it looks like you have one variable for getting the item count, but a different variable for moving the books:

Function CheckBooks(objectReference player)int totalBooks = 0if(player.GetItemCount(VendorItemBook) > 0)totalBooks = player.GetItemCount(VendorItemBook)rhodes_GreylordSanctum_BooksSortedMessage.Show(totalBooks)player.RemoveItem(BookList, Max, true, BookChest)Debug.Trace("CK01: CheckBooks(player) has Completed. " + totalBooks + " Total Books Moved.")endIfendFunction

You're using VendorItemBook for the GetItemCount, but BookList for moving. Maybe one of the books you moved isn't a "vendor" book?

thanks for your reply, I had thought about that possibility but i check the CreationKit and looked into the Edit of both of the Brief History of the Empire books used and both have that Keyword. I never checked to make sure they were both in my formlist though, ill check that out.

roadmaster
User avatar
Silencio
 
Posts: 3442
Joined: Sun Mar 18, 2007 11:30 pm

Post » Fri Nov 16, 2012 7:10 pm

return a value of zero? The purpose of the " > 0 " is to not process anything if the player doesnt have any books.

When you use the code as JustinOther showed:
If PlayerREF.GetItemCount(akItem)
It will be evaualted as a BOOL, so zero will be false otherwise, true. (Actually, that can vary on the language, so hopefully applies the same to Papyrus, but I know the zero=false part is correct.) So what JustinOther is saying by "it's cheaper" is that there are less instructions for the computer to perform. Not a big deal on one little place, but if you start getting in to large lists, it can potentially make a difference.
User avatar
ChloƩ
 
Posts: 3351
Joined: Sun Apr 08, 2007 8:15 am

Post » Fri Nov 16, 2012 11:53 am

Good call, Sollar. Some of the vanilla forms don't have the keywords you'd expect them to. Same with FormLists and their members. '> 0': GetItemCount can return 0 if that's the count, but the condition
If PlayerREF.GetItemCount(akItem)
...will still only be true if the count isn't 0.

Ahh I think i understand now, if the count is zero the if statement will be false, but if it actually is greater than 0 then it will be true. So the if statement will only process when the count is greater than zero. right?

I come from a background of C# .net and am used to doing == > < checks in my if statements.

roadmaster
User avatar
Tania Bunic
 
Posts: 3392
Joined: Sun Jun 18, 2006 9:26 am

Post » Fri Nov 16, 2012 5:58 pm

Ahh I think i understand now, if the count is zero the if statement will be false, but if it actually is greater than 0 then it will be true. So the if statement will only process when the count is greater than zero. right?

roadmaster
Disco! :) If you need to invert it...
If !PlayerREF.GetItemCount(akItem) ; will be true only when the count is 0
User avatar
Dagan Wilkin
 
Posts: 3352
Joined: Fri Apr 27, 2007 4:20 am

Post » Fri Nov 16, 2012 11:58 am

Well i decided to drop the VendorItemBook Keyword usage and switched to the FormList usage, I still dont understand why VendorItemBook wasn't working right, But as i learn more about the qwirks of papyrus Im sure i'll eventually figure out what was causing the problem. I'll also look into using the Actor Property.

thanks for your help guys.

New code works as expected.
Function CheckBooks(objectReference player)  int totalBooks = 0  if(player.GetItemCount(BookList))	totalBooks = player.GetItemCount(BookList)	rhodes_GreylordSanctum_BooksSortedMessage.Show(totalBooks)	player.RemoveItem(BookList, Max, true, BookChest)Debug.Trace("CK01: CheckBooks(player) has Completed.  " + totalBooks + " Total Books Moved.")  endIfendFunction


roadmaster
User avatar
mishionary
 
Posts: 3414
Joined: Tue Feb 20, 2007 6:19 am


Return to V - Skyrim