Jump to content

[Solved] PartModule with Dynamically created KSPFields


Recommended Posts

ok so been toying with this for a couple of days and keep running into roadblocks, and i'm not great at reflection, so hoping someone wants a challenge while i continue making other parts of my mod within skill range :D 

basicly i'm trying to add bars to part / kerbal right click menu, for that i need to have KSPField / BaseField, now the tricky part, they have to be able to be created dynamically, getting setup from a ConfigNode. basicly i need the equiv of adding this to a partmodule

[KSPField(guiActive = true, guiName = "Hunger", guiFormat = "#0.00\\%"), UI_ProgressBar(scene = UI_Scene.Flight, minValue = 0f, maxValue = 100f)]
public float value = 50f;

but dynamically made from

STAT
{
	name = Hunger
	min = 0
	max = 100
	initial = 50
	guiFormat = #0.0\\%
}

currently kinda giving up and just using 50 KSPField, which looks sloppy, but its what works atm

Edited by anxcon
Link to comment
Share on other sites

I don't think this is possible.  KSPField and the UI controls expect there to be an actual field backing them.  If they're all floats then you could create a finite number of them and then assign the GUI properties after they've been loaded.

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...