Subroutines

Non-platform specific questions.

Subroutines

Postby jazz_e_bob » Thu Apr 22, 2004 12:03 pm

At the moment I am using Actors with Activation Events to hold subroutines.

For example: MoveAllActorsHome, ResetScores or FadeAllPlayers...

Is there a better way to do this?

Sometimes this doesn't work well because an Activation Event seems to work in parallel with the code after it. Normal subroutines, on the other hand, interrupt the program flow until they complete.

Comments? Anyone? Bueller?

Image
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby ingsan » Thu Apr 22, 2004 1:25 pm

What are subroutines, jazz ?
Is that to save, load vars or something like that ?
User avatar
ingsan
 
Posts: 580
Joined: Mon Nov 17, 2003 4:02 pm
Location: Maurician LADY in FRANCE
Score: 6 Give a positive score

Postby Just4Fun » Thu Apr 22, 2004 2:32 pm

ingsan,
A subroutine is like a little sub program that runs,when called, within your actual program.
Like:
"My Subroutine to draw some random lines"
-----> your code to drawlines
end of subroutine

Your actual program flow:
------> some code
call "My Subroutine to draw some random lines"
------> your program jumps to the subroutine code to draw lines and returns here.
------> continue with your program code.
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score

Postby ingsan » Thu Apr 22, 2004 5:43 pm

What i can understand is that a subroutine is a code that you write and save for later use :? i'm hope I'm getting it :(
I'm impatiently awaiting an answer to Jazz-e-bob's post !

Thank you Just-4-Fun :wink:
User avatar
ingsan
 
Posts: 580
Joined: Mon Nov 17, 2003 4:02 pm
Location: Maurician LADY in FRANCE
Score: 6 Give a positive score

Postby jazz_e_bob » Thu Apr 22, 2004 8:04 pm

I often find myself saving out chunks of script and merging them back into several other scripts. It's, tedious, prone to error AND if you update the routine you need to edit each and every place it is used.

This is where subroutines are useful. :idea:

At the moment I use an actor with the subroutine in its activation event.

eg SendActivationEvent("resetGame");

Thanks for the feedback.

Image

Hope ewes are all well. :)
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby makslane » Thu Apr 22, 2004 11:18 pm

You can put your subroutines in the Global code editor
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby jazz_e_bob » Fri Apr 23, 2004 3:47 am

makslane wrote:You can put your subroutines in the Global code editor


I thought you couldn't read or set actor properties with Global code. :oops:
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby makslane » Fri Apr 23, 2004 12:44 pm

You can't write the internals vars, but can read
And the user vars you can write and read

Don't works ?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby jazz_e_bob » Fri Apr 23, 2004 8:01 pm

It all seems ok from here. :)

You can't write the internals vars, but can read
And the user vars you can write and read


Internal vars? Do you mean local? Examples? :?

In my test I was able to destroy an actor and set its xvelocity with global code.
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby makslane » Sat Apr 24, 2004 6:29 pm

internal vars: x, y, xscreen, yscreen, r, g, b, transp, ...
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby jazz_e_bob » Mon Apr 26, 2004 2:24 am

Why can't we update internal vars then?

(This means you can't write a subroutine that moves a group of actors to a specific location for instance.)
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby jazz_e_bob » Mon Apr 26, 2004 4:37 am

Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby jazz_e_bob » Mon Apr 26, 2004 10:26 am

No I haven't. :(

This method creates even more problems!!

Help!!! What is the best way to write subroutines in GE? :?

( Subroutines are the only method I know for managing program complexity. )

jazz
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby jazz_e_bob » Mon Apr 26, 2004 11:05 am

I have a cunning plan...

Image
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby makslane » Mon Apr 26, 2004 11:54 am

What's the problem with your method?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest