Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,393 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
how to use other .c files #432895
11/18/13 20:44
11/18/13 20:44
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

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: Dega] #432896
11/18/13 20:45
11/18/13 20:45
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
#include "Encounters.c"


3333333333
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
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

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
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

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 Offline
Senior Expert
Quad  Offline
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 Offline
Senior Expert
Quad  Offline
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
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

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 Offline
Expert
Uhrwerk  Offline
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
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

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.

Code:
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 Offline
Expert
Uhrwerk  Offline
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:
Code:
#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...
Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1