Author Topic: Binding a GUI  (Read 585 times)

HOPEFULLY this is the last post i'll have to make. So here's whats happening... I'm trying to make a GUI. It works. I want to bind a key to the console command instead of having to put in canvas.pushDialog(___); every single time i want to open the GUI. I named the script 'Kyjus' (for simplicity).

in the .gui file (the file that mission editor made), the bottom (which i added) looks like this:
_____________________________ ______________
//--- OBJECT WRITE END ---

function pushKyjus(%Gui)
{
   %Gui = canvas.pushDialog(Kyjus);
}
_____________________________ ______________

My .cs file looks like this:
_____________________________ ___________
exec("./Kyjus.gui");
moveMap.bind(keyboard, "m", pushKyjus);
}
_____________________________ ______________

when I open Blockland, and press M, it doesn't open. Nor does it open when i push ctrl-m, alt-m, or shift-m. There must be one little mistake that I made, but i just can't figure out what! Am I leaving something out? Help is GREATLY appreciated. (keep in mind it works perfectly if you enter the console command directly)

Tom

Are your trying the code in game or in the Menu? See, there isn't a good way to make a keybind work in the main menu.

This probably isn't your problem, but don't use moveMap.bind(). Use this method instead:
Code: [Select]
if(!$ModNameBindings)
{
$remapDivision[$remapCount] = "Keybind Category";
$remapName[$remapCount] = "Keybind Name";
$remapCmd[$remapCount] = "Function to call";
$remapCount++;
$ModNameBindings = true;
}
If you use this you get an option to set the keybind and it won't break peoples keybinds.

Also, the argument for the keybind function should be not be %GUI. Use code like this instead.
Code: [Select]
function pushKyjus(%val)
{
if(!%val)
return;

canvas.pushDialog(Kyjus);;
}

IT WORKS! Thank you so much!!!! That was a very nice surprise to come home from school to!