E1513: crash in def_console

Posted By: ngisiger

E1513: crash in def_console - 11/23/08 00:42

Hello All.

I have a problem with local variables, it appears. I encountered it while programming a level, and have narrowed the problem to the following very small piece of code. This is my script (in lite-C):

----------------------------------------------
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

function main()
{
video_switch(7,0,1);
wait(3);
level_load("probleme2.WMB");
wait(2);
}


action a_object()
{
VECTOR* distance = {x=0;y=0;z=0;}
}
-------------------------------------------------

Whenever I attach this script to a level (even if it does not contain an entity), and I press "tab" to see the console, the message "Error 1513: Crash in def_console" appears instead. And if I add other pieces of code afterwards, then it does funny stuff or does not work at all.

Does anybody have a clue what is wrong here? I'm sure it's very obvious, but I have no clue what it is is. Aren't we allowed to define vectors as local variables?

Thanks a lot for any help.

Thomas

PS: I am using A7.5 Pro running on Athlon dual core, WinXP Pro, and 1 Gig of RAM.
Posted By: Ottawa

Re: E1513: crash in def_console - 11/25/08 23:35

Hi!

Why are you defining a vector inside the Action?
VECTOR* distance = {x=0;y=0;z=0;}

Did you try placing this line outside the Action?

Ottawa smile
Posted By: heinekenbottle

Re: E1513: crash in def_console - 11/26/08 00:28

Originally Posted By: Ottawa
Hi!

Why are you defining a vector inside the Action?
VECTOR* distance = {x=0;y=0;z=0;}

Did you try placing this line outside the Action?

Ottawa smile


local vectors are legal.


@ngisiger: Are you sure you need a vector pointer? Try removing the star.

Posted By: ngisiger

Re: E1513: crash in def_console - 11/27/08 00:30

Hello Ottawa and Heinekenbottle.

Thank you very much for both your replies.

@Ottawa: you're right - when I place the exact same definition outside the action, then it works perfectly. That's what I ended up doing (although I like using local variables to make my actions more portable).

@Heinekenbottle: you're right also - if I remove the "*" as you suggest, then the local vector definition seems to work.

I'll admit to being a bit confused as to how we are supposed to define vectors in lite-C:

VECTOR v = {x=0;y=0;z=0;}

or

VECTOR* v = {x=0;y=0;z=0;}

It seems one works for local variables, and the other for global variables. I find the manual could be a little clearer on that point.

Thanks again!

Thomas
Posted By: Ottawa

Re: E1513: crash in def_console - 11/28/08 00:52

Hi! smile

I've looked at the manual and found the answer
to this situation under

beginner's mistakes

Mistake 4: Using pointers the wrong way

Good reading smile

Ottawa
Posted By: ngisiger

Re: E1513: crash in def_console - 12/06/08 16:34

Hi again.

Thanks! That Figures (I AM a beginner in lite-C). smile

Despite my beginner difficulties, I already find lite-C a HUGE improvement over wdl. I am working on scripts which move around a large number of entities. In wdl, we had to use handles for pointers to access entities. I was simply getting lost in the code.

Now, I simply create structures such as the following

typedef struc{
var x;
var y;
var z;
var pan;
var tilt;
var roll;
ENTITY* ent;
} bit

bit stuff[100];

With this, accessing, moving and orienting whole sets of entities is completely straightfoward.

Thanks again, Ottawa (I guess I should call myself Montreal - that's where I live) laugh

Thomas
Posted By: Ottawa

Re: E1513: crash in def_console - 12/08/08 00:14

Hi Tomas! smile

It just happened that the information was in that section.

We all have our troubles accesing and learning new things.

Salut de Michel smile
© 2023 lite-C Forums