| Blockland Forums > Modification Help |
| Day/Night Cycle |
| (1/2) > >> |
| DYLANzzz:
I wanted to try my hand at making something like this. How would I get the sun object? Would I have to loop through the mission group and check for each object for the sun or what? |
| TripleNickels:
--- Code: ---function getSun() { for(%i=0;%i<missionGroup.getCount();%i++) { %obj = missionGroup.getObject(%i); if(%obj.getClassname() $= "Sun") { %sun = %obj; break; } } if(isObject(%sun)) return %sun; return 0; } --- End code --- This should only be ran when necessary because it will probably lag some, especially if there are a sizable amount of bricks / other objects. I suggest you run it on a map change or load when there's not many objects left from mission cleanup. |
| cciamlazy:
Already been done so why? |
| Destiny/Zack0Wack0:
You'll find that a large majority (if not all) have the 'sun object' directly named Sun. So you can just use Sun.dostuff();. What you might want to do for compatability, is check if there is an object called Sun first and if there isn't use TripleNickels method, otherwise just use the Sun object directly. |
| TripleNickels:
--- Quote from: Destiny/Zack0Wack0 on July 02, 2011, 09:05:42 PM ---You'll find that a large majority (if not all) have the 'sun object' directly named Sun. So you can just use Sun.dostuff();. What you might want to do for compatability, is check if there is an object called Sun first and if there isn't use TripleNickels method, otherwise just use the Sun object directly. --- End quote --- You're thinking of Sky. Sun isn't ever named Sun as far as I've seen. |
| Navigation |
| Message Index |
| Next page |