• 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!

Legacy GM [SOLVED] Need Help Debugging Something

So, my game works totally fine on my machine. I run windows 10. I am making a sandbox survival game, with an inventory and crafting and stuff.

Here's my problem. I downloaded it from my site on a school computer today and it worked totally fine at first. It generated the world, set up the graphics correctly, (I have code that resizes window to work full-screen on computers of any size), and ran with less lag on larger worlds than on my machine. However, it didn't seem to respond to clicking on the inventory slots in any way.

I wondered if it was because the school computers were windows 7, but all of my other projects work fine. I also thought it could be because the school computer had a much larger screen. I made a slight change that I think *might* fix the problem, in that case. It may also be a really weird restriction on the school computers specifically, but once again, my other projects work fine. (Also, I've pretty much outsmarted the school restrictions in every way already, hee hee). However, the game works perfectly on my machine so I can't really test it.

Unless someone knows of a specific issue with windows 7, I'd like if some people could download the game and test it for me. I want to know whether the inventory works for other computers/users/screens etc. Screenshots would be very helpful. In addition, if you press control, and then type: "clicktest_show" and press enter, it will put blue blocks in the location of the inventory slots, so I can see if they are somehow out of position.

Here is a download link: Link Removed

If you want more details, check my signature. Thanks a bunch!
 
Last edited:
Q

Quelandoris

Guest
Could you post the code relevant to clicking on the inventory? I tried it on my machine (Win10 with a 1920x1080 screen) and couldnt get it to work either.
 
Yeah, I'll share the code in a bit, I need to find the right stuff and check a few things. In the meantime, can you run the clicktest_show command I mentioned in the thread and share a screenshot. I need to know if the blue boxes are on your screen or not.

Here is the code that creates the objects. The game is already maximized. This is a little bit complicated, but it works on my computer, so I'm super confused...

Code:
//Creating clicktest objects for main inventory
width = display_get_width();
w_center = width/2;
height = display_get_height();
h_center = height/2;

var slot = 0;
while (slot < global.max_slot)
 {
 var inst = instance_create((w_center+(64*(slot-(global.max_slot/2)))), height-96, obj_clicktest); //Clicktests
 inst.var_slot = slot;
 slot += 1;
 }
This is the code for obj_clicktest (minus stuff that shouldn't effect this in any way)

Create Event:
Code:
gox = x;

goy = y;
Step Event:
Code:
depth = obj_player.depth - 1;
x = view_xview[0] + gox;
y = view_yview[0] + goy;
Draw GUI event:
Code:
scr_draw_item();
if (global.selected_slot == var_slot)
 {
 draw_sprite(spr_clicktest_selected, 0, gox, goy);
 }
if (show_tooltip == true && global.inventory[#0, var_slot] != 0)
 {
 draw_text(gox, goy-32, string(global.tooltip[#global.inventory[#0, var_slot], global.language]) + " x" + string(global.inventory[#1, var_slot]));
 }
Based on the code for the clicktest object, the items in the inventory shouldn't even draw their sprite and their quantity if the object wasn't in the right place, so I'm lost as to why it isn't registering the click event...

When it's left clicked, it just runs the code that makes the item move into the mouse. Nothing there effects anything other than global variables.
 
Last edited:
Okay, this means that the click-test objects are not in the correct place.

Try walking until you find an item on the ground and pick it up, or use the command (with control): "give apple 10". You have to input the first word, press enter, enter the second word, press enter and enter the final word. Does the item show up in the inventory slots?

Here is what it should do. (Seriously, I'm SO confused).


Edit: So, I'm wondering if the clicktest objects are deactivated before they teleport to the view location somehow? Let me investigate that.

Here is a new download link: Link Removed

I made it so that clicktest objects are not deactivated like other objects. In theory it shouldn't matter, but see if it works now.
 
Last edited:
Q

Quelandoris

Guest
Yeah, I'll share the code in a bit, I need to find the right stuff and check a few things. In the meantime, can you run the clicktest_show command I mentioned in the thread and share a screenshot. I need to know if the blue boxes are on your screen or not.

Here is the code that creates the objects. The game is already maximized. This is a little bit complicated, but it works on my computer, so I'm super confused...

Code:
//Creating clicktest objects for main inventory
width = display_get_width();
w_center = width/2;
height = display_get_height();
h_center = height/2;

var slot = 0;
while (slot < global.max_slot)
 {
 var inst = instance_create((w_center+(64*(slot-(global.max_slot/2)))), height-96, obj_clicktest); //Clicktests
 inst.var_slot = slot;
 slot += 1;
 }
This is the code for obj_clicktest (minus stuff that shouldn't effect this in any way)

Create Event:
Code:
gox = x;

goy = y;
Step Event:
Code:
depth = obj_player.depth - 1;
x = view_xview[0] + gox;
y = view_yview[0] + goy;
Draw GUI event:
Code:
scr_draw_item();
if (global.selected_slot == var_slot)
 {
 draw_sprite(spr_clicktest_selected, 0, gox, goy);
 }
if (show_tooltip == true && global.inventory[#0, var_slot] != 0)
 {
 draw_text(gox, goy-32, string(global.tooltip[#global.inventory[#0, var_slot], global.language]) + " x" + string(global.inventory[#1, var_slot]));
 }
Based on the code for the clicktest object, the items in the inventory shouldn't even draw their sprite and their quantity if the object wasn't in the right place, so I'm lost as to why it isn't registering the click event...

When it's left clicked, it just runs the code that makes the item move into the mouse. Nothing there effects anything other than global variables.

When trying to check the location of the mouse relative to the gui, you want to use "device_mouse_x_to_gui(0)" and "device_mouse_y_to_gui(0)." I suspect that might be the start of your troubles.
 
When trying to check the location of the mouse relative to the gui, you want to use "device_mouse_x_to_gui(0)" and "device_mouse_y_to_gui(0)." I suspect that might be the start of your troubles.
The game is maximized. The mouse coordinate relative to the GUI, relative to the view, and relative to the device is exactly the same. (Or at least should be).

EDIT: Also, that doesn't explain why it works on my computer and not your, nor why the blue boxes don't show up like they should.

EDIT2: No, that's not what the issue was. I figured it out a massive part of it. More information will come later. I have mostly fixed it. The rest of the changes will be in a new topic, because the real problem is mostly unrelated... Thanks for your help.
 
Last edited:
Solved. It was an issue with the way I scaled stuff onto the game. It was three lines of code changed to fix. Thanks for your help. My links are updated with the fixed file, so they should work on all computers. (Because I know what the issue was, I was able to test this on my computer, so I know it works).
 
Top