Compiling problems

Post » Sun Jun 17, 2012 6:43 pm

I am attempting to make a bag of holding. It will work by having the play equip an armour item with a script it detects that it is equipped waits for menus to be closed then will unequip itself and open a container which is kept safely in another cell.

My current code:

Scriptname BagOfHoldingARMRSCRP extends ObjectReference  Int iCountObjectReference Property BoHCONT AutoArmor Property BagOfHoldingARMO AutoEvent OnEquipped(Actor akActor)	Utility.Wait(0.5)	BoHCONT.BlockActivation(False)	Game.GetPlayer().UnequipItem(BagOfHoldingARMO, False, False)    if akActor == Game.GetPlayer()			Debug.Notification("Working after menu closed")			BoHCONT.Activate(Game.GetPlayer())			Debug.Notification("Container activated!")	endifEndEvent

What doesn't work

  • Doesn't unequip
  • Container doesn't open
What does work
  • All the Debug.Notification()'s work
  • Waits till menus are closed before doing anything
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Mon Jun 18, 2012 4:12 am

The function Activate() does not exist for in the default Container Script, nor does it exist in the Form Script from which it extends.

Also I don't think the OnEquipped event exists for container types either.
User avatar
djimi
 
Posts: 3519
Joined: Mon Oct 23, 2006 6:44 am

Post » Mon Jun 18, 2012 6:51 am

Basically this script is attached to an armour item which when equipped will open up the container menu allowing you to place items inside. Or this is what I would like to achieve Activate may be the wrong command for that then.

The fact that my script extends ObjectReference means that it is an ObjectReference script therefore OnEquipped is available for use.
User avatar
Jessica Lloyd
 
Posts: 3481
Joined: Fri Aug 25, 2006 2:11 pm

Post » Sun Jun 17, 2012 11:25 pm

All I would like to know it how to 'activate' a container remotely. I cannot find a function that works.

Any help at all would be appreciated.
User avatar
Richard
 
Posts: 3371
Joined: Sat Oct 13, 2007 2:50 pm

Post » Sun Jun 17, 2012 9:23 pm

You need to use an ObjectReference property instead of a Container property.
User avatar
Alexandra Louise Taylor
 
Posts: 3449
Joined: Mon Aug 07, 2006 1:48 pm

Post » Sun Jun 17, 2012 5:05 pm

Thanks, the script now compiles however it doesn't open up the container. How do I make it so??
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Sun Jun 17, 2012 8:28 pm

Is the ObjectReference property filled in?
User avatar
latrina
 
Posts: 3440
Joined: Mon Aug 20, 2007 4:31 pm

Post » Sun Jun 17, 2012 7:19 pm

You need to use http://www.creationkit.com/Utility.Wait_(Papyrus) before the activation to make sure it happens when not in a menu.

Here's the code on http://www.mediafire.com/?si6e1dywqs577ic's ARMO item...
Spoiler
ScriptName BagOfHoldingArmorScript extends ObjectReferenceInt iCountObjectReference Property BagOfHoldingREF AutoArmor Property BagOfHoldingARMO AutoEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)	If akNewContainer		If akOldContainer			If (akOldContainer == Game.GetPlayer())				akOldContainer.RemoveItem(BagOfHoldingARMO, 1, True, akOldContainer)			EndIf		ElseIf (akNewContainer == Game.GetPlayer())			iCount = akNewContainer.GetItemCount(BagOfHoldingARMO)			If (iCount > 0)				iCount -= 1				akNewContainer.RemoveItem(BagOfHoldingARMO, iCount, True)			EndIf		EndIf	Else;If !akNewContainer		If BagOfHoldingREF.IsDisabled()			BagOfHoldingREF.Enable()		EndIf		BagOfHoldingREF.MoveTo(Self)		Disable()		Delete()	EndIfEndEvent;==========================Event OnEquipped(Actor akActor)	BagOfHoldingREF.BlockActivation(False)	Game.GetPlayer().UnequipItem(BagOfHoldingARMO, False, True)	Utility.Wait(0.5)	If akActor == Game.GetPlayer()		BagOfHoldingREF.Activate(Game.GetPlayer())	EndIfEndEvent

Alternatively, you could use http://www.creationkit.com/RegisterForSingleUpdate_-_Form and move the activation into an http://www.creationkit.com/OnUpdate_-_Form event. There's always more than one way to skin a cat.
User avatar
Rebecca Clare Smith
 
Posts: 3508
Joined: Fri Aug 04, 2006 4:13 pm

Post » Mon Jun 18, 2012 1:55 am

I feel that I understand most of your code. But does Activate show the container menu even when it is in another cell?? It is still not working for me if so. I believe I have set up the properties correctly having BoHCONT pointing to the instance of the object and BagOfHoldingARMO pointing to the armour object.
Is there something I'm missing here?? Do I need a script on the container itself?

Code attached to my armour object now:
Spoiler

Scriptname BagOfHoldingARMRSCRP extends ObjectReference  Int iCountObjectReference Property BoHCONT AutoArmor Property BagOfHoldingARMO Auto;Reference to the container versionEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)        if akNewContainer                if akOldContainer                        if (akOldContainer == Game.GetPlayer())                                akOldContainer.RemoveItem(BagOfHoldingARMO, 1, True, akOldContainer)                        endif                elseif (akNewContainer == Game.GetPlayer())                        iCount = akNewContainer.GetItemCount(BagOfHoldingARMO)                        if (iCount > 0)                                iCount -= 1                                akNewContainer.RemoveItem(BagOfHoldingARMO, iCount, True)                        endif                endif        ;elseif !akNewContainer                if BoHCONT.IsDisabled()                        BoHCONT.Enable()                endif                BoHCONT.MoveTo(Self)                Disable()                Delete()        endifEndEventEvent OnEquipped(Actor akActor)        BoHCONT.BlockActivation(False)        Game.GetPlayer().UnequipItem(BagOfHoldingARMO, False, True)        Utility.Wait(0.5)        if akActor == Game.GetPlayer()                BoHCONT.Activate(Game.GetPlayer())        endifEndEvent
User avatar
Josephine Gowing
 
Posts: 3545
Joined: Fri Jun 30, 2006 12:41 pm

Post » Sun Jun 17, 2012 5:55 pm

I believe what JustinOther is suggesting is that you put in a small http://www.creationkit.com/Wait_-_Utility before you show the container menu. This is because when the player equips your item, the inventory menu is being shown, and the request to show the container menu (via your Activate) is ignored, because the inventory menu is in the way. Wait() will not return until the player leaves the inventory menu, so then when you Activate() there shouldn’t be anything in the way preventing the container menu from showing.
User avatar
luis dejesus
 
Posts: 3451
Joined: Sun Aug 19, 2007 7:40 am

Post » Mon Jun 18, 2012 12:02 am

There is a Wait(), and the menu still doesn't show up.
User avatar
Kat Stewart
 
Posts: 3355
Joined: Sun Feb 04, 2007 12:30 am


Return to V - Skyrim