GameMaker [SOLVED] Isolate a function within code?

PlayerOne

Member
Is there a way to isolate a function within gml? Using draw_set_alpha in this example:

Code:
DRAW:
draw_text(x,y,"Hello World...");


vvvvvvvvvvvvvvvvvvvv
if (!test_var)
{
draw_set_alpha(0.5)
draw_text(x,y,"hello!");
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

draw_text(x,y,"hello people...");
Within the arrows I want to isolate a function like draw_set_alpha, have that execute only with the desired code in the brackets, and not have it affected anywhere else in the game. Same goes for the exit statement if that is at all possible.
 

FrostyCat

Redemption Seeker
Anyone asking for functionality like this simply needs to organize their code better and stop designing code around imaginary language features.

For draw_set_*() functions, create a script that contains your conventional defaults, then call it every time after you deviate from it.
Code:
///draw_unset()
{
draw_set_colour(c_black);
draw_set_alpha(1);
draw_set_font(0);
draw_set_blend_mode(bm_normal);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
}
For exit, pull the code into a script, then run the script where the code used to be.
 
Top