Okay, I'm trying to make a GUI that displays the buttons on an elevator. GUI 2 is the panel and button 0 is the first button. My goal is to make it so when the player clicks button 0, the doors close, the command parser waits for 3 seconds, the doors open again, and the character walks out. I've never actually done direct scripting before, so I've probably screwed up some mundane detail:
#sectionstart interface_click // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(2, 0) {
// This function is obsolete, from 2.62 and earlier versions.
gui[2].Visible = false;
// Elevator doors close.
object[0].Visible = true;
object[0].SetView(9);
object[0].Animate(0, 5, eOnce, eBlock);
object[0].StopAnimating();
object[0].SetView(11);
// Elevator moves.
Wait(120);
// Elevator doors open.
object[0].SetView(10);
object[0].Animate(0, 5, eOnce, eBlock);
object[0].StopAnimating();
object[0].SetView(12);
// Todd exits.
character[Todd].Walk(97, 151, eBlock);
character[Todd].changeroom(3, 305, 167);
}
When I try to test the game, I get a PE03: Parse Error at '2' on that second line. GUI 2 does exist, so I don't understand what the problem is.
One thing that bothers me is that comment that reads "this function is obsolete." Is there a more recent function I should be using? Please help.
If you want to use the obsolete function, the code should be:
function interface_click(int interface, int button) {
if ((interface == 2) && (button == 0)) {
//The rest of your code here
}
}
However, if you want to do it in a more up to date way, go to the GUI Editor, select GUI 2, and double click the correct button (you must give it a name first). Then put your code within the script function that pops up.
EDIT: Nevermind, going to use a dialog instead of a GUI. Thanks anyway.
GG's answer will be good next time you come to making a GUI for something, though. And you really should use the 'up to date' method, not interface_click.