0 registered members (),
744
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: LC to C-script
[Re: 3run]
#403756
06/25/12 18:04
06/25/12 18:04
|
Joined: Oct 2010
Posts: 73 0110111
CodeMaster
OP
Junior Member
|
OP
Junior Member
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
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
Senior Expert
|
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:
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 :>
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.
|
|
|
|