Jump to content

How to make a droppable static


Leubast

Recommended Posts

Could anyone help me? I'm trying to make a mod that adds an item and when dropped from your inventory it becomes a static object (specifically, a type of crafting table, but can be taken anywhere). Then crouch and using it will pick it back up.



Link to comment
Share on other sites

You need two items, one misc item for the inventory and one furniture (not static if it's a crafting table) item. Each object needs a script.

 

The misc item that will be in inventory needs an OnContainerChanged() event which will place the furniture version of the crafting table in front of the player and delete itself when it moves from the player's inventory and into the world (destination is None).

 

The furniture item will need a script that allows you to pick it back up, which actually means adding a new version of the misc item to the player's inventory and deleting itself. The traditional methods both use OnActivate(). One gives a menu with the choice to use or take. The other checks to see if the player is sneaking to make the decision about which action to take. Personally I prefer a slightly more complicated script where a normal activate is use and the drag operation is take.

Link to comment
Share on other sites

Ok, I'm trying to make a script on the crafting furniture that makes it, once grabbed (hold E), adds the misc item to the players inventory, disables itself and deletes itself (to remove it from the world).

Scriptname _CShack_CWorkbenchStatic extends ObjectReference  
Event OnGrab ()
	Game.GetPlayer().additem(Carpenter's Workbench, 1)
	Disable()
	Delete()
EndEvent

I'm very new to scripting and I tried as best as I could. Could anyone give me some scripting pointers?

Link to comment
Share on other sites

That's close, but "Carpenter's Workbench" looks like the name of your misc item. You need its formID which you'll have to assign into a property in the CK.

 

So that would be something like:

 

ScriptName _CShack_CWorkbenchStatic extends ObjectReference  

Event OnGrab()
	Game.GetPlayer().AddItem(CShack_CWorkbenchMisc, 1)
	Disable()
	Delete()
EndEvent

ObjectReference Property CShack_CWorkbenchMisc Auto
Then the code on the misc. item would be something like:

 

ScriptName _CShack_CWorkbenchMisc extends ObjectReference 
Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	if !akNewContainer ; being dropped into the world
		ObjectReference workbench = PlaceAtMe(CShack_CWorkbenchStatic, 1, false, true)
		Actor PlayerRef = Game.GetPlayer()
		float angle = PlayerRef.GetAngleZ()
		workbench.MoveTo(PlayerRef, Math.Sin(angle) * 150, Math.Cos(angle) * 150, 0, false)
		workbench.SetAngle(0.0, 0.0, angle + 180)
		workbench.Enable()
		Disable()
		Delete()
	endif
EndEvent

ObjectReference Property CShack_CWorkbenchStatic Auto
The 150 numbers control how far in front of the player the item appears and you may or may not need to adjust the 180 that sets the angle since different pieces of furniture are set up differently (some need 90, some -90, some 0).
Link to comment
Share on other sites

  • Recently Browsing   0 members

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