There's a problem that's completely stumped me. I'm attempting to change my player's walk speed and view using a GUI. In my GUI are two buttons of relevance named btnRunOn and btnRunOff.
function btnRunOn_Click(GUIControl *control, MouseButton button)
{
player.SetWalkSpeed(12, 12);
player.ChangeView(2);
}
function btnRunOff_Click(GUIControl *control, MouseButton button)
{
player.SetWalkSpeed(6, 6);
player.ChangeView(1);
}
I've been editing my code for the last few days, trying new things each time, yet I get the same issue: My buttons don't seem to do anything. Both buttons are set to RunScript, everything is set to Clickable, there are no transparent elements overlaying them, their names are spelt correctly and their animations register as expected, they just won't run the function. What could the problem be? Thank you in advance.
Whenever there's something not working, the first thing to do is to find out whether these functions are run at all. You can do this in two ways:
1. Use a very simple command that creates a visible effect. "Display" is usually best for this.
2. Place a "breakpoint" inside the function and see if it triggers when you run the game and press this button.
You set breakpoints by either clicking on a empty piece of panel to the left from the script, or F9 key, or right click -> Toggle Breakpoint.
If you find out that the function does not run, yet the button animates as pressed, then double check that the event is actually connected to the button, similar to this:
https://adventuregamestudio.github.io/ags-manual/images/acintro3_02.png
You're right, they weren't linked. Note to self: If there's no function name next to the event name, they aren't linked. Rookie mistake, I apologize. Thanks for the help.