E
EZTALES
Guest
hey yall,
i was just wondering if it was possible to make a line of text only appear when a player comes in contact with the object, and presses (in this case) Z;
my code is this at the moment, is saying the text with the player being on the object, but when i press Z it goes to the next line of text:
heres the code..
any help is appreciated, and btw the obj_testtext is its own object, and is not attached to any other object
i was just wondering if it was possible to make a line of text only appear when a player comes in contact with the object, and presses (in this case) Z;
my code is this at the moment, is saying the text with the player being on the object, but when i press Z it goes to the next line of text:
heres the code..
Code:
Create Event:
Var: Set text to a value of 1 that applies to the player that's not relative.
//all the variables
text=1
textmax=0
i=0
imax=0
str=''
nextsound=0
effect=0;
(next code action)
//all the strings
str[1]=" Howdy there!"
str[2]=" This is a textbox!"
str[3]=" did you know!"
str[4]=" The end."
//textmax's value should be how many strings you have.
textmax = 4;
Code:
Destroy Event
Var: set Variable to object player. the variable is named text and has a value of 0: it is not relative.
Stop sound: snd_plaintext.
Code:
step event (this is a big one)
destroy: object_interact:
Set variable text to 1
execute code:
imax=string_length(str[text])
if i<imax
{
i+=1
}
//for people who like z
if keyboard_check_pressed(ord('Z'))
{
if text=textmax{
if i=imax{
instance_destroy();
}
}
else
{
if text<textmax{
if i=imax
{
text+=1
i=0
}
}
else
{
instance_destroy();
}
}
}
//for people who like enter
if keyboard_check_pressed(vk_enter)
{
if text=textmax{
if i=imax{
instance_destroy();
}
}
else
{
if text<textmax{
if i=imax
{
text+=1
i=0
}
}
else
{
instance_destroy();
}
}
}
//for people who like x
if keyboard_check_pressed(ord('X'))
{
i=imax
}
//for people who like shift
if keyboard_check_pressed(vk_shift)
{
i=imax
}
Code:
Draw Event
draw_set_font(fnt_textbox_normal)
//normal text
if effect = 0{
draw_set_color(c_white);
draw_text(view_xview+0,view_yview+10,string_copy(str[text],0,i));
}
else
{
//shaky text
if effect = 1{
draw_set_color(c_white);
draw_text(view_xview+30+random_range(-1, 1),view_yview+170+random_range(-1, 1),string_copy(str[text],0,i));
}
else
{
//red text
if effect = 2{
draw_set_color(c_red);
draw_text(view_xview+30,view_yview+170,string_copy(str[text],0,i));
}
else
{
//yellow text
if effect = 3{
draw_set_color(c_yellow);
draw_text(view_xview+30,view_yview+170,string_copy(str[text],0,i));
}
else
{
//red shaky text
if effect = 4{
draw_set_color(c_red);
draw_text(view_xview+30+random_range(-1, 1),view_yview+170+random_range(-1, 1),string_copy(str[text],0,i));
}
else
{
//yellow shaky text
if effect = 5{
draw_set_color(c_yellow);
draw_text(view_xview+30+random_range(-1, 1),view_yview+170+random_range(-1, 1),string_copy(str[text],0,i));
}
else
{
//ghosty shaky text
if effect = 6{
draw_set_color(c_white);
randomize();
draw_text(view_xview+30+random_range(-1, 1),view_yview+170+random_range(-1, 1),string_copy(str[text],0,i));
draw_text_colour(view_xview+30+random_range(-1.25, 1.25),view_yview+170+random_range(-1.25, 1.25),string_copy(str[text],0,i),c_white,c_white,c_white,c_white,.5);
draw_text_colour(view_xview+30+random_range(-1.25, 1.25),view_yview+170+random_range(-1.25, 1.25),string_copy(str[text],0,i),c_white,c_white,c_white,c_white,.25);
}
else
{
//red ghosty shaky text
if effect = 7{
draw_set_color(c_red);
randomize();
draw_text(view_xview+30+random_range(-1, 1),view_yview+170+random_range(-1, 1),string_copy(str[text],0,i));
draw_text_colour(view_xview+30+random_range(-1.25, 1.25),view_yview+170+random_range(-1.25, 1.25),string_copy(str[text],0,i),c_red,c_red,c_red,c_red,.5);
draw_text_colour(view_xview+30+random_range(-1.25, 1.25),view_yview+170+random_range(-1.25, 1.25),string_copy(str[text],0,i),c_red,c_red,c_red,c_red,.25);
}
else
{
//yellow ghosty shaky text
if effect = 8{
draw_set_color(c_yellow);
randomize();
draw_text(view_xview+30+random_range(-1, 1),view_yview+170+random_range(-1, 1),string_copy(str[text],0,i));
draw_text_colour(view_xview+30+random_range(-1.25, 1.25),view_yview+170+random_range(-1.25, 1.25),string_copy(str[text],0,i),c_yellow,c_yellow,c_yellow,c_yellow,.5);
draw_text_colour(view_xview+30+random_range(-1.25, 1.25),view_yview+170+random_range(-1.25, 1.25),string_copy(str[text],0,i),c_yellow,c_yellow,c_yellow,c_yellow,.25);
}
else
{
if effect = 9{
draw_set_color(c_green);
draw_text(view_xview+30,view_yview+170,string_copy(str[text],0,i));
}
}
}
}
}
}
}
}
}
}