Page 1 of 1

Anyone knows something about C/C++/Lite-C?

Posted: Tue May 20, 2008 5:39 pm
by Matte
I just started with Lite-C (a simplified version of C), and I wanted to create a script with some stuff I already learned.
So I started creating a script, but apparently, there is a problem in it. Could anyone tell me what the problem is? This is the script (colored version in the attachment :P)

Code: Select all

////////////////////////////////////////////////////////////////////
#include <acknex.h> 
#include <default.c>
////////////////////////////////////////////////////////////////////
var txt = 0
STRING* text_str = "You are stupid!"; //Apparently there is something wrong here
STRING* no_str = "You are very stupid!";
////////////////////////////////////////////////////////////////////
TEXT* bold_txt =
{
	pos_x = 300;
	pos_y = 230;
	flags = visible;
}
////////////////////////////////////////////////////////////////////
function_ifbold
{ if (var txt = 0)
(bold_txt.pstring)[0] = text_str; //I want the program to display text_str if var is 0
else
(bold_txt.pstring)[0] = no_str; //I want the program to display no_str if var is not 0
}
button (200, 100, quitnormal_pcx, quitover_pcx, quitclicked_pcx, function_ifbold, NULL, NULL);
////////////////////////////////////////////////////////////////////
function main()
{
       video_mode = 7; 
    screen_color.blue = 1; 
}
////////////////////////////////////////////////////////////////////

Re: Anyone knows something about C/C++/Lite-C?

Posted: Tue May 20, 2008 10:26 pm
by Allanon
Never worked with Lite-C but shouldn't there be a semicolon after var txt = 0?

Also, in C/C++ you would need parentheses after a function name so should there be parentheses after function_ifbold?

Or should function_ifbold actually be function ifbold()? Note that I replaced the underscore character with a space and added parentheses.

Re: Anyone knows something about C/C++/Lite-C?

Posted: Wed May 21, 2008 1:09 am
by jonas
Oh wow... I'm sure glad I never attempted to learn Lite-C that looks...very un-normal.

Code: Select all

TEXT* bold_txt =
{
   pos_x = 300;
   pos_y = 230;
   flags = visible;
}
I'm assuming its creating a new TEXT? But then with in { } 's? Something about that just looks wrong... Or is this the way Lite-C works?

Re: Anyone knows something about C/C++/Lite-C?

Posted: Wed May 21, 2008 7:31 am
by Matte
jonas wrote:Oh wow... I'm sure glad I never attempted to learn Lite-C that looks...very un-normal.

Code: Select all

TEXT* bold_txt =
{
   pos_x = 300;
   pos_y = 230;
   flags = visible;
}
I'm assuming its creating a new TEXT? But then with in { } 's? Something about that just looks wrong... Or is this the way Lite-C works?
It's the way it works. Lite-C is something in between a scripting language and programming languages.
Allanon wrote:Never worked with Lite-C but shouldn't there be a semicolon after var txt = 0?

Also, in C/C++ you would need parentheses after a function name so should there be parentheses after function_ifbold?

Or should function_ifbold actually be function ifbold()? Note that I replaced the underscore character with a space and added parentheses.
Thank you very much! Indeed, there should be a semicolon after var and parentheses after the function.
So thx!

Re: Anyone knows something about C/C++/Lite-C?

Posted: Wed May 21, 2008 6:20 pm
by Matte
After editing, there appears to be another fault in the code.

Code: Select all

////////////////////////////////////////////////////////////////////
#include <acknex.h> 
#include <default.c>
////////////////////////////////////////////////////////////////////
var txt = 0;
STRING* text_str = "You are stupid!"; 
STRING* no_str = "You are very stupid!";
////////////////////////////////////////////////////////////////////
TEXT* bold_txt =
{
   pos_x = 300;
   pos_y = 230;
   flags = visible;
}
////////////////////////////////////////////////////////////////////
function_ifbold ()
{ if (var txt = 0)
(bold_txt.pstring)[0] = text_str; //I want the program to display text_str if var is 0
else
(bold_txt.pstring)[0] = no_str; //I want the program to display no_str if var is not 0
}
button (200, 100, quitnormal_pcx, quitover_pcx, quitclicked_pcx, function_ifbold, NULL, NULL);
////////////////////////////////////////////////////////////////////
function main()
{
       video_mode = 7; 
    screen_color.blue = 1; 
}
////////////////////////////////////////////////////////////////////
The problem is somewhere with the function ifbold. It doesn't work with function_ifbold(), it also doesn't work with function_ifbold ().

Re: Anyone knows something about C/C++/Lite-C?

Posted: Thu May 22, 2008 12:44 am
by Allanon
I was curious so I investigated Lite-C and found that it is the scripting language for the Game Studio engine. I downloaded and looked at the example scripts and found that there is a lot wrong with your code.

First, make visible capital letters like this: flags = VISIBLE;

And the ifbold function should probably look like this:

Code: Select all

function ifbold()
{
    if (txt == 0)
        str_cpy((bold_txt.pstring)[0], text_str);
    else
        str_cpy((bold_txt.pstring)[0], no_str);
}
Also the button function looks out of place because it doesn't seem to be defined and it is not being called from within a function or the main function. But if this is some weird scripting call then the ifbold function should be defined like this in this function:
button (200, 100, quitnormal_pcx, quitover_pcx, quitclicked_pcx, ifbold, NULL, NULL);

NOTE: I didn't test the changes I suggested so they could be incorrect also there might be more errors that I missed.

Re: Anyone knows something about C/C++/Lite-C?

Posted: Thu May 22, 2008 5:19 pm
by Matte
Allanon wrote:I was curious so I investigated Lite-C and found that it is the scripting language for the Game Studio engine. I downloaded and looked at the example scripts and found that there is a lot wrong with your code.

First, make visible capital letters like this: flags = VISIBLE;

And the ifbold function should probably look like this:

Code: Select all

function ifbold()
{
    if (txt == 0)
        str_cpy((bold_txt.pstring)[0], text_str);
    else
        str_cpy((bold_txt.pstring)[0], no_str);
}
Also the button function looks out of place because it doesn't seem to be defined and it is not being called from within a function or the main function. But if this is some weird scripting call then the ifbold function should be defined like this in this function:
button (200, 100, quitnormal_pcx, quitover_pcx, quitclicked_pcx, ifbold, NULL, NULL);

NOTE: I didn't test the changes I suggested so they could be incorrect also there might be more errors that I missed.
TY

Re: Anyone knows something about C/C++/Lite-C?

Posted: Sat Jun 07, 2008 3:47 pm
by LtForce
If you'd ask me, I'd tell you to throw that Lite-C to a trash can where it belongs and start learning regular C++, because that Lite-C is a mix of C++ and pascal and it looks odd. It'll be hard for you to start using C++

Re: Anyone knows something about C/C++/Lite-C?

Posted: Sat Jun 07, 2008 7:54 pm
by hgt_terry
I Agree you might as well start learning C++ its hard to go from pascal or C_Lite to C++ the others allow you to get away with some stuff formating ext but when you do go to C++ its like learning all over again.

C++ may seem hard at first but is a lot better to do it now rather than train you brain with somthing the move up which will take a lot longer.

You will thank us in time to come.

Terry

Re: Anyone knows something about C/C++/Lite-C?

Posted: Sun Jun 08, 2008 3:53 am
by AndyCR
I used Lite-C's predecessor, C-Script, for many years. If it's anything like it's parent I would suggest you save your sanity by switching to a decent language, or at the very least one that works. (Try parsing a decently complex text file like XML in it and see how far you get with language structure and even bugs in the language's file I/O functions.)

Re: Anyone knows something about C/C++/Lite-C?

Posted: Sun Jun 08, 2008 8:06 am
by Allanon
Lite-C is the scripting language for the Game Studio engine so he might be stuck using it.

Re: Anyone knows something about C/C++/Lite-C?

Posted: Thu Jun 12, 2008 1:28 pm
by Matte
Thanks for the replies everyone