Line data Source code
1 0 : /* 2 : 3 : OOScript.h 4 : 5 : Abstract base class for scripts. 6 : Currently, Oolite supports two types of script: the original property list 7 : scripts and JavaScript scripts. OOS, a format that translated into plist 8 : scripts, was supported until 1.69.1, but never used. OOScript unifies the 9 : interfaces to the script types and abstracts loading. Additionally, it falls 10 : back to a more "primitive" script if loading of one type fails; specifically, 11 : the order of precedence is: 12 : script.js (JavaScript) 13 : // script.oos (OOS) 14 : script.plist (property list) 15 : 16 : Oolite 17 : Copyright (C) 2004-2013 Giles C Williams and contributors 18 : 19 : This program is free software; you can redistribute it and/or 20 : modify it under the terms of the GNU General Public License 21 : as published by the Free Software Foundation; either version 2 22 : of the License, or (at your option) any later version. 23 : 24 : This program is distributed in the hope that it will be useful, 25 : but WITHOUT ANY WARRANTY; without even the implied warranty of 26 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 : GNU General Public License for more details. 28 : 29 : You should have received a copy of the GNU General Public License 30 : along with this program; if not, write to the Free Software 31 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 32 : MA 02110-1301, USA. 33 : 34 : */ 35 : 36 : #import <Foundation/Foundation.h> 37 : 38 : @class Entity; 39 : 40 : 41 0 : @interface OOScript: NSObject 42 : 43 : /* Looks for path/world-scripts.plist, path/script.js, then path/script.plist. 44 : May return zero or more scripts. 45 : */ 46 0 : + (NSArray *)worldScriptsAtPath:(NSString *)path; 47 : 48 : // Load named scripts from Scripts folders. 49 0 : + (NSArray *)scriptsFromFileNamed:(NSString *)fileName; 50 0 : + (NSArray *)scriptsFromList:(NSArray *)fileNames; 51 : 52 0 : + (NSArray *)scriptsFromFileAtPath:(NSString *)filePath; 53 : 54 : // Load a single JavaScript script. 55 0 : + (id)jsScriptFromFileNamed:(NSString *)fileName properties:(NSDictionary *)properties; 56 : // As above, but load from the "AIs" directory 57 0 : + (id)jsAIScriptFromFileNamed:(NSString *)fileName properties:(NSDictionary *)properties; 58 : 59 0 : - (NSString *)name; 60 0 : - (NSString *)scriptDescription; 61 0 : - (NSString *)version; 62 0 : - (NSString *)displayName; // "name version" if version is defined, otherwise just "name". 63 : 64 0 : - (BOOL) requiresTickle; 65 0 : - (void)runWithTarget:(Entity *)target; 66 : 67 : @end