Jump to content

[WIP] [1.12.x] MOARdV's Avionics Systems - MAS Interactive IVA! (v1.3.7, 7 April 2023)


MOARdV

Recommended Posts

2 hours ago, Vexmae said:

Thanks you for replying me :).  I would like to know if it's possible to create a script for a "rainbow mode" for the panel dividers ? ( like the rainbow mode on a  rgb keyboard ( i know this is a bit stupid but help me please) ( i tried with a friend to make a lua code but we failed )

Thanks for reading me 

I actually thought about rainbow mode when I was writing the response.

To answer your question, yes, it's possible to create a script for it, although it will change all of the dividers at the same time (no wave effects).  It will be a little bit more complicated.  When I finish work today, I will see if I can put it together quickly.

Link to comment
Share on other sites

21 minutes ago, MOARdV said:

I actually thought about rainbow mode when I was writing the response.

To answer your question, yes, it's possible to create a script for it, although it will change all of the dividers at the same time (no wave effects).  It will be a little bit more complicated.  When I finish work today, I will see if I can put it together quickly.

We tried to make a script but it didn't work 

( This file is named RGB.lua )

Spoiler
function onTick()

x = 0
y = false

    if x > 1 then
        y = true
    end
    
    if x < 0 then
        y = false
    end
    
    if y == true then
        x = x - 0.01 --c'est la vitesse
        else
        x = x + 0.01 --c'est la vitesse
        
    end
	
	fc.SetPersistent("PD_RGB_RED", math.sin(x)*255)
	fc.SetPersistent("PD_RGB_GREEN", math.sin(x+2)*255)
	fc.SetPersistent("PD_RGB_BLUE", math.sin(x+4)*255)
end

 

( This one is MAS_Script.cfg )
 

Spoiler
//Loading the RGB .lua with this cfg file

MAS_LUA
{
	name = VEXARP_Scripts
	
	script = VexarpIVA/VexarpIVACore/Scripts/RGB.lua
}

 

( and this one is RGB_Backlight.cfg )

Spoiler
PROP
{
    name = MAS_VEXARP_RGB_Divider

    MODEL
    {
        model = ASET/ASET_Props/Misc/PanelDivider/PanelDivider
    }

    MODULE
    {
        name = MASComponent

        COLOR_SHIFT
        {
            name = BackLight On/Off
            transform = PanelDivider
            variable = fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))
            passiveColor = 0,0,0,255
            activeColor = fc.GetPersistentAsNumber("PD_RGB_RED"),fc.GetPersistentAsNumber("PD_RGB_GREEN"),fc.GetPersistentAsNumber("PD_RGB_BLUE"),255
            blend = true
        }

    }
}

 

actually the lua code is not mine but one of my friend said he know how to code in lua because he play Stormworks and gave me this code

4 minutes ago, Vexmae said:

actually the lua code is not mine but one of my friend said he know how to code in lua because he play Stormworks and gave me this code

i don't knowwhat is function.OnTick( ), i don't find it in the lua documentation

Edited by Vexmae
Link to comment
Share on other sites

3 hours ago, Vexmae said:

i don't knowwhat is function.OnTick( ), i don't find it in the lua documentation

That is a custom function that your friend wrote.  With what you have, you are 99% done with something you can test.  Change RGB_Backlight.cfg like this (one new component):

Spoiler
PROP
{
    name = MAS_VEXARP_RGB_Divider

    MODEL
    {
        model = ASET/ASET_Props/Misc/PanelDivider/PanelDivider
    }

    MODULE
    {
        name = MASComponent

        TRIGGER_EVENT
        {
            name = Update divider color
        	event = OnTick()
        	// Only updates if backlight is on.  Can also use variable = 1 to always update color.
        	variable = fc.GetPersistentAsNumber("Backlight") > 0
        	autoRepeat = true
        }
        COLOR_SHIFT
        {
            name = BackLight On/Off
            transform = PanelDivider
            variable = fc.Conditioned(fc.GetPersistentAsNumber("Backlight"))
            passiveColor = 0,0,0,255
            activeColor = fc.GetPersistentAsNumber("PD_RGB_RED"),fc.GetPersistentAsNumber("PD_RGB_GREEN"),fc.GetPersistentAsNumber("PD_RGB_BLUE"),255
            blend = true
        }

    }
}

 

TRIGGER_EVENT will call the script 10x per second.

The Lua script may need some debugging.  The 'x' and 'y' variable might need to be declared outside of the function body - I think, the way they are written, they are always going to be set to '0' and 'false' each time the script is called, so the color will not change.  The formula used to set the color needs changed - it will set each color to a value between -255 and +255 (anything less than zero will be treated as zero).  Maybe instead use

127.5 + math.sin(x) * 127.5

127.5 + math.sin(x + 2) * 127.5

127.5 + math.sin(x + 4) * 127.5

One thing that may happen - the more dividers you have, the faster it might change, since the TRIGGER_EVENT is on each prop, and each prop is going to call OnTick().  I think the script might need a small change to prevent that, but I'll need to look at it in the morning.

Link to comment
Share on other sites

I need help again,  i want a button to activate that rgb mode, i tried creating a prop, the action on the collider is:
 

onClick = fc.SetPersistent("WRP_R", fc.GetPersistentAsNumber("VEX_RGB_RED")), fc.SetPersistent("WRP_G", fc.GetPersistentAsNumber("VEX_RGB_GREEN")), fc.SetPersistent("WRP_B",fc.GetPersistentAsNumber("VEX_RGB_BLUE"))

and the active color of the pannel divider is

activeColor = fc.GetPersistentAsNumber("WRP_R"), fc.GetPersistentAsNumber("WRP_G"), fc.GetPersistentAsNumber("WRP_B"), 255

( there is the TRIGGER_EVENT from before in that pannel divider .cfg too)

and the pannel divider don't light up at all because i'm not good at making props
 

Link to comment
Share on other sites

1 hour ago, Vexmae said:

I need help again,  i want a button to activate that rgb mode, i tried creating a prop, the action on the collider is:

What do you want the button to do?

  1. Press the button to pause RGB mode, press again to start it?
  2. Press the button to start RGB mode, press again and the divider becomes a color (like white, or whatever color) and pauses?

1 is easy to do - the collider on the button would be

onClick = fc.TogglePersistent("VEX_RGB_ENABLE")

The beginning of the Lua script would be

function onTick()

  if fc.GetPersistentAsNumber("VEX_RGB_ENABLE") == 0 then
    return
  end
  -- Rest of function, same as it is now

This will make the RGB mode pause when VP_RGB_ENABLE is 0.  fc.TogglePersistent("VP_RGB_ENABLE") changes VP_RGB_ENABLE from 0 to 1, or from 1 to 0, each time it is pressed.  You do not need an extra TRIGGER_EVENT that way.

If you want option 2, it is the same, except in the Lua script:

function onTick()

  if fc.GetPersistentAsNumber("VEX_RGB_ENABLE") == 0 then
    fc.SetPersistent("VEX_RGB_RED", 255)
    fc.SetPersistent("VEX_RGB_GREEN", 255)
    fc.SetPersistent("VEX_RGB_BLUE", 255)

    return
  end
  -- Rest of function, same as it is now

 

Link to comment
Share on other sites

Hi, it's me (again). i'm writting a script and i need the script to wait for 2 seconds. i tried to make a function like that:
 

function Wait(seconds)
  local start = fc.UT
  repeat until fc.UT > fc.UT + seconds
 end
  

i also tried:
 

x = 0

function wait(seconds)
    if x = x then 
		x = x + 0.1 --The script should be run 10 times per second so the value of x should go up by 1 every second
	end
		
	if x > 60 then
		x = 0
	end
	
	repeat until x > x + seconds
end

but none of this worked and it juste give me a initialization error, can you help me with that ?

i also tried to play a sound with the lua script like that:

fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/warning, 100, false)

and it doesn't work too ( an initialization error too and no sound played but the script still works ) i would like help with that too ..

The whole code looks like that

Spoiler
x = 0

-- function wait(seconds)
    -- if x = x then 
		-- x = x + 0.1 --The script should be run 10 times per second so the value of x should go up by 1 every second
	-- end
		
	-- if x > 60 then
		-- x = 0
	-- end
	
	-- repeat until x > x + seconds
-- end

function MAS_VEXARP_MainComp()

if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_State") < 1 then
	if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then
		--wait(6)
		if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then
			fc.TogglePersistent("MAS_VEXARP_MainComp_State")
			fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/goodbip, 1, false)
		elseif fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") < 1 then
			fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/badbip, 1, false)
			--wait(1)
			fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/badbip, 1, false)
		end
	end
elseif fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_State") > 0 then
	if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then
		--wait(3)
		if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then
			fc.TogglePersistent("MAS_VEXARP_MainComp_State")
			fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/warning, 1, false)
			--wait(1)
			fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/fanstop, 1, false)
		elseif fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") < 1 then
			fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/badbip, 1, false)
			--wait(1)
			fc.PlayAudio( VexarpIVA/VexarpIVACore/Sounds/Startup/badbip, 1, false)
		end
		end
	end
end	

( Some lines are in front of -- because they just make the script crash )


i'm sorry if i'm getting annoying by asking help that often 

Thanks for reading me.
 

 

Edited by Vexmae
edited because i forgot a part of my message
Link to comment
Share on other sites

15 hours ago, Vexmae said:

i'm writting a script and i need the script to wait for 2 seconds

This is a little tricky - the game loop in Unity calls the MAS code ten times per second, and if something in a MAS script pauses for two seconds, the entire game will hang for that amount of time.  What you need to do is have two parts - one part where you set a timer (such as using onClick, or in a different script), and a trigger event that looks for the timer.

-- In a collider onClick event
onClick = fc.SetPersistent("VP_Event_Trigger_Time", fc.UT() + 2)

-- TRIGGER_EVENT
variable = fc.GetPersistentAsNumber("VP_Event_Trigger_Time") >= fc.UT()
autoRepeat = false

 

15 hours ago, Vexmae said:

i also tried to play a sound with the lua script like that

The audio clip name needs to be a "string" surrounded with quotation marks:

fc.PlayAudio("VexarpIVA/VexarpIVACore/Sounds/Startup/warning", 100, false)

 

Link to comment
Share on other sites

thanks you for helping me, i managed to make the code work but now i have another problem ( i'm so sorry i'm too dumb too understand how to make the code but i want to make something really good ):

when i want to play a  sound ( commented --First Sound in the code ) is played well but none of the others PlayAudio work (even if i copy / paste the first line that works)  

Here is the code:

Spoiler
-- To help anyone who will read my code to understand all of that if else mess i'm gonna comment every line

function MAS_VEXARP_MainComp() -- Function for a button to toggle the iva ( like MainBus or Battery switches )

if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_State") < 1 then -- if the main computer is off
	if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then -- and if the button is pressed
		if fc.GetPersistentAsNumber("MAS_VEXARP_Event_Trigger_Time") > fc.UT() then -- Wait 5 Seconds
			if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then -- If the button is still pressed
				fc.TogglePersistent("MAS_VEXARP_MainComp_State") -- turn the main computer ON
				fc.PlayAudio( "VexarpIVA/VexarpIVACore/Sounds/Startup/goodbip", 1, true) -- Play a beep sound (like on a computer) // First Sound
			elseif fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") < 1 then -- if the button is not pressed anymore
				fc.PlayAudio( "VexarpIVA/VexarpIVACore/Sounds/Startup/badbip+fanstop", 1, true) -- Play an error sound and don't turn on the computer // Second Sound
			end
		end
	end
elseif fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_State") > 0 then -- if the main computer is on
	if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then -- if the button is pressed
		if fc.GetPersistentAsNumber("MAS_VEXARP_Event_Trigger_Time") > fc.UT() then -- Wait 5 seconds
			if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") > 0 then -- if the button is still pressed
				fc.TogglePersistent("MAS_VEXARP_MainComp_State") -- Turn the main computer off
				fc.PlayAudio( "VexarpIVA/VexarpIVACore/Sounds/Startup/warning+fanstop", 1, true) -- Play a computer stopping sound // Third Sound
			elseif fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_Button") < 1 then -- if the button is not played anymore
				fc.PlayAudio( "VexarpIVA/VexarpIVACore/Sounds/Startup/badbip", 1, true) -- play an error sound and don't turn off the computer // Fourth Sound
				end
			end
		end
	end	
end

function MAS_VEXARP_WAIT() --This is the Wait script, it start only one time when the button is pressed
		fc.SetPersistent("MAS_VEXARP_Event_Trigger_Time", fc.UT() + 5) -- Set the timer to 5 seconds
		if fc.GetPersistentAsNumber("MAS_VEXARP_MainComp_State") < 1 then -- If the main coumputer is Off
			fc.PlayAudio( "VexarpIVA/VexarpIVACore/Sounds/Startup/starthdd", 1, false) -- Play a computer start sound // This sound works
		end
end

-- All sounds are in the .wav file format 

 

Can you help me ( again i'm sorry ) with that ?

Thanks for reading me.

Edited by Vexmae
edited because i have made a writting error, english is a bit difficult :c
Link to comment
Share on other sites

  • 3 weeks later...
On 9/19/2021 at 2:43 PM, The Brazilian Luigi said:

How do I check the error log? There is an error related to this mod. I think its the reason all I can see is the HUD

On 9/27/2021 at 1:30 PM, Ilya_Torshov said:

I'm having an issue with this mod. During loading it gets stuck when loading  MAS-ASET/ALCORMFD40x20/MAS_ALCOR_MFD1

Please see this post. There are simply too many potential causes to diagnose without more info.

 

Link to comment
Share on other sites

i think i am having an issues with this mod. when i play with tundra the screens for crew dragon show up but it blank on the screen i have all of the depends and it still does not work i play in 1.11.

Link to comment
Share on other sites

  • 2 weeks later...

Greetings @MOARdV I absolutely love your prop pack so much i caught the IVA creators bug myself. I just finished a cockpit but im having a problem. i looked hard through all the wiki documentation and could not find any reference to what i was looking for. Long story short, i cant seem to find the command to toggle FSengines on and off. the switches you provide respond to rocket engines but not the stock ksp turboshaft or firespitter helicopter engines. is there any way to setup the internal props to interact with the helicopter and propeller blades? Im literally a lightbulb and a switch away from releasing this IVA. very frustrating. Any help would be appreciated.

I did manage to find an ugly workaround but id rather do it properly. I tried putting lines like GetFSengineBladedEnabled() ToggleFSengineBladedEnabled(), ive tried using the FSActionGroup "engine" which the start/stop button by firespitter uses but no luck. what am i doing wrong?

Edited by johnnydope
additional relevant comments
Link to comment
Share on other sites

On 10/14/2021 at 7:21 AM, johnnydope said:

what am i doing wrong?

You're not doing anything wrong - MAS doesn't have Firespitter support (I never use that mod).  I haven't added support for the stock propeller / rotor system, either, since I rarely make atmospheric craft.  There is some support for Advanced Jet Engines parts, but I don't know if it does what you need.

Link to comment
Share on other sites

OK. Thanks anyway. I do however have a question of a new subject. MechJeb & kOs. RPM fixed MechJeb & kOs integration and it fully works on the JSI version of the 40x20 mfd. The ALCOR mfd and any MAS mfd fails to see mechjeb or kOs present. Why is that? No more autopilot for MAS right now it seems. I installed everything fresh in a new install of ksp and tested this on IVA's already made by others. Its a shame. That beautiful autopilot board in the OPT JHT cockpit you made i cant even use right now...... (sadface)

Link to comment
Share on other sites

17 hours ago, johnnydope said:

OK. Thanks anyway. I do however have a question of a new subject. MechJeb & kOs. RPM fixed MechJeb & kOs integration and it fully works on the JSI version of the 40x20 mfd. The ALCOR mfd and any MAS mfd fails to see mechjeb or kOs present. Why is that? No more autopilot for MAS right now it seems. I installed everything fresh in a new install of ksp and tested this on IVA's already made by others. Its a shame. That beautiful autopilot board in the OPT JHT cockpit you made i cant even use right now...... (sadface)

kOS support is on my to-do list, but I have not had time for modding for a while.

I have not looked at KSP 12.x for more than a quick peek, so it's possible that something changed in MJ that broke the MAS interface with it.  I haven't heard anything else about MJ and MAS misbehaving, though.

Link to comment
Share on other sites

  • 1 month later...
On 12/11/2021 at 6:05 PM, Tonas1997 said:

MAS seems to make the screen go black when a capsule implementing its IVA elements detaches from a Modular Launchpads base. The issue was identified here and I managed to replicate it as well :/

I saw the issue on the MAS GitHub as well (thanks for submitting that, so it doesn't get forgotten).  I need to see the KSP.log to see if there's a hint about what's going haywire.  I don't currently have MLP installed, and I've been too busy in Real Life to spend much time on KSP, so the more info the better.

Link to comment
Share on other sites

On 12/11/2021 at 6:05 PM, Tonas1997 said:

MAS seems to make the screen go black when a capsule implementing its IVA elements detaches from a Modular Launchpads base. The issue was identified here and I managed to replicate it as well :/

 

On 12/13/2021 at 7:49 AM, MOARdV said:

I saw the issue on the MAS GitHub as well (thanks for submitting that, so it doesn't get forgotten).  I need to see the KSP.log to see if there's a hint about what's going haywire.  I don't currently have MLP installed, and I've been too busy in Real Life to spend much time on KSP, so the more info the better.

I found a temporal workaround.

 Since Modular Launchpads base in some towers is using squad space GenericSpace3, there is a JSI patch adding props and mfd's: generic3-cockpit-patch.cfg, and MAS Avionic Systems patch JsiToMasUpgrade.cfg is upgrading the props to MAS, so either renaming to "*.nocfg" or deleting the generic3-cockpit-patch.cfg or JsiToMasUpgrade.cfg should workaround the issue, i prefered the first one.

 

 

 

Link to comment
Share on other sites

Are there instructions somewhere for adding the camera functionality to existing parts? I tried to add it to some of the cameras from Tantares by copying the existing configs, and the modules are appearing on the parts in the editor,  but they don't actually work at all as cameras.

Link to comment
Share on other sites

1 hour ago, baldamundo said:

Are there instructions somewhere for adding the camera functionality to existing parts? I tried to add it to some of the cameras from Tantares by copying the existing configs, and the modules are appearing on the parts in the editor,  but they don't actually work at all as cameras.

I cant remember if MAS has its own, built-in camera support, or not. It *may* need, but have support for, some of the sepertely downloadable camera mods.
ie HullCam, KURS Docking cam, etc

Not sure if there is Neptune Camera support or not..?? If I get back to KSP Soon™, I may investigate NC support

Link to comment
Share on other sites

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