Jump to content

Screen messages help


Recommended Posts

Whenever I reach mach one, nothing happens. No message , nothing.


public void Update()
{
double mach;
mach = vessel.mach;

if (mach == 1)
{
ScreenMessages.PostScreenMessage("Mach 1", 2f, ScreenMessageStyle.UPPER_CENTER);
}
}

i suck at see sharp(lol), so if you explain any revisions, will you copy and paste the code above and put the revisions in that. And then explain what you did.

much appreciated,

Ryan

Link to comment
Share on other sites

It's actually probably the IF(mach == 1) line as that line will only be true if your mach number is 1.00000000000000000

As the number is never that, it will be 0.999912423345 one frame and 1.00000342543 the next, the IF statement never goes true.

You will need to rework that in some way depending on what exactly you are wanting to do.

D.

Link to comment
Share on other sites

@landeTLS: Doing that will display a new message every update frame while your speed is faster then Mach 1, probably not what is wanted.

How to rework it depends on what is being done. Show the message as long as you are above Mach 1? Show the message once when you first hit it? Does the message reset and show a second time if you drop back down below Mach 1 and then go faster then Mach 1 a second time?

D.

Link to comment
Share on other sites

Maybe

if (mach >= 1)
{
ScreenMessages.PostScreenMessage("Mach 1", 2f, ScreenMessageStyle.UPPER_CENTER); }

But that will also display the message if you're at mach 2, 3,... or more. To keep the message only with mach 1 :

if (mach >= 1 && mach < 2)
{
ScreenMessages.PostScreenMessage("Mach 1", 2f, ScreenMessageStyle.UPPER_CENTER);
}

Edited by simon56modder
Link to comment
Share on other sites

How about:


bool isMach;
Public Void Update ()
{
float mach = (float)vessel.mach;
If (mach >= 1f && !isMach)
{
//post your message
isMach = true
}
if (mach < 1f)
{
IsMach = false
}
}

this should only show once each time when the craft breaks mach 1

Edited by landeTLS
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...