thrownaway9k
Member
I've been trying to implement a look command in my game, similar to what you'd find in Dwarf Fortress. An X appears on the screen, moves around just like the player, and whatever is underneath the X, has it's name displayed in the top left.
I've tried numerous different codes, each yielding different results. I didn't think to save some of them unfortunately, so this is the only one I got to show for. But this is in my Draw GUI event for my "X Cursor" object:
All of my objects have a variable in them named "Name". And name, always gives out a string with their name, as in Name = "Skeleton". So great, but this code only flashes 1 string of "Skeleton" in the upper left screen before disappearing immediately. In my debug window, it also displays "Text Drawn" twice, and only ever twice. Never does it display "Empty". So this is all very confusing to me.
I tried using global.ObjList[|j] or [|i], but that actually makes it worse. It doesn't even display "Text Drawn" or flash the string.
I'm trying to make it so that, whenever my X is highlighted over no object at all, no text is displayed. and when it IS highlighting an object, it'll display the string from every object in that positions Name variable. I'd really appreciate some help, thanks!
GMS2 IDE v2.2.5.481 Runtime v.2.2.5.378
I've tried numerous different codes, each yielding different results. I didn't think to save some of them unfortunately, so this is the only one I got to show for. But this is in my Draw GUI event for my "X Cursor" object:
Code:
if !place_empty(x,y,all){
var obj,notme,i;
obj = all;
notme = true;
global.ObjList = ds_list_create();
i = collision_point_list(x,y,obj,false,notme,global.ObjList,true);
ds_list_add(global.ObjList,i);
if obj == noone {
ds_list_empty(global.ObjList);
show_debug_message("Empty")
}
// now actually draw the items
if collision_point_list(x,y,obj,false,notme,global.ObjList,false) != noone {
for(var j=0; j < ds_list_size(global.ObjList); j += 1){
if variable_instance_exists(global.ObjList,"Name") {
draw_text(50, 30, string(global.ObjList.Name))
show_debug_message("Text Drawn");
}
}
}
}
I tried using global.ObjList[|j] or [|i], but that actually makes it worse. It doesn't even display "Text Drawn" or flash the string.
I'm trying to make it so that, whenever my X is highlighted over no object at all, no text is displayed. and when it IS highlighting an object, it'll display the string from every object in that positions Name variable. I'd really appreciate some help, thanks!
GMS2 IDE v2.2.5.481 Runtime v.2.2.5.378
Last edited: