Awesome! I just tested the printf() thing, and it works! It even created the entity I wanted. I'll need to resize it in MED, though, as it's a little too big.
EDIT: ok, I have a problem. I have set up a test function for using mag_create:
Code:
void mag_toggle()
{
while(1)
{
switch(key_lastpressed)
{
case 25:
mag_create("posmagnet.mdl","negmagnet.mdl",curpos,POSITIVE);
case 49:
mag_create("posmagnet.mdl","negmagnet.mdl",curpos,NEGATIVE);
}
wait(1);
}
}
The thing is, when I press P or N (that's the keys the scancodes correspond to), it creates
tons of little magnet models (they don't attract/repel each other yet, the math for the actual behavior hasn't been worked out, but I have an idea). maybe this has to do with the fact that I'm using a while loop?
I've also modified the mag_create function a little, too, but it shouldn't be of any real consequence:
Code:
I had remembered that the STRING* I had set up as a parameter wasn't being used, so
I've created an additional one for a secondary model (the negative magnet), and I've
incorporated the STRING*s in the ent_create functions within mag_create:
MAGNET* mag_create(STRING* filename1,STRING* filename2,VECTOR* pos,int pole)
{
MAGNET* tmp= malloc(sizeof(MAGNET));
tmp->pole= pole;
switch(pole)
{
case POSITIVE:
{
ENTITY* ent_post= ent_create(filename1,curpos,phys_objsphere);
tmp->entity= ent_post;
}
case NEGATIVE:
{
ENTITY* ent_negt= ent_create(filename2,curpos,phys_objsphere);
tmp->entity= ent_negt;
}
}
return tmp;
}
(btw, removing the while loop makes it not work.)