Jump to content

tried to make script to transfer items between settlements, need help


Recommended Posts

hi, sorry for my bad english,

i like to make mod, the mod is simple,

everytime you activate or access workshop ( the red one ),

all items in other workshop will move to that workshop,

in this example it will move all items from red truck shop into sanctuary

 

Event workshop.OnActivate
SelectedWorkshopID = get.workshop.id

;if SelectedWorkshopID is sanctuary,
;move all items from Red Rocket truck stop to sanctuary
if workshopID == 250fe
54bae.removeallitems 250fe
endif
EndEvent

note : 250fe is sanctuary workshop id in console command

and 54bae is red truck shop workshop id in console command

 

in this moment i like to know :

1. how to input global workshop ID to papyrus property, so i no need to copy the script for every workshop

2. if global workshop id do not exist, how to add every single of them?

3. can removeallitems work in papyrus script?

4. if my program wrong, may you fix it?

Link to comment
Share on other sites

I would love to help, but your starting point would suggest that I would need to write the whole mod, which I have already done.

 

This is some fairly advanced stuff, but here you go:

WorkshopParentScript Property pWorkshopParentScript Auto Const Mandatory
ObjectReference	Property pPlayerREF Auto Const Mandatory
Keyword	Property pLocTypeWorkshop Auto Const Mandatory
GlobalVariable Property pSKK_WULock Auto Mandatory
GlobalVariable Property pSKK_WUDebug Auto Mandatory
Sound Property pUIWorkshopModeItemPickUpWorkbench Auto Const Mandatory	
Sound Property pUIWorkshopModeItemPutdownWorkbench Auto Const Mandatory
Sound Property pUIWorkshopModeItemPutDownFail Auto Const Mandatory
Message	Property pSKK_WUWorkshopConsolidate Auto Const Mandatory

Function WorkshopInventoryConsolidate()

pSKK_WULock.SetValue(1)

If pPlayerRef.GetcurrentLocation().Haskeyword(pLocTypeWorkshop)

	WorkshopScript DestinationREF = pWorkshopParentScript.GetWorkshopFromLocation(pPlayerRef.GetcurrentLocation() )

	If DestinationREF != None && DestinationREF.OwnedByPlayer == TRUE && DestinationRef.Is3DLoaded() == TRUE

		pUIWorkshopModeItemPickUpWorkbench.Play(pPlayerREF)
	
		WorkshopScript[] WorkshopREFs = pWorkshopParentScript.Workshops 
		Int iIndex = 0 
		Int iCount = 0

		While iIndex < WorkshopREFs.Length 
	
			If (WorkshopREFs[iIndex] != None) && (WorkshopREFs[iIndex].OwnedByPlayer == TRUE) && (DestinationREF != WorkshopREFs[iIndex])
			
				WorkshopREFs[iIndex].RemoveAllItems(DestinationREF, abKeepOwnership = true)
				iCount +=1
			
				If pSKK_WUDebug.getValue() >= 1 
					Debug.Trace("SKK_WU.WorkshopConsolidate " + iCount + " from " + WorkshopREFs[iIndex] + " to " + DestinationREF )
				EndIf
			
			EndIf

			iIndex += 1
	
		EndWhile
		
		pUIWorkshopModeItemPutDownWorkbench.Play(pPlayerREF)
		pSKK_WUWorkshopConsolidate.Show(iCount)			; Consolidated %.0f workshop inventories
	
	Else
	
		pUIWorkshopModeItemPutDownFail.Play(pPlayerREF)
		pSKK_WUNoOwnedWorkshop.Show()
	
	EndIf

EndIf

pSKK_WULock.SetValue(0)

EndFunction

UPDATE WARNING: RemoveAllItems() can loose stuff if the destination reference is in an unloaded cell which is why there is a Is3Dloaded() test.

Edited by SKK50
Link to comment
Share on other sites

I would love to help, but your starting point would suggest that I would need to write the whole mod, which I have already done.

which you have already done? can i get the link?

 

Console commands and their syntax are invalid for papyrus.

similar question then,

how add caps to sanctuary workshop?

 

Game.GetWorkshop("sanctuary").AddItem(gold, 100, false)

Link to comment
Share on other sites

That code is used in both Workshop Ownership & Attacks and SKK Quantum Storage which are the names of mods that you can search on.

 

EDIT: or click on my signature, its all there ...

Edited by SKK50
Link to comment
Share on other sites

  • Recently Browsing   0 members

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