~Hakurei Shrine~ > Rika and Nitori's Garage Experiments |
※ Danmakufu Q&A/Problem thread 3 ※ |
(1/366) > >> |
Helepolis:
Welcome to the Question and Answer (or any problem/help me) thread for Danmakufu Important notice (26-04-2016): This thread will function as the general Danmakufu Q&A from this point on As we all know, 0.12m is heavily outdated. It has become ancient :V So far, we've been keeping two threads to help people with their questions or problems. However, Ph3 is no longer considered scary or difficult as we got a skilled community with various people to help out. It is time to move on and leave 0.12m alone. If you have 0.12m questions (because of old scripts and such), feel free to ask them in here. * Previous thread: https://www.shrinemaiden.org/forum/index.php/topic,16584.0.html * Danmakufu Wiki: http://dmf.shrinemaiden.org/wiki/Main_Page * The Great information thread: http://www.shrinemaiden.org/forum/index.php/topic,6181.0.html |
Helepolis:
Last ongoing question by Zhan_Fox which had started here. Below a guote from the last post. --- Quote from: Zhan_fox on January 30, 2016, 09:33:50 AM ---Oh, Sorry my English is not clear? I want to connect two objects (like for example GetObjectDistance(obj1,obj2) ), but both objects are in different loop making rings. With SetCommonData (as you said before) I have no imagination how could I do that. --- End quote --- |
Drake:
I was waiting for an elaboration because I'm pretty sure my last post needed a concrete example. --- Code: ---let listA = []; let listB = []; // note that this is specifically a function, which creates and sets up a single object we want function ObjectA(y){ // create and initialize the object let objA = CreateShotA1(20, y, 1, 25, DS_BALL_S_RED, 20); // task *within* a function, which keeps running even when the function returns task DoStuffA(){ // running loop while(!Obj_IsDeleted(objA)){ // in this example, A bullets change color when they collide with B bullets let collision = false; ascent(i in 0..length(listB)){ if(GetObjectDistance(objA, listB[i]) < 20){ ObjShot_SetGraphic(objA, DS_BALL_S_BLUE); collision = true; break; } } if(!collision){ ObjShot_SetGraphic(objA, DS_BALL_S_RED); } yield; } } // run the above task DoStuffA(); // return the object ID you just created to store it in a variable with higher scope return objA; } // similar to above function ObjectB(y){ let objB = CreateShotA1(364, y, 1, 155, DS_BALL_S_RED, 20); task DoStuffB(){ while(!Obj_IsDeleted(objB)){ let collision = false; ascent(i in 0..length(listA)){ if(GetObjectDistance(objB, listA[i]) < 20){ ObjShot_SetGraphic(objB, DS_BALL_S_BLUE); collision = true; break; } } if(!collision){ ObjShot_SetGraphic(objB, DS_BALL_S_RED); } yield; } } DoStuffB(); return objB; } ascent(i in 0..10){ listA = listA ~ [ ObjectA(20+i*20) ]; // creates ten of the ObjectA bullets listB = listB ~ [ ObjectB(20+i*20) ]; // creates ten of the ObjectB bullets loop(10){yield;} } --- End code --- There are better ways to code this particular example, but hopefully this illustrates my previous post. Note that both A objects and B objects are created in different function scopes and have different behaviour, but still reference each other. The functions that create the objects return their IDs, so you can store the object IDs using variables declared in higher scopes (so they're more accessible). The tasks within each function still run independently of each other, even though the function surrounding it returns. |
Jean Fox:
--- Quote from: Drake on January 31, 2016, 07:52:25 AM ---I was waiting for an elaboration because I'm pretty sure my last post needed a concrete example. --- Code: ---let listA = []; let listB = []; function ObjectA(y){ let objA = CreateShotA1(20, y, 1, 25, DS_BALL_S_RED, 20); task DoStuffA(){ while(!Obj_IsDeleted(objA)){ let collision = false; ascent(i in 0..length(listB)){ if(GetObjectDistance(objA, listB[i]) < 20){ ObjShot_SetGraphic(objA, DS_BALL_S_BLUE); collision = true; break; } } if(!collision){ ObjShot_SetGraphic(objA, DS_BALL_S_RED); } yield; } } DoStuffA(); return objA; } function ObjectB(y){ let objB = CreateShotA1(364, y, 1, 155, DS_BALL_S_RED, 20); task DoStuffB(){ while(!Obj_IsDeleted(objB)){ let collision = false; ascent(i in 0..length(listA)){ if(GetObjectDistance(objB, listA[i]) < 20){ ObjShot_SetGraphic(objB, DS_BALL_S_BLUE); collision = true; break; } } if(!collision){ ObjShot_SetGraphic(objB, DS_BALL_S_RED); } yield; } } DoStuffB(); return objB; } ascent(i in 0..10){ listA = listA ~ [ ObjectA(20+i*20) ]; // creates ten of the ObjectA bullets listB = listB ~ [ ObjectB(20+i*20) ]; // creates ten of the ObjectB bullets loop(10){yield;} } --- End code --- There are better ways to code this particular example, but hopefully this illustrates my previous post. Note that both A objects and B objects are created in different function scopes and have different behaviour, but still reference each other. The functions that create the objects return their IDs, so you can store the object IDs using variables declared in higher scopes (so they're more accessible). The tasks within each function still run independently of each other, even though the function surrounding it returns. --- End quote --- WOW! IT'S WORKING! I never would have guessed to do like that. Thank you! My superhero! |
Lollipop:
2 questions. 1. How to do a magic circle (the circles that spin around the boss) 2. How to spawn familiars |
Navigation |
Message Index |
Next page |