Some short not working code

Posted By: gameplan

Some short not working code - 06/12/12 22:31

Hi,

I have some problems with this code snippet. I get an error message "X is not part of function". This code is part of the rain code from this site:
http://opserver.de/wiki/index.php?title=Basic_Rain/Snow_Effect

vec_set(my.x,vector(
cycle(my.x,camera.x-Weatherbox.x,camera.x+Weatherbox.x),
cycle(my.y,camera.y-Weatherbox.y,camera.y+Weatherbox.y),
cycle(my.z,camera.z-Weatherbox.z,camera.z+Weatherbox.z)));

Maybe it has to do with wdl to lite-c conversion, but I dont have any idee why this lines dont work.

Thanks
Posted By: krial057

Re: Some short not working code - 06/13/12 00:00

That part seems to be correct. Could you post your whole code? Have you changed var weatherbox[3] to VECTOR weatherbox?
Posted By: GameScore

Re: Some short not working code - 06/13/12 07:51

i think you should change

Code:
var Weatherbox[3];


into
Code:
VECTOR Weatherbox;


couz you work with vectors not with var`s
Posted By: gameplan

Re: Some short not working code - 06/13/12 13:20

Here the whole code:
Still doesnt work.

Quote:

VECTOR Weatherbox;
VECTOR Wind_direction; //Movement speed and direction

Wind_direction.x = 0;
Wind_direction.y = 0;
Wind_direction.z = -20;

BMAP* Weather_bmap = "raindrop.tga"; //The particle bmap

function Weather_part_event()
{
//keep the particle within the box
vec_set(my.x,vector(
cycle(my.x,camera.x-Weatherbox.x,camera.x+Weatherbox.x),
cycle(my.y,camera.y-Weatherbox.y,camera.y+Weatherbox.y),
cycle(my.z,camera.z-Weatherbox.z,camera.z+Weatherbox.z)));

//update the movement speed and direction
vec_set(my.vel_x,vector(Wind_direction.x,Wind_direction.y,Wind_direction.z));

my.lifespan = 100; // live forever
}

function Weather_part()
{
//place particles at random positions within the box
vec_set(my.x,vector(camera.x+random(Weatherbox.x*2)-Weatherbox.x,
camera.y+random(Weatherbox.y*2)-Weatherbox.y,
camera.z+random(Weatherbox.z*2)-Weatherbox.z));

my.bmap = Weather_bmap;
my.size = random(1)+2;
my.move = on;

my.function = Weather_part_event;
}

function CreateWeatherParticles(cx,cy,cz,numparticles)
{
Weatherbox.x = cx/2;
Weatherbox.y = cy/2;
Weatherbox.z = cz/2;

//create the particles
effect(Weather_part,numparticles,nullvector,nullvector);
}


There is now a new errormessage: "vel_x is not member of ENTITY"
Posted By: Espér

Re: Some short not working code - 06/13/12 13:29

try using VECTOR*
and you need to fill a Vector INSIDE a function laugh

as next, use PARTICLE* as effect function argument - like:

function weather_part(PARTICLE* p)

and replace all the 'my' Pointer inside that functions with 'p'
Posted By: gameplan

Re: Some short not working code - 06/13/12 18:02

I replaced all my pointer with p, now I get this message: "move is not part of PARTICLE"
Posted By: PadMalcom

Re: Some short not working code - 06/13/12 18:18

Schreib's groß, MOVE. Solche Dinge findest du auch raus, wenn du in das Handbuch schaust. Je früher du lernst das Ding zu benutzen desto schneller lernst du die Sprache.
Posted By: gameplan

Re: Some short not working code - 06/13/12 18:30

Nein, das wird nicht großgeschrieben, das gibt sonst einen Syntaxerror. Außerdem verwende ich sehrwohl das Handbuch, kein Grund mich anzugreifen. Des Weiteren wäre es sinnvoller, eine Antwort auf Englisch zu geben, da die bisherige Diskussion ebenfalls auf Englisch geführt wurde.
Posted By: Rei_Ayanami

Re: Some short not working code - 06/13/12 18:45

There is no "move" only MOVE in LiteC.

If you think otherwise, proof it wink
Posted By: gameplan

Re: Some short not working code - 06/13/12 18:54

Manual:
Quote:

my.move
Ist dieses Flag gesetzt, bewegt sich der Partikel mit seinem Geschwindigkeitsvektor und beschleunigt mit seiner Schwerkraftsbeschleunigung.
Wertebereich:
on - Partikel können sich bewegen
off - keine Partikelbewegung (default:off)

Posted By: rayp

Re: Some short not working code - 06/13/12 18:58

Quote:
MOVE
If this flag is set, the particle moves with its velocity vector, and accelerates with its gravity acceleration.
Type:
flag, particles only
I think my.move was c-script wasnt it ?
Posted By: Rei_Ayanami

Re: Some short not working code - 06/13/12 19:55

Originally Posted By: rayp
Quote:
MOVE
If this flag is set, the particle moves with its velocity vector, and accelerates with its gravity acceleration.
Type:
flag, particles only
I think my.move was c-script wasnt it ?


Exactly.
Posted By: gameplan

Re: Some short not working code - 06/13/12 22:06

So there is a difference between german and english manual. I think that my code is correct now. Everything is fantastic at this point. Thank you for your help and effort.

Quote:

VECTOR Weatherbox;
VECTOR Wind_direction; //Movement speed and direction

Wind_direction.x = 1;
Wind_direction.y = 10;
Wind_direction.z = -20;

BMAP* Weather_bmap = "raindrop.tga"; //The particle bmap

function Weather_part_event(PARTICLE* p)
{
//keep the particle within the box
vec_set(p.x,vector(
cycle(p.x,camera.x-Weatherbox.x,camera.x+Weatherbox.x),
cycle(p.y,camera.y-Weatherbox.y,camera.y+Weatherbox.y),
cycle(p.z,camera.z-Weatherbox.z,camera.z+Weatherbox.z)));

//update the movement speed and direction
vec_set(p.vel_x,Wind_direction);

p.lifespan = 100; // live forever
}

function Weather_part(PARTICLE* p)
{
//place particles at random positions within the box
vec_set(p.x,vector(camera.x+random(Weatherbox.x*2)-Weatherbox.x,
camera.y+random(Weatherbox.y*2)-Weatherbox.y,
camera.z+random(Weatherbox.z*2)-Weatherbox.z));

set(p, MOVE);
p.bmap = Weather_bmap;
p.size = random(1)+2;


p.event = Weather_part_event;
}

function CreateWeatherParticles(cx,cy,cz,numparticles)
{
Weatherbox.x = cx/2;
Weatherbox.y = cy/2;
Weatherbox.z = cz/2;

//create the particles
effect(Weather_part,numparticles,nullvector,nullvector);
}



Posted By: PadMalcom

Re: Some short not working code - 06/14/12 06:41

@gameplan: Sorry I never meant to attack you, all I wanted is to teach you. Teaching might sound rough at some point wink

There manual is mostly correct at least regarding important topics such as upper case / lower case issues. Pay attention that you always look for the Lite-C code instead of C-script, you shouldn't mix the languages.
© 2024 lite-C Forums