Gamestudio Links
Zorro Links
Newest Posts
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
Camera always moves upwards?
by VoroneTZ. 02/19/26 13:13
Hedge on FXCM, 4 or 5?
by Martin_HH. 02/16/26 16:09
Zorro version 3.0 prerelease!
by jcl. 02/12/26 14:05
MarginCost discrepancy?
by jcl. 02/12/26 14:02
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (titanicpiano14, VoroneTZ, paulk, Dirk4Vantas, alx), 7,719 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem with random and integers #150009
08/24/07 11:03
08/24/07 11:03
Joined: Aug 2004
Posts: 19
New Hampshire, USA
GregM Offline OP
Newbie
GregM  Offline OP
Newbie

Joined: Aug 2004
Posts: 19
New Hampshire, USA
I am getting a syntax error in lite-c when I use this command:


i = int(random(3));

"i" is a var. I lookeded in the manual and this appears to be a valid command but "int" doesn't seem to be recognized.

I am including the proper libraries (I think)
#include <acknex.h>
#include <default.c>

Has anyone else had this problem or can you tell me what I am missing?

Thanks.

Re: problem with random and integers [Re: GregM] #150010
08/24/07 11:08
08/24/07 11:08
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Look into afuncs.h:
Quote:

EXT var F(integer)(var);




Try this:
Code:
i = integer(random(3));



Re: problem with random and integers [Re: HeelX] #150011
08/25/07 12:35
08/25/07 12:35
Joined: Aug 2004
Posts: 19
New Hampshire, USA
GregM Offline OP
Newbie
GregM  Offline OP
Newbie

Joined: Aug 2004
Posts: 19
New Hampshire, USA
Thank you. This works. The manual has an example that uses "int" to force the random function to be an integer.

Re: problem with random and integers [Re: GregM] #150012
08/25/07 13:47
08/25/07 13:47
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
The given example is C-Script, not Lite-C. int is a data type in Lite-C, not a function. To avoid confusion with the datatype C-Script int() was renamed to integer() in Lite-C.


Always learn from history, to be sure you make the same mistakes again...

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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