File: readme.txt

package info (click to toggle)
oolite 1.65-6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,532 kB
  • ctags: 1,504
  • sloc: objc: 56,004; ansic: 1,201; python: 1,086; java: 267; sh: 259; perl: 259; makefile: 65; xml: 39
file content (272 lines) | stat: -rw-r--r-- 10,450 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
Oolite script compiler.

Copyright (c) 2006 David Taylor. All rights reserved.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.0/
or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

You are free:

o to copy, distribute, display, and perform the work
o to make derivative works

Under the following conditions:

o Attribution. You must give the original author credit.
o Noncommercial. You may not use this work for commercial purposes.
o Share Alike. If you alter, transform, or build upon this work,
  you may distribute the resulting work only under a license identical to this one.

For any reuse or distribution, you must make clear to others the license terms of this work.
Any of these conditions can be waived if you get permission from the copyright holder.
Your fair use and other rights are in no way affected by the above.


Introduction
------------

This program reads an Oolite script written in a BASIC-like syntax and creates an XML
PList version of it.

The format of the BASIC-like file is:

scriptname

// comments must start with // and be the only thing on the line
if xxx [and xxx ...] then
	// indentation is ignored
	actions
[else
	actions]
endif

if xxx [and xxx ...] then
	actions
[else
	actions]
endif


The scriptname must be a single word on the first line of the script file.

Comments must be the only thing on a line, and start with //. Leading whitespace is ignored.
Comments can appear anywhere after the script name.

The script itself must only have "if" statements at the "top level". Multiple conditions
can be given to an if statement by using "and". The conditions be put on more than one line.
Newlines are ignored between "if" and "then"

The end of the conditions is marked with the word "then", which must be followed by
one or more "actions" which are written exactly as they are in the XML version of the script.
You can only put one action on each line, and leading whitespace is ignored.

You can use "else" followed by more actions to generate the else array of the XML script.

The if/else block is finished with the word "endif"


Installation
------------

You must have a working JRE to use this program.

Create a directory for the program, such as C:\ooscript. Then create a set of directories under
that called "dt\oolite\scriptcompiler". The ScriptCompiler.class file goes in the bottom directory.

In the above example, the fully qualified filename for the class file will be:
C:\ooscript\dt\oolite\scriptcompiler.class


How to run it
-------------

You can use the compile.bat file that is included as follows:

compile <script name>

e.g.

compile "C:/Program Files/Oolite/Addons/longway.oxp/Config/script.oos"

If you are not using Windows, issue the command:

java -classpath <parent directory of the "dt" package directory> dt.oolite.scriptcompiler.ScriptCompiler <script name>

Using the installation example above (note filenames with space MUST be surrounded by double quotes):

C:\>java -classpath c:\ooscript dt.oolite.scriptcompiler.ScriptCompiler "C:/Program Files/Oolite/Addons/longway.oxp/Config/script.oos"
Oolite script compiler
Copyright 2006 David Taylor. All rights reserved.
transforming C:/Program Files/Oolite/Addons/longway.oxp/Config/script.oos
to C:/Program Files/Oolite/Addons/longway.oxp/Config/script.plist


Example input/output
--------------------

Translating the longway_round mission to the simplified script syntax gives:

long_way_round
if galaxy_number equal 0 then
	if dockedAtMainStation_bool equal YES then
		if mission_longwayround undefined and planet_number equal 3 then
			setMissionMusic: none
			setGuiToMissionScreen
			addMissionText: long_way_round_Biarge_briefing
			set: mission_longwayround STAGE1
			setMissionDescription: em1_short_desc1
		endif

		if mission_longwayround equal STAGE1 and plaent_number equal 248 then
			setMissionMusic: none
			setGuiToMissionScreen
			addMissionText: long_way_round_Soladies_briefing
			awardCredits: 500
			set: mission_longwayround STAGE2
			setMissionDescription: em1_short_desc2
		endif

		if mission_longwayround equal STAGE2 and planet_number equal 233 then
			setMissionMusic: none
			setMissionImage: loyalistflag.png
			setGuiToMissionScreen
			addMissionText: long_way_round_Qubeen_briefing
			awardCredits: 2000
			setMissionImage: none
			set: mission_longwayround MISSION_COMPLETE
			clearMissionDescription
		endif
	endif

	if mission_longwayround equal STAGE2 and
	   planet_number equal 233 and
	   status_string equal STATUS_EXITING_WITCHSPACE then
		addShips: rebel 2
	endif

	if mission_longwayround equal STAGE2 and
	   status_string equal STATUS_IN_FLIGHT and
	   planet_number equal 233 and
	   scriptTimer_number lessthan 60 then
		checkForShips: rebel
		if shipsFound_number lessthan 5 and d100_number lessthan 50 then
			addShips: rebel 1
		endif
	endif
endif

Running this through the script compiler gives:

<?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>long_way_round</key>
    <array>
        <dict>
            <key>conditions</key>
            <array>
                <string>galaxy_number equal 0</string>
            </array>
            <key>do</key>
            <array>
                <dict>
                    <key>conditions</key>
                    <array>
                        <string>dockedAtMainStation_bool equal YES</string>
                    </array>
                    <key>do</key>
                    <array>
                        <dict>
                            <key>conditions</key>
                            <array>
                                <string>mission_longwayround undefined</string>
                                <string>planet_number equal 3</string>
                            </array>
                            <key>do</key>
                            <array>
                                <string>setMissionMusic: none</string>
                                <string>setGuiToMissionScreen</string>
                                <string>addMissionText: long_way_round_Biarge_briefing</string>
                                <string>set: mission_longwayround STAGE1</string>
                                <string>setMissionDescription: em1_short_desc1</string>
                            </array>
                        </dict>
                        <dict>
                            <key>conditions</key>
                            <array>
                                <string>mission_longwayround equal STAGE1</string>
                                <string>plaent_number equal 248</string>
                            </array>
                            <key>do</key>
                            <array>
                                <string>setMissionMusic: none</string>
                                <string>setGuiToMissionScreen</string>
                                <string>addMissionText: long_way_round_Soladies_briefing</string>
                                <string>awardCredits: 500</string>
                                <string>set: mission_longwayround STAGE2</string>
                                <string>setMissionDescription: em1_short_desc2</string>
                            </array>
                        </dict>
                        <dict>
                            <key>conditions</key>
                            <array>
                                <string>mission_longwayround equal STAGE2</string>
                                <string>planet_number equal 233</string>
                            </array>
                            <key>do</key>
                            <array>
                                <string>setMissionMusic: none</string>
                                <string>setMissionImage: loyalistflag.png</string>
                                <string>setGuiToMissionScreen</string>
                                <string>addMissionText: long_way_round_Qubeen_briefing</string>
                                <string>awardCredits: 2000</string>
                                <string>setMissionImage: none</string>
                                <string>set: mission_longwayround MISSION_COMPLETE</string>
                                <string>clearMissionDescription</string>
                            </array>
                        </dict>
                    </array>
                </dict>
                <dict>
                    <key>conditions</key>
                    <array>
                        <string>mission_longwayround equal STAGE2</string>
                        <string>planet_number equal 233</string>
                        <string>status_string equal STATUS_EXITING_WITCHSPACE</string>
                    </array>
                    <key>do</key>
                    <array>
                        <string>addShips: rebel 2</string>
                    </array>
                </dict>
                <dict>
                    <key>conditions</key>
                    <array>
                        <string>mission_longwayround equal STAGE2</string>
                        <string>status_string equal STATUS_IN_FLIGHT</string>
                        <string>planet_number equal 233</string>
                        <string>scriptTimer_number lessthan 60</string>
                    </array>
                    <key>do</key>
                    <array>
                        <string>checkForShips: rebel</string>
                        <dict>
                            <key>conditions</key>
                            <array>
                                <string>shipsFound_number lessthan 5</string>
                                <string>d100_number lessthan 50</string>
                            </array>
                            <key>do</key>
                            <array>
                                <string>addShips: rebel 1</string>
                            </array>
                        </dict>
                    </array>
                </dict>
            </array>
        </dict>
    </array>
</dict>
</plist>