|
|
I want solution to the easy problem
#269436
06/03/09 05:45
06/03/09 05:45
|
Joined: Jun 2009
Posts: 12 bahrain
abdulla
OP
Newbie
|
OP
Newbie
Joined: Jun 2009
Posts: 12
bahrain
|
Hi !! I have a small problem .. I want to help me. How do I make the object go and back repeatedly ?? For example .. The object goes to the point A and then return to point B and then go again to point A .. Thus ?? this is my code : action monster1 { my.enable_scan = on; my.event = monster_1; while (1) { my.x += 1.5; ent_cycle("walk", my.skill46); my.skill46 += 4 * time; if(my.x > 12) { while(1) { my.x -= 1.5; my.pan = 180; ent_cycle("walk", my.skill46); my.skill46 += 4 * time; wait(1); } } wait(1); } } This code makes the object Just go and back then continue walking 
|
|
|
Re: I want solution to the easy problem
[Re: abdulla]
#269439
06/03/09 05:59
06/03/09 05:59
|
Joined: Apr 2009
Posts: 298 Southern Oceans
KiwiBoy
Member
|
Member
Joined: Apr 2009
Posts: 298
Southern Oceans
|
HI, try it like this action monster1 { var goback = 1; my.enable_scan = on; my.event = monster_1; while (goback > 0) { my.x += 1.5; ent_cycle("walk", my.skill46); my.skill46 += 4 * time; my.skill1 += 1 *time_step; if(my.skill1 > 12)//adjust as required { my.x -= 1.5; my.pan = 180; ent_cycle("walk", my.skill46); my.skill46 += 4 * time; } return; } } or base your script on similar. Here skill1 has been used as a timer and when it runs out, your char walks backwards and return loops it. Not tried, just hurridly edited from yours to show a way 
Use the 'manual' Luke, the manual is your friend. 'Self reminder' My WebPage
|
|
|
Re: I want solution to the easy problem
[Re: Cowabanga]
#269507
06/03/09 11:37
06/03/09 11:37
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
Serious User
|
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
and here is this
var counter = 0;
action monster1
{
my.enable_scan = on;
my.event = monster_1;
while (1){ wait(1);
//always loop animation in a while
ent_cycle("walk", my.skill46);
my.skill46 += 4 * time;
if(my.x < 12){//use a multiple of 1.5 (3, 4.5, 6, 7.5...12)
my.x += 1.5;
counter += 1.5;//same as your movement amount
my.pan = 0;// you need to reset the pan here
}
if(my.x >= 12){
my.x -= 1.5;
counter += 1.5;//keep adding, removes further coding
my.pan = 180;
}
if(counter> 24){counter = 0;}//reset the counter, cause the enemy should be back where he was.
}
}
remember, as soon as you get into a while loop, you can not perform 'ifs' outside of its loop, unless you provide your script a way to exit to the if statement... Enjoy 
|
|
|
Re: I want solution to the easy problem
[Re: DLively]
#269563
06/03/09 14:15
06/03/09 14:15
|
Joined: Jun 2009
Posts: 12 bahrain
abdulla
OP
Newbie
|
OP
Newbie
Joined: Jun 2009
Posts: 12
bahrain
|
Devon thank you .. but if monster is go to Point B he isn't back to A .. how ?? 
|
|
|
Re: I want solution to the easy problem
[Re: abdulla]
#269619
06/03/09 19:11
06/03/09 19:11
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
User
|
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
Hm when I want to make that I use this (it's nearly the self then the other) :
my.skill1+=0.5*time_step;
if(my.skill2==0) { my.pan=0; my.x+=1.5; if(my.skill1>=12) { my.skill1=0; my.skill2=1; }}
if(my.skill2==1) { my.pan=180; my.x-=1.5; if(my.skill1>=12) { my.skill1=0; my.skill2=0; }}
Last edited by hopfel; 06/03/09 19:13.
Hilf mir, dir zu helfen!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|