• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Dialog box does not pop up

I

</iKON1K>

Guest
Hello, I am trying to make dialog window to pop up, whenever I collide with NPC and press Space button. But it does not work.
Code:
 Movement Script 
///move (hspd, vspd, update_facing)
var hspd = argument0;
var vspd = argument1;
var update_facing = argument2;
// Horizontal movement
if (!place_meeting(x+hspd, y, o_solid)) {
    x += hspd;
} 
if(place_meeting(x, y, o_adam)){
    if(keyboard_check_pressed(vk_space)){
    messageGiver = place_meeting(x,y,o_adam);
    PCTalking = self;
    s_dialogue();
    }
}
// Vertical movement
if (!place_meeting(x, y+vspd, o_solid)) {
    y += vspd;
}
if(place_meeting(x, y, o_adam)){
    if(keyboard_check_pressed(vk_space)){
    messageGiver = place_meeting(x,y,o_adam);
    PCTalking = self;
    s_dialogue();
    }
}
var dir = point_direction(0, 0, hspd, vspd);
var dis = point_distance(0, 0, hspd, vspd);
if (update_facing && dis > 0) {
    facing = get_facing(dir);
}
var moved = x != xprevious || y != yprevious;
// Update the sprite
if (!moved) {
    image_speed = 0;
    image_index = 0;
} else {
    image_speed = .2;
}
// Return true if we are able to move
return moved;
Code:
  Dialog Script
///Begin dialogue between player and messageGiver
dialogueBox = instance_create(view_wport[view_current] / 2, view_hport[view_current] / 2,o_dialog_box);
Code:
Dialog System script
globalvar PCTalking, messageGiver;
Thank you
 

Simon Gust

Member
interesting code.
One thing that could be happening is that the o_dialog_box is being created but not where you want it.
Code:
instance_create(view_wport[view_current] / 2, view_hport[view_current] / 2,o_dialog_box);
the x and y positions are absolute and if your view is not exactly x0 and y0 in the room, the o_dialog_box gets misplaced.
Code:
var xx = view_xview[view_current] + view_wport[view_current];
var yy = view_yview[view_current] + view_hport[view_current];
dialogueBox = instance_create(xx, yy, o_dialog_box);
Then, make sure messageGiver receives the actual id of the person you're talking to.
place_meeting() does not return the id, it only returns true or false.
Code:
messageGiver = instance_place(x, y, o_adam);
 
Top