Is there a way to get a list of all the items in an ObjectRe

Post » Tue Nov 20, 2012 11:49 am

Context: I want to be able to make it so that when I open my inventory, it opens the inventory of a specific actor instead. My logical progression for this was to replace all of the items in the player's inventory with all the items in the Actor's inventory, and then switch it back after the effect ends.

I know you can freely add and remove items from the inventory, but I can't figure out what items to remove/add. RemoveAllItems won't work because it just adds to the actor's current inventory, so I need a way to remove all of the items from the player's inventory, save them as a property, put all of the actor's items into the player's inventory, and then reverse it all after the effect ends. Is there any way to do this, or a different way that would solve my problem?
User avatar
RUby DIaz
 
Posts: 3383
Joined: Wed Nov 29, 2006 8:18 am

Post » Tue Nov 20, 2012 6:42 am

Snip. See Below.
User avatar
Rozlyn Robinson
 
Posts: 3528
Joined: Wed Jun 21, 2006 1:25 am

Post » Tue Nov 20, 2012 4:33 pm

what if you used a 3rd /temp container. so you could do something like:

..pseudo code..Start Some Effect	 game.getplayer().removeallitems(TempContainer)    ;Moves all player items to the temp container	 utility.wait(0.1)	 SomeActor.RemoveAllItems(Game.GetPlayer())   Moves all of Some Actors items to the now empty player.	 utility.wait(0.1)	 TempContainer.RemoveAllItems(SomeActor)  Moves all the Items in the temp container to Some Actor.  (so all in all, the contents would seem to 'switch" between the actor and the player.EndEffectEnding Effect   ;When the effect is over, do the same thing and the items should 'switch' back.  Not sure, but you may want to put a wait or something. 	 game.getplayer().removeallitems(TempContainer)	 utility.wait(0.1)	 SomeActor.RemoveAllItems(Game.GetPlayer())	 utility.wait(0.1)	 TempContainer.RemoveAllItems(SomeActor)EndEffect  ....
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Tue Nov 20, 2012 6:12 pm

Depending on what you're trying to achieve, it might be a lot easier to use this instead: http://www.creationkit.com/OpenInventory_-_Actor
User avatar
Marine Arrègle
 
Posts: 3423
Joined: Sat Mar 24, 2007 5:19 am

Post » Tue Nov 20, 2012 11:39 am

what if you used a 3rd /temp container. so you could do something like:

..pseudo code..Start Some Effect	 game.getplayer().removeallitems(TempContainer)	;Moves all player items to the temp container	 utility.wait(0.1)	 SomeActor.RemoveAllItems(Game.GetPlayer())   Moves all of Some Actors items to the now empty player.	 utility.wait(0.1)	 TempContainer.RemoveAllItems(SomeActor)  Moves all the Items in the temp container to Some Actor.  (so all in all, the contents would seem to 'switch" between the actor and the player.EndEffectEnding Effect   ;When the effect is over, do the same thing and the items should 'switch' back.  Not sure, but you may want to put a wait or something.	 game.getplayer().removeallitems(TempContainer)	 utility.wait(0.1)	 SomeActor.RemoveAllItems(Game.GetPlayer())	 utility.wait(0.1)	 TempContainer.RemoveAllItems(SomeActor)EndEffect  ....
Where would I get the temporary container, though? I thought about using this same method, but I wouldn't know where to store the items temporarily.


Depending on what you're trying to achieve, it might be a lot easier to use this instead: [link]
Yeah, I saw that but that would allow you to transfer items between the player and the character. Plus I wouldn't be able to, for instance, drop items from that inventory.
User avatar
Camden Unglesbee
 
Posts: 3467
Joined: Wed Aug 15, 2007 8:30 am

Post » Tue Nov 20, 2012 3:59 pm

Where would I get the temporary container, though? I thought about using this same method, but I wouldn't know where to store the items temporarily.
You have to create it in the CK. stick it inworld somewhere. I usually have my own, 'dummy/empty' room that i put things like that in. You could place it in a testing hall too.

edit: You would need to make a new container. no items in it, and make sure it doesn't respawn. then you need to add that container somewhere in the world.

after that, in the spell script etc.. whichever one you use to have the code swap inventories you would add something like this:

ObjectReference Property NameOfTempContainer  Auto

You then need to point that reference to the object in-world via the properties screen.


edit: Just wanted to point out too, that using removeallitems will NOT move quest items. They stay on the player. I have no idea how to turn quest items into non quest items and back again.
User avatar
Samantha Mitchell
 
Posts: 3459
Joined: Mon Nov 13, 2006 8:33 pm

Post » Tue Nov 20, 2012 8:49 am

Well I guess technically, I got what I asked for. Now everyone is running around naked though, and removeAllItems() doesn't seem to work on chests, so it isn't giving me my items back...

Interactions with inventories in papyrus seem very limited for some reason.
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Tue Nov 20, 2012 5:40 pm

Im not sure what you mean by doesn't work on chests. I use that on one of my mods to move all items from chests to players and tempchests.
to remove all items from a chest to a player would be this:
NameOfChest.RemoveAllItems(Game.Getplayer())   

The NameOfChest has to be defined though in the script beforehand and have it's property pointing to the actual chest in - world.
User avatar
A Dardzz
 
Posts: 3370
Joined: Sat Jan 27, 2007 6:26 pm

Post » Tue Nov 20, 2012 3:37 am

Im not sure what you mean by doesn't work on chests. I use that on one of my mods to move all items from chests to players and tempchests.
to remove all items from a chest to a player would be this:
NameOfChest.RemoveAllItems(Game.Getplayer())  

The NameOfChest has to be defined though in the script beforehand and have it's property pointing to the actual chest in - world.

This is the code I have:

ObjectReference Property tempContainer AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)   akCaster.removeAllItems(tempContainer,true,true)   akTarget.removeAllItems(akCaster,false,true)EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)   akCaster.removeAllItems(akTarget,false,true)   tempContainer.removeAllItems(akCaster,false,true) EndEvent
My problem is that the items transfer from the player's inventory to the chest, and then the npcs items to the player, but afterwards the items go back to the npc and the player's items are still stuck in the chest.

Also, it seems kinda weird that there's a field for transferring quest items even tough it doesn't work.
User avatar
leni
 
Posts: 3461
Joined: Tue Jul 17, 2007 3:58 pm

Post » Tue Nov 20, 2012 12:50 pm

I haven't worked with script effects much on other actors etc but what if you
replaced the akCaster with the actual player? game.getplayer().

As you have it, I can't see why it wouldn't work but just for testing see what happens when you try game.getplayer().

I'm curious myself.

edit: and yes, the parameter to move quests I believe is broken. supposed to work but doesn't.
User avatar
Kelsey Anna Farley
 
Posts: 3433
Joined: Fri Jun 30, 2006 10:33 pm

Post » Tue Nov 20, 2012 5:44 pm

after looking at it, are you sure your items are actually in the temp chest and not just being removed into nothing?

ObjectReference Property tempContainer Auto ;if this isn't pointing to an actual container inworld, then the items are being removed and not moved.

just to double check, in the spell effect window where your script is, click the properties button then make sure TempContainer is filled with the actual in-world container. I know I keep saying that, but I've missed doing that several times myself in scripts to find out, that's what slipped through.

Edit: as a test to see if your items are being moved to the temp chest and not removed, do this in the script:

ObjectReference Property tempContainer AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)   akCaster.removeAllItems(tempContainer,true,true)   akTarget.removeAllItems(akCaster,false,true)EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster);   akCaster.removeAllItems(akTarget,false,true);  tempContainer.removeAllItems(akCaster,false,true) tempContainer.Activate(Game.GetPlayer())                 ;This when the effect is over, should open the temp container.  If it doesn't open, or there's nothing inside, then your items are either not being transferred to it, or your property hasn't been filled in the CK. EndEvent
User avatar
James Rhead
 
Posts: 3474
Joined: Sat Jul 14, 2007 7:32 am

Post » Tue Nov 20, 2012 1:50 am

after looking at it, are you sure your items are actually in the temp chest and not just being removed into nothing?

ObjectReference Property tempContainer Auto ;if this isn't pointing to an actual container inworld, then the items are being removed and not moved.

just to double check, in the spell effect window where your script is, click the properties button then make sure TempContainer is filled with the actual in-world container. I know I keep saying that, but I've missed doing that several times myself in scripts to find out, that's what slipped through.

Edit: as a test to see if your items are being moved to the temp chest and not removed, do this in the script:

ObjectReference Property tempContainer AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)   akCaster.removeAllItems(tempContainer,true,true)   akTarget.removeAllItems(akCaster,false,true)EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster);   akCaster.removeAllItems(akTarget,false,true);  tempContainer.removeAllItems(akCaster,false,true)tempContainer.Activate(Game.GetPlayer())				 ;This when the effect is over, should open the temp container.  If it doesn't open, or there's nothing inside, then your items are either not being transferred to it, or your property hasn't been filled in the CK.EndEvent

I specifically went to the actual location of the chest and checked inside. The items were still there. Also, switching to Game.Getplayer() doesn't do anything different =(
User avatar
Rob
 
Posts: 3448
Joined: Fri Jul 13, 2007 12:26 am

Post » Tue Nov 20, 2012 11:40 am

This is going to bug me now too. Try the above anyhow, see if the container opens via the script. I'm wondering if the OnEffectFinish isn't firing like it should. OR.. i found this on the wiki:

http://www.creationkit.com/OnEffectFinish_-_ActiveMagicEffect

"By the time this event is called, the active magic effect may have already been deleted by the game. Any native calls to this active magic effect may fail."

I won't have time now, but I'm going to see if i can reproduce something similar later tonight. As now I want to know how to do this and why It's not working as it should.
User avatar
Trevor Bostwick
 
Posts: 3393
Joined: Tue Sep 25, 2007 10:51 am

Post » Tue Nov 20, 2012 4:15 am

This is going to bug me now too. Try the above anyhow, see if the container opens via the script. I'm wondering if the OnEffectFinish isn't firing like it should. OR.. i found this on the wiki:

[link]

"By the time this event is called, the active magic effect may have already been deleted by the game. Any native calls to this active magic effect may fail."

I won't have time now, but I'm going to see if i can reproduce something similar later tonight. As now I want to know how to do this and why It's not working as it should.

I know it's not that, though, as the npc's items go back to the npc.

Also, I get this error when I try to use Activate():
Attempting to add temporary variable named ::tempContainer_var to free list multiple times
User avatar
Zoe Ratcliffe
 
Posts: 3370
Joined: Mon Feb 19, 2007 12:45 am

Post » Tue Nov 20, 2012 5:35 pm

I just tried /made a test plugin/ that works. you cast it on someone, the items get swapped. then after 10 seconds.. (the time i have it set for the spell to last) it swaps inventories back.

I tried it on everyone, and it seems as is, only followers will re-equip their items. Everyone else doesn't. May be a way to force others with another function added to the script.

here's a link to the File if you want to check it out: https://dl.dropbox.com/u/49220981/CS_SpellTesting.rar
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Post » Tue Nov 20, 2012 6:42 am

if you want the naked NPC's to wear their clothes again. add this to the script: akTarget.SetPlayerTeammate()


Here's the Magic Effect Script from the testmod for an example.

Spoiler
Scriptname CSSpellTestEffectScript extends ActiveMagicEffect  ObjectReference Property CSTestCont AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	akCaster.RemoveAllItems(CSTestCont)	utility.wait(0.5)	akTarget.RemoveAllItems(akCaster)EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)	akTarget.SetPlayerTeammate()	akCaster.RemoveAllItems(akTarget)	utility.wait(0.5)	CSTestCont.RemoveAllItems(akCaster)	Debug.notification("Moving Items back to player")	akTarget.SetPlayerTeammate(False)EndEvent
User avatar
cheryl wright
 
Posts: 3382
Joined: Sat Nov 25, 2006 4:43 am


Return to V - Skyrim