0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
how to use other .c files
#432895
11/18/13 20:44
11/18/13 20:44
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 100
|
So I am trying to write several scripts and I need Encounters.c to be used in Main.c but it won't recognize the functions from it. Am I supposed to only use one script for everything or can I do this??? Thanks
boolean my.awesomeness = so true;
|
|
|
Re: how to use other .c files
[Re: Quad]
#432897
11/18/13 20:48
11/18/13 20:48
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 100
|
is there anything else I should know about doing this? I tried that and it won't work.
boolean my.awesomeness = so true;
|
|
|
Re: how to use other .c files
[Re: Dega]
#432898
11/18/13 21:11
11/18/13 21:11
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 100
|
Okay I got it to work but now every time Encounters.c does anything in the game it gets an error saying "Error:E1513" and says it crashed. Can you tell me anything about that?
boolean my.awesomeness = so true;
|
|
|
Re: how to use other .c files
[Re: Dega]
#432899
11/18/13 21:14
11/18/13 21:14
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
There are probably like a hundred things you need to know about that. "it won't work" simply means nothing, there can be truck load of reasons for that and i can't guess which one. What error you actually get? For starters: - Included file needs to be on the same directory as your main file, otherwise you need to use relative path. like #include "scripts/someFile.c"
- You should include your file at the beginning of your main.c, not in the middle of some code.
- You need to make sure you do not include same files twice or take proper measures to not break anything in case you need to do that.
- In lite-c/acknex environment, if you do not have any #includes default.c and acknex.h are automatically included for you. acknex.h is mandatory for engine to work. So if you have any self-included files you need to include acknex.h manually probably before ALL of your custom includes.
3333333333
|
|
|
Re: how to use other .c files
[Re: Quad]
#432900
11/18/13 21:15
11/18/13 21:15
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
For your second message you need to post your project and/or script files.
3333333333
|
|
|
Re: how to use other .c files
[Re: Quad]
#432901
11/18/13 21:27
11/18/13 21:27
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 100
|
Okay I got the code working without the error but I had to erase all the code in the Encounter.c function. It seems I need to learn how to make code work in other files. Any tutorials with included .c files I could take a look at?
boolean my.awesomeness = so true;
|
|
|
Re: how to use other .c files
[Re: Dega]
#432903
11/18/13 22:30
11/18/13 22:30
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
You really don't need a tutorial for that. It's easy as pie. Just imagine that when you write " include "sample.c" this will place the contents of sample.c exactly where you have the include.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: how to use other .c files
[Re: Uhrwerk]
#432932
11/19/13 16:39
11/19/13 16:39
|
Joined: Dec 2010
Posts: 100
Dega
OP
Member
|
OP
Member
Joined: Dec 2010
Posts: 100
|
For some reason when I put this in a void it gets an error e1513 which says I am referencing something that isn't there.
void goto_encounter() {
//put player in the encounter room
player.x = 0;
player.y = 0;
player.z = -300;
}
boolean my.awesomeness = so true;
|
|
|
Re: how to use other .c files
[Re: Dega]
#432939
11/19/13 19:34
11/19/13 19:34
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Please describe your problem in more detail. What do you mean by "when I put this in a void"? The following code compiles perfectly fine:
#include <acknex.h>
void goto_encounter()
{
//put player in the encounter room
player.x = 0;
player.y = 0;
player.z = -300;
}
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|