Page 1 of 2
Subroutines
Posted:
Thu Apr 22, 2004 12:03 pm
by jazz_e_bob
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?
Posted:
Thu Apr 22, 2004 1:25 pm
by ingsan
What are subroutines, jazz ?
Is that to save, load vars or something like that ?
Posted:
Thu Apr 22, 2004 2:32 pm
by Just4Fun
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.
Posted:
Thu Apr 22, 2004 5:43 pm
by ingsan
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
Posted:
Thu Apr 22, 2004 8:04 pm
by jazz_e_bob
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.
At the moment I use an actor with the subroutine in its activation event.
eg SendActivationEvent("resetGame");
Thanks for the feedback.
Hope ewes are all well.
Posted:
Thu Apr 22, 2004 11:18 pm
by makslane
You can put your subroutines in the Global code editor
Posted:
Fri Apr 23, 2004 3:47 am
by jazz_e_bob
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.
Posted:
Fri Apr 23, 2004 12:44 pm
by makslane
You can't write the internals vars, but can read
And the user vars you can write and read
Don't works ?
Posted:
Fri Apr 23, 2004 8:01 pm
by jazz_e_bob
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.
Posted:
Sat Apr 24, 2004 6:29 pm
by makslane
internal vars: x, y, xscreen, yscreen, r, g, b, transp, ...
Posted:
Mon Apr 26, 2004 2:24 am
by jazz_e_bob
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.)
Posted:
Mon Apr 26, 2004 4:37 am
by jazz_e_bob
Posted:
Mon Apr 26, 2004 10:26 am
by jazz_e_bob
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
Posted:
Mon Apr 26, 2004 11:05 am
by jazz_e_bob
I have a cunning plan...
Posted:
Mon Apr 26, 2004 11:54 am
by makslane
What's the problem with your method?