New Line in mission.runScreen?

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Post Reply
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

New Line in mission.runScreen?

Post by byronarn »

I know I have been asking a lot of scripting questions on here lately, but I don't know where else to post them. Is this the right place, or should these questions be posted elsewhere?

Anyways, my latest question: How do you get new lines on the mission.runScreen screen? I have tried the common "\n" (as suggested here) but it does not insert any new lines, but rather shows the "\n" as literal characters.

Here is the code I'm using:

Code: Select all

mission.runScreen({
			title: "The Crown Prince",
			message: "As you leave your ship to take a shor stroll through the station, you hear somone callout, \"Hey, Commander!\"\n\nYou turn towards the voice and see a large blue feline. \"Can I help you?\" you ask politely.\n\n\"I need to get to Xeesle within the next week, but faster is even better! I will give you 100Cr upfront, and 1000Cr when we get there. What do you say?\"",
			choicesKey: "yesno_choices"
		},
		function (choice)
		{
			if (choice === "1_YES")  player.consoleMessage("Yay!");
			else if (choice === "2_NO")  player.consoleMessage("Boo.");
		});
What am I doing wrong?
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4630
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: New Line in mission.runScreen?

Post by phkb »

Hmm, that looks OK. The only thing I can think to suggest is to check the text encoding of the script file. Make sure it's UTF-8.
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Re: New Line in mission.runScreen?

Post by byronarn »

phkb wrote: Wed Mar 29, 2017 5:53 am
Hmm, that looks OK. The only thing I can think to suggest is to check the text encoding of the script file. Make sure it's UTF-8.
That solved the problem! Notepad++ was encoding it in ANSI. I changed it to UTF-8 and now it's working.

One of these days, I'll have enough experience to be able to intuitively know that I need to check the encoding. :lol:
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: New Line in mission.runScreen?

Post by Norby »

Are the words "shor" and "somone" some kind of slang or simple typo?
If you have time you can consider using missiontext.plist as a storage of your messages.
It is possible to make some variations just use descriptions.plist and [keyname] in the text.
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Re: New Line in mission.runScreen?

Post by byronarn »

Norby wrote: Wed Mar 29, 2017 9:16 am
Are the words "shor" and "somone" some kind of slang or simple typo?
Simple typos for "short" and "someone".
Norby wrote: Wed Mar 29, 2017 9:16 am
If you have time you can consider using missiontext.plist as a storage of your messages.
It is possible to make some variations just use descriptions.plist and [keyname] in the text.
I can definitely see the advantages to using descriptions.plist for variation, but what is the advantages of storing all my messages in missiontext.plist?
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: New Line in mission.runScreen?

Post by Norby »

byronarn wrote: Wed Mar 29, 2017 10:59 am
what is the advantages of storing all my messages in missiontext.plist?
For example:
- easier to see through the whole story over a size,
- you can use numbered messages even in cycles as expandMissionText("youroxp"+this.$number);
- stage driven mission flow is also possible like in The Collector,
- needed for translating to other languages.
Post Reply