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 )
////////////////////////////////////////////////////////////////////
#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;
}
////////////////////////////////////////////////////////////////////
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
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:
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.
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:
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.
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++
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.
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.)