Code: Select all
this.personalities-mclane-attacked=['first text','second text','third','fourth'];
PS: Using that array, this.personalities-mclane-attacked[0,0] should produce 'f', this.personalities-mclane-attacked[0,4] would give you 't' etc...
Moderators: winston, another_commander
Code: Select all
this.personalities-mclane-attacked=['first text','second text','third','fourth'];
Code: Select all
{
mclane-personalities-shoutout0="first";
mclane-personalities-shoutout1="second";
....
mclane-personalities-shoutout10="eleventh";
....
}
Code: Select all
this.shoutouts=[];
this.startUp= function() {
var i=0;
this.shoutouts=[];
while(expandDescription('[mclane-personalities-shoutout'+i+']') !='mclane-personalities-shoutout'+i) {
this.shoutouts.push(expandDescription('[mclane-personalities-shoutout'+(i++)+']');
}
//other stuff
...
};
The script would need to be told all of the description keys that we want to use. From the top of my head:Commander McLane wrote:So, how do I convert the arrays in descriptions.plist into an JS-array? I haven't yet managed to address the array-entries in descriptions.plist one by one. If I try something like personalities-mclane-attacked[n], I don't get the n'th entry in the personalities-mclane-attacked array, but the n'th letter in one random entry. What is the correct JS syntax?
Code: Select all
var descriptions = array['mclane-attacked', 'mclane-harried', 'mclane-worried'],
i,
descriptionName;
this.personalityDescriptions = [];
for (i = 0; i < descriptions.length; i += 1) {
descriptionName = descriptions[i];
this.descriptions[descriptionName] = expandDescription('personalities-' + descriptionName);
}
Code: Select all
this.descriptions['mclane-attacked']
I agree. While my base implementation works across the board, improvements such as what Kaks has suggested can make it easier to to code up more flexible solutions.Kaks wrote:There's just one problem with pmw57's approach: expandDescription collapses an array of alternative strings into just one string. Using the example above, only one of all possible 'mclane-attacked' strings is ever stored inside the this.descriptions object.
Using my approach all the mclane-attacked strings can be made available for js to pick using Math.random().
Code: Select all
this.randomMessage = function (messageBase) {
var messages = [],
messageKey = '',
index = 1;
// add base message if it exists
if (this.descriptions[messageBase]) {
messages.push(this.descriptions[messageBase]);
}
// add 0 message if it exists
if (this.descriptions[messageBase + '0']) {
messages.push(messageBase + '0');
}
// check for messages from 1 upwards
while (this.descriptions[messageBase + index]) {
messages.push(messageBase + index);
index += 1;
}
messageKey = messages[Math.floor(messages.length * Math.random())];
return this.descriptions(messageKey);
};
Code: Select all
message = this.randomMessage('mclane-personalities-shoutout');
So there is no way to convert a descriptions.plist array as it is into a JS array. I was afraid so.Kaks wrote:There's just one problem with pmw57's approach: expandDescription collapses an array of alternative strings into just one string. Using the example above, only one of all possible 'mclane-attacked' strings is ever stored inside the this.descriptions object.
Code: Select all
"personalities-kaks-witchspace" = (
"This should be interesting...",
"Oooh, shiny!",
"Ah, that's what it looks like!"
);
Code: Select all
this.ship.commsMessage(expandDescription("[personalities-kaks-witchspace]"))
Code: Select all
this.ship.commsMessage(expandDescription("[personalities-kaks-witchspace]", 1))
How about something like this:Commander McLane wrote:It does? Well that's news. Up until now I didn't realise that the descriptions were capable of random messages.Kaks wrote:There's just one problem with pmw57's approach: expandDescription collapses an array of alternative strings into just one string.
Commander McLane wrote:Using the example above, only one of all possible 'mclane-attacked' strings is ever stored inside the this.descriptions object.
Code: Select all
this.descriptions['personalities-kaks-witchspace'] = [
"This should be interesting...",
"Oooh, shiny!",
"Ah, that's what it looks like!"
];
Code: Select all
Array.prototype.random = function () {
return this[Math.floor(Math.random() * this.length)];
};
Code: Select all
this.ship.commsMessage(this.description['personalities-kaks-witchspace'].random());
Code: Select all
this.ship.commsMessage(this.description['personalities-kaks-witchspace'][1]);
Well, yes, it does. Actually it's the whole point of having arrays in descriptions.plist. I thought we were there already. If I may remind you of your original question about Random Hits:pmw57 wrote:It does? Well that's news. Up until now I didn't realise that the descriptions were capable of random messages.Kaks wrote:There's just one problem with pmw57's approach: expandDescription collapses an array of alternative strings into just one string.
The whole point of using an array named [random_hits_rocks_number2] in descriptions.plist is that when it is expanded (regardless whether by legacy or JS), one of the array-entries is randomly chosen by the engine.Commander McLane wrote:That's not a variable, but an entry in descriptions.plist (and yes, Random Hits uses a lot of those for the randomized descriptions).pmw57 wrote:The property list uses variables such as [random_hits_rocks_number2].
If you want its content in a JS script, use expandDescription("[random_hits_rocks_number2]").
Yes, I know all that. My only question was specifically: How can I automatically convert the array out of descriptions.plist into an JS-array. Or in other words: How do I get from this (entry in descriptions.plist, not in a JS worldscript):How about something like this:We can easily give arrays (all arrays) a random method that they can call on.Code: Select all
this.descriptions['personalities-kaks-witchspace'] = [ "This should be interesting...", "Oooh, shiny!", "Ah, that's what it looks like!" ];
So you can then show a random description withCode: Select all
Array.prototype.random = function () { return this[Math.floor(Math.random() * this.length)]; };
Code: Select all
this.ship.commsMessage(this.description['personalities-kaks-witchspace'].random());
Code: Select all
"personalities-kaks-witchspace" = (
"This should be interesting...",
"Oooh, shiny!",
"Ah, that's what it looks like!"
);
Code: Select all
this.description = array['descriptions.plist entry personalities-kaks-witchspace, first subentry',
'descriptions.plist entry personalities-kaks-witchspace, second subentry',
'descriptions.plist entry personalities-kaks-witchspace, third subentry',
...,
'descriptions.plist entry personalities-kaks-witchspace, last subentry']
That can not be one automatically from JS, but if you want to migrate the descriptions over you can use some backend processing to automatically convert the OpenStep code to JS property lists. That's about the best solution there is at this stage.Commander McLane wrote:I am asking for a JS routine that would extract the content of descriptions.plist automatically and put it in a list of JS arrays (or a three-dimensional JS-array, doesn't matter).
I shall stick with expandDescription for now, as being the most compatible manner in which to achieve things. Developments can occur later on, as and when need be.LittleBear wrote:Should point out nothing in Random Hits is hand coded, every message and BB board is randomly generated by the engine on the fly from the words listed in the arrays. The arrays are also nested so it could be a bit of a [random_hits_describe_pain] in the [random_hits_describe_place] to unravel them all! The descriptions file is about 40,000 words in about 5,000 arrays. I'm perfectley happy with you converting if you want to, but it would be an much bigger task than converting the script. If you have a look through the descriptions.plist I've flagged what each word list relates to with comments, but it'd be a big job to convert.
I once had such a bug when I still had the ATI 4870x2. Sometimes this glow according to my engine speed setting was not only set for my ship, but for every object in the whole ooniverse...since switching to nVidia I have not seen it again, but it might have had it's source somewhere else. Could it be that you did add some new ship which overwrites working shaders for other ships with a buggy one?Commander McLane wrote:But I think there is something wrong with its shaders. On acceleration the whole ship turns yellow, which looks distinctly odd: