Kerbal Inventory System (KIS)

Kerbal Inventory System (KIS)

1M Downloads

TweakScale: Zero cost of a tweakable item

ihsoft opened this issue ยท 6 comments

commented

On the forum: http://forum.kerbalspaceprogram.com/index.php?/topic/101928-112-kerbal-inventory-system-kis-1212/&page=115#comment-2714443

GUESS: It looks TweakScale module needs to start before it can provide the right part's scale. Since in the ditor all the info is grabbed from the prefab the cost may become zero.

commented

As far as I understand KIS takes the TweakScale::DryCost value from the part's config node. This is fine if the configNode is made from a physical part but will not work for the prefab. The problem is that this kspField does not come from a part config but is calculated afterwards.

In KIS_item.cs: GetCost, the simplest solution would be to always return availablePart.cost when examining a prefab, and only look for a TweakScale module when examining a physical part. Prefabs are always unscaled, so a TweakScale module should never change the properties of a part that comes directly from the editor inventory.

Another way would be to use the partModule::getModuleCost() or part.getModuleCosts() methods from the stock interface. You would call those on the physical part if present, or on the prefab if coming from the editor inventory. This will work for TweakScale (a prefab returns moduleCost=0) and would also support other cost-changing partModules without the need of explicitly knowing them.

Would one of those solutions work for you?

commented

Well, it may work. Though, the current approach in KIS has issues: cost and volume of the part are not stored in KISItem, and when these values are needed they are calculated from prefab. I.e. they will always be unscaled when calculating inventory mass and cost :( I think I'll change the inventory approach first, then fix the usage of tweak scale.

commented

This should be solved from the TweakScale side now (dev version). I found a way to write the dryCost of the prefab at an early time. Now it shows up with the right cost when dragged directly from the part list into an inventory.

commented

Great! Please, close the bug once the new version is released.

commented

Fixed in TweakScale v2.3.4. It looks like I can't close the issue because you created it.

commented

The TweakScale module of an unscaled part should always report a correct moduleCost and moduleMass of zero. If this fails for some half-initialized state then it is likely a bug on my side. I'll have a look at the issue.