|
Post by Jeff on Jun 1, 2013 1:32:07 GMT
This code was origionally from marble blast emerald, and then went into old dead Project Revolution.
It checks to see if a skybox is missing. Simple as that.
To use:
echo(levelSkyWorks("path_to_file.mis"));
Will return 1 or 0, one obviously being yes, a skybox exists.
function levelSkyWorks(%file) { %fo = new FileObject(); %sky = ""; if (%fo.openForRead(%file)) { while (!%fo.isEOF()) { %line = %fo.readLine(); %line = trim(%line); if (strStr(%line, "materialList = \"") != -1) { //Here we have it! %sky = getSubStr(%line, 16, strLen(%line)); //Getting a little tricky... %sky = getSubStr(%sky, 0, (strLen(%sky) - 2)); break; } } %fo.close(); } if (isFile(expandFilename(%sky))) { %skyIsOk = true; } %fo.delete(); return %skyIsOk; }
Enjoy
|
|
|
Post by Trace on Jun 1, 2013 7:05:00 GMT
Any chance you could add an option to it to modify the skybox to a default one if the the skybox is not found?
|
|
|
Post by Aayrl on Jun 1, 2013 15:51:38 GMT
To extend on Trace's concept, it's possible to simply read through the skybox directory and generate an array of all of the possible skyboxes. I'm curious if you could randomly assign a skybox from this array each time you load a mission.
~Aayrl
|
|
|
Post by Jeff on Jun 1, 2013 20:20:30 GMT
^ has already been done in PR I believe. I know I coded that a while ago. Easy as eating a slice of pie with whipped cream.
|
|
|
Post by CyberFox on Jun 2, 2013 21:08:14 GMT
i actually did something similar with my MatrixMaze levels:
$skybox_url = getrandom(4); if ( $skybox_url == 0 ){ $skybox_url = "~/data/skies/intermediate/intermediate_Sky.dml"; $sun_1 = "0.531491 -0.606518 -0.591314"; $sun_2 = "1.000000 0.900000 0.200000 1.000000"; $sun_3 = "0.300000 0.300000 0.240000 1.000000"; } else if ( $skybox_url == 1 ){ $skybox_url = "~/data/skies/beginner/beginner_Sky.dml"; $sun_1 = "-0.444514 0.746881 -0.494547"; $sun_2 = "1.000000 1.000000 1.000000 1.000000"; $sun_3 = "0.300000 0.300000 0.300000 1.000000"; } else if ( $skybox_url == 2 ){ $skybox_url = "~/data/skies/expert/expert_Sky.dml"; $sun_1 = "0.444514 -0.746881 -0.494547"; $sun_2 = "0.600000 0.600000 0.600000 1.000000"; $sun_3 = "0.300000 0.300000 0.450000 1.000000"; } else if ( $skybox_url == 3 ){ $skybox_url = "~/data/skies/advanced/advanced_Sky.dml"; $sun_1 = "-0.668065 -0.506593 -0.545026"; $sun_2 = "1.600000 1.600000 1.600000 1.000000"; $sun_3 = "0.400000 0.400000 0.400000 1.000000"; } else{ $skybox_url = "~/data/skies/bonus/bonus_Sky.dml"; $sun_1 = "-0.00945897 -0.68078 -0.732427"; $sun_2 = "0.600000 0.600000 0.250000 1.000000"; $sun_3 = "0.400000 0.400000 0.300000 1.000000"; }
You could lots of fun shizzle to make you levels a less repetitive.
Use altcode 0160 to make a non breaking space or write the other is just bad style...
|
|
|
Post by Aayrl on Jun 3, 2013 20:31:20 GMT
Perfect, Cyberfox. I was on a work machine at the time and did not have the opportunity to write one up myself - figured someone had it already and could toss it in the MBDK for anyone that was looking for the functionality.
~Aayrl
|
|
|
Post by Jeff on Jun 4, 2013 1:45:56 GMT
nice one CF
|
|