45+ (NSArray *)worldScriptsAtPath:(NSString *)path
47 NSFileManager *fmgr =
nil;
48 NSString *filePath =
nil;
50 NSArray *result =
nil;
52 BOOL foundScript = NO;
54 fmgr = [NSFileManager defaultManager];
57 filePath = [path stringByAppendingPathComponent:@"world-scripts.plist"];
71 filePath = [path stringByAppendingPathComponent:@"script.js"];
72 if ([fmgr oo_oxzFileExistsAtPath:filePath]) foundScript = YES;
75 filePath = [path stringByAppendingPathComponent:@"script.es"];
76 if ([fmgr oo_oxzFileExistsAtPath:filePath]) foundScript = YES;
86 result = [NSArray arrayWithObject:script];
98 filePath = [path stringByAppendingPathComponent:@"script.plist"];
99 if ([fmgr oo_oxzFileExistsAtPath:filePath])
117 if (result ==
nil && foundScript)
126+ (NSArray *)scriptsFromFileNamed:(NSString *)fileName
128 NSArray *result =
nil;
132 result = [
self scriptsFromFileAtPath:path];
137 OOLogERR(
@"script.load.notFound",
@"Could not find script file %@.", fileName);
144+ (NSArray *)scriptsFromList:(NSArray *)fileNames
146 NSEnumerator *nameEnum =
nil;
148 NSMutableArray *result =
nil;
149 NSArray *scripts =
nil;
151 result = [NSMutableArray arrayWithCapacity:[fileNames count]];
153 for (nameEnum = [fileNames objectEnumerator]; (
name = [nameEnum nextObject]); )
155 scripts = [
self scriptsFromFileNamed:name];
156 if (scripts !=
nil) [result addObjectsFromArray:scripts];
163+ (NSArray *)scriptsFromFileAtPath:(NSString *)filePath
166 if (![[NSFileManager defaultManager] oo_oxzFileExistsAtPath:filePath])
return nil;
168 NSString *extension = [[filePath pathExtension] lowercaseString];
170 if ([extension isEqualToString:
@"js"] || [extension isEqualToString:
@"es"])
172 NSArray *result =
nil;
174 if (script !=
nil) result = [NSArray arrayWithObject:script];
177 else if ([extension isEqualToString:
@"plist"])
187 OOLogERR(
@"script.load.badName",
@"Don't know how to load a script from %@.", filePath);
192+ (id)jsScriptFromFileNamed:(NSString *)fileName properties:(NSDictionary *)properties
194 NSString *extension =
nil;
195 NSString *path =
nil;
197 if ([fileName length] == 0)
return nil;
199 extension = [[fileName pathExtension] lowercaseString];
200 if ([extension isEqualToString:
@"js"] || [extension isEqualToString:
@"es"])
205 OOLogERR(
@"script.load.notFound",
@"Could not find script file %@.", fileName);
210 else if ([extension isEqualToString:
@"plist"])
212 OOLogERR(
@"script.load.badName",
@"Can't load script named %@ - legacy scripts are not supported in this context.", fileName);
216 OOLogERR(
@"script.load.badName",
@"Don't know how to load a script from %@.", fileName);
221+ (id)jsAIScriptFromFileNamed:(NSString *)fileName properties:(NSDictionary *)properties
223 NSString *extension =
nil;
224 NSString *path =
nil;
226 if ([fileName length] == 0)
return nil;
228 extension = [[fileName pathExtension] lowercaseString];
229 if ([extension isEqualToString:
@"js"] || [extension isEqualToString:
@"es"])
234 OOLogERR(
@"script.load.notFound",
@"Could not find script file %@.", fileName);
239 else if ([extension isEqualToString:
@"plist"])
241 OOLogERR(
@"script.load.badName",
@"Can't load script named %@ - legacy scripts are not supported in this context.", fileName);
245 OOLogERR(
@"script.load.badName",
@"Don't know how to load a script from %@.", fileName);
252 return [NSString stringWithFormat:@"\"%@\" version %@", [
self name], [
self version]];