R
relic1882
Guest
I've been using some assets that allow me to change some of their values within the room editor by going to the variables button. I'm uncertain how this is accomplished.
My goal here is that I made a text box object that works perfectly, but I'd have to set the text manually within the object and that would require making a whole lot of them just for basic dialogue. Is there a way that I can conveniently set the text variable within the creation code of my dialog box so that I can access it with the variables button in the room editor? Can I do that while putting the object in multiple locations in a room and give them each a different text that way?
Thanks for the read! I put the code below for my dialogue box.
My goal here is that I made a text box object that works perfectly, but I'd have to set the text manually within the object and that would require making a whole lot of them just for basic dialogue. Is there a way that I can conveniently set the text variable within the creation code of my dialog box so that I can access it with the variables button in the room editor? Can I do that while putting the object in multiple locations in a room and give them each a different text that way?
Thanks for the read! I put the code below for my dialogue box.
Code:
////////////CREATE///////////////////
y_button_on = false;
showTextBox = false;
//variable storing the dialogue that is drawn
text = "This is the text. Please change me to make it work for the scene.";
//get the width of the sprite for the dialogue box for word wrapping
boxWidth = sprite_get_width(TextBoxSprite);
//get the height of the font used for spacing purposes
stringHeight = string_height(text) / 2;
//create button prompt
instance_Y_Button = instance_create_layer(x, y - 20, "UIlayer", Y_button_Prompt);
//////////////STEP///////////////////
//activate interaction prompt if player is close
if (distance_to_object(Player1) <= 10) && !showTextBox
{
y_button_on = true;
instance_activate_object(instance_Y_Button); //activate player prompt
}
else if (distance_to_object(Player1 > 10))
{
y_button_on = false;
instance_deactivate_object(instance_Y_Button); //deactivate player prompt
}
//if interaction prompt is active, enable text box and deactivate the interaction prompt
if (y_button_on && Player1.inputInteract)
{
instance_deactivate_object(instance_Y_Button);
showTextBox = true;
}
//if player walks away from object while text is up, disable text and reset values
if (distance_to_object(Player1) > 10) && showTextBox
{
y_button_on = false;
showTextBox = false;
}
/////////////////////DRAW////////////////////
//if player interacts, draw text
if (showTextBox)
{
//draw textbox
draw_sprite(TextBoxSprite, 0, x, y - sprite_get_height(TextBoxSprite) - 10);
//draw text
draw_set_font(fontTextBox);
draw_text_ext(x, y - sprite_get_height(TextBoxSprite) - 10, text, stringHeight, boxWidth);
}