1 registered members (henrybane),
1,182
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
confused about c script, lite c, wdl
#157888
09/30/07 12:15
09/30/07 12:15
|
Joined: Sep 2007
Posts: 658 germany
Tiles
OP
User
|
OP
User
Joined: Sep 2007
Posts: 658
germany
|
I know nothing about programming. Am at fighting my way through the lite C tutorial to change this. Haven't understood this much til now though to be honest. This language seems to be a nightmare to me. Nothing is really logical yet. Just everything made of special cases. One of my biggest trouble is what the 3d GS engine uses with which ending. This one is code from the Lite C tutorial. And so it should be Lite C code. It rotates an object: Code:
action rotate_plane() { while (1) { my.pan = my.pan + 2 * time_step; wait (1); } }
But just when i save it as WDL. Then it works perfect. Saving it as *.c and including it into my mainscript gives me errors though. And the level won't start. Why? It is Lite C code Well, no problem up to this point. Just save it as *.wdl and everything is good. But what i wanted to do is to rotate an object while pressing a key. And now i am lost. Because the Lite C code from the tutorial spits out syntax errors about missing semicolon when trying to adopt it to this case : Code:
action rotate_plane() { while (1) { if (key_a) my.pan += my.pan + 2 * time_step; wait (1); } }
|
|
|
Re: confused about c script, lite c, wdl
[Re: Tiles]
#157889
09/30/07 12:49
09/30/07 12:49
|
Joined: Jul 2006
Posts: 503 Australia
adoado
User
|
User
Joined: Jul 2006
Posts: 503
Australia
|
First of all, if you are new here, Welcome! Its funny you say that you think programming is not logical. That is what programming is - logical. In fact, thats why most errors occur during runtime, because the engine is doing exactly as you have told it to do, you may have just told it the wrong thing. The reason that the "rotate while pressing a key" did not work is because of several reasons You have a conditional statement in their "if (key_a).." but after this you must place some curly brackets to state exactly what to do if that condition is met. It must be: Code:
if (key_a) { my.pan += 2 * time_step; } wait (1);
Also, having "my.pan += my.pan .." is pointless. the "+=" combination already adds whats on the right, to whats on the left. So my.pan += my.pan + 2 * time_step; should be, my.pan += 2 * time_step; OR my.pan = my.pan + 2 * time_step; Hope it helps, Adoado.
|
|
|
Re: confused about c script, lite c, wdl
[Re: adoado]
#157890
09/30/07 16:49
09/30/07 16:49
|
Joined: Sep 2007
Posts: 658 germany
Tiles
OP
User
|
OP
User
Joined: Sep 2007
Posts: 658
germany
|
Thanks for the warm welcome. I am indeed completely new to 3D Gamestudio. Not to gamemaking though. I just haven't used a language yet, and also not in 3D. And so what once was one mouseclick becomes a programing task that eats days and weeks from what i can see. Oops, that "+" which is too much ... . Wasn't there when i tinkered around with the problem. Seems that it came in when i copy n pasted all the code around to post it here, sorry Your advice is very useful. Now i see where i thought wrong. And it starts to make sense now. The brackets are the signs to say "then". That was the bit i was missing. This code is my first working code now. Thank you for that Code:
action rotate_plane() { while (1) { if (key_a) { my.pan += 2 * time_step; } wait (1); } }
Something to optimize here? Okay, that was the one part. But what about my other question. Lite C code in an WDL file? Does WDL decide by itself if it is Lite C or C script? When do i / can i / must i save as WDL, when as C? Because a *.c file cannot provide an action that shows up in the WED from what my experiments has shown me.
|
|
|
Re: confused about c script, lite c, wdl
[Re: Tiles]
#157891
10/01/07 05:05
10/01/07 05:05
|
Joined: Jul 2006
Posts: 503 Australia
adoado
User
|
User
Joined: Jul 2006
Posts: 503
Australia
|
Glad to hear it works Yes, basically the brackets determine what "block" of code must be done when something else is done. Basically, all the definitions (text, panel, material, action, etc.) all start and end with curly bracket pairs, as well as functions, "if", "else" and "while". An optimization? I am not sure. Rather than continuously looping - while(1), maybe have the function occur by saying (although it may have to be written differently to get the same effect): Code:
Function Rotate_Me() { //Rotation here } .. on_a = Rotate_Me();
I have not had much experience with Lite-C, but I think WDL files are C-script only. File ending in .c are Lite-C files. To make a lite-C file. Go to SED, and save it as a file with the .c extension - then go into WED and go to File >> Map Properties >> Add Map and choose the .c file. As I said, I have not had much experience from Lite-C. Hope it helps Adoado.
|
|
|
Re: confused about c script, lite c, wdl
[Re: adoado]
#157892
10/01/07 06:56
10/01/07 06:56
|
Joined: Sep 2007
Posts: 658 germany
Tiles
OP
User
|
OP
User
Joined: Sep 2007
Posts: 658
germany
|
Thank you very much. That enlightens me a lot. Makes sense to run the code only when key is pressed The Lite C versus C Script problem remains though. No way to add C scripts under map properties. Here i define my main file. Same code saved as *.c and included in my mainscript doesn't give me back the action. It doesn't appear. Makes it even sense to use Lite C? Must i learn the older C Script?
Last edited by Tiles; 10/01/07 07:11.
|
|
|
Re: confused about c script, lite c, wdl
[Re: Tiles]
#157893
10/01/07 12:22
10/01/07 12:22
|
Joined: Sep 2007
Posts: 658 germany
Tiles
OP
User
|
OP
User
Joined: Sep 2007
Posts: 658
germany
|
Cannot get it to work with the function Code:
Function Rotate_Me()
{ my.pan += 2 * time_step; wait (1); } action rotate ()
{ on_a = Rotate_Me(); } Every other combinations that i have tested leaded from easy "last line wrong" messages up to abnormal program terminations. This one at least does nothing The more i try to dive into the language problem the more respect i have from you people out there that are manage to even make games with it. One's for sure. This is something to become mad at it. Even the simplest basics needs days and weeks to find out how it is meant to work, not even being sure about the language in use. Is this Lite C, C Script? WDL?
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|