Jump to content

Connect craftingstation to a container...


Recommended Posts

Hi!!

 

I would like some help on how to connect a cookingpot to a container, a barrel in this case. This is in my own house and i just want to connect the one barrel to the pot!

 

The idea is to automatic get acces to all the food in that barrel when you activate the cookingpot.

 

Any ideas that can point me in the right direction would be most appreciated!! :)

 

Have a nice day ! // Anna

 

 

 

 

 

 

Link to comment
Share on other sites

Without hacking the game engine or possibly intercepting the appropriate calls via an SKSE DLL, it is not possible to have a specific container's contents accessed when activating a crafting station. The game is, as far as I know, hardcoded to look into the player's inventory when using any of the crafting UI menus.

 

What most mods do in this instance would be to transfer the items from the container(s) to the player inventory and then transfer any unused items back to the container(s) at some point.

 

When you transfer the items would be up to you, honestly. The player could cast a spell or press a hotkey to transfer the items and then activate the container. A perk entry point could be created that replaces the default activation of the crafting station, it would transfer the items and then activate the crafting station. A script could be added to the crafting station that blocks normal player activation, transfers the items and then activates the crafting station.

 

The spell and hotkey options require an extra step on the player's part but allows the crafting station UI to recognize all the items in the player inventory.

The perk entry point or added script method will cause the crafting station UI to not recognize the items newly added to the player inventory. They will still be there and be usable, they will just be greyed out until the first object has been crafted.

A script added to the crafting station that makes use of the BlockActivation function will break access to the crafting station if uninstalled and the blocked activation not disabled before hand.

 

Automatic Item Storage is one mod that can be used to link a specific container to a specific crafting station. This mod, if like its LE predecessor, will have the minor UI issue previously mentioned and will break access to crafting stations should the mod be uninstalled mid-game. Please note that I have not used the SSE version of this mod and I have not used the LE version in a long time, the blocked activation issue after uninstallation may have since been resolved.

 

I prefer to use my own Inventory Management System mod instead. (i.e. have access to remote containers at all times and use a hotkey to transfer items and then activate the crafting station)

Link to comment
Share on other sites

Hii :)

 

Thank you for your time!

 

You know what, for me this sounds really complicated. In my mind i thought this would be pretty easy and straight forward... And had there been a touturial video " ala DF127" on this it wouldnt have been any probs at all !!

 

Alright, i will need time to look this over...

 

.... :ermm: ....

Link to comment
Share on other sites

IsharaMeradin is quite right. It's actually quite a tricky thing to get working effectively as the engine was simply never designed to support it.

 

I did some investigations into this, and in my mod The Sidrat, I have a 'sorting chest' - which will distribute items to several chests specialising in particular resources, and a 'storage portal' spell to access these chests remotely. Each of these resource chests has a limited amount of item types it will accept (Eg the potions chest will only accept ingredients).

 

What I found I needed to do was to create new 'linked' crafting stations to a given resource chest with a script that identifies when crafting is beginning and ending.

 

On beginning it would move all the items from the linked chest to a second hidden chest with a 'removeAllItems', which with a onItemAdded event, detected when items were placed into it, and would then create duplicate resources in the player's inventory.

 

On ending it would empty the hidden chest, and with a similar onItemRemoved event, it would extract a similar amount of items from the player's inventory back into the original container. This would of course mean if resources were usedin crafting it would favour the ones held in the player's original inventory, but that seems fair.

 

This could take a second or two if there were many different stacks of resources, but the animation to start crafting and end crafting usually covers this - and by the time you've decided what you're going to craft it's almost certain to have finished. It would also unavoidably give the 'you are carrying too much' notification, but at least that's only hidden in the top left!

 

This forced duplication of items could mean things like player enchanted weapons etc could lose their enchantments - but as it's only done on resources, this isn't the case. Soul gems seems to work fine.

 

Notice this can all be done without SKSE - as I've tried to make the mod without the need for external requirements and compatible with XBox one which doesn't support SKSE (although if you do have SKSE installed on PC it does enhance some things).

 

One additional thing - I ended up having a lever next to the crafting station to switch between vanilla and linked versions of the station as some players liked to have additional mods which change the vanilla stations.

 

Hope this helps - dafydd99

Link to comment
Share on other sites

Hi!!

 

I would like some help on how to connect a cookingpot to a container, a barrel in this case. This is in my own house and i just want to connect the one barrel to the pot!

 

The idea is to automatic get acces to all the food in that barrel when you activate the cookingpot.

 

Any ideas that can point me in the right direction would be most appreciated!! :smile:

 

Have a nice day ! // Anna

 

perhaps review any visible code from this mod, which already provides hooks for linking containers to workstations?

 

Automatic Item Storage

https://www.nexusmods.com/skyrimspecialedition/mods/8224

 

(and which I've been using for the past ~2 years quite successfully)

Link to comment
Share on other sites

Hello, I agree with IsharaMeradin. I would transfer all the items to the player when you activate the crafting station, then transfer them back afterwords. Here's how I would do it:

 

Scriptname TM_ObjectReferenceScript extends ObjectReference 
{This script is attached to the crafting station reference}

ObjectReference Property LinkedContainer Auto 
{This Is the container linked to this crafting station}

Actor Property PlayerRef Auto

Form[] ContainerForms 
Int[] Amounts
Bool Busy = false

Event OnActivate(ObjectReference akActionRef) 
    If akActionRef == PlayerRef
        While Busy == true 
            ;wait for this script to finish doing it's thing 
        EndWhile
        
        Busy = true
        ContainerForms = LinkedContainer.GetContainerForms() ;save all forms in linked container to array 
        Int i = ContainerForms.Length
        Amounts = Utility.CreateIntArray(i) ;init Amounts array to same length as ContainerForms Array 
        While i > 0 ;save all item amounts to Amounts array
            i -= 1 
            Amounts[i] = LinkedContainer.GetItemCount(ContainerForms[i]) 
        EndWhile
        
        LinkedContainer.RemoveAllItems(akActionRef) ;transfer all items in LinkedContainer to the player
        RegisterForMenu("Crafting Menu")
        Busy = false
    Endif
EndEvent 

Event OnMenuClose(String menuName) 
    Busy = true
    UnregisterForMenu("Crafting Menu") 
    Int i = ContainerForms.Length
    While i > 0 
        i -= 1 
        Int Amount = PlayerRef.GetItemCount(ContainerForms[i]) 
        If Amount > Amounts[i] 
            Amount = Amounts[i]
        Endif 
        
        If Amount > 0 
            PlayerRef.RemoveItem(ContainerForms[i], Amount, True, LinkedContainer) ;remove items not used back to linked container.
        Endif 
    EndWhile 
    
    ;clear arrays from script memory
    ContainerForms = Utility.CreateFormArray(0) 
    Amounts = Utility.CreateIntArray(0)
    Busy = false 
EndEvent

Note that this script does require skse, and also I would change the name of the script to something more unique

Link to comment
Share on other sites

  • Recently Browsing   0 members

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