Difference between revisions of "Script.plist"

From Elite Wiki
m
m (Tagged as Legacy scripting)
 
(22 intermediate revisions by 7 users not shown)
Line 1: Line 1:
'''script.plist''' Used by [[missions]] and [[OXP]]'s to check [[conditions]] and change scripted parameters accordingly. In OXP's it provides Oolite with additional information to generate and populate customised systems. Every condition is followed by a scripted action, a '[[Do]]' or '[[Else]]' entry, a 'do' entry can be nested (have conditions, followed by Do)
+
'''script.[[plist]]''' Used by [[Oolite_Missions|missions]] and [[OXP]]'s to check [[conditions]] and perform scripted actions accordingly. The legacy scripting engine used by this is not recommended for use in new OXPs - use [[Oolite_JavaScript_Reference|Javascript]] for scripted behaviour instead.
  
== Conditions ==
+
In OXP's it can provide Oolite with additional information to generate and populate customised systems.
Check whether the current status of one of a number of queriable states and '''''mission_variables''''' are '''equal''', '''lessthan''', '''greaterthan''' a given value or state, or '''oneof''' a list of space separated states.
+
 
 +
== Structure ==
 +
 
 +
''script.plist'''s structure is a dictionary, each entry is a particular script with a unique key.
 +
 
 +
Each script is an array of actions and conditional statements that are executed or checked at regular intervals (every 10 seconds or so during flight or docking).
 +
 
 +
For increased performance of a script one needs to add nested structures within the script structure. see: [[Structured Legacy Scripts]]
 +
 
 +
== Actions ==
 +
 
 +
An action is a simple string referring to a [[methods|method]]
 +
 
 +
== Conditional statements ==
 +
 
 +
Conditional statements consist of a dictionary with entries for the keys  '''conditions''' and '''do''' (and optionally '''else'''.)
 +
 
 +
=== conditions ===
 +
 
 +
'''conditions''' consists of an array of tests to be performed. Each test checks whether the current status of one of a number of [[Methods#Querying_states|queriable states]] and [[mission_variable]]s are '''equal''', '''lessthan''', '''greaterthan''' a given value or state, or '''oneof''' a list of comma separated states.
 +
Note: As of v1.69 also a '''notequal''' operator will be available for Legacy scripting.
 +
 
 +
Multiple conditions may be specified, a logical 'AND' is applied to determine whether the conditions are met or not.
 +
 
 +
If all the conditions are met then the '''do''' entry is executed, if any are not met then the '''else''' entry is executed (if it exists).
  
 
example:
 
example:
Line 12: Line 36:
 
  </dict>
 
  </dict>
  
=== Queriable states ===
+
=== do ===
States ending in '''_number''' return a floating point value, those ending in '''_bool''' return '''YES''' or '''NO''', '''_string''' return strings according to the query.
 
  
==== Player States ====
+
'''do''' consists of an array of actions (and further conditional statements if required), executed if the '''conditions''' are met.
mission_string;
 
status_string;
 
gui_screen_string;
 
score_number;
 
credits_number;
 
scriptTimer_number;
 
legalStatus_number;
 
fuel_level_number; // returns the fuel level in LY
 
dockedAtMainStation_bool;
 
  
==== Search Results ====
+
Example:
  shipsFound_number;
+
  <key>do</key>
  foundEquipment_bool;
+
  <dict>
 +
    <array>
 +
        <string>addShips: asp-cloaked 1</string>
 +
        <string>addShips: pirate 12</string>
 +
    </array>
 +
</dict>
  
==== Random Numbers ====
+
=== else ===
d100_number;
 
pseudoFixedD100_number;
 
  
==== TIme ====
+
'''else''' consists of an array of actions (and further conditional statements if required), executed if the '''conditions''' are NOT met.
clock_number; // returns the game time in seconds
 
clock_secs_number; // returns the game time in seconds
 
clock_mins_number; // returns the game time in minutes
 
clock_hours_number; // returns the game time in hours
 
clock_days_number; // returns the game time in days
 
 
 
==== System States ====
 
galaxy_number;
 
planet_number;
 
sunWillGoNova_bool; // returns whether the sun is going to go nova
 
sunGoneNova_bool; // returns whether the sun has gone nova
 
dockedStationName_string; // returns 'NONE' if the player isn't docked, [station name] if it is, 'UNKNOWN' otherwise
 
systemGovernment_string;
 
systemGovernment_number;
 
systemEconomy_number;
 
systemTechLevel_number;
 
systemPopulation_number;
 
systemProductivity_number;
 
 
 
==== Mission Choice Results ====
 
missionChoice_string; // returns nil or the key for the chosen option
 
 
 
== Do ==
 
The actions ([[methods]]) to perform when conditions are met.  
 
  
 
Example:
 
Example:
  <key>do</key>
+
  <key>else</key>
 
  <dict>
 
  <dict>
 
     <array>
 
     <array>
         <string>addShips: asp-cloaked 1</string>
+
         <string>addShips: super-pirate 1</string>
        <string>addShips: pirate 12</string>
 
 
     </array>
 
     </array>
 
  </dict>
 
  </dict>
  
== Else ==
 
Actions performed when conditions are not met. Same as "Do".
 
  
{{Stub}}
 
  
 +
==Examples==
  
 +
A few simple ''rendezvous'' scripts, to make ships appear in space, can be found in [[OXP_howto_plist#script.plist|here]].
  
 +
Missions are offered with special commands.
 +
How to do this so you won't disturb other OXP missions is seen [[OXP_mission_offering|here]]. 
  
  
--------------------------------------------------------------------------------
 
 
[[Category:Oolite]]
 
[[Category:Oolite]]
[[Cathegory:OXP_howto]]
+
[[Category:Oolite scripting]] [[Category:Legacy scripting]]

Latest revision as of 09:45, 9 August 2021

script.plist Used by missions and OXP's to check conditions and perform scripted actions accordingly. The legacy scripting engine used by this is not recommended for use in new OXPs - use Javascript for scripted behaviour instead.

In OXP's it can provide Oolite with additional information to generate and populate customised systems.

Structure

script.plist's structure is a dictionary, each entry is a particular script with a unique key.

Each script is an array of actions and conditional statements that are executed or checked at regular intervals (every 10 seconds or so during flight or docking).

For increased performance of a script one needs to add nested structures within the script structure. see: Structured Legacy Scripts

Actions

An action is a simple string referring to a method

Conditional statements

Conditional statements consist of a dictionary with entries for the keys conditions and do (and optionally else.)

conditions

conditions consists of an array of tests to be performed. Each test checks whether the current status of one of a number of queriable states and mission_variables are equal, lessthan, greaterthan a given value or state, or oneof a list of comma separated states. Note: As of v1.69 also a notequal operator will be available for Legacy scripting.

Multiple conditions may be specified, a logical 'AND' is applied to determine whether the conditions are met or not.

If all the conditions are met then the do entry is executed, if any are not met then the else entry is executed (if it exists).

example:

<key>conditions</key>
<dict> 
    <array>
        <string>shipsFound_number equal 0</string>
    </array>
</dict>

do

do consists of an array of actions (and further conditional statements if required), executed if the conditions are met.

Example:

<key>do</key>
<dict>
    <array>
        <string>addShips: asp-cloaked 1</string>
        <string>addShips: pirate 12</string>
    </array>
</dict>

else

else consists of an array of actions (and further conditional statements if required), executed if the conditions are NOT met.

Example:

<key>else</key>
<dict>
    <array>
        <string>addShips: super-pirate 1</string>
    </array>
</dict>


Examples

A few simple rendezvous scripts, to make ships appear in space, can be found in here.

Missions are offered with special commands. How to do this so you won't disturb other OXP missions is seen here.