Author Topic: Could anyone tell me what's gone wrong here?  (Read 1385 times)

Hello I'm struggling with this simple test GUI script, it's so long ago since I used guis...

Here's the two problems:
  • The movemap.Bind isn't actually binding the key.
  • There is a gui called chatInput, which is a GuiTextEditCtrl, I've tried chatInput.getValue(); in the console and it works perfectly, but when I try to in the client.cs it doesn't show anything.


Code: [Select]
exec("./BlocklandWorkbench.gui");
moveMap.bind(keyboard, "alt x", pushBlocklandWorkbench);

function sendBWChat() {
MessageBoxOK("Test!", chatInput.getValue());
}

Help will be greatly appreciated.

For your first problem. Does the function pushBlocklandWorkbench actually exist? Could you show us the function? The keybind is trying to call this function. Also, most people let the user bind their own custom key to things with this:
Code: [Select]
$remapDivision[$remapCount] = "Keybind Category";
$remapName[$remapCount] = "Keybind Name";
$remapCmd[$remapCount] = "functionName";
$remapCount++;

For your second problem. Are you sure chatInput exists? Are you calling the sendBWChat function? Are you sure the value of chatInput isn't just blank? Also, I'd suggest naming the GuiTextEditCtrl with a prefix to prevent another mod using a GUI element with the same name. Something like BLWorkBench_chatInput maybe?

For the first problem here's the GUI code for the function at the bottom.

Code: [Select]
//--- OBJECT WRITE END ---

function pushBlocklandWorkbench(%Gui) {
%Gui = canvas.pushDialog(BlocklandWorkbench);
}

You'll understand why it has to be bound by script later  :cookieMonster:
I've decided to go ahead and make project "Blockland Workbench", starting off with an Internet Relay Chat.



The second problem I've fixed now, Thanks Jes!

Ok. About the keybind. I'm assuming you want it to work in the Main Menu too? In which case you'll need to bind it to GlobalActionMap instead of moveMap. You're pushBlocklandWorkbench is also messed up. The first variable of the function assigned to the key bind will be a boolean for wether the button was pushed(true) or released(false). Plus assigning the return of something, assigning it to a local variable, and then doing nothing with it is entirely pointless.

Ok. About the keybind. I'm assuming you want it to work in the Main Menu too? In which case you'll need to bind it to GlobalActionMap instead of moveMap. You're pushBlocklandWorkbench is also messed up. The first variable of the function assigned to the key bind will be a boolean for wether the button was pushed(true) or released(false). Plus assigning the return of something, assigning it to a local variable, and then doing nothing with it is entirely pointless.

Ok thanks, I'll try that!

I always thought that the returned variable had a purpose (%gui).

Ok thanks, I'll try that!

I always thought that the returned variable had a purpose (%gui).
%gui isn't returned and it isn't even a well named variable in that function. The thing that returns a value is canvas.pushDialog();