The cog's purpose and function is explained in the description. If you've followed the 'is this possible?' thread, this may look familiar. Frankly, this just doesn't seem to work. It checks out with parSec, and the errors are probably quite obvious, but the painter has trouble seeing fault in his art.
Code:
# skyuniversal.cog
# v. 1.0
# This cog dynamically changes every surface flagged as 'sky' (0x200) in the level
# on a user-defined interval, simulating the passing of a day. This cog should also
# be coupled with a user-designed dispatcher cog which can then implement other changes
# throughout the level based on the time of day.
#
# [Grismath]
#======================================================================================#
symbols
message startup
message pulse
flex timeint // Duration of each time period (pulse length)
int period=1 local // Current time period (dawn, day, etc.)
material dawn
material day
material late
material dusk
material night
int X=0 local
cog dispatcher // Level-custom dispatching cog
end
#======================================================================================#
code
#--------------------------------------------------------
startup:
Sleep(0.5);
SetPulse(timeint);
return;
#--------------------------------------------------------
pulse:
for(X=0; X<=GetSurfaceCount(); X=X+1) {
if(GetSurfaceFlags(X) == 0x200) {
if(period==1) {
SetSurfaceMat(X, dawn);
}
if(period==2) {
SetSurfaceMat(X, day);
}
if(period==3) {
SetSurfaceMat(X, late);
}
if(period==4) {
SetSurfaceMat(X, dusk);
}
if(period==5) {
SetSurfaceMat(X, night);
}}}
if(period==1) SendMessage(dispatcher, user1);
if(period==2) SendMessage(dispatcher, user2);
if(period==3) SendMessage(dispatcher, user3);
if(period==4) SendMessage(dispatcher, user4);
if(period==5) SendMessage(dispatcher, user5);
if(period==5) period=0;
period=period+1;
return;
#--------------------------------------------------------
end
) I don't know whats wrong with your's Grismath, I don't know. ![http://forums.massassi.net/html/confused.gif [http://forums.massassi.net/html/confused.gif]](http://forums.massassi.net/html/confused.gif)

![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)
) to utilise this funtion. It's a lot more efficient, especially on the potential scale of this cog.