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

Discuss any other topics here
Post Reply
Matte
Posts: 321
Joined: Fri Oct 19, 2007 7:49 pm

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

Post 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; 
}
////////////////////////////////////////////////////////////////////
Attachments
wrongscript.JPG
Script
(60.72 KiB) Downloaded 5 times
Last edited by Matte on Wed May 21, 2008 7:34 am, edited 1 time in total.
Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

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

Post 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.
User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

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

Post 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?
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack
Matte
Posts: 321
Joined: Fri Oct 19, 2007 7:49 pm

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

Post 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!
Matte
Posts: 321
Joined: Fri Oct 19, 2007 7:49 pm

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

Post 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 ().
Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

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

Post 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.
Matte
Posts: 321
Joined: Fri Oct 19, 2007 7:49 pm

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

Post 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
User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

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

Post 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++
Lithuanians for Georgia!
User avatar
hgt_terry
RF Dev Team
Posts: 167
Joined: Sun Feb 24, 2008 12:20 am
Location: England

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

Post 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
User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

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

Post 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.)
Allanon
Posts: 493
Joined: Mon Aug 29, 2005 8:23 am

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

Post by Allanon »

Lite-C is the scripting language for the Game Studio engine so he might be stuck using it.
Matte
Posts: 321
Joined: Fri Oct 19, 2007 7:49 pm

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

Post by Matte »

Thanks for the replies everyone
Post Reply