[Questions] Adding weight limit to containers

Post » Sat Jun 01, 2013 12:19 pm

Hello all

First of all, I'm very new to modding and using the Creation Kit. I watched some tutorial videos and I'm willing to try something out.

You see: I'm trying to give all containers in the game (Vanilla, DLC and ones added by mods) weight limits. For instance: a chest should have be able to store more items than a barrel or a small sack.

I did some searching and I came across this script on the forums:

Spoiler

Besides from the videos I watched, I have totally no experience at all with scripting. So, to be sure, I have some questions before I'm going to try this out:

I apologise in advance for possibly newbie-sounding questions. Here goes.

1. I want to add a message when a container is full: "This is full. ()" So, for instance: This barrel is full. (150)

Should I just add the following?

Debug.Notification("This  is full. ( "Current weight: " + fCurrentWeight )")

I thought I should put it just beneath the first and second "RemoveItem(akBaseItem, 1, False, akSourceContainer)". Is it correct to put it there?

So that will make the following:

Float fCurrentWeightFloat Property fMaxWeight = 420.0 AutoEvent OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)    Float fWeight = akBaseItem.GetWeight()    If aiItemCount > 1        Float fWeightTotal = fWeight * aiItemCount        If fCurrentWeight + fWeightTotal > fMaxWeight            Int iCount = aiItemCount            While iCount > 0                iCount -= 1                If fCurrentWeight + fWeight > fMaxWeight                    RemoveItem(akBaseItem, 1, False, akSourceContainer)                                        Debug.Notification("This  is full. ( "Current weight: " + fCurrentWeight )")                Else                    fCurrentWeight += fWeight                EndIf            EndWhile        Else            fCurrentWeight += fWeightTotal        EndIf    ElseIf fCurrentWeight + fWeight < fMaxWeight        fCurrentWeight += fWeight    Else        RemoveItem(akBaseItem, 1, False, akSourceContainer)                Debug.Notification("This  is full. ( "Current weight: " + fCurrentWeight )")    EndIfEndEvent

Does this look okay?

2. I don't want to change anything directly in a Bethesda Masterfile/mod plugin. I want to make my own plugin containing the changes (that apply the scripts). To do that I simply need to select a master file, don't select an active file, make the changes and then save the file as a new plugin?

3. The changes themselves. Just to make sure I'm doing the right thing. I need to select the container, right-click, select edit.

Then, in that window, I need to click "add". (I get an error: SCRIPTS: Cannot open store for class "SKI_configBase", missing file? which I just ignore I guess?)

Then, new script. -> Give it a name (Extends: ObjectReference). Right click on the script -> Edit source -> Enter the code above.

Then, save the file as a new plugin.

Should that do the trick, or did I forget something important?

Sorry if this may sound newbie, but I guess I have to start somewhere.

Thanks in advance

Kind regards

Andre

User avatar
helliehexx
 
Posts: 3477
Joined: Fri Jun 30, 2006 7:45 pm

Post » Sat Jun 01, 2013 8:25 am

The script looks solid enough, though I'm no scripting expert.

The SKI_CONFIGBASE thing is related to SkyUI. Ignore it.

I think you're forgetting one step; after attaching the script to a container, you need to go to the properties and fill in the Max Weight with a value that is appropriate for that container.

User avatar
Sarah Evason
 
Posts: 3507
Joined: Mon Nov 13, 2006 10:47 pm


Return to V - Skyrim