Author Topic: GUI Help  (Read 3630 times)

You don't need to change every single line on the file. Just the name of the file. The key bind probably doesn't work because you changed every single line.

Also, it would help if you posted your .zip ..
I only changed it when it said "Home"


Here's the updated file

Code: [Select]
[...]
    if(home.isawake()) //assuming that home is the name of your gui
        canvas.popdialog(home);
    else
        canvas.pushdialog(home);
 [...]
Code: [Select]
//--- OBJECT WRITE BEGIN ---
new GuiControl(home) {
    profile = "GuiDefaultProfile";
    horizSizing = "right";
    vertSizing = "bottom";
[...]
fixed the 2 broken parts

the gui name is home.gui though....


the gui name is home.gui though....

The name of the file that contains the gui is "home.gui"
The name of the actual GUI itself is LogBotGUI

understand?  A .gui file merely indicates that it contains code, and that the convention is for that code to be GUI code.  The actual GUI itself is declared inside that file and has been given a name.  You can put multiple GUIs in one file if you want, so how would  canvas.pushdialog(home.gui); be able to figure out which one to open?  It makes more sense that you use the name of the GUI control and not the file that it happens to be saved in.


Code: [Select]
    if(LogBotGUI.isawake())
        canvas.popdialog(LogBotGUI);
    else
        canvas.pushdialog(LogBotGUI);

The name of the actual GUI itself is LogBotGUI
No it isn't, if you look at his file
Code: [Select]
new GuiControl(home.gui) {
He wants to call the gui "home"

Haha, I was helping him correctly rename it last night. I was getting him to change it to HomeGUI. Unfortunately he had to go though.

No it isn't

His gui is already named LogBotGUI and that is a perfectly fine name.
You don't need to make this any more confusing than it already is.

To clarify
The usage of home.gui was in reference to the name of the file, which can be as ambiguous as he wants.  I'm the one that originally inferred that he tried to name it "home" and was clearly wrong.

His original code
Code: [Select]
canvas.pushdialog(LogBotGUI.gui);should have tipped me off otherwise earlier.

Naming an object "home" is terrible namespace, there is a decent chance that something else may come along named the same thing, and suddenly the code will no longer work.
« Last Edit: April 24, 2013, 03:19:45 PM by Nexus »

I only changed it when it said "Home"


Here's the updated file
Alright, I will try my best to explain :

Your GUI Control's name is "home.gui". You need to name this something else such as "LogBotHome" and don't try "Home" because like Nexus said, their are many other client mods which may use a GUI Control called "Home" since it is a common name. For example -

Code: [Select]
new GuiControl(LogBotHome) {

...and you'd have to update your client.cs script to accommodate for that -

Code: [Select]
if(LogBotHome.isawake()) //assuming that home is the name of your gui
          canvas.popdialog(LogBotHome);
     else
          canvas.pushdialog(LogBotHome);
}

That code simply needs to be replaced. When we say that only .cs or .gui files are executable in Blockland, it doesn't apply to functions such as ::pushDialog() or ::popDialog(), this is when you are tying to exec(""); a file.

I will thank you forever! Now I am beginning to understand it all! I thought that the GUI had to be named the same as the file.gui is named. Silly me. =P  Thank you for all of the help. Ill let you know if I mean when i need your help again.

Can you guys give me some useful controls for guis?


ALSO, in the picture below, there are 2 boxes that I can type in and then an enter button near the center. How to I make it so when I press the Enter button, it updates the variables before adding the variables?
« Last Edit: April 24, 2013, 06:25:44 PM by MrLoganator111 »

When you create a text edit control, you should give it a specific name, such as myTextInput for example
Then to read what people have written in the text box, you do this

Code: [Select]
%input = myTextInput.getValue();

Then you can do whatever you want with %input
After reading the text in the box, you can then clear the text box by doing

Code: [Select]
myTextInput.setValue("");

Thanks Nexus!

Ok so now Im doing an Overhaul on the gui. I am making multiple pages so I can have more commands. Im trying to make it so when I click a button, it closes the current LogBotHome gui and opens up the LogBotServerCmds gui. I put this in, but it just closes LogBotHome.

Code: [Select]
          command = "canvas.popdialog(LogBotHome);";
         altCommand = "canvas.popDialog(LogBotServerCmds);";

Thanks Nexus!

Ok so now Im doing an Overhaul on the gui. I am making multiple pages so I can have more commands. Im trying to make it so when I click a button, it closes the current LogBotHome gui and opens up the LogBotServerCmds gui. I put this in, but it just closes LogBotHome.

Code: [Select]
         command = "canvas.popdialog(LogBotHome);";
         altCommand = "canvas.popDialog(LogBotServerCmds);";
Do this to make it work:
Code: [Select]
command = "canvas.popdialog(LogBotHome);canvas.pushDialog(LogBotServerCmds);";

Remember, canvas.pushDialog(GUI); is to open a GUI and canvas.popDialog(GUI); is to close a GUI.

I suggest that once you start having a button do multiple things with one click, it might be a good idea to give that button its own function.

Code: [Select]
command = "special_button_function();";

Code: [Select]
function special_button_function()
{
    canvas.popdialog(LogBotHome);
    canvas.pushDialog(LogBotServerCmds);
}