Jump to content

What is wrong with RemoveIems?


Pellape

Recommended Posts

No matter if I use RemoveItem or RemoneItemNS, 1 item gets removed and I know I had 30 items

Player.RemoveItemNS Object StackSize

Does anyone have problems with this function? I also seen this in my remade Fletching mod, where not all resources gets removed at lap 1 but at lap 2.

 

I could make a loop, removing 1 item each lap to get a work around. I could also make an xOBSE bug report to see if Idle can sort it out.

Link to comment
Share on other sites

When you use an improper command, do you get a report stating why the command did not work?

 

Because you need to state the Base ID and the number to be removed. As in: player.removeitem 0003577 1 will remove one item.

Link to comment
Share on other sites

Nope. I did not need to check it as I did use it 2 lines above to add the same item to the chest:

I show the whole end section and the section above will only disturb, as it handle all exceptions

					If ( StackSize > 0 && Object.IsContainer == 0 )
						Set ItemsStr to sv_Construct "%z%n have %.0f of %n - " ItemsStr, Chest, StackSizeChest, Object
						If ( ItemType == 38 ) 
							If ( PekHobbitHomeSettingsQST.SoulGems == 2 )
								Chest.AddItemNS SoulGem5Grand5GrandSoul StackSize
							ElseIf ( PekHobbitHomeSettingsQST.SoulGems == 1 )
								Chest.AddItemNS Object StackSize
							EndIf
						Else
							Chest.AddItemNS Object StackSize
						EndIf
						Player.RemoveItemNS Object StackSize
						Set ItemsStr to sv_Construct "%z%.0f of %n added - " ItemsStr, StackSize, Object
						
						Let StackSizeChest := Chest.GetItemCount Object
						Set ItemsStr to sv_Construct "%z%n now have %.0f of %n%r" ItemsStr, Chest, StackSizeChest, Object			

I do also use a lot of set for my strings as I feel it it's easier. Old habit. I could have made the last row like this:

Let ItemsStr := $ItemsStr + Chest + "now have " + " " + StackSizeChest + " of " + Object + "%r"

But I didn't... :wink: The format of the old way is the same in C with printf, where we add % inside the string and the args after it, like a string called variable

printf ("This is what this variable holds %s", $varible);

The new way is more like basic... Just a format anyway, like comparing swedish and english, the words comes in a different order, direct in Swedish and indirect in english, active and passive sentences where Let is active and Set is passive.

 

Retros fletching
So I did notice this bug first when I rewrote Retro's fletching mod, making it more dynamic and letting me decide how many arrows to make each round. As long as your fletching is not 100, then I do not recommend more than 40 arrows each round but when you are 100, you wanna make all at the same time. So.

Lets make 10 bone arrows. First time I tell the mod to make 10, as I only have resources for 10 arrows in this example, it makes them, but only removes 1 single resource and the next round the mod makes, still in menumode, then it tells you you can make 9 arrows, so you make 9 arrows and then it removes the rest of the resources. So with 10 resources, if 1 resource makes 1 arrow, I got 19 arrows. I do not mind and did not care but it is wrong, specially in the sorter, that will go public.

Maybe it is only me that have this bloody bug but it cant be as I have the same issue with the fletching mod at both my computers.

The Loop

This is the work around I will use later I think

While ( stacksize > 0 )
	Player.RemoveItemNS Object StackSize
	Let StackSize := Player.GetItemCount Object
Loop

If the player wants to keep 1 item, lets say a tool, then I will have one more row, that adds one item back to the player. This is not how I wanted the script to look like, which is filled with work arounds and fixes.

Edited by Pellape
Link to comment
Share on other sites

Hm, RemoveItem works fine for me.

 

 

The only known issue is that if you have a stack of stolen and a stack of non-stolen items, then RemoveItem will not work accurately.

 

You've 30 stolen pieces of paper.

And 1 non-stolen piece of the same paper.

 

"RemoveItem" will tell you that 30 items got removed, but only one got really removed as RemoveItem only takes care of the non-stolen stack.

If you have just stolen items, then it will take care of the stolen stack of items and work properly.

 

 

Issues only arise if you have both. Stolen and non-stolen.

 

I've made a similar workaround for this issue as you did, but I remove one item after another in that one, until the total amount of items I need to remove is met. :smile:

Link to comment
Share on other sites

Good no one noticed a bug in my loop... :wink:

 

I did write

While ( stacksize > 0 )
	Player.RemoveItemNS Object StackSize
	Let StackSizeChest := Player.GetItemCount Object
Loop

But it is not the stack in the chest we delete as it is the stack of the player... :wink:

While ( stacksize > 0 )
	Player.RemoveItemNS Object StackSize
	Let StackSize := Player.GetItemCount Object
Loop

If I used it without checking it, it would caused an infinite loop, freezing the game

Edited by Pellape
Link to comment
Share on other sites

but the thing is that I only have 1 stack of repair hammers.

That's weird.

I never had issues with RemoveItem removing the proper amount of items of one stack.

 

 

Your loop appear different to the one I use.

As I remove one item after another and reduce the item count either one by one to exit the loop at 0.

 

Yet that was meant to catch the issue when having a normal stack and a stack of stolen goods.

 

 

It still bugs me that you have issues with just one item getting removed from one stack. :/

Link to comment
Share on other sites

My loop is made to be as optimal as possible and as fast as possible. We use to code like that in Morrowind 16 years ago, removing 1 item in a time and it is not optimal now when I have a sorting database of at least 10 chests and 719 objects/items and my goal was to make it as fast as possible.

 

Scanning all chests do take aprox 3s and sorting 2s. We should also remember that my quest is set to 1s and 0.005 when you activate it, so in reality, the sorting itself takes approx 1s and 1s to activate. It all depends on the size of stuff you handle and I will handle more than 719 items as this is only after 1h of game play, where I added the chests I do sort but they are not completed and will never be I guess. Everything is dynamic in it, not a single static reference nor object, well except for a Grand soul gem... And my 2 exception chests.

 

As i do havethis issue at 2 computers, something is messing up the removeitems anyway.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...