Jump to content

Multiple independent lights in one part / GUI text change


Recommended Posts

(NB: A somewhat related topic I started very recently was fully resolved and included as part of hoojiwana's modding info compilation, so I figured I'd create a new one for a rather different and unusual scenario)

In an attempt to further extend the capabilities of the ModuleLight PartModule, I decided to consider a case where there were multiple independently-controllable lighted windows in a part:

- Said part is a habitation module for space stations

- There are six windows total

- The first two windows are for the "Galley" area, and so will be toggled together

- The remaining four are for the individual Sleeping Areas, two each on the Port and Starboard sides, to be toggled individually

My first attempt involved simply duplicating ModuleLight for each set of animations:

MODULE
{
name = ModuleLight
lightName =
useAnimationDim = true
lightBrightenSpeed = 1
lightDimSpeed = 1
resourceAmount = 0.002
animationName = KHabWinLights_Galley
useResources = true
}

MODULE
{
name = ModuleLight
lightName =
useAnimationDim = true
lightBrightenSpeed = 1
lightDimSpeed = 1
resourceAmount = 0.002
animationName = KHabWinLights_SS_Port_1
useResources = true
}

MODULE
{
name = ModuleLight
lightName =
useAnimationDim = true
lightBrightenSpeed = 1
lightDimSpeed = 1
resourceAmount = 0.002
animationName = KHabWinLights_SS_Port_2
useResources = true
}

MODULE
{
name = ModuleLight
lightName =
useAnimationDim = true
lightBrightenSpeed = 1
lightDimSpeed = 1
resourceAmount = 0.002
animationName = KHabWinLights_SS_Star_1
useResources = true
}

MODULE
{
name = ModuleLight
lightName =
useAnimationDim = true
lightBrightenSpeed = 1
lightDimSpeed = 1
resourceAmount = 0.002
animationName = KHabWinLights_SS_Star_2
useResources = true
}

When loaded in-game and during flight, five Lights On / Lights Off GUI buttons are displayed in the context menu as expected, but only the last-defined light (i.e. the Second Starboard Sleep Station window) actually toggles.

1) How would one go about making individually toggleable lights?

2) Would it be possible to have a "master" switch for all the lights in the one module i.e. toggle all the animations at the same time?

3) Extending (2), would it be possible to have the other individual toggle switches recognize their corresponding lights' current state, and display the appropriate GUI text appropriately?

i.e.User clicks "Lights On" -> All windows in that particular module are lit -> GUI for all other lights automatically now show "Galley Light Off", "SleepStation Port 1 Off" etc., and vice versa

4) Would it be possible to change the GUI button text for each of the light toggles?

"Galley Light On/Off", "SleepStation Port 1 On/Off", "SleepStation Port 2 Off" etc. is more user-friendly than several identical instances of "Lights On/Off"

I have a feeling that I may have to go down the plugin route in order to create this functionality. Thoughts?

Link to comment
Share on other sites

Don't use ModuleLight, use ModuleAnimateGeneric and emissive surfaces separated into six gameobjects, plus six Unity animations modifying those emissive surfaces and light sources instead. If some have to be synced, leave them in one object/animation. Context menu captions will correctly reflect the state and you can add custom text there.

Not possible to add master switch.

Link to comment
Share on other sites

  • 2 weeks later...

Yeah, moduleLight is for actual shadow casting lights (light components in unity) rather than emissive textures (which only light up themselves).

A master switch isn't possible in the config file but would be a very simple plugin.

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