Jump to content

[WIP] TweakScale - Development Thread


pellinor

Recommended Posts

So am I correct in understanding that i need only add the tweak scale module, with proper variables, and if the user does have tweak scale installed, it will be called, and if they don't the game should just ignore the module?

Yep.

You can either specify which scales you want the user to be able to scale the part to using 'scaleFactors' & 'scaleNames' or you can leave those out and the part will just use the default scales.

Link to comment
Share on other sites

Something funny going on in 1.51. What happened:

1. In SPH, makin' a spaceplane.

...

I had this happen to me several times back with 1.50, so this problem isn't new to this version. I never figured out a pattern to it with regard to which parts were susceptible. I know that when I encountered it, it seemed to happen rehappen with that particular part consistently, UNTIL I exited back to KSC and then reentered the VAB (or SPH). Then I was able to build the thing I was trying to build before without issue, using the same parts in the same configuration. So, whatever this bug is, it's a strange one.

Link to comment
Share on other sites

Yep.

You can either specify which scales you want the user to be able to scale the part to using 'scaleFactors' & 'scaleNames' or you can leave those out and the part will just use the default scales.

Thanks so much. The mod is up, you can look for it on kerbalstuff, github or the forums under the name RocketWatch. You'll see very quickly why it makes sense for this part in particular to have Tweakscale.

Link to comment
Share on other sites

I currently don't use Tweakscale, as I am in the middle of an almost all stock save. Only info mods allowed, and Proc fairings, but that's besides the point. I am finishing up a mod i made months ago in prep to release it tonight. I originally did not include Tweakscale support, but it is a part that should really have it. So am I correct in understanding that i need only add the tweak scale module, with proper variables, and if the user does have tweak scale installed, it will be called, and if they don't the game should just ignore the module?

I see two viable option for that.

1st: (Somewhat crapy but easy) Let the user decide to install or not that particular MM config file. (If he/she has TS include it otherwise delete it)

2nd: (Professional) MM has the ability to use (NEEDS[scale]) Just look into some of the better mod's compatibility configs sure you can find it there and can take a look how to use it. (Maybe start with B9)

In this way your additional config file will be inteligent enought if it founds TS it adds the necessary parameters to your part.

Edited: ---------------

Thank you. I wasn't aware of the correct syntax. So edited the post. For avoid later confusions.

AND Yes That was exactly I thought of.

----------------

Edited by Ricardo79
Link to comment
Share on other sites

I currently don't use Tweakscale, as I am in the middle of an almost all stock save. Only info mods allowed, and Proc fairings, but that's besides the point. I am finishing up a mod i made months ago in prep to release it tonight. I originally did not include Tweakscale support, but it is a part that should really have it. So am I correct in understanding that i need only add the tweak scale module, with proper variables, and if the user does have tweak scale installed, it will be called, and if they don't the game should just ignore the module?

I'd recommend something like this:

@PART[yourpart]:FOR[yourmod]:NEEDS[Scale]
{
MODULE
{
name = TweakScale
type = stack
defaultScale = 2.5
}
}

I've copied this from DMagic's science mod, "NEEDS[scale]" seems to refer to Scale.dll instead of the TweakScale directory (I'm not sure about that). Omitting this will load fine, but causes an error in the logfile if TweakScale is not present. "FOR" mainly gives the timing, and can probably be omitted.

This adds a tweakScale module to the part, giving it the 'stack' scaling behavior.

defaultScale says what size the unscaled part is. For percentage-based scaling (type=free), leave out defaultScale to start at 100%.

I'd recommend to test your config. Just put TweakScale into Gamedata, start a new sandbox save, see if it scales in the editor, remove TweakScale. No need to touch your stock save.

Link to comment
Share on other sites

I have a suspicion that those hotkey objects conflict with something in other mods (like in the regolith/kas bug). The Latest dev version 1.51.1 properly checks them for nullrefs before use.

Please test if this fixes the bug (as I could not reproduce it).

Using this version shows this in the log when i try attaching the Mk2 Liquid Fuel Fuselage:

InvalidOperationException: Operation is not valid due to the current state of the object
at System.Linq.Enumerable.Single[UrlConfig] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0

at System.Linq.Enumerable.Single[UrlConfig] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.get_PartNode () [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.get_ModuleNode () [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.Setup () [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.GetModuleCost (Single defaultCost) [0x00000] in <filename unknown>:0

at Part.GetModuleCosts (Single defaultCost) [0x00000] in <filename unknown>:0

at ShipConstruct.SaveShip () [0x00000] in <filename unknown>:0

at ShipConstruction.CreateBackup (.ShipConstruct ship) [0x00000] in <filename unknown>:0

at EditorLogic.SetBackup () [0x00000] in <filename unknown>:0

at EditorLogic.<SetupFSM>m__95 (.KFSMState to) [0x00000] in <filename unknown>:0

at KerbalFSM.RunEvent (.KFSMEvent evt) [0x00000] in <filename unknown>:0

at EditorLogic.OnPodSpawn (.AvailablePart pod) [0x00000] in <filename unknown>:0

at EditorLogic.SpawnPart (.AvailablePart partInfo) [0x00000] in <filename unknown>:0

at EditorLogic.OnPartListIconTap (.AvailablePart p) [0x00000] in <filename unknown>:0

at EditorPartList.TapIcon (.AvailablePart part) [0x00000] in <filename unknown>:0

at EditorPartIcon.OnTap () [0x00000] in <filename unknown>:0

at EditorPartIcon.MouseInput (.POINTER_INFO& ptr) [0x00000] in <filename unknown>:0

at UIButton.OnInput (.POINTER_INFO& ptr) [0x00000] in <filename unknown>:0

at AutoSpriteControlBase.OnInput (POINTER_INFO ptr) [0x00000] in <filename unknown>:0

at UIManager.DispatchHelper (.POINTER_INFO& curPtr, Int32 camIndex) [0x00000] in <filename unknown>:0

at UIManager.DispatchInput () [0x00000] in <filename unknown>:0

at UIManager.Update () [0x00000] in <filename unknown>:0

(Filename: Line: -1)

InvalidOperationException: Operation is not valid due to the current state of the object
at System.Linq.Enumerable.Single[UrlConfig] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0

at System.Linq.Enumerable.Single[UrlConfig] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.get_PartNode () [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.get_ModuleNode () [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.Setup () [0x00000] in <filename unknown>:0

at TweakScale.TweakScale.OnStart (StartState state) [0x00000] in <filename unknown>:0

at Part.ModulesOnStart () [0x00000] in <filename unknown>:0

at Part+.MoveNext () [0x00000] in <filename unknown>:0

(Filename: Line: -1)

I tried using just tweakscale in a stock install, it worked perfectly with no errors where i was getting them in my modded install.

It's probably interfering with some other mod as you said, any idea which mods are more likely to conflict?

I've tried removing TweakableEverything as others have suggested but i still get the same errors.

My mod list

8U2ERHR.png

Link to comment
Share on other sites

Using this version shows this in the log when i try attaching the Mk2 Liquid Fuel Fuselage:

InvalidOperationException: Operation is not valid due to the current state of the object
at System.Linq.Enumerable.Single[UrlConfig] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Single[UrlConfig] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at TweakScale.TweakScale.get_PartNode () [0x00000] in <filename unknown>:0
at TweakScale.TweakScale.get_ModuleNode () [0x00000] in <filename unknown>:0
at TweakScale.TweakScale.Setup () [0x00000] in <filename unknown>:0

That's a long modlist, I don't even know half of the names. However, the first thing I'd remove for testing are the 'myTweakScale' files.

        /// <summary>
/// The ConfigNode that belongs to the part this modules affects.
/// </summary>
private ConfigNode PartNode
{
get
{
return GameDatabase.Instance.GetConfigs("PART").Single(c => c.name.Replace('_', '.') == part.partInfo.name)
.config;
}
}

This is the function that fails. I have no idea why it does this replacing, or if this is the correct way to get the config node of a part. Any ideas?

Edited by pellinor
Link to comment
Share on other sites

Hi pellinor and/or others who could chime in - a quick thought.

Wouldn't adding this to the ScaleExponents config make it so that parachutes could be tweakscaled successfully? Has anyone tried tweakscale + parachutes yet?

TWEAKSCALEEXPONENTS

{

name = ModuleParachute

semiDeployedDrag = 2

fullyDeployedDrag = 2

}

I assume that semiDeployedDrag and fullyDeployedDrag are the variables that ought to increase with size, right? And that the parachute's visual model (including its canopy) will all get scaled up with the container's model... maybe?

EDIT: Also, perhaps someone can assist me with Regolith's resource converter and harvester modules and the code I'd need to use for a TWEAKSCALEEXPONENTS{} that would work with it. Here's what the module looks like:

An example of a resource converter:

MODULE

{

ConverterName = Smelt Ore

name = REGO_ModuleResourceConverter

StartActionName = Start Ore->Metal

StopActionName = Stop Ore->Metal

RecipeInputs = ElectricCharge,21.0,Ore,0.16

RecipeOutputs = Metal,0.12,False

}

An example of a resource harvester module:

MODULE

{

name = REGO_ModuleResourceHarvester

HarvesterType = 0

Efficiency = 1

RecipeInputs = ElectricCharge,6

ResourceName = Minerals

ConverterName = Mineral Drill

StartActionName = Start Mineral Drill

StopActionName = Stop Mineral Drill

}

All I could figure out how to do for sure was change the "Efficiency" (which is what controls the rate of extraction of the harvester... it's a weird nomenclature...) by doing (successfully) the following:

TWEAKSCALEEXPONENTS{

name = REGO_ModuleResourceHarvester

Efficiency = 2

}

But what about the other variables, like the RecipeInputs (which isn't just a simple Variable = Number setup) that are in a list-ish format? How could I do a correct TWEAKSCALEEXPONENTS{} definition for those? And what about lists like "RecipeInputs = ElectricCharge,21.0,Ore,0.16"?

Edited by AccidentalDisassembly
Link to comment
Share on other sites

That's a long modlist, I don't even know half of the names. However, the first thing I'd remove for testing are the 'myTweakScale' files.

        /// <summary>
/// The ConfigNode that belongs to the part this modules affects.
/// </summary>
private ConfigNode PartNode
{
get
{
return GameDatabase.Instance.GetConfigs("PART").Single(c => c.name.Replace('_', '.') == part.partInfo.name)
.config;
}
}

This is the function that fails. I have no idea why it does this replacing, or if this is the correct way to get the config node of a part. Any ideas?

I found what was causing the errors. There's a part in the D12 B9 expansion mod that has the same filename as the MK2 Liquid Fuel Fuselage. :rolleyes:

Link to comment
Share on other sites

Has anyone found a workaround for the scaled root part resizing itself on scene changes?

it's driving me crazy.

I just tried the latest dev version and it broke all my ships, so I reverted back to the previous version and previous save before installing the latest version and they're all still broken, loading them in the VAB I can't see anything, the parts fill the screen and I can't zoom out.

I really wish I could just go back 1.44 as that was the last version that didn't seem to go haywire

Link to comment
Share on other sites

I assume that semiDeployedDrag and fullyDeployedDrag are the variables that ought to increase with size, right? And that the parachute's visual model (including its canopy) will all get scaled up with the container's model... maybe?

For the current drag model I don't think so. As far as I know, the drag value is a coefficient that is multiplied with mass. So they should already scale well.

EDIT: Also, perhaps someone can assist me with Regolith's resource converter and harvester modules and the code I'd need to use for a TWEAKSCALEEXPONENTS{} that would work with it. Here's what the module looks like:

Still have to look into that. There are config options for lists (somewhere in the OP of the old thread), and a hacky approach would be to just scale the list as a whole. Probably the strings will silently fail, and maybe even the booleans wil be preserved without breaking anything.

PS: for the harvesters we only need the efficiency because this scales the recipes. The problem is only the converters because they scale the recipes.

Edited by pellinor
Link to comment
Share on other sites

For the current drag model I don't think so. As far as I know, the drag value is a coefficient that is multiplied with mass. So they should already scale well.

Still have to look into that. There are config options for lists (somewhere in the OP of the old thread), and a hacky approach would be to just scale the list as a whole. Probably the strings will silently fail, and maybe even the booleans wil be preserved without breaking anything.

PS: for the harvesters we only need the efficiency because this scales the recipes. The problem is only the converters because they scale the recipes.

Ah, ok, so for the harvesters something happens along the lines of multiplying everything going on (EC consumed, resources produced, whatever) by the efficiency number? I had thought that scaling "efficiency" would simply scale the output without changing EC consumption. At least that one's covered then.

So for parachutes, then, I assume the best option would be to specifically make a scaletype for them where the mass scales as a square function - rather than 2.5, as it is now - since I'm just assuming that the parachute's drag would roughly correspond to the surface area of the chute. That's easy enough to do!

Thanks for the info!

Link to comment
Share on other sites

Hey, I like the work on TweakScale,

however your TweakScale version breaks Infernal Robotics.

It leads to thousands of exceptions thrown when trying to use the infernal robotics parts outside of the VAB and crashes the game.

Using the ExceptionDetector plugin for visibility.

The last it showed before crashing was MuMech something exceptions and only infernal robotics only let me control in one direction, using the other direction command lead to the exceptions.

The only changed thing between working and not working, was updating from the old TweakScale 1.50 to your newest version.

Link to comment
Share on other sites

Question, I try to create a fine controlled stack unit.

I defined my own scale type but turning on freescale only show the first and last scale factor


SCALETYPE
{
name = stack_noozle
freeScale = false
scaleFactors = 0.5, 0.625, 0.75, 0.875, 1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2.0, 2.125, 2.25, 2.375, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4.0,

4.25, 4.5, 4.75, 5.0
scaleNames = 0.5m, 0.625m, 0.75m, 0.875m, 1m, 1.125m, 1.25m, 1.375m, 1.5m, 1.625m, 1.75m, 1.875m, 2m, 2.125m, 2.25m, 2.375m, 2.5m, 2.75m, 3m, 3.25m, 3.5m,

3.75m, 4m, 4.25m, 4.5m, 4.75m, 5m
defaultScale = 2.5

ATTACHNODES
{
base = 1
top = Stack:1
top01 = Stack:1
top02 = Stack:1
top03 = Stack:1
bottom = Stack:1
bottom01 = Stack:1
bottom02 = Stack:1
bottom03 = Stack:1
bottom04 = Stack:1
}

TWEAKSCALEEXPONENTS
{
mass = 2
}
}

How can I unleash freescale? How can I use FreeScale, to make my scale type truely freescale, with smallest increment possible?

Link to comment
Share on other sites

Hey, I like the work on TweakScale,

however your TweakScale version breaks Infernal Robotics.

It leads to thousands of exceptions thrown when trying to use the infernal robotics parts outside of the VAB and crashes the game.

Using the ExceptionDetector plugin for visibility.

The last it showed before crashing was MuMech something exceptions and only infernal robotics only let me control in one direction, using the other direction command lead to the exceptions.

The only changed thing between working and not working, was updating from the old TweakScale 1.50 to your newest version.

So is this why my game just keeps crashing? (updated recently).

Thank you for pointing out the plugin for tracking exeptions.

Link to comment
Share on other sites

Question, I try to create a fine controlled stack unit.

I defined my own scale type but turning on freescale only show the first and last scale factor

How can I unleash freescale? How can I use FreeScale, to make my scale type truely freescale, with smallest increment possible?

For now, the freescale mode does not know scalefactors (I'm working on a new version of the KAE tweakable to allow this in future versions). In the current version you need to set the increments for the arrow buttons explicitely. I'd recommend something like this:


incrementLarge = 1.25
incrementSmall = 0.625
incrementSlide = 0.025

Link to comment
Share on other sites

Hey, I like the work on TweakScale,

however your TweakScale version breaks Infernal Robotics.

It leads to thousands of exceptions thrown when trying to use the infernal robotics parts outside of the VAB and crashes the game.

Using the ExceptionDetector plugin for visibility.

The last it showed before crashing was MuMech something exceptions and only infernal robotics only let me control in one direction, using the other direction command lead to the exceptions.

The only changed thing between working and not working, was updating from the old TweakScale 1.50 to your newest version.

I can not reproduce your issue, tried with the latest release of TweakScale(1.51.1) and IR(0.19.3) from KerbalStuff. So far, I put a hinge on a mk1 pod, moved it, launched, moved it again in both directions. Not seeing any exceptions, and both directions work for me. It might depend on the part though, as IR has several custom scaletypes.

Link to comment
Share on other sites

I can not reproduce your issue, tried with the latest release of TweakScale(1.51.1) and IR(0.19.3) from KerbalStuff. So far, I put a hinge on a mk1 pod, moved it, launched, moved it again in both directions. Not seeing any exceptions, and both directions work for me. It might depend on the part though, as IR has several custom scaletypes.

Hm, I will try again tomorrow and then report back.

Link to comment
Share on other sites

I can not reproduce your issue, tried with the latest release of TweakScale(1.51.1) and IR(0.19.3) from KerbalStuff. So far, I put a hinge on a mk1 pod, moved it, launched, moved it again in both directions. Not seeing any exceptions, and both directions work for me. It might depend on the part though, as IR has several custom scaletypes.

The exception probably only occus when you rescale it to a size different from the default one. I had the same problems with KSPI. Durring initialisation of the Flight screen, when it calls some higher resource function, the functions throws an exception (while unscaled there is no problem). I managed to solve the problem by catching the exception and return a default value instead.

Edited by FreeThinker
Link to comment
Share on other sites

The exception probably only occus when you rescale it to a size different from the default one. I had the same problems with KSPI. Durring initialisation of the Flight screen, when it calls some higher resource function, the functions throws an exception (while unscaled there is no problem). I managed to solve the problem by catching the exception and return a default value instead.

Still does not occur for me. I can move scaled hinges in both directons, in the editor and on the launchpad.

Link to comment
Share on other sites

Just a quick note: I just deleted MJeb today morning :( . It is 23:06 here. So I am getting tired of the neverending game :D

No crasses, no freeze.

I do have Irobotics and TScale installed on this KSP and used it a lot today (assembling a MKS/IRobotics Mün base).

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...