Help with PlaceAtMe item swapping (like portable campsite)

Post » Tue Nov 20, 2012 10:41 am

Hey guys, I can't seem to get my head around the following. What I've done is create a Portable Skinning Kit misc object, that when activated while sneaking, deletes itself, and places a crafting station version of itself in it's place. This can then be used to craft pelts. When you sneak+activate the crafting station, it deletes itself, and adds the portable kit misc object back to your inventory. What seems to be happening, is it works to place the crafting station first time, but never again, nothing gets placed the next time.

Anybody able to help?

Misc Object script

Spoiler

Scriptname HISPortSkinScript extends ObjectReference  Actor Property PlayerRef  Auto  Furniture Property HISCraftingSkinningRackPort1  Auto  MiscObject Property HISPortSkin2  Auto  Event OnLoad()BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)	If PlayerREF.IsSneaking() == TrueFloat posX = GetPositionX();Float posY = GetPositionY() ;Float posZ = Game.GetPlayer().GetPositionZ() + 1;Float angX = Game.GetPlayer().GetAngleX();Float angY = Game.GetPlayer().GetAngleY();Float angZ = Game.GetPlayer().GetAngleZ();ObjectReference placeditem = Self.PlaceAtMe(HISCraftingSkinningRackPort1)placeditem.SetPosition(posX, posY, posZ)placeditem.SetAngle(0, angY, angZ)Disable()Delete()	Debug.MessageBox("Portable Skinning kit Set Up")elsePlayerRef.AddItem(Self, 1)endifEndEvent

Crafting Station Script

Spoiler

Scriptname HISPortSkinFurnScript extends ObjectReference  Actor Property PlayerRef  Auto  MiscObject Property HISPortSkin2  Auto  Event OnActivate(ObjectReference akActionRef)if PlayerREF.IsSneaking() == True  PlayerREF.Additem(HISPortSkin2, 1, abSilent = true)		 Disable()Delete()		   Debug.Notification("Portable Skinning Kit Recovered")ElseActivate(PlayerREF, true)endifEndEvent


EDIT:

Nevermind. After messing with the script I got it working. I think it was the BlockActivation OnLoad event that fixed it :smile: Edited scripts in post.
User avatar
pinar
 
Posts: 3453
Joined: Thu Apr 19, 2007 1:35 pm

Post » Tue Nov 20, 2012 3:36 pm

Might be ...snappier:
Spoiler
ScriptName HISPortSkinScript Extends ObjectReference  Actor Property PlayerRef AutoFurniture Property HISCraftingSkinningRackPort1 AutoMiscObject Property HISPortSkin2 AutoEvent OnLoad()	BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)	If PlayerREF.IsSneaking()		Disable()		ObjectReference kPlacedItem = PlaceAtMe(HISCraftingSkinningRackPort1, 1, False, True)		kPlacedItem.SetAngle(0.0, PlayerRef.GetAngleY(), PlayerRef.GetAngleZ())		kPlacedItem.Enable()		Delete()	Else		PlayerRef.AddItem(GetBaseObject())	EndIfEndEvent
Does the Z position shift of +1 matter? If not, you can go without that line as the other parameters should be inherited when the PlaceAtMe happens.
User avatar
Alberto Aguilera
 
Posts: 3472
Joined: Wed Aug 29, 2007 12:42 am

Post » Tue Nov 20, 2012 3:54 am

Might be ...snappier:
Spoiler
ScriptName HISPortSkinScript Extends ObjectReference  Actor Property PlayerRef AutoFurniture Property HISCraftingSkinningRackPort1 AutoMiscObject Property HISPortSkin2 AutoEvent OnLoad()	BlockActivation()EndEventEvent OnActivate(ObjectReference akActionRef)	If PlayerREF.IsSneaking()		Disable()		ObjectReference kPlacedItem = PlaceAtMe(HISCraftingSkinningRackPort1, 1, False, True)		kPlacedItem.SetAngle(0.0, PlayerRef.GetAngleY(), PlayerRef.GetAngleZ())		kPlacedItem.Enable()		Delete()	Else		PlayerRef.AddItem(GetBaseObject())	EndIfEndEvent
Does the Z position shift of +1 matter? If not, you can go without that line as the other parameters should be inherited when the PlaceAtMe happens.

That works much better mate, the kit gets placed quicker and doesn't fly around when born anymore lol :P

The ELSE statement needs to stay the same though:

PlayerRef.AddItem(Self, 1)

This:

PlayerRef.AddItem(GetBaseObject())

Adds another instance of the object to your inventory, but leaves the item on the ground. I know Delete() would work there, but I prefer the original method :)
User avatar
Nicholas C
 
Posts: 3489
Joined: Tue Aug 07, 2007 8:20 am

Post » Tue Nov 20, 2012 4:37 am

Ah, that's right 'cause Self in that context is the ObjectReference that is scripted. Cool, and glad to hear the other parts helped. Reminds me a lot of the switcharoo in Bag of Holding.
User avatar
Shannon Lockwood
 
Posts: 3373
Joined: Wed Aug 08, 2007 12:38 pm


Return to V - Skyrim