Ã, Ã, Ã, I'm trying to have the TAB button toggle the inventory on and off.Ã, I'm having a problem because my code makes the inventory flicker, on , off, on ,off.
Ã, Ã, Ã, I've been trying to combat this by writing code that checks if the TAB button is pressed.Ã, I think I'm going in the right direction in theory, but in practice I really have no clue what I'm doing.
In main global script file:
//Helps with Inventory on/off
bool pressingTAB;
In repeatedly_execute():
//Help with Inventory on/off
if (pressingTAB == true) {
Ã, if (IsKeyPressed(9) == false) pressingTAB = false;Ã, Ã,Â
}
In - function on_key_press(int keycode):
if ((keycode==9) && (pressingTAB == false)} { // TAB, show inventory toggle
Ã, if (gInventory.Visible == false) {
Ã, Ã, openInventory();
Ã, Ã, pressingTAB = true;
Ã, }
Ã, else {
Ã, Ã, gInventory.Visible = false;
Ã, Ã, Ã, pressingTAB = true;
Ã, }
Ã, Ã, Ã, As usual, if anybody has any ideas, I'd be grateful to hear.
Thanks in advance.
Try this:
Top of the Global script:
bool pressingTAB;
Rep_ex:
if (IsKeyPressed(9)) {
if (pressingTAB == false) {
if (gInventory.Visible == false) openInventory();
else if (gInventory.Visible == true) gInventory.Visible = false;
}
pressingTAB = true;
}
else pressingTAB = false;
And you shouldn't need the on_key_press code. You had the right idea, using the bool to check if the button was being held so the GUI didn't 'flicker', but I think you had the conditions a little screwy.
Excellent! It works perfect. Thanks, Ashen.