I'm working on an OXP that allows your passenger to send you messages. I am having issues with a segment of the code. I've isolated it to the following portion of code. Can anyone see why the message isn't displaying? (x is the randomly selected passenger.)
(...)
else if (player.alertCondition === 1) {
var messageText = ["I'm bored. Are we there yet?", "I can't wait to get there. I have important business to do, you know.",
"Just think, in your father's day, a trip like this would have taken twice as long!",
"I have heard many stories about this system. Let's hope half of them aren't true!",
"Does this ship have bathroom facilities?", "I like pie.", "You are fully licensed and bonded, right?",
"Sir, your in-flight magazines are wildly out of date!", "You call yourself a pilot? You fly like a pregnant yak!"];
player.consoleMessage(player.ship.passengers[x].name + " (Going to " + player.ship.passengers[x].destinationName + "): " + messageText[floor(Math.random()*messageText.length)]);
}
(...)
The code works in all the other conditions (in a fire fight, the temperature too hot, mass locked, etc.), but not in this one. What did I do wrong?
A non-existent property is not generate any warning in js but considered silently to false, so the mistyped condition was never true. This was a special treat when I finally found it.
A non-existent property is not generate any warning in js but considered silently to false, so the mistyped condition was never true. This was a special treat when I finally found it.
Shortly after I solved the issue of this thread, I came across another bug. It took me an hour to realize what was wrong with this:
A non-existent property is not generate any warning in js but considered silently to false, so the mistyped condition was never true. This was a special treat when I finally found it.
A non-existent property is not generate any warning in js but considered silently to false, so the mistyped condition was never true. This was a special treat when I finally found it.
Ship is bacon!? Smivs has admitted to ship lunching from station, in response to my ship lurching from station.
You could also simplify the scripting by removing all the messages from the script using 'expandDescription' and moving the text to a descriptions.plist.
{
"passengerChatterDocked" = ("I'm bored. Are we there yet?", "I can't wait to get there. I have important business to do, you know.", "Just think, in your father's day, a trip like this would have taken twice as long!", "I have heard many stories about this system. Let's hope half of them aren't true!", "Does this ship have bathroom facilities?", "I like pie.", "You are fully licensed and bonded, right?", "Sir, your in-flight magazines are wildly out of date!", "You call yourself a pilot? You fly like a pregnant yak!");
}
Commander Smivs, the friendliest Gourd this side of Riedquat.
You could also simplify the scripting by removing all the messages from the script using 'expandDescription' and moving the text to a descriptions.plist.
I think you meant expandMissionText() and missiontext.plist? And now that the subject has come up, is there any difference at all in the way descriptions.plist and missiontext.plist function?
I've never been sure whether the entries in missiontext were globally available or restricted to that OXP? When I re-wrote Explorers' Club, I moved all the strings to a missiontext file, but I gave all the entries an explorerClub_ prefix, on the assumption they are all merged into one pool.
I tend to use missionText for mission screens etc, and Descriptions for console messages etc. I'm not sure if there is actually any convention or recommendations regarding this.
Commander Smivs, the friendliest Gourd this side of Riedquat.
And now that the subject has come up, is there any difference at all in the way descriptions.plist and missiontext.plist function?
Very little, nowadays. The expandDescription function takes a string which may contain some descriptions entries in [], giving a warning for unrecognised entries, while the expandMissionText function takes a string which is expected to be the name of a key in missiontext.plist, silently returning null if it doesn't exist.
The contents of missiontext.plist are easier to access directly from a mission screen if you don't need to modify them (or can do all the modification with simple expansions such as %H or mission variables)
The contents of descriptions.plist are more suited to randomisation using arrays.
Both files are merged, so you do need to prefix your entries.
A non-existent property is not generate any warning in js but considered silently to false, so the mistyped condition was never true. This was a special treat when I finally found it.