GUI Controls

Gui Controls are used to pop up a window on the players screen, on client-side. The functions that are used are:

function onPlayerGrabs(pl) {
    var popup = GUI.showpopup({
        title: "Welcome to " + Server.getconfig().gamename + "!",
        width: 400,
        height: 300
    });
    popup.innerHTML = '<br><center>Enter text:</center>' +
        '<input id="textfield" type="text" style="position:absolute;left:80px;top:100px;width:300px;height:30px;" value="Texttt"></input>' +
        '<select id="selectfield" style="position:absolute;left:80px;top:140px;width:300px;height:40px;font-size:24px;">' +
        '  <option>SWORD</option>' +
        '  <option selected>HEAD</option>' +
        '  <option>BODY</option>' +
        '</select>' +
        '<input id="actionbutton1" type="submit" class="button" style="left:132px;top:250px;width:200px;height:40px;" value="Finish"></input>';

    var self = this;
    GUI.onclick("actionbutton1", function(event) {
        pl.chat = "text: " + GUI.get("textfield").value + " - " + GUI.get("selectfield").value;
        GUI.hidepopup();
    });
}  

// Hide button by id
GUI.hide("actionbutton1");

// Hide button by object
let button = GUI.get("actionbutton1");
GUI.hide(button);

// Get current value of text inputs or select fields
let value = GUI.get("textfield").value;
echo("value: " + value); // prints it on browser developer console

// Change the text of a text input
GUI.get("textfield").value = "hmmm";