Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 639 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
return; #451065
04/28/15 09:21
04/28/15 09:21
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Quote:
Terminates the function


Is this required at the end of EVERY function?

what if its occupying an action inside of a while loop? still return every frame?

Code:
function groove(ENTITY* ent){
    vec_set(ent.x, my.x);
    return;
}
action radio(){
    while(good_song == playing){wait(1);
        groove(player);
    }
}



Thanks guys! laugh


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: return; [Re: DLively] #451068
04/28/15 09:39
04/28/15 09:39
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: DLively
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.

Originally Posted By: DLively
what if its occupying an action inside of a while loop? still return every frame?

Code:
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?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: return; [Re: 3run] #451070
04/28/15 10:03
04/28/15 10:03
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline 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.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: return; [Re: DLively] #451071
04/28/15 10:13
04/28/15 10:13
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: DLively
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!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: return; [Re: 3run] #451090
04/28/15 16:17
04/28/15 16:17
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline 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.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: return; [Re: DLively] #451091
04/28/15 16:25
04/28/15 16:25
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
where you put your "wait" actually depends on what you are doing.


3333333333
Re: return; [Re: Quad] #451093
04/28/15 16:35
04/28/15 16:35
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Thanks for your response Quad.

Perhaps you can explain to me a bit better what it is you mean, because I don't understand entirely.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: return; [Re: Quad] #451094
04/28/15 16:36
04/28/15 16:36
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: DLively
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:
Originally Posted By: Manual
* 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!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: return; [Re: 3run] #451095
04/28/15 16:43
04/28/15 16:43
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Quote:
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.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: return; [Re: DLively] #451097
04/28/15 16:47
04/28/15 16:47
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: DLively
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?

Originally Posted By: DLively
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?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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