Problem with planetinfo.plist

General discussion for players of Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Problem with planetinfo.plist

Post by Commander McLane »

I'm trying to script a dynamic planetinfo.plist, in order to make special market situations like disasters that raise the price of a specific commodity possible.

As a very first step I included script_actions in my planetinfo.plist in order to see how they work. Here's my small script:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>0 55</key>
	<dict>
	<key>name</key>
	<string>Leeeesti</string>
	<key>script_actions</key>
	<array>
		<dict>
			<key>conditions</key>
			<array>
				<string>mission_actsOfGod_running equal RUNNING</string>
			</array>
			<key>do</key>
			<array>
				<key>station</key>
				<string>alternative_station</string>
			</array>
		</dict>
	</array>
	</dict>
</dict>
</plist>
Later I want to try variable-names instead of "0 55", but I got stuck even without that.

In the log-file the following lines appear as soon as I am jumping to the system:
2007-03-13 13:00:12.603 Oolite[1851] ***** PlayerEntity DOES NOT RESPOND TO scriptAction: "station"
2007-03-13 13:00:12.603 Oolite[1851] ***** PlayerEntity DOES NOT RESPOND TO scriptAction: "alternative_station"
and I have no idea what I'm doing wrong. I've copied the syntax from Ionics, so I guess it should work.

The name-key is just so that I can check whether out of the script_actions the plist works, which it does. If I include that name-key in the <key>do</key>-part the whole thing becomes even more mysterious, because I will also get a
***** PlayerEntity DOES NOT RESPOND TO scriptAction: "Leeeesti"
in my log-file, but not a preceeding
***** PlayerEntity DOES NOT RESPOND TO scriptAction: "name"
Any ideas what's wrong here?

And, yes, of course, the mission_actsOfGod_running-variable is set correctly in the script.plist, and the alternative_station is defined in shipdata.plist.

So do I miss something very obvious here, or what is the problem? Thanks for any clues!
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Problem with planetinfo.plist

Post by JensAyton »

Commander McLane wrote:

Code: Select all

<array>
    <key>station</key>
    <string>alternative_station</string>
</array>
This does not make sense. An array can’t contain keys. I’m mildly surprised to see that it actually does load under OS X’s PList parser; the keys are treated as strings. I suspect you’re copying a bug from Ionics; that stuff doesn’t look like it’s supposed to be inside a "do".
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

So would this make more sense?:

Code: Select all

			<array>
				<string>"station" = "alternative_station"</string>
			</array>
I just hadn't thought that it's a bug in Ionics. I supposed it to be working code.

But still, why was the <key>name</key>-entry in the array not answered with an error message, only the three others?


EDIT: No, didn't work either. Got a
***** PlayerEntity DOES NOT RESPOND TO scriptAction: ""station" = "alternative_station""
in my log-file. Perhaps without quotationmarks?


EDIT again: Nope, neither without quotationmarks. :idea: Ah, as I am in script_actions, perhaps I ought to use "setSpecificPlanetinfo:" or something like that?


another EDIT: Nope as well. Looks like I should resort to doing that all in sript.plist instead of planetinfo.plist, which is a possibility.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Commander McLane wrote:
But still, why was the <key>name</key>-entry in the array not answered with an error message, only the three others?
This part of the parsing is done by a lower-level component in Cocoa (OS X) or GNUstep over which we have no control. As I said, I’m surprised it “worked”.

As for the rest, well, I don’t really understand the scripting system, although I’m getting to learn it as I rewrite it. A potential problem is that there seems to be duplication – scripts occuring in various locations may be treated in different ways – although I’m not sure of that one yet.
User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

Post by Ramirez »

Commander McLane wrote:

another EDIT: Nope as well. Looks like I should resort to doing that all in script.plist instead of planetinfo.plist, which is a possibility.
Yes, using a setSpecificPlanetInfo within the script.plist should work OK. If you need to set the planetinfo for a range of systems, an alternative could be to use setPlanetInfo instead. This only applies changes to the system the player is currently in, but can be tailored to specific types of planets using the script conditions. This would save having to identify each and every system that could be affected by a wider event (e.g. because of a rise in fuel prices in all democracies or something like that).
Download Resistance Commander plus many other exciting OXPs HERE
Post Reply