Jump to content

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


MOARdV

Recommended Posts

11 hours ago, Manul said:

did not expect 1.9 to break any mods but it did. Cameras don't see nearby objects in 1.9

KSP 1.9 made changes to the camera system for the Windows version of the game (but not Linux or Mac).  When I have time to get a KSP 1.9 development environment configured and I can get some testers to verify that Mac and Linux work, I will look at it.

Link to comment
Share on other sites

18 hours ago, MOARdV said:

KSP 1.9 made changes to the camera system for the Windows version of the game (but not Linux or Mac).  When I have time to get a KSP 1.9 development environment configured and I can get some testers to verify that Mac and Linux work, I will look at it.

I almost forgot to tell about  IndexOutOfRange exception in function GetMultiModeEngineMode(). Looks like the problem is in MasFlightComputerProxy.cs

        public double GetMultiModeEngineMode()
        {
            for (int i = vc.multiModeEngines.Length; i >= 0; --i)
            {
                if (vc.multiModeEngines.runningPrimary == false)

I suppose that index of the last element of  an array should be Length - 1

Edited by Manul
Link to comment
Share on other sites

13 hours ago, Zerolera said:

What do you need to be a IVA designer? a program like unity?

You'll need the Unity editor (which is free), and you need the Squad's Part Tools to load/save the IVA configs from here

 

Link to comment
Share on other sites

1 hour ago, Zerolera said:

I think that make a IVA will take more effort than I thought

If you have everything set up correctly (follow the instructions for PartTools) it's as easy as placing parts in the spaceplane hangar, controls are similar. Set the location of GameData folder for Part Tools, open an IVA (Spaces tab in Part Tools window), spawn props and move/rotate them as you do in SPH. Switching between local/absolute coordinates is also available.

Edited by Manul
Link to comment
Share on other sites

6 hours ago, Zerolera said:

you can´t change the texts of the buttons, panels, etc?

You can't do it in the editor but you can copypaste a prop config and create your own version with a text you need (don't forget to change the prop's name)

To see your IVA in a game you need to save it to cfg in Unity editor and put it somewhere in gamedata. GameData\ your_mod_name\Spaces will be the best choice, you can also create a folder called Props for custom props. And of course you need a patch that changes some part's IVA to your IVA and adds required modules. See \MOARdV\FlightSystems\MAS_mk1-3.cfg for an example. Here is an example how my patch for Flanker cockpit looks like:

Spoiler

@PART[Type-AdvancedFlanker]
{
    MODULE
    {
         name = MASFlightComputer
                 gLimit = 100
                 baseDisruptionChance = 0.0
                 requiresPower = false
                 rate = 0.0
          PERSISTENT_VARIABLES
        {
                   MAS_GPWS_ON = 0
        }
    }
    @INTERNAL
    {
        @name = TypeFlankerIVA_MAS
    }
}

 

Edited by Manul
Link to comment
Share on other sites

@MOARdV @Manul Is there a way to set startTranslation and endTranslation in the translation node with a script? I want to move a prop with 2 different translations, but the second translation is overwriting the current position of the first. I wrote two small functions to take care of this, but startTranslation seems to be read directly as a Vector3. Is there any way to accomplish what I'm after here?

 

Edit: I think I figured out how to do what I wanted to do. I'll update this post later.

Edited by dsonbill
Link to comment
Share on other sites

12 hours ago, dsonbill said:

@MOARdV @Manul Is there a way to set startTranslation and endTranslation in the translation node with a script? I want to move a prop with 2 different translations, but the second translation is overwriting the current position of the first. I wrote two small functions to take care of this, but startTranslation seems to be read directly as a Vector3. Is there any way to accomplish what I'm after here?

 

Edit: I think I figured out how to do what I wanted to do. I'll update this post later.

It looks like I never upgraded the start/end translation to accept variables, so they're currently vec3 instead of three variable digits.  It looks like the ASET props that wanted to use two translations used two transforms, as well.

Link to comment
Share on other sites

15 minutes ago, MOARdV said:

It looks like I never upgraded the start/end translation to accept variables, so they're currently vec3 instead of three variable digits.  It looks like the ASET props that wanted to use two translations used two transforms, as well.

I mostly figured out how to do what I wanted - the seat just needs to be back in the default height before moving to the second position. Is there any way to make a script wait and come back? I have an idea of how to do this with a trigger component already.

 

Skip to 1:00 to see the seat in action:



For anyone wondering how I did this: https://gist.github.com/dsonbill/3d74d6d860ad75c56425bf55f0dab46

Edited by dsonbill
Link to comment
Share on other sites

49 minutes ago, dsonbill said:

I mostly figured out how to do what I wanted - the seat just needs to be back in the default height before moving to the second position. Is there any way to make a script wait and come back? I have an idea of how to do this with a trigger component already.

That's a clever way to work around the limited panel space!  1-seat IVAs are always tricky to pack everything you need into them.

As for getting the position - you would probably need to use something like fc.SetPersistentBlended() (here) as the variable controlling the seat position.  That would let you query the position via the persistent variable.

To try to demonstrate, since it's a little convoluted:

--SEAT POSITION SWITCH COLLIDER_EVENT:

onClick = fc.TogglePersistent("GoalVerticalPosition")

--SEAT POSITION VERTICAL TRANSLATION:

variable = fc.SetPersistentBlended("VerticalPosition", fc.GetPersistentAsNumber("GoalVerticalPosition"), 0.25)

"GoalVerticalPosition" tells you which position the seat is moving to.  "VerticalPosition" tells you where it's at currently (the 0.25 in the blended means it will take 4 seconds to change positions - that's where you control how quickly it moves).  If fc.Abs(fc.GetPersistentAsNumber("GoalVerticalPosition") - fc.GetPersistentAsNumber("VerticalPosition")) is small (<0.001, for instance), the seat is done moving.  You'd do the same thing with a HorizontalPosition and GoalHorizontalPosition,.

Since you're only going to have a couple of SetPersistentBlended calls in the IVA, it won't be too expensive (processing time) to use.  Using two variables also lets you deduce which direction the seat is moving, if you wanted indicator lights for that.

Link to comment
Share on other sites

1 hour ago, MOARdV said:

That's a clever way to work around the limited panel space!  1-seat IVAs are always tricky to pack everything you need into them.

As well as un-optimal viewing angles, even if you can squeeze stuff in... especially MFDs and anything displaying ever-changing text displays.

@dsonbill this seat thing can open whole new IVA possibilities, and be a boon, both to IVA makers ingeneral, and for moar acceptance/usage of MAS.

Also, i know this is still in the experimental/dev stage, but can the seat/transform thing be completely added to existing IVAs, and the transforms all dealt with, with existing transforms in the models (handled/added with code), or might it require transforms/ adjustements made to the IVA models themselves?

1 hour ago, MOARdV said:

Since you're only going to have a couple of SetPersistentBlended calls in the IVA, it won't be too expensive (processing time) to use.

And this leads to what my next question would have been: What, if any, affect on performance would there be? Also, how badly does the number of active seats in an IVA affect performance? Or is it mainly the added active props & MFDs for additional crew stations, that would most affect performance?

Link to comment
Share on other sites

5 hours ago, Stone Blue said:

What, if any, affect on performance would there be? Also, how badly does the number of active seats in an IVA affect performance? Or is it mainly the added active props & MFDs for additional crew stations, that would most affect performance?

The SetPersistentBlended call is as expensive as GetPersistentAsNumber until it has to start updating the value.  Then it's as expensive as the Get call plus a Set call, basically (plus the tiny bit of maths involved in blending).  In the grand scheme of things, I suspect an active MFD with text and graphics is more expensive than this would be.

EDIT: Maybe I should answer that for someone who's not spent too much time bouncing around in my source code. :) Both the "set" and the "get" are more expensive than a lot of the MAS functions, but they are still pretty streamlined.  The "Flight" page in MAS MFD2, for example, will be require more CPU cycles to update.  For any command pod or reasonable flight deck, I'd think that the adjustable seats would be no big deal, as far as introducing lag.

Edited by MOARdV
Link to comment
Share on other sites

I now have another problem. I'm trying to port the ASET Clock/Timer, but I'm running into a strange error:
 

[ERR 18:04:06.382] [MASComponent] Error in ANIMATION_PLAYER Timer Button Push:

[ERR 18:04:06.385] [MASComponent] System.ArgumentException: Error parsing variable "SUP_TimerButtonPushed()" ---> MoonSharp.Interpreter.SyntaxErrorException: ')' expected (to close '(' at line 1) near 'Space'

My animation component looks like this:
 

ANIMATION_PLAYER
{
	name = Timer Button Push
	animation = TestTimerButton
	animationSpeed = 1.0
	variable = SUP_TimerButtonPushed()
}

Link to the full config and script: https://gist.github.com/dsonbill/4f59dea3cf15bbf38b066778d4333ac8

Also, I am aware that there may be a better way to do some of what I'm doing - I'll clean up the way it works and use more efficient variable processing as I go along.

 

Edit: I even tried being silly:
 

variable = SUP_TimerButtonPushed())

...to no avail.

Edited by dsonbill
Link to comment
Share on other sites

11 hours ago, dsonbill said:

I'm trying to port the ASET Clock/Timer, but I'm running into a strange error:

I think the problem may be in your script -  you've got a local variable named 'SUP_TimerButtonPushed', and a function with the same name.  The function replaces the boolean that was named SUP_TimerButtonPushed, so when you say 'if SUP_TimerButtonPushed then', Lua thinks you're referring to the function.  I think renaming the local variable to something like SUP_TimerButtonPushedState will solve the issue.

In case you weren't aware, the ASET Clock/Timer is in core MAS (MAS_ASET_ClockTimer in GameData/MOARdV/MAS_ASET/ASET_ClockTimer/ASET_ClockTimer.cfg). 

Link to comment
Share on other sites

20 minutes ago, MOARdV said:

I think the problem may be in your script -  you've got a local variable named 'SUP_TimerButtonPushed', and a function with the same name.  The function replaces the boolean that was named SUP_TimerButtonPushed, so when you say 'if SUP_TimerButtonPushed then', Lua thinks you're referring to the function.  I think renaming the local variable to something like SUP_TimerButtonPushedState will solve the issue.

Ha thank you, I am definitely stupid at times. The error is still confusing as a whole, but I guess I'll learn to live with the vague outputs of Moonsharp.

20 minutes ago, MOARdV said:

In case you weren't aware, the ASET Clock/Timer is in core MAS (MAS_ASET_ClockTimer in GameData/MOARdV/MAS_ASET/ASET_ClockTimer/ASET_ClockTimer.cfg). 

I actually didn't see it when I was looking around - I'll probably finish porting it over, then take a look at your implementation to see how you've done it, which is likely much more efficient. Hopefully I can see more how you do things, as the Clock/Timer isn't exactly simple.

 

Lastly, it looks like there's no way to add new fonts via asset bundles. Is this planned at all? I'd rather like to use unicode for certain things, and porting things over with CBFG is a huge pain. There's also BMFont, but it doesn't look like MAS supports its file format fully.

 

I'd really like to solve this:

c9d64887cd964f566838d3bb16933dbb.png

and I was hoping a new font might do the trick.

Edited by dsonbill
Link to comment
Share on other sites

11 minutes ago, dsonbill said:

Lastly, it looks like there's no way to add new fonts via asset bundles. Is this planned at all?

I hadn't considered it, to be honest.  I figured the fonts already there were fairly thorough (the Liberation Sans font has unicode support - I've used it to display Cyrillic characters), although the fixed-width limitations on the MFD will skew characters.  Since I need to update the asset bundle loader anyway, I will see if there's an easy way for me to support additional fonts from other asset bundles.

Link to comment
Share on other sites

4 hours ago, MOARdV said:

I hadn't considered it, to be honest.  I figured the fonts already there were fairly thorough (the Liberation Sans font has unicode support - I've used it to display Cyrillic characters), although the fixed-width limitations on the MFD will skew characters.  Since I need to update the asset bundle loader anyway, I will see if there's an easy way for me to support additional fonts from other asset bundles.

Thank you - it's greatly appreciated. Since my end goal is to have IVAs where people can program their own MFDs entirely, I figured the calligraphy glyphs are particularly important.

 

I ended up replacing mas-font.assetbundle to test out some fonts - Unifont gets a lot closer, though it's against the aesthetic I think you want with the new MFDs, which is a very clean font. I'm going to be playing around some more with settings and such to see if I can get it even closer to how it's supposed to look.

 

eb297c838bedbaecb4dd119ee8acc934.png

 

Edit: I'm guessing there's some line spacing going on in the above?

Edited by dsonbill
Link to comment
Share on other sites

4 hours ago, dsonbill said:

Edit: I'm guessing there's some line spacing going on in the above?

It looks like it.  I didn't really account for text-mode graphics when I wrote the text renderer - I figured people would use an IMAGE node to represent the graphics they needed (which is why the MFD directory has so many textures).

If you can point me at the Unifont, and it's got a compatible license, I can include it in an updated MAS release (if nothing else, I can kick out a point release to include that an a couple of 1.8.x update leftovers, since I still haven't moved to 1.9.x in my dev environment).

Link to comment
Share on other sites

There are two fonts I've been looking at - Unifont (GPL), which you've seen above, and UbuntuMono Nerd Font Mono  (Ubuntu Font License) which is shown below:

b6f544991c431242c7a9d5f630cdbe55.png

These are the closest to looking like they're supposed to, so they're the ones I've brought to your attention. Unifont is probably more desirable - it not only has probably the most glyphs of any font (not sure but this seems accurate), but it has a style that isn't quite the same as InconsolataGO, so it can fill a gap. On the other hand, UbuntuFont is very clean, and the version I've linked to supports many glyphs.

If I had to pick one, I'd say Unifont is the winner considering all of the above.

As far as backgrounds go, I may end up writing a special backgroundhandler for kPM - I still haven't decided exactly.

 

 

Here's some more examples for reference, using Unifont, 32pt, normal style:

Spoiler

d66a7ac9a3c761ddc83529868ad18a5f.png

 

326e4e678ef0b5b10806a38514570ed5.png

 

Edited by dsonbill
Link to comment
Share on other sites

1 hour ago, RurouniDonut said:

I'm trying to add props to existing mods but the displays don't seem to work :l I'm trying to replace the props in the Probe Control Room mod with props from this one. They show up but they don't do anything.

 

You need to add a MASFlightComputer to the command module:
 

MODULE
{
    name = MASFlightComputer
    requiresPower = true
    gLimit = 4.7
    baseDisruptionChance = 0.20
    rate = 0.025
    RPM_COLOROVERRIDE
    {
        COLORDEFINITION
        {
            // 'white' label unlit color
            name = ASET_SWITCHER_NAME_ZEROCOLOR
            color =  213, 213, 213, 255
        }
        COLORDEFINITION
        {
            name = ASET_NUMINPUT_DISPLAY_GHOSTCOLOR
            color = 0, 255, 0, 31
        }
        COLORDEFINITION
        {
            name = ASET_NUMINPUT_DISPLAY_POSITIVECOLOR
            color = 0, 255, 0, 255
        }
        COLORDEFINITION
        {
            name = ASET_NUMINPUT_DISPLAY_NEGATIVECOLOR
            color = 0, 0, 0, 0
        }
    }
}

 

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