Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 984 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
A little "wait" problem #218372
07/28/08 09:47
07/28/08 09:47
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
Hello,

I have a little problem. I have 5 entities, those are the same models. So I have 1 model to save diskspace and create it 5 times with ent_create. Every entity have this code:

Code:
action arm1 {
	arm01 = my;
	my.passable = on;
	
	vec_for_vertex(temp,my,86);
	ent_create("ZTkrzn.mdl",temp,kruis1);
	
	var anim_time = 0;
	var anim;
	
	ang_sin = 0;
	speed_arm = 0.3;
	max_arm = 0;
	
	wait(-1);
	
	while(1) {
		vec_for_vertex(temp,ondermolen1,259);
		
		my.x = temp.x;
		my.y = temp.y;
		my.z = temp.z;
		my.pan = ondermolen1.pan;
		
		ent_animate(my, "windmill", anim, ANM_cycle);
		anim += anim_time;
		anim_time = 2*time_step;
		
		if(key_r == 1) {
			if(max_arm <= 8) {
				max_arm += 0.1*time_step;
			}
		}
		if(key_f == 1) {
			if(max_arm > 0) {
				max_arm -= 0.1*time_step;
			}
		}
		
		ang_sin += speed_arm;
		if(ang_sin >= 360) {
			ang_sin += 360;
		}
		
		my.tilt = -max_arm+sin(ang_sin) * max_arm;
		
		wait(1);
	}
}

The only difference is that the first wait-function is different. The other 4 entities have wait(-2), wait(-3) and so on.

The problem is that the entities start at the same point as arm1 and then after a couple of seconds jump back to their original position.

Is there a sollution for this problem?

Re: A little "wait" problem [Re: Polypfreak1987] #218373
07/28/08 09:52
07/28/08 09:52
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
one way u can do this:

if ur no of entities are fixed and u know first one has which no of waits, then u create 5 different actions for each with different waits in them. and attach them accordingly as u create the entities.

else within one action only u can give conditions like

if(....)

wait(-1)

else if(...)

wait(-2)

....
.....


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: A little "wait" problem [Re: delinkx] #218405
07/28/08 13:04
07/28/08 13:04
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

Joined: Dec 2005
Posts: 116
:deleted:
reason=stop it already


Re: A little "wait" problem [Re: delinkx] #218454
07/28/08 18:25
07/28/08 18:25
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
Originally Posted By: delinkx
one way u can do this:

if ur no of entities are fixed and u know first one has which no of waits, then u create 5 different actions for each with different waits in them. and attach them accordingly as u create the entities.

else within one action only u can give conditions like

if(....)

wait(-1)

else if(...)

wait(-2)

....
.....

Do you mean like this?
Code:
function move() {
	if(arm01) {
		wait(-1);
	} else if(arm02) {
		wait(-2);
	} else if(arm03) {
		wait(-3);
	} else if(arm04) {
		wait(-4);
	} else if(arm05) {
		wait(-5);
	}
}

And in the entity-code:
Code:
action arm1 {
	arm01 = my;
	my.passable = on;
	
	vec_for_vertex(temp,my,86);
	ent_create("ZTkrzn.mdl",temp,kruis1);
	
	var anim_time = 0;
	var anim;
	
	ang_sin = 0;
	speed_arm = 0.3;
	max_arm = 0;
	
	//wait(-1);
	move();
	
	while(1) {
		vec_for_vertex(temp,ondermolen1,259);
		
		my.x = temp.x;
		my.y = temp.y;
		my.z = temp.z;
		my.pan = ondermolen1.pan;
		
		ent_animate(my, "windmill", anim, ANM_cycle);
		anim += anim_time;
		anim_time = 2*time_step;
		
		if(key_r == 1) {
			if(max_arm <= 8) {
				max_arm += 0.1*time_step;
			}
		}
		if(key_f == 1) {
			if(max_arm > 0) {
				max_arm -= 0.1*time_step;
			}
		}
		
		ang_sin += speed_arm;
		if(ang_sin >= 360) {
			ang_sin += 360;
		}
		
		my.tilt = -max_arm+sin(ang_sin) * max_arm;
		
		wait(1);
	}
}


Re: A little "wait" problem [Re: Polypfreak1987] #218507
07/29/08 02:27
07/29/08 02:27
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
Originally Posted By: Polypfreak1987
Originally Posted By: delinkx
one way u can do this:

if ur no of entities are fixed and u know first one has which no of waits, then u create 5 different actions for each with different waits in them. and attach them accordingly as u create the entities.

else within one action only u can give conditions like

if(....)

wait(-1)

else if(...)

wait(-2)

....
.....

Do you mean like this?
Code:
function move() {
	if(arm01) {
		wait(-1);
	} else if(arm02) {
		wait(-2);
	} else if(arm03) {
		wait(-3);
	} else if(arm04) {
		wait(-4);
	} else if(arm05) {
		wait(-5);
	}
}

And in the entity-code:
Code:
action arm1 {
	arm01 = my;
	my.passable = on;
	
	vec_for_vertex(temp,my,86);
	ent_create("ZTkrzn.mdl",temp,kruis1);
	
	var anim_time = 0;
	var anim;
	
	ang_sin = 0;
	speed_arm = 0.3;
	max_arm = 0;
	
	//wait(-1);
	move();
	
	while(1) {
		vec_for_vertex(temp,ondermolen1,259);
		
		my.x = temp.x;
		my.y = temp.y;
		my.z = temp.z;
		my.pan = ondermolen1.pan;
		
		ent_animate(my, "windmill", anim, ANM_cycle);
		anim += anim_time;
		anim_time = 2*time_step;
		
		if(key_r == 1) {
			if(max_arm <= 8) {
				max_arm += 0.1*time_step;
			}
		}
		if(key_f == 1) {
			if(max_arm > 0) {
				max_arm -= 0.1*time_step;
			}
		}
		
		ang_sin += speed_arm;
		if(ang_sin >= 360) {
			ang_sin += 360;
		}
		
		my.tilt = -max_arm+sin(ang_sin) * max_arm;
		
		wait(1);
	}
}



yeps this should do the work.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: A little "wait" problem [Re: delinkx] #218575
07/29/08 10:30
07/29/08 10:30
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
So, now I have the following code:

Code:
function move() {
	if(arm01) {
		wait(-1);
	} else if(arm02) {
		wait(-2);
	} else if(arm03) {
		wait(-3);
	} else if(arm04) {
		wait(-4);
	} else if(arm05) {
		wait(-5);
	}
}

action arm1 {
	arm01 = my;
	my.passable = on;
	
	vec_for_vertex(temp,my,86);
	ent_create("ZTkrzn.mdl",temp,kruis1);
	
	var anim_time = 0;
	var anim;
	
	ang_sin = 0;
	speed_arm = 0.3;
	max_arm = 0;
	
	//wait(-1);
	move();
	
	while(1) {
		vec_for_vertex(temp,ondermolen1,259);
		
		my.x = temp.x;
		my.y = temp.y;
		my.z = temp.z;
		my.pan = ondermolen1.pan;
		
		ent_animate(my, "windmill", anim, ANM_cycle);
		anim += anim_time;
		anim_time = 2*time_step;
		
		if(key_r == 1) {
			if(max_arm <= 8) {
				max_arm += 0.1*time_step;
			}
		}
		if(key_f == 1) {
			if(max_arm > 0) {
				max_arm -= 0.1*time_step;
			}
		}
		
		ang_sin += speed_arm;
		if(ang_sin >= 360) {
			ang_sin += 360;
		}
		
		my.tilt = -max_arm+sin(ang_sin) * max_arm;
		
		wait(1);
	}
}

But when I want to test my game I have these errors:

"else if(arm03){" <- Parameter unknown else bad keyword in {}

and this one:
"wait(-3)" <- Parameter unknown wait bad keyword in {}

How can I fix this?

Re: A little "wait" problem [Re: Polypfreak1987] #218578
07/29/08 11:13
07/29/08 11:13
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
The "{" is missing after the else, thats why you get the syntax error.

"else if" would work in lite-C but not in the old WDL language.

Re: A little "wait" problem [Re: Tobias] #218604
07/29/08 13:41
07/29/08 13:41
Joined: Aug 2006
Posts: 96
Netherlands
P
Polypfreak1987 Offline OP
Junior Member
Polypfreak1987  Offline OP
Junior Member
P

Joined: Aug 2006
Posts: 96
Netherlands
Thank you, that did work well. But now I have another problem to call the function. I have the following code:

Code:
function move() {
	if(arm01) {
		wait(-1);
	} else {
		if(arm02) {
			wait(-2);
		}
	}  else {
		if(arm03) {
			wait(-3);
		}
	}  else {
		if(arm04) {
			wait(-4);
		}
	}  else {
		if(arm05) {
			wait(-5);
		}
	} 
}
action arm1 {
	arm01 = my;
	my.passable = on;
	
	vec_for_vertex(temp,my,86);
	ent_create("ZTkrzn.mdl",temp,kruis1);
	
	var anim_time = 0;
	var anim;
	
	ang_sin = 0;
	speed_arm = 0.3;
	max_arm = 0;
	
	//wait(-1);
	move();
	
	while(1) {
		vec_for_vertex(temp,ondermolen1,259);
		
		my.x = temp.x;
		my.y = temp.y;
		my.z = temp.z;
		my.pan = ondermolen1.pan;
		
		ent_animate(my, "windmill", anim, ANM_cycle);
		anim += anim_time;
		anim_time = 2*time_step;
		
		if(key_r == 1) {
			if(max_arm <= 8) {
				max_arm += 0.1*time_step;
			}
		}
		if(key_f == 1) {
			if(max_arm > 0) {
				max_arm -= 0.1*time_step;
			}
		}
		
		ang_sin += speed_arm;
		if(ang_sin >= 360) {
			ang_sin += 360;
		}
		
		my.tilt = -max_arm+sin(ang_sin) * max_arm;
		
		wait(1);
	}
}

And I get the following error:

"move();" <- Bad of missing parameter

Last edited by Polypfreak1987; 07/29/08 13:45.
Re: A little "wait" problem [Re: Polypfreak1987] #218711
07/30/08 03:26
07/30/08 03:26
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
am not sure abt this.. but i think this is y u getting this:

maybe from an action function u cannot call another function. am not sure of this. if this is true, then the code in ur move() function, u can simply put it within ur action function itself.

and i think since u using the parameters arm01, arm02... etc.. these are from "my" entity and gets recognised within the action function but wont be recognised in the move() funtion unless u pass the parameters by reference to that function.

so i think best is u put all the code of move() function within the action function itself. it should be ok.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: A little "wait" problem [Re: Polypfreak1987] #219001
07/31/08 16:38
07/31/08 16:38
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
you've gone a little AWOL with you're brackets...

Code:
function move() {
	if(arm01) {
		wait(-1);
	}else{
		if(arm02) {
			wait(-2);
		}else{
			if(arm03) {
				wait(-3);
			}else{
				if(arm04) {
					wait(-4);
				}else{
					if(arm05) {
						wait(-5);
					}
				}
			}
		}
	} 
}


your elses will not follow the if command as you're closing them too early
you probably don't need the else if arm05 as after arm04 it must be arm05 (i'm guessing this bit)

NB: i'm sure you can call a function from an action

Hope this helps

Page 1 of 2 1 2

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