Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → SkyUniversal problems
SkyUniversal problems
2002-08-23, 7:44 AM #1
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
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 9:05 AM #2
This is a quick cog I did to test if sky mat changing is possible.
Code:
# Jedi Knight Cog Script
#
# sky_changer.cog
#
# Quick sky changing cog
#
# [DP]
#

symbols
message         pulse
message         startup
surface         side
surface         side1
surface         side2
surface         side3
surface         side4
surface         side5
material        sky
material        sky1
int             i                                         local
int             j=0                                       local

end

code

startup:
   SetPulse(5);
   Return;

pulse:
   j = 1 - j;
   For(i=0; i<=5; i=i+1)
   {
      SetSurfaceMat(side, sky[j]);
   }
   Return;

end
It works just fine. So with my first cog, it must have been the coding. (that was back when I didn't know cogwriter or Parsec existed [http://forums.massassi.net/html/redface.gif] ) I don't know whats wrong with your's Grismath, I don't know. [http://forums.massassi.net/html/confused.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

[This message has been edited by Descent_pilot (edited August 23, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-23, 9:37 AM #3
...that's for simple material changing.

My cog checks to see whether or not a surface is flagged as 0x200 (sky) and runs thru every surface in the level.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 10:02 AM #4
Your not defining the mats in symbols... you need to do it like.

material mat1=dflt.mat local

and usually this:

if(GetSurfaceFlags(X) == 0x200)


is written as


if(GetSurfaceFlags(X) & 0x200)




[This message has been edited by The_New_Guy (edited August 23, 2002).]
- Wisdom is 99% experience, 1% knowledge. -
2002-08-23, 10:14 AM #5
No, you dont have to make them local. I did a few of these types of cogs, back when I first started cogging. I never made the materials local, and they worked.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-08-23, 10:44 AM #6
Quote:
<font face="Verdana, Arial" size="2">Originally posted by GBK:
No, you dont have to make them local. I did a few of these types of cogs, back when I first started cogging. I never made the materials local, and they worked.

</font>



My point wasnt if they were local or not, my point was he hasnt defined which mat
he's changing the surfaces too.


Ignore the local. This is taken from DATAMASTER:

--------------------------------------------
The material symbol type is used to store a reference to a mat file.

Syntax:

material mat1 local

And to assign a mat file directly to the variable, use:

material mat1=dflt.mat local

--------------------------------------------

Its possible he purposely omitted defining them, but when you define a variable like:

material dawn

its purpose is so later in the cog you can do something like this:

dawn = GetSurfaceMat(X);

The Jedi Knight engine is not smart enough to realize dawn = dawn.mat. It must be defined.

- Wisdom is 99% experience, 1% knowledge. -
2002-08-23, 11:12 AM #7
Dude... you can define them in JED.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 11:24 AM #8
The new guy could be right on the flags part, you might have to use 'If(BitTest(GetSurfaceFlags(X), 512))' Give that a try. [http://forums.massassi.net/html/wink.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-23, 11:34 AM #9
Oi, BitTest, I'll try it.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 4:17 PM #10
Umm, as a level cogger, I always assume a cog is going to be used in JED. Defining those materials in JED is a piece of cake, reguardless of what the Datamaster says.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-08-23, 4:23 PM #11
New Guy is right about the flags. And both BitTest() and the ampersand operator return a number with only the bits that both input numbers had. For example, (0x5 & 0x4) returns 0x4.

Code:
X<=GetSurfaceCount()


That condition is wrong. You should use the '<' operator there. Remember that designations start at 0 while counts start at 1.

You could have period start at 0 and use something like SetSurfaceMat(x, dawn[period]);. And the same for the SendMessage()'s. That would clean up the code some.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 24, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-23, 4:32 PM #12
As for the DataMaster's example, it's only an example showing how to define materials. It doesn't mean that you have to make it local or that you have to define the material in the cog. As the Symbol Type's notes say:

Quote:
<font face="Verdana, Arial" size="2">The examples for the symbol types in this section have the "local" extension. This is only to show that the symbol accepts an extension. No symbol type has to have one.</font>


------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-27, 3:07 AM #13
Sorry to revive a dead topic but I finally got it to work. ;]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-27, 4:47 AM #14
Great. [http://forums.massassi.net/html/wink.gif]

Too many people leave a thread before saying whether or not their problem was resolved. And that leaves us moderators to wonder. So I don't mind your taking a thread from the morgue to follow up your problem.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-27, 4:06 PM #15
You might want to create a variant of the wthr cogs (or I'll do it [http://forums.massassi.net/html/tongue.gif]) to utilise this funtion. It's a lot more efficient, especially on the potential scale of this cog.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.

↑ Up to the top!