Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (3run, AndrewAMD), 667 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
wdl -> lite-c conversion question #143890
07/27/07 19:46
07/27/07 19:46
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
how will this function look in lite-c? still dont get that stuff

Code:

function vec_randomize (&vec, range)
{
vec[0] = random(1) - 0.5;
vec[1] = random(1) - 0.5;
vec[2] = random(1) - 0.5;
vec_normalize(vec,random(range));
}



thanx for your patience





www.earthcontrol.de
quoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
Re: wdl -> lite-c conversion question [Re: ello] #143891
07/27/07 23:40
07/27/07 23:40
Joined: Aug 2006
Posts: 652
Netherlands
bstudio Offline
User
bstudio  Offline
User

Joined: Aug 2006
Posts: 652
Netherlands
Code:

function vec_randomize(var* vec, range)
{
vec[0] = random(1) - 0.5;
vec[1] = random(1) - 0.5;
vec[2] = random(1) - 0.5;
vec_normalize(vec,random(range));
}



try this, the range might have to be indicated by an int but i don't know for sure


BASIC programmers never die, they GOSUB and don't RETURN.
Re: wdl -> lite-c conversion question [Re: ello] #143892
07/28/07 09:12
07/28/07 09:12
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Quote:

Code:
function vec_randomize (&vec, range)
{
vec[0] = random(1) - 0.5;
vec[1] = random(1) - 0.5;
vec[2] = random(1) - 0.5;
vec_normalize(vec,random(range));
}






If you want to switch completely to Lite-C there are a few things you should consider (or be aware of). Lets take this piece of code for example:

  • try to forget about "function" functions ^^ try to add return types. If you don't return anything, use void here.
  • Always specify the parameter types. the "&" in CScript indicated a var array of 3 elements. So if you want to pass a Var[3] array, using var* as type is right: arrays are passed as pointers to the first element of the array. If you use then [ ], the size in bytes of the first item is multiplied with the number in the brackets to get the adress of the desired variable (this is also the reason why LiteC doesn't give an error if you exceed an array).
  • be careful about VECTORs, ANGLEs and var [3] arrays. Although they have the same datastructure, you should take care of it when you pass e.g. a var[3] to an engine function which expects a VECOR* struct. Add a cast in here to gain safety.


Re: wdl -> lite-c conversion question [Re: HeelX] #143893
07/28/07 10:34
07/28/07 10:34
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
thank you for those hints. i am now off for holidays. good bye!


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

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