Legacy GM Interacting with objects sort-of works, except...

A

AtomicToilet

Guest
Holargh!

I've written some code that works pretty well (I'm prototyping a 2D side scroller investigation thingy) except it displays the first line of text every time the player passes by the object in question. OR, it disappears after a few button clicks. Like thus:


and this (though this is far, far less common):

-----------------------------------------------------------
Here's all the relevant code!
First, in the obj_investigate

Create event:

Code:
first_look = true;
Alarm[0] event:
Code:
first_look = false;
Draw event:
Code:
///INVESTIGATE

//Player is next to object and presses 'Investigate' a first time
if (first_look == true) && (obj_player.investigate == true) && (obj_mouse.image_index == 2) && (obj_player.key_investigate)
{
draw_set_colour(c_white);
draw_set_font(fnt_player);
draw_set_halign( fa_center );
draw_set_valign( fa_middle );
draw_text_transformed(obj_player.x,obj_player.y-40, "Roses.",.5,.5,image_angle);
draw_text_transformed(obj_player.x,obj_player.y-30, "Not as dead as they should be.",.5,.5,image_angle);
alarm[0] = 15;
}

//Player is next to object and presses 'Investigate' a second (or third, etc) time
else if (first_look == false) && (obj_player.investigate == true) && (obj_mouse.image_index = 2) && (obj_player.key_investigate)
{
draw_set_colour(c_white);
draw_set_font(fnt_player);
draw_set_halign( fa_center );
draw_set_valign( fa_middle );
draw_text_transformed(obj_player.x,obj_player.y-40, "Which means someone",.5,.5,image_angle);
draw_text_transformed(obj_player.x,obj_player.y-30, "could still be here...",.5,.5,image_angle);
}

//These can be commented-out with no impact whatsoever (I thought they might help :( )
else if obj_player.investigate == true && !(obj_player.key_investigate)
{
//do nothing
}
else if obj_player.investigate == false
{
//do nothing
}
and in the obj_player:

Create event:
Code:
investigate = false;
Step event:
Code:
///INVESTIGATE

if !place_meeting(x,y,obj_investigate)
{
next_to = false;
}
Collision with obj_investigate event:
Code:
if (key_investigate)
{
investigate = true;
}
And there we go. I've tried commentating out/switching around variables so many times now I've actually lost track. HAAALLPPPP!
 

CloseRange

Member
It's hard to help when we don't know what's wrong.... What are you trying to do?
Do you want it so the player touches the object and text fades away (even while touching it)?
Do you want it to stay there as long as the player is touching it, but once the player stops touching it the text should never appear again?
Do you want it so the player touches it and it never dissapears?
Do you want the text to animate in some way that it isn't?
 
A

AtomicToilet

Guest
Apologies, CloseRange - the text should only display whenever the player is close to the object and when they click the '?' cursor on it.

Which of course works the second time I click on the object (hence the text change) but for some reason not the first time (so my issue is, the game shouldn't display the 'Roses' text every time the player object touches the object, even when the cursor is nowhere near it).
 

roozilla

Member
Add show_debug_message where you are setting your boolean variables. You'll probably notice that your logic variables are toggling when you expect them not to.
 
A

AtomicToilet

Guest
I did that, but the main two variables (first_look and investigate) work exactly as they should (ie. first_look starts as true, switches to false once the cursor is pressed on the object / investigate starts as false, switches to true once Player 'collides' with object. I changed

Code:
if !place_meeting(x,y,obj_investigate)
{
investigate = false;
}
in the Player move script, otherwise investigate stays as true once the player has moved past the object (next_to was a previous variable that isn't in use anymore)- which tidied that small glitch up, but I still can't figure out what's telling the obj_investigate draw event to draw the first lot of text every time the player walks past the object, rather than only when they click the object. :bash:
 
Last edited by a moderator:
Top