If it's reading it only once per system, presumably I don't need to reset at the end, right? Here's what I'm about to test (I'm still unsure as to whether there should be some more <dict>s in there):
<key> only makes sense inside a <dict>, and each condition/do/else needs to be in a dictionary. This really is easier using the OpenStep syntax instead of XML; this:
This might be an easier way to do it (might work better on the dice). In descriptions .plist set an array with the different co-ordinates as variables. Eg somthing like:-
<key>mission_my_mission_start_position_number</key>
<array>
<string>145000 -29000 60500</string>
<string>250024.81 25.77 -102991.52</string>
... etc etc for all your different co-ords
</array>
Cos Oolite randomly picks one of your co-ordinate numbers in the strings from the list set as [mission_my_mission_start_position_number], that should work to give you the random effect you want. I used this wheeze in RandomHits to get a random number of rocks near the Space Bars and create a random starting position for the victims.
[/code]
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
How do I convert the two bits at the end, and do I still need to reset taranis_frigate_d100 at the end? (If so, I'm confused as to why - won't Oolite just roll a new number the next time it reads the plist, i.e. when you re-enter the system?)
*EDIT* Well, it works... except that it always seems to select the first set of coordinates. Like, five or six times in a row.
also my experience with "random" selections from a description.plist. For a certain system, the majority of the selections are always the same. In an other system it might be an other. I noticed this in 1.65/1.69 but it might be also under 1.70.
Just a question why you only select with a chance of 1%. This means you have to enter that specific system 100 times to see it once. It looks a little to rare to me.
I think the problem is that "random" in Oolite isn't really random; it's, well, pseudo-random, determined by the seed.
I think we can imagine it like a long list of numbers that are somehow randomly evenly distributed between 0 and 99. If a script calls for a random number, the engine just takes the next number from the list.
So, Roberto, if you load a save-game for testing purposes, the list will always be the same, and of course the position the engine has reached on the list will always be the same. Therefore also the next number in the list will always be the same.
In reality and with many OXPs installed this is not so big an issue, because scripts are executed in a random order. So if you reload a savegame, any of the scripts may get the "next number from the list", and your script will then get the second-to-next or third-to-next, which for the player looks more randomly. But in any situation where only one script could require a "next number from the list", it will always get the same number, if started from the same position on the list.
I think the problem is that "random" in Oolite isn't really random; it's, well, pseudo-random, determined by the seed.
Just for testing purposes I made once a description.plist with content: one, two, three etc. Then in flight I issued a commsMessage with this description on every update. 4 out of 5 time it used the same text. When I jumped into an other system, an other number was the dominant message. When coming back in a system I was before, the same message as before was dominant. Distributed over all systems it is random but within a system some selections are preferred.
The problem here is that Oolite uses two different “random” number generators, and both are used both for things that should be “really” random and for things that should be predictable. Maybe we should add a third one for “really really random” things…