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 → Simple Cog Syntax
Simple Cog Syntax
2003-04-22, 1:10 PM #1
I can't for the life of me figure out what I've done wrong here. Here's a part of the code.
Code:
	for(i=0; i<10; i=i+1)
	{
		if(Ghost0 < 0) return;	// return if the current ghost item is not used.
		if(Light0 > -1)
		{
			DestroyThing(Light0);
			Light0 = -1;
		}
	    FocalSector = GetThingSector(FocalObject);
	    GhostPos = GetThingPos(Ghost0);
			Light0 = CreateThingAtPos(LightObject, FocalSector, GhostPos, '0 0 0');
		SetThingFlags(Light0, 0x1);
		SetThingLight(Light0, LightVal0, 0);
		if(Light0 == -1) PrintInt(i);
	}
	Return;


The symbols are all there, but the problem lies where I assign lights 0-9 to the created thing - returns a -1, which leads me to believe I have the wrong layout for the create thing. Anyone?

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-22, 3:59 PM #2
if you think that it is a problem with the createthingatpos use

Light0 = CreateThing(LightObject, Ghost0};

i think the problem is somwhere else though prolly something with the array but i don't see anything wrong but i only glanced over it

------------------
roses are red, violets are blue, I am schizophrenic, and so am I!
roses are red, violets are blue, I am schizophrenic, and I am too!
2003-04-22, 4:06 PM #3
im not sure but i dont think you can use a return in an array.
you could try it like this to test it.
Code:
for(i=0; i<10; i=i+1)
  {
  if(Ghost0 >= 0)
    {
    //-rest of array here...
    }
  }
return;

last time i tried a return in an array it didnt work. but it may just be me.

------------------
Famous last words - "It seemed like a good idea at the time."
2003-04-22, 7:05 PM #4
I can't use just "CreateThing". The purpose was to assign a thing to a new sector without changing its position (dynamic lighting). I'm not sure about the return in an array. Everything works except for the assignment of Lights 0-9. When the "PrintInt" command executes, everything returns -1. I also tried using "stop;" instead of "return;", but it made no difference. Maybe cogflags?

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-23, 12:28 AM #5
I've got it!!!
Try CaptureThing(Light0); after each CreateThing().
That should work!

/Edward
------------------
Sometimes I ask for help.
Sometimes I give it.
Edward's Cognative Hazards
2003-04-23, 8:43 PM #6
I think capturething is used in class cogs to bind the cog to the thing, but... what the heck. I'll try anything right now.

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-24, 6:50 PM #7
Neither of those techniques worked. I should have realized CaptureThing wouldn't work since the thing wasn't being created in the first place. [http://forums.massassi.net/html/redface.gif]

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-25, 2:36 PM #8
WHY CRUEL WORLD?!?!?!?!

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-25, 3:23 PM #9
From what I can see your cog is perfect, there is not an error anywhere. Maybe if you tried posting your symbols section too we could help further, because that might be where the problem really lies.

------------------
2003-04-25, 5:14 PM #10
Code:
Thing        FocalObject                                                      
Thing        Ghost0                                                           
Thing        Ghost1                                                           
Thing        Ghost2                                                           
Thing        Ghost3                                                           
Thing        Ghost4                                                           
Thing        Ghost5                                                           
Thing        Ghost6                                                           
Thing        Ghost7                                                           
Thing        Ghost8                                                           
Thing        Ghost9                                                           
Thing        Light0                             local                         nolink
Thing        Light1                             local                         nolink
Thing        Light2                             local                         nolink
Thing        Light3                             local                         nolink
Thing        Light4                             local                         nolink
Thing        Light5                             local                         nolink
Thing        Light6                             local                         nolink
Thing        Light7                             local                         nolink
Thing        Light8                             local                         nolink
Thing        Light9                             local                         nolink
sector       FocalSector                        local                         nolink
vector       GhostPos                           local                         
Flex         LightVal0                                                        
Flex         LightVal1                                                        
Flex         LightVal2                                                        
Flex         LightVal3                                                        
Flex         LightVal4                                                        
Flex         LightVal5                                                        
Flex         LightVal6                                                        
Flex         LightVal7                                                        
Flex         LightVal8                                                        
Flex         LightVal9                                                        
Int          i                                  local                         
Template     LightObject=Ghost                                                

end


I've already tried removing "noLink" on lights 0-9, and it had no effect.

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-25, 6:06 PM #11
have you tried putting a =-1 after all those thing symbols. like this:
Code:
thing   focalobject=-1
thing   ghost0=-1
thing   ghost1=-1
...
thing   light0=-1     local nolink
thing   light1=-1     local nolink
...

even if they are going to be changed in jed.
dont know if that will make a difference but it could. one of my cogs needed it once.

------------------
Famous last words - "It seemed like a good idea at the time."
2003-04-25, 6:56 PM #12
Not sure if this will help, but I think you should take out the '0' in all of the arrays with "Light0" so that it is just "Light". Also do this for "Ghost0"

That's how I have my arrays, and they all work.

If you want I could post my version of this cog. It has the player as the focal object, but you can change that. (It's made for multiplayer to run locally on each comp.)

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-04-26, 9:26 AM #13
Light crashed my game (always does)... maybe you have a later version of JK? (like 1.02 or something like that)
The -1 thing didn't do anything, either.

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-26, 4:44 PM #14
i did some testing with a cog i made from what you gave us. this is the cog.
Code:
symbols
#-----
message   startup
message   timer
thing     focal_obj 
thing     ghost0=-1
thing     ghost1=-1
thing     ghost2=-1
thing     ghost3=-1
thing     ghost4=-1
thing     ghost5=-1
thing     ghost6=-1
thing     ghost7=-1
thing     ghost8=-1
thing     ghost9=-1
thing     light0=-1     local
thing     light1=-1     local
thing     light2=-1     local
thing     light3=-1     local
thing     light4=-1     local
thing     light5=-1     local
thing     light6=-1     local
thing     light7=-1     local
thing     light8=-1     local
thing     light9=-1     local
sector    focal_sec     local
vector    ghost_pos     local 
flex      lite_val0=0.0
flex      lite_val1=0.0
flex      lite_val2=0.0
flex      lite_val3=0.0
flex      lite_val4=0.0
flex      lite_val5=0.0
flex      lite_val6=0.0
flex      lite_val7=0.0
flex      lite_val8=0.0
flex      lite_val9=0.0
int       i=0     local 
template  light_tpl=light0.0
#-----
end
#-----
code
#-----
startup:
  SetTimer(1.0);
return;
#-----
timer:
  for(i=0; i<10; i=i+1)
    {
    if(ghost0 >= 0)
      {
      if(light0 != -1)
        {
        DestroyThing(light0);
        light0 = -1;
        }
      focal_sec = GetThingSector(focal_obj);
      ghost_pos = GetThingPos(ghost0);
      light0 = CreateThingAtPos(light_tpl, focal_sec, ghost_pos, '0 0 0');
      SetThingFlags(light0, 0x1);
      SetThingLight(light0, lite_val0, 0);
      if(light0 <= -1)
        {
        PrintInt(i);
        }
      }
    }
  SetTimer(0.5);
return;
#=====
end

when i was testing and tried to use ghost as the template (like what you have listed in your symbols) it didnt work it just did the little PrintInt thing. so at first i tried just changing the template to somthing else like one of the crate templates, and it worked. because of the sector assignment thing i couldnt see them but i could collide with them and they were putting off light. so i tried just using one of the light templates and it worked too. switching back to the ghost template it didnt work again. so from my testing it is the template you are using, try changing it and see if its the same for your cog.
hope that helps you.

------------------
Famous last words - "It seemed like a good idea at the time."
2003-04-27, 7:24 AM #15
The parts of the symbols and code sections that you posted look fine, you'll need to post the entire cog. The problem is with the arguments you're giving CreateThingAtPos(), not with your arrays or syntax.

When using arrays in your code, give a valid variable name followed by an integer enclosed by brackets. For example: varName[int]. Whatever variable name you use *must* be the same name as your first array variable in the symbols section. So if there's a '0' at the end of the name in the symbols, there must be a zero in the variable name in the code section.



------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-04-27, 11:58 AM #16
I changed the ghost template so it's based on _ghostStructure like the other ghost lights and it works now. [http://forums.massassi.net/html/biggrin.gif] Thanks sooooo much.

Does anyone want to help with my previous AiJump Post?

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music
2003-04-28, 1:36 AM #17
now that is intresting, ghosts dont work? that would explain some stuff, i wonder why......

------------------
I am pjb.
Another post......
another moment of my life wasted.....
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2003-04-28, 6:29 AM #18
I think its because with a ghost, type=ghost, where as with ghoststructure, type=cog. Coulda just changed the type, I guess. It'd probably be a good idea if I just made a new ghost (in case it messes something else in another cog). Wierd though. When I first wrote this cog using a ghost template, it worked, but when I added to it, it stopped.

------------------
May the forks be with you.
There is a great disturbance in my shorts...
Catloaf, meet mouseloaf.
My music

↑ Up to the top!