Author Topic: How do I make guis?  (Read 3513 times)

Oh, I was thrown off by his "so you don't need to press a button for it to work" comment.

Yeah, parent PlayGui::onWake(%this) and call your function. Then as the last line of your function do something like cancel($myFunctionSched); $MyFunctionSched = schedule(500, 0, myFunction);

Then, parent PlayGui::onSleep(%this) and add in cancel($MyFunctionSched); to stop the loop from running when you're not looking at the play screen anymore (e.g. main menu).

Would checking for server connection's object work too?

Oh, I was thrown off by his "so you don't need to press a button for it to work" comment.

Yeah, parent PlayGui::onWake(%this) and call your function. Then as the last line of your function do something like cancel($myFunctionSched); $MyFunctionSched = schedule(500, 0, myFunction);

Then, parent PlayGui::onSleep(%this) and add in cancel($MyFunctionSched); to stop the loop from running when you're not looking at the play screen anymore (e.g. main menu).
you mean like this: PlayGui::onWake(%this) ServerConnection.getPing() cancel($myFunctionSched); $MyFunctionSched = schedule(500, 0, myFunction); parent::PlayGui::onSleep(%this) cancel($MyFunctionSched);
Please mind that  I am extremely new to coding.

You need to format it, look at someone else's code to see how they do it. What you posted has to be in a function. It also has to be in a package because you're parenting something.

Also your parent is onSleep but you're doing something with onWake.

Where he put myFunction you need to replace it with the name of your function. You should have a separate function to handle the schedule and echoing the ping or doing whatever you want to do with it. You should just have your parent of playGUI::onWake call your function once and it'll handle your schedule from there.

Example:

function myPingLoop() {
    echo(serverConnection.getPing());
    cancel($myPingLoopSchedule);
    $myPingLoopSchedule = schedule(500, 0, myPingLoop);
}

You need to format it, look at someone else's code to see how they do it. What you posted has to be in a function. It also has to be in a package because you're parenting something.

Also your parent is onSleep but you're doing something with onWake.

Where he put myFunction you need to replace it with the name of your function. You should have a separate function to handle the schedule and echoing the ping or doing whatever you want to do with it. You should just have your parent of playGUI::onWake call your function once and it'll handle your schedule from there.

Example:

function myPingLoop() {
    echo(serverConnection.getPing());
    cancel($myPingLoopSchedule);
    $myPingLoopSchedule = schedule(500, 0, myPingLoop);
}
Ah I see, it looked like a command to me at first, so do I paste it into the bottom of the gui script?

After your package of onWake and onSleep, yeah. And just have onWake call the function and onSleep cancel the schedule.

After your package of onWake and onSleep, yeah. And just have onWake call the function and onSleep cancel the schedule.
But, how to I make this into a download able mod? I mean, the GUI is part of the play gui insted of its own canvas. Do I just save the play gui with the other gui?

It might help to know what you're tying to do. Do you want to print it on the playGUI? Take a look at another add-on to learn how to package code into a working add-on.

But, how to I make this into a download able mod? I mean, the GUI is part of the play gui insted of its own canvas. Do I just save the play gui with the other gui?

Save only your GUI, then do PlayGUI.add(YourGUI) to add it to the PlayGUI. You might need to reset its position after doing that.

Save only your GUI, then do PlayGUI.add(YourGUI) to add it to the PlayGUI. You might need to reset its position after doing that.
Thanks! But the thing I  want is  the ping number, ON The gui, not the console

Thanks! But the thing I  want is  the ping number, ON The gui, not the console

That's where coding comes in. You've been given an example of a function that will get the ping every x ms, and you have a GUI. Put them together.