Jump to content

Help with SetWeight


Recommended Posts

I'm trying to dynamically set the weight of a misc item in the players inventory.

 

Basic what I have as the (not)working bit is... there is obviously a lot more code around it :wink:

 

float fWeight
fWeight = 50.0
TWMiscRef.SetWeight( fWeight )

 

This does not work though...
can it be done or am I not interpreting what the function is suppose to do correctly ???

 

Thanks for any help :smile:

 

 

P.S.

I have also tried using a formlist to access and setwieght to the base item... that didn't work either :sad:

Edited by TheWanderer001
Link to comment
Share on other sites

You need to set the weight on the base object rather than the reference. The weight change will affect all instances of the object.

 

Here is a working example that I use to change the weight of an object in the inventory that opens a container which is intended to represent additional and / or more specific categories:

 

 

Function SetRepItemWeight(GlobalVariable GV, ObjectReference TheCont, Form RepItem)
If GV.GetValue() == 0.0
Float CurrentWeight = 0.0
CurrentWeight = TheCont.GetTotalItemWeight()
RepItem.SetWeight(CurrentWeight)
EndIf
EndFunction

This is an SKSE required function. GV is a global variable used to indicate whether or not this container category is weightless. TheCont is the pre-placed container that is used to hold the items in the "category". TheRepItem is the base form of the inventory held object which represents the container category.

Your use will obviously be different but you can use the example to see where you may have gone wrong. It should also be noted that the weight won't immediately reflect in the inventory if the weight change is taking place while in the inventory. Inventory will need to be closed and reopened for it to be noticeable.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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