2 registered members (AndrewAMD, VoroneTZ),
1,258
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: It does what it likes -.-
[Re: Ottawa]
#306807
01/25/10 04:05
01/25/10 04:05
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
Rename your var and see what happens. Honestly I have had this help before. Usually from spelling mistakes you can't see. If not then could you post a bit more of your code so we can see more of what is happening.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Re: It does what it likes -.-
[Re: FoxHound]
#306916
01/25/10 19:46
01/25/10 19:46
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
Ok, here some more code; The game is german, so the variables are German too, I tried to commend them that you can understand it. This is the whole fire-function:
function feuer(pox,poy) { var aufgenommen=0; //create the variable "aufgenommen" if(feuani==-2) {animationfeuer(); feuani=0;} //animate the fire PANEL* feua = pan_create("pos_x=0;pos_y=0;flags=OVERLAY | VISIBLE;",8); //create the fire pan_setwindow(feua,0,0,0,30,18,feu_bmp,feuani,0); //animate the fire with window my = ent_create("gegum.mdl",nullvector,NULL); //give the fire an entity my.skill3=50; //live of the fire my.flags=INVISIBLE; //set the Entity on invisible my.skill6=2; while(my.skill3>=0) //repead while the life of the fire is bigger than zero { vec_set(my.x,vector(feua.pos_x+15*my.skill3/50,feua.pos_y+9*my.skill3/50,0)); //set the position of the entity on the position of the fire-panel feua.pos_x=stage_a.pos_x+pox-15*my.skill3/50; feua.pos_y=stage_a.pos_y+poy-9*my.skill3/50; //position of the fire on the map named "stage_a" feua.scale_x=my.skill3/50; feua.scale_y=my.skill3/50; //scale the fire proportional with his live if(my.skill3<50) my.skill3+=1*time_ste; //rebuild the fire from time to time wait(1); } media_tune(snd_play(zisch_snd,NULL,100),100,150,100); //make a sound ptr_remove(feua); //delete the fire-panel ent_remove(my); //delete the entity from the fire feuerzahl+=1; //count the firenumber }
And there the whole code for the water:
function distanz(pox, poy) //This function is triggered by the player { attart = bmap_create("att1.bmp"); //create the bitmap PANEL* flobj = pan_create("pos_x=0;pos_y=0;bmap=attart;flags=OVERLAY | VISIBLE;",10); //create the water-panel var posl[2]; posl[0]=pox; posl[1]=poy; //set the positions while(flobj.skill_x<100&&flobj.skill_y==0) //repeat until it finds a target or the time is off { flobj.pos_x=stage_a.pos_x+posl[0]-4.5; flobj.pos_y=stage_a.pos_y+posl[1]-4.5; //set the positions on the map flobj.skill_x+=4*time_step; //count the skill_x of the panel posl[1]-=16*time_step; //move the water if(vec_dist(vector(pox,poy,0),vector(posl[0],posl[1],0))>18) //if the water is away from this one who shots {c_scan(vector(flobj.pos_x+4.5,flobj.pos_y+4.5,0),my.pan,vector(360,0,9),NULL);} //look for targets if(you) //if there's a target { if(vec_dist(you.x,vector(stage_a.pos_x+posl[0]-4.5,stage_a.pos_y+posl[1]-4.5,0))<=9) //if the target near you { effectiv = 30; you.skill3-=effectiv; //damage the target
if(flobj.skill_y==0) { snd_play(platsch_snd,NULL,effectiv*3); //make a sound flobj.skill_y=1;} }} wait(1); } pan_remove(flobj); //remove the water }
And last, the function of the scenario (cutted):
function part_3() {
. . .
feuer(200,850); feuer(130,920); feuer(240,1000); feuer(400,980); feuer(270,920); //create the fires
. . .
dialog("Lösche alle Feuer!"); //function for a dialog . . .
beep(); var i = 0; while(feuerzahl<5) //the test-loop from ottawa { for (i=1; i<5; i++) { test = i; //test is a value, who I see on a digit beep();wait(-2); } //beep every second } beep();beep();beep();beep(); //test, if the function continues
. . .
}
The whole code works, only this problem with the firenumber don't do what it should do. Hope, there are enough informations.
Hilf mir, dir zu helfen!
|
|
|
Re: It does what it likes -.-
[Re: hopfel]
#306933
01/25/10 22:21
01/25/10 22:21
|
Joined: Aug 2005
Posts: 1,185 Ukraine
Lion_Ts
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,185
Ukraine
|
The sample at the thread start is correct. just try it and you should see. I have free 5min and just tried your sample:
INT32 firenumber = 0;
function inc_firenumber()
{
++firenumber;
DBG_INFO1("firenumber:%d.", firenumber)
}
function clear_firenumber()
{
firenumber = 0;
DBG_INFO1("firenumber:%d.", firenumber)
}
void main()
{
on_i = inc_firenumber;
on_c = clear_firenumber;
while(firenumber<5)
{
DBG_INFO1("inside loop - firenumber:%d.", firenumber)
wait(-1);
}
DBG_INFO1("EXIT firenumber:%d.", firenumber)
}
this is the console output (I pressed the 'I' key periodically):
[INF|temp_test.c|main] inside loop - firenumber:0.
[INF|temp_test.c|inc_firenumber] firenumber:1.
[INF|temp_test.c|main] inside loop - firenumber:1.
[INF|temp_test.c|main] inside loop - firenumber:1.
[INF|temp_test.c|inc_firenumber] firenumber:2.
[INF|temp_test.c|main] inside loop - firenumber:2.
[INF|temp_test.c|main] inside loop - firenumber:2.
[INF|temp_test.c|main] inside loop - firenumber:2.
[INF|temp_test.c|inc_firenumber] firenumber:3.
[INF|temp_test.c|main] inside loop - firenumber:3.
[INF|temp_test.c|inc_firenumber] firenumber:4.
[INF|temp_test.c|main] inside loop - firenumber:4.
[INF|temp_test.c|main] inside loop - firenumber:4.
[INF|temp_test.c|inc_firenumber] firenumber:5.
[INF|temp_test.c|main] EXIT firenumber:5.
there are few reason to get failed with your loop:- a global variable modified suddenly (somewhere in your code); for example, inside an action of many concurrent entities; - global variable has wrong type (comparing with 'while' statement); for example using signed or high precision var to test smth like: "x == .5" - wrong 'while' statement; suggestions:- at first, search over your files for the 'firenumber' to see, where you try to modify it. - at second, add more debug printouts to see the execution flow. - try to debug.
|
|
|
Re: It does what it likes -.-
[Re: Lion_Ts]
#306983
01/26/10 12:34
01/26/10 12:34
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
Jea Thank you to take your time to try to lift this problem. But I discovered, the variable 'firenumber' is not the fault; I displaced "while(firenumber<5){wait(1);}" with "while(!key_space)wait(1);" If I press space before I extinguishe one fire, it works fine. If I extinguishe one fire before I press space, nothing happens. So the fire-function must make the scenario-function stuck. So I wrote this five lines: feuer(200,850); feuer(130,920); feuer(240,1000); feuer(400,980); feuer(270,920); In another function and, I was amazed, it works! To test something I replaced the "my" from the fire-function with another entity-pointer and it works with this five lines in the scenario-function also. So I ask me; why gets a function stuck, if I remove his "my" pointer?
Hilf mir, dir zu helfen!
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|