2 registered members (Ayumi, kzhao),
1,354
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
return;
#451065
04/28/15 09:21
04/28/15 09:21
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Is this required at the end of EVERY function? what if its occupying an action inside of a while loop? still return every frame?
function groove(ENTITY* ent){
vec_set(ent.x, my.x);
return;
}
action radio(){
while(good_song == playing){wait(1);
groove(player);
}
}
Thanks guys!
|
|
|
Re: return;
[Re: DLively]
#451068
04/28/15 09:39
04/28/15 09:39
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Is this required at the end of EVERY function? No, but if you want to terminate function at the middle or right at the beggining (if something is wrong, f.e. empty pointer?) you can use it. what if its occupying an action inside of a while loop? still return every frame?
function groove(ENTITY* ent){
vec_set(ent.x, my.x);
return;
}
action radio(){
while(good_song == playing){wait(1);
groove(player);
}
}
As far as I know, your example will just run a function (groove), which will move player at 'radio' entity position and then terminate.. It will be the same as if 'return' wasn't there at all, that's not the way 'return' meant to be used. Return can also terminate function with a loop inside, but if there is a 'wait' inside of that loop, return won't be able to return any value (f.e. if you want to return a variable), because (as the manual says) 'wait' already returns to the calling function before the final return statement is excecuted. Anyway, it's not for the first time I see you putting 'wait' at the beginning of the loop, and I wonder why?
|
|
|
Re: return;
[Re: 3run]
#451070
04/28/15 10:03
04/28/15 10:03
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Thanks 3run.
I figured I didn't need them there, but wanted to make 100% sure.
I put my wait at the beginning for organizational purposes. It doesn't make any (real) difference in the way it runs.
Cheers!
Last edited by DLively; 04/28/15 10:05.
|
|
|
Re: return;
[Re: DLively]
#451071
04/28/15 10:13
04/28/15 10:13
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
I put my wait at the beginning for organizational purposes. It doesn't make any (real) difference in the way it runs. Sure it does not, but it's not really a good way to organize your code, and I hope that you don't use such approach in your tutorials. Cheers!
|
|
|
Re: return;
[Re: 3run]
#451090
04/28/15 16:17
04/28/15 16:17
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
Oh? Please, Explain to me why its not a good way to organize my code because it seems you're bothered that I have a specific way of doing things...
Last edited by DLively; 04/28/15 16:19.
|
|
|
Re: return;
[Re: Quad]
#451094
04/28/15 16:36
04/28/15 16:36
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Oh? Please, Explain to me why its not a good way to organize my code because it seems you're bothered that I have a specific way of doing things... There is no SPECIFIC ways to do things here. If you like specific ways, go and create your own language or game engine. With Acknex you can do things correct, or incorrect. Placing 'wait' in most of your code/situation (which I've been noticing for a quiet a while) at the beginning of the loop is incorrect (even if not noticeable for your eyes, cause it's only one frame!). And stop acting like that! If you don't like people helping you (by advice or anything else), don't ask for help and be on your own. Cheers! Edit: technically you wait one frame before the loop, and then run the script, but normally loop should run the script and then wait for one frame and run it over again! It may mix things up at the end (you and me pointers f.e.), and you'll be trying to find your mistake endlessly! Edit2: if you still trying to be a smart ass, open manual and read about 'wait'. Especially read about 'Scheduler List' and the order it's stored! Also take a look at this: * wait(1) is often used at the end of a while loop which is to be executed once per frame cycle. Don't try to reinvent the wheel, instead just try to learn the engine with it's functionalities!
|
|
|
Re: return;
[Re: 3run]
#451095
04/28/15 16:43
04/28/15 16:43
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
And stop acting like that! If you don't like people helping you (by advice or anything else), don't ask for help and be on your own. Like what? Im asking you to tell me the correct reason since you'd seemed to have it. I didn't realize you'd have your own secret reasons. You still never told me why its incorrect.
Last edited by DLively; 04/28/15 16:43.
|
|
|
Re: return;
[Re: DLively]
#451097
04/28/15 16:47
04/28/15 16:47
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Like what? Im asking you to tell me the correct reason since you'd seemed to have it. I didn't realize you'd have your own secret reasons. You still never told me why its incorrect. Do I need to remind you about my help I offered with creating some basic tutorials? And then you just got 'sad' somehow and advised me to create tutorials on my own? Only cause I wanted to create something more basic that fps tutorials you are working and advised to use better input than having tons of if/else for just making player move in XY directions? Okay, then based on your last answer your wrong. I had this discussion on this forum already. It doesn't make a difference. I've edited previous post, plus share a link where you can prove me that I'm wrong?
|
|
|
|