Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 744 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
LC to C-script #403749
06/25/12 17:35
06/25/12 17:35
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
for(i = 0; i < j; i ++)

How write this in c-script?

Re: LC to C-script [Re: CodeMaster] #403750
06/25/12 17:39
06/25/12 17:39
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
"for" loop works only with lite-c. I guess you can some how work around it, but I'm not sure. The main idea is, that loop runs till "i" is smaller than "j" in the example you've posted above. Play with loops, may be you could find a way to handle it.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: LC to C-script [Re: 3run] #403752
06/25/12 17:46
06/25/12 17:46
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
i = 0;
while(i < j)
{
//code here
i++
}

Last edited by Rei_Ayanami; 06/25/12 17:47.
Re: LC to C-script [Re: Rei_Ayanami] #403754
06/25/12 17:54
06/25/12 17:54
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Rei_Ayanami@ you screwed everything up grin I wanted him to come to that point himself!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: LC to C-script [Re: 3run] #403756
06/25/12 18:04
06/25/12 18:04
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
first thanks for help guys!

i think this will not work beacuse i must put this in while loop and then i=0 will be whole time zero, and i++ also will report error in c-script.

There is complete function where i need this
Code:
action act_emitter()
{
	while(1)
	{
		for(k = 0; k < 3; k++)
		{
			p_lightning1_size = 4+random(4);
			i = vec_dist(my.x,p_effect_target);
			j = floor(i/32)-1;
			vec_set(temp,my.x);
			vec_set(temp3,my.x);
			for(i = 0; i < j; i ++)
			{
				vec_diff(temp2,p_effect_target,temp);
				vec_normalize(temp2,32);
				vec_add(temp3,temp2);
				temp3.z += (1-random(2))*(8+k*3);
				vec_diff(temp2,temp3,temp);
				effect(p_lightning1,1,temp,temp2);
				effect(p_lightning2,1,temp,temp2);
				vec_set(temp,temp3);
			}
			vec_diff(temp2,p_effect_target,temp);
			effect(p_lightning1,1,temp,temp2);
			effect(p_lightning2,1,temp,temp2);
		}
		
		my.tilt += 2*time_step;
		my.tilt %= 360;
		vec_set(temp,vector(700,0,0));
		vec_rotate(temp,my.pan);
		vec_add(temp,my.x);

		c_trace(my.x,temp,IGNORE_MODELS);
		if(trace_hit)
		{
			effect(p_laser_hit,3,target,normal);
			vec_set(temp,target);
		}
		vec_diff(temp2,temp,my.x);
		j = vec_length(temp2)/16;
		for(i = 0; i < j; i++)
		{
			vec_lerp(temp3,my.x,temp,i/j);
			effect(p_laser,1,temp3,temp2);
			effect(p_laser2,1,temp3,temp2);
		}
		time_factor = 1-key_ctrl*0.75;
		wait(1);
	}
}



Re: LC to C-script [Re: CodeMaster] #403757
06/25/12 18:14
06/25/12 18:14
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I won't fix that (but it's really easy :> ). Use simple work around for setting variable to zero. Something like this:
Code:
function blahblah(){
	var run_at_once = 1;
	while(1){
		if(run_at_once == 1){
			....
			
			// all stuff you'll insert in here, will run only once
			// will you'll set "run_at_once" again to "1"
			
			...
			run_at_once = 0;
		}
		wait(1);
	}
}

For "i++" you shouldn't use exactly that, Rei just showed you the place of "i++" from the "for" loop.
Instead of that, you need to create a var, insert set it to the initial value, make a comparison (as in "for").
And then increase it by 1 each tick, that will do the job, this is really first steps which you need to handle yourself.

Edit: I've just made it myself :>

Code:
action act_emitter(){
	// variables:
	var run_once[3];
	var comp_var[3];
	var end_var[3];
	// set start for "once" variable:
	vec_fill(vector(run_once[0], run_once[1], run_once[2]), 0);
	// main loop:
	while(1){
		// init first end var:
		end_var[0] = 3; // as in the script
		// init first start var:
		if(run_once[0] == 0){
			comp_var[0] = 0; // init!
			run_once[0] = 1;
		}
		// first fake "for" loop:
		while(comp_var[0] < end_var[0]){
			// init second end var:
			end_var[1] = 3;
			// init second start var:
			if(run_once[1] == 0){
				comp_var[1] = 0; // init!
				run_once[1] = 1;
			}
			// second fake "for" loop:
			while(comp_var[1] < end_var[1]){
				// increase second loop variable:
				comp_var[1] += 1;
				wait(1);
			}
			// increase first loop variable:
			comp_var[0] += 1;
			wait(1);
		}
		// init second end var:
		end_var[2] = 3;
		// init second start var:
		if(run_once[2] == 0){
			comp_var[2] = 0; // init!
			run_once[2] = 1;
		}
		// third fake "for" loop:		
		while(comp_var[2] < end_var[2]){
			// increase third loop variable:
			comp_var[2] += 1;
			wait(1);			
		}
		wait(1);
	}
}



Last edited by 3run; 06/25/12 19:03.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: LC to C-script [Re: wowlijetgold] #403923
06/28/12 12:24
06/28/12 12:24
Joined: Oct 2010
Posts: 73
0110111
C
CodeMaster Offline OP
Junior Member
CodeMaster  Offline OP
Junior Member
C

Joined: Oct 2010
Posts: 73
0110111
thank you 3run i will try your code


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