TweakScale: Zero cost of a tweakable item
ihsoft opened this issue ยท 6 comments
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.
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?
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.
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.
Fixed in TweakScale v2.3.4. It looks like I can't close the issue because you created it.