Jump to content

[LE] When transferring items from container to player via script, I cannot transfer the items back.


corrado33

Recommended Posts

Say I put the following script on a chest.

event onActivate(objectReference akActivator)
		int mannItems = self.GetNumItems()
		int counter = 0
		debug.notification("TotalItems: " + mannItems)
		while (counter < mannItems)
			self.removeitem(self.GetNthForm(counter),1,TRUE,game.getplayer())
                        counter += 1
		endwhile
endEvent

It will transfer everything in a chest to the player.

 

It works great.

 

But... it won't let me then transfer the items BACK to the chest. It's like it continues to run forever. If I try to put something that's been transferred to me BACK into the chest, it'll just give it right back to me.

 

How cant I make it... not do this?

 

EDIT: Geeze programmer's curse strikes again. As soon as I ask for help I figure it out.

 

change counter += 1 to mannItems -= 1

Edited by corrado33
Link to comment
Share on other sites

Say I put the following script on a chest.

event onActivate(objectReference akActivator)
		int mannItems = self.GetNumItems()
		int counter = 0
		debug.notification("TotalItems: " + mannItems)
		while (counter < mannItems)
			self.removeitem(self.GetNthForm(counter),1,TRUE,game.getplayer())
                        counter += 1
		endwhile
endEvent

It will transfer everything in a chest to the player.

 

It works great.

 

But... it won't let me then transfer the items BACK to the chest. It's like it continues to run forever. If I try to put something that's been transferred to me BACK into the chest, it'll just give it right back to me.

 

How cant I make it... not do this?

 

EDIT: Geeze programmer's curse strikes again. As soon as I ask for help I figure it out.

 

change counter += 1 to mannItems -= 1

Ah, I didn't know such a command existed. That's the downside to just discovering this language. :) Thanks!

Link to comment
Share on other sites

Ah, I didn't know such a command existed. That's the downside to just discovering this language. :smile: Thanks!

 

If you haven't already you might check out https://www.creationkit.com/index.php?title=Category:Papyrus

As boring as it's going to be it's worth at least browsing through the list of all the different functions to know what's out there. You don't necessarily need to understand what they all do immediately. But later having seen the names, it may prove useful to remember that something might exist to do what you want.

Link to comment
Share on other sites

 

Ah, I didn't know such a command existed. That's the downside to just discovering this language. :smile: Thanks!

 

If you haven't already you might check out https://www.creationkit.com/index.php?title=Category:Papyrus

As boring as it's going to be it's worth at least browsing through the list of all the different functions to know what's out there. You don't necessarily need to understand what they all do immediately. But later having seen the names, it may prove useful to remember that something might exist to do what you want.

 

Ah! I had been to that specific site but was unaware that it listed all available commands. I thought you had to go into each individual... part (like object reference) It's perfect! Thanks.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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