Page 1 of 1
How much of C is there?
Posted:
Fri Apr 27, 2012 12:38 pm
by digiot
Hello !
I read at some places,that not all of C is implemented in the
GE-codeeditor.
Can anyone tell me,what C-constructs and behaviours exactly won't
work?
Greetings!
digiot
Re: How much of C is there?
Posted:
Fri Apr 27, 2012 1:46 pm
by skydereign
You can't import libraries (unless you don't plan to export, but you still need to copy it over to your game directory) which means no importing linked lists and similar (unless you convert it). There are actually a lot of things from some of the math, string, and standard libraries that you can't do, so it is easier to explain what you can do. Almost all C functions that are implemented can be found here.
http://game-editor.com/docs/script_reference.htmThere are one or two that are missing from that list, and from my experience the memcpy doesn't actually work like memcpy does in C.
Re: How much of C is there?
Posted:
Sat Apr 28, 2012 3:20 am
by digiot
Maybe,I'm not using the right term for what I mean.
As a C-novice,I will only use standart/simple "constructs",
as there are:
- Pre-compiler directives
Have I understand you right,that I can't use "#include <stdio.h>",and such?
- What's about the scope of variables?Can I use extern,global,local?
- Can I use auto,static,register?
I know,that the variables are automatically declared,depending from there I
do this.But the main-function is the highest level?So I can't declare real
global ones?Only the GE-inbuild ones are globals?
I read,that it's recommended,to use the editors menus,to create new variables.
Or is it more a strictly must?
- New functions I have to declare/define in main?So the whole code is the
main-function?
The more I dive into C and GE,the more I get confused!
My problem is to know,if I did a mistake,or the code I created can't work
in GE.
Greetings!
puzzled digiot
Re: How much of C is there?
Posted:
Sat Apr 28, 2012 3:40 am
by skydereign
Ok, your mistake is comparing the two. gE uses parts of C, it is by no means actually C. There is no such thing as main, that is already handled. There are no #includes (since when you export it doesn't carry over), and that means scope of variables is strictly global (or in the case of an actor variable, just another variable in the Actor struct). Why would you want to use auto? Events are kind of like functions in terms of scope, so there isn't really ever a need to use extern (with the subset of C that gE uses, such things aren't necessary or even suggested). You can however use register, if you really wanted. But you mention you are a C novice, so if that is true at least half of this stuff should just be foreign to you. Variables can be declared in two ways. Either in a script (global code or an event script) or via the gui method provided by gE. Those are the only ways of creating variables.
So, from your response it sounds more like you are asking questions about C, since there is no main in gE. The equivalent is the game loop, but since we can't actually see that, you really shouldn't think about it that way. Knowing how C works will benefit you when making games in gE, but trying to connect the two can serve to confuse you even more.
Re: How much of C is there?
Posted:
Sat Apr 28, 2012 5:25 am
by digiot
I think,I got it!
You are absolutely right,I was misled by statements like "using C"!
It had to be stated clearly,that you don't use really C,but only the
code looks like.Other people might run away,if they think they have to
use C.
So I can put my spot on the game-concept(nearly complete),and creating
the graphics,thats fine!
But one point is left for me:Can I use user defined functions?
Thank you for your quick responses!
digiot
Re: How much of C is there?
Posted:
Sat Apr 28, 2012 5:30 am
by skydereign
I know I've been saying it isn't C, but it is a close enough simulacrum to call it C. It uses C, the compiler treats it as such, but gE isn't what you would call a normal programming environment. That is where the differences between C and gE's C lie. There are a lot of things missing that you would use in a full C environment, but the scripting language is still C (syntax/grammer/everything).
Re: How much of C is there?
Posted:
Sat Apr 28, 2012 2:30 pm
by digiot
Ok,ok,it's fine as it is!
But what's about the user defined functions,at least?
Greetings!
digiot
Re: How much of C is there?
Posted:
Sat Apr 28, 2012 3:51 pm
by skydereign
Write those in global code. You can declare functions and variables there. All you need to remember to do is give the global code script a name, and add it.
Re: How much of C is there?
Posted:
Sat Apr 28, 2012 6:51 pm
by digiot
Thank you for your kind instructions!They will save me a lot of time
and should allow me a good starting.
1 up for you!
Greetings!
digiot