PDA

View Full Version : Simple Cog Syntax



DogSRoOL
04-22-2003, 04:10 PM
I can't for the life of me figure out what I've done wrong here. Here's a part of the code.

for(i=0; i<10; i=i+1)
{
if(Ghost0[i] < 0) return; // return if the current ghost item is not used.
if(Light0[i] > -1)
{
DestroyThing(Light0[i]);
Light0[i] = -1;
}
FocalSector = GetThingSector(FocalObject);
GhostPos = GetThingPos(Ghost0[i]);
Light0[i] = CreateThingAtPos(LightObject, FocalSector, GhostPos, '0 0 0');
SetThingFlags(Light0[i], 0x1);
SetThingLight(Light0[i], LightVal0[i], 0);
if(Light0[i] == -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...

Han5678
04-22-2003, 06:59 PM
if you think that it is a problem with the createthingatpos use

Light0[i] = CreateThing(LightObject, Ghost0[i]};

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!

DSLS_DeathSythe
04-22-2003, 07:06 PM
im not sure but i dont think you can use a return in an array.
you could try it like this to test it.


for(i=0; i<10; i=i+1)
{
if(Ghost0[i] >= 0)
{
//-rest of array here...
}
}
return;

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

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

DogSRoOL
04-22-2003, 10:05 PM
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...

Edward
04-23-2003, 03:28 AM
I've got it!!!
Try CaptureThing(Light0[i]); after each CreateThing().
That should work!

/Edward
------------------
Sometimes I ask for help.
Sometimes I give it.

DogSRoOL
04-23-2003, 11:43 PM
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...

DogSRoOL
04-24-2003, 09:50 PM
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...

DogSRoOL
04-25-2003, 05:36 PM
WHY CRUEL WORLD?!?!?!?!

------------------
May the forks be with you.
There is a great disturbance in my shorts...

*_Seifer_*
04-25-2003, 06:23 PM
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.

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

DogSRoOL
04-25-2003, 08:14 PM
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...

DSLS_DeathSythe
04-25-2003, 09:06 PM
have you tried putting a =-1 after all those thing symbols. like this:


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.

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

SG-fan
04-25-2003, 09:56 PM
Not sure if this will help, but I think you should take out the '0' in all of the arrays with "Light0[i]" so that it is just "Light[i]". Also do this for "Ghost0[i]"

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!"

DogSRoOL
04-26-2003, 12:26 PM
Light[i] 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...

DSLS_DeathSythe
04-26-2003, 07:44 PM
i did some testing with a cog i made from what you gave us. this is the cog.


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[i] >= 0)
{
if(light0[i] != -1)
{
DestroyThing(light0[i]);
light0[i] = -1;
}
focal_sec = GetThingSector(focal_obj);
ghost_pos = GetThingPos(ghost0[i]);
light0[i] = CreateThingAtPos(light_tpl, focal_sec, ghost_pos, '0 0 0');
SetThingFlags(light0[i], 0x1);
SetThingLight(light0[i], lite_val0[i], 0);
if(light0[i] <= -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.

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

SaberMaster
04-27-2003, 10:24 AM
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 (http://www.geocities.com/sabersdomain/fileframe.html), Parsec (http://www.geocities.com/sabersdomain/fileframe.html), Scribe (http://www.geocities.com/sabersdomain/fileframe.html), and the EditPlus Cog Files (http://www.geocities.com/sabersdomain/fileframe.html).

DogSRoOL
04-27-2003, 02:58 PM
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 (http://forums.massassi.net/html/Forum4/HTML/003700.html)?

------------------
May the forks be with you.
There is a great disturbance in my shorts...

[SF]pjb
04-28-2003, 04:36 AM
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.....

DogSRoOL
04-28-2003, 09:29 AM
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...