Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,008 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Lite-C Workshops function compute_days() #210699
06/12/08 11:51
06/12/08 11:51
Joined: Jul 2006
Posts: 76
uk london
F
FireArm Offline OP
Junior Member
FireArm  Offline OP
Junior Member
F

Joined: Jul 2006
Posts: 76
uk london
Hi im finally getting around to learning script with Lite-C Workshops ,but i got a small problem already.

im on Workshop 03: Functions.
And every time i try to run my code it dont ,and i cant see a problem with it?.
i got to the part which my code is

////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
var my_age = 19;
var days_a_year = 365;
var number_of_days; // we need to calculate this value
////////////////////////////////////////////////////////////////////
PANEL* pDisplay =
{
digits (10, 10, 5, *, 1, number_of_days);
flags = VISIBLE;
}
////////////////////////////////////////////////////////////////////
function main()
{
screen_color.blue = 150;
compute_days();
}
////////////////////////////////////////////////////////////////////
function compute_days()
{
number_of_days = my_age * days_a_year;
}
////////////////////////////////////////////////////////////////////


But every time i try to run it i get a error that says

Error im 'MAIN' line 17: 'compute_days' undeclared identifier

< compute_days();>
.Can't compile SCRIPT03.C

Please Help.

Re: Lite-C Workshops function compute_days() [Re: FireArm] #210719
06/12/08 13:30
06/12/08 13:30
Joined: Sep 2005
Posts: 274
Switzerland - Zurich
zwecklos Offline
Member
zwecklos  Offline
Member

Joined: Sep 2005
Posts: 274
Switzerland - Zurich
Hi there,
you have to put your function above the main function.
the enginge reads your script from the top till downside.
like reading a book.

...
..
.
///////////////////////////////////////////////////////////////
function compute_days()
{
number_of_days = my_age * days_a_year;
}
///////////////////////////////////////////////////////////////
function main()
{
screen_color.blue = 150;
compute_days();
}
///////////////////////////////////////////////////////////////

cheers

Last edited by zwecklos; 06/12/08 13:31.
Re: Lite-C Workshops function compute_days() [Re: zwecklos] #210735
06/12/08 14:44
06/12/08 14:44
Joined: Jul 2006
Posts: 76
uk london
F
FireArm Offline OP
Junior Member
FireArm  Offline OP
Junior Member
F

Joined: Jul 2006
Posts: 76
uk london
sorry i fegot to report back i did finally solve the problem, but still thanks.
And with what i learned so far i made this script from workshop 6 resouces

heres my script i made , you press buttion then text moves right.
its more easy then i though it would be.


////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>

STRING* aloha_str = "Welcome to Paradise Island!";
TEXT* greetings_txt =
{
pos_x = 10;
pos_y = 10;
string (aloha_str) ;
flags = VISIBLE;
}
BMAP* mouse_pcx = "mouse.pcx"; // bitmap used for the mouse pointer
function main()
{
video_mode = 7;
screen_color.red = 150;
mouse_map = mouse_pcx;
mouse_mode = 2;
while (1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
wait (1);
}

}

function move_text()
{
while(1)
{
wait(1);
greetings_txt.pos_x += 1;
}
}

//////////////////////////////////////////////////////////////////////

PANEL* main_pan =
{
bmap = "main.pcx";
pos_x = 250;
pos_y = 200;
button (250, 134, "quitclicked.pcx", "quitnormal.pcx", "quitover.pcx", move_text, NULL, NULL);
flags = OVERLAY | VISIBLE;
}

//////////////////////////////////////////////////////////////////////

Re: Lite-C Workshops function compute_days() [Re: FireArm] #210746
06/12/08 15:37
06/12/08 15:37
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
btw, to solve that problem that zwecklos mentioned, in the future you can use something called function prototyping which means you write the function name before main(), and then you can make the function after main. Kinda confusing?...

#include <acknex.h>;

function hello_world();

function main()
{
beep();
hello_world();
}

function hello_world()
{
printf("hello world");
beep();
}

so the function at the top acts like a pointer to the function below main();
function prototyping is familiar in C++.

Re: Lite-C Workshops function compute_days() [Re: DJBMASTER] #210751
06/12/08 16:24
06/12/08 16:24
Joined: Jul 2006
Posts: 76
uk london
F
FireArm Offline OP
Junior Member
FireArm  Offline OP
Junior Member
F

Joined: Jul 2006
Posts: 76
uk london
thank's
also is it possable to use "if" just to check 1 thing?.

for example
if shutdowngame is equal to 0 the games shuts down, with no "else" or "or"

i tryed this but it dont work
if (shutdowngame == 0)
{
sys_exit(NULL);
}

--------------------------------------------------------
Edit fixed it
while(1)
{
if (shutdowngame == 0)
{
sys_exit(NULL);
}
wait(1);
}

Last edited by FireArm; 06/12/08 19:09.

Gamestudio download | 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