Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
1 registered members (henrybane), 1,182 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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 Offline OP
User
Tiles  Offline 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);
}
}




trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
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
A
adoado Offline

User
adoado  Offline

User
A

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.


Visit our development blog: http://yellloh.com
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 Offline OP
User
Tiles  Offline 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.


trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
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
A
adoado Offline

User
adoado  Offline

User
A

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.


Visit our development blog: http://yellloh.com
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 Offline OP
User
Tiles  Offline 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.

trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
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 Offline OP
User
Tiles  Offline 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?


trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
Re: confused about c script, lite c, wdl [Re: Tiles] #157894
10/02/07 07:26
10/02/07 07:26
Joined: Sep 2007
Posts: 658
germany
Tiles Offline OP
User
Tiles  Offline OP
User

Joined: Sep 2007
Posts: 658
germany
Got it working with function now. Phew. Stupid me. All i had to do was to change my formerly action to a function. And add the action to start the function then

A bit strange though that i need to check the keypressing twice.

Code:

function Rotate_me()
{
while (1)
{
if (key_a)
{
my.pan += 2 * time_step;
}
wait (1);
}
}

action rotate ()

{
on_a = Rotate_Me();
}




trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
Re: confused about c script, lite c, wdl [Re: Tiles] #157895
10/02/07 08:33
10/02/07 08:33
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
you don't need, because you check it also in the function + it's an endless loop so it is enough if you just call the function:

Code:
function Rotate_me()
{
while (1)
{
if (key_a)
{
my.pan += 2 * time_step;
}
wait (1);
}
}

action rotate ()
{
Rotate_Me();
}



Re: confused about c script, lite c, wdl [Re: Scorpion] #157896
10/02/07 09:50
10/02/07 09:50
Joined: Sep 2007
Posts: 658
germany
Tiles Offline OP
User
Tiles  Offline OP
User

Joined: Sep 2007
Posts: 658
germany
Thanks for that, is indeed working, but, hmm, now i am really confused. I just want to call the function when the "a" key is pressed. So that the loop doesn't run always. That's what i wanted to achieve. Else i could have left it with the first working action from above.

Any further advice?


trueSpace 7.6, A7 commercial
Free gamegraphics, freewaregames http://www.reinerstilesets.de
Die Community rund um Spiele-Toolkits http://www.clickzone.de
Re: confused about c script, lite c, wdl [Re: Tiles] #157897
10/02/07 09:56
10/02/07 09:56
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
there is nothing wrong with that, there is no better way.

i mean you call the function if 'a' is pressed, but put an endless loop into that function is a bit more senseless

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