Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: papste on Fri 26/06/2009 07:30:39

Title: Disabled control gets automatically enabled when character changes room
Post by: papste on Fri 26/06/2009 07:30:39
I have disabled the control btnWalk "btnWalk.Enabled = false;" which is connected to the SetCursorMode (mode 0). However the button gets enabled automatically every time the character changes room. Is there a way to avoid this? I want the button to stay permanently disabled until i decide to re-enable it.

Having to program the command  "if (condition == true) btnWalk.Enabled = false" at room load (Before fade in) would not be a desired solution, meaning i have to add it to the script for every single room individually.

(edit): I am using version AGS 3.1.2 SP1
Title: Re: Disabled control gets automatically enabled when character changes room
Post by: Shane 'ProgZmax' Stevens on Fri 26/06/2009 08:03:32
What version of AGS are you using?  I haven't encountered this problem but one way around it is, rather than to disable the button entirely, just go into the runscript call when the button is pressed and do a quick global boolean check that you can set true/false to allow walking.  This way you could also have a message pop-up explaining why the person can't walk right now.
Title: Re: Disabled control gets automatically enabled when character changes room
Post by: Khris on Fri 26/06/2009 08:31:07
Quote from: papste on Fri 26/06/2009 07:30:39meaning i have to add it to the script for every single room individually.

No, you don't:

// global script

function on_event (EventType event, int data) {
  if (event == eEventEnterRoomBeforeFadein) {
    if (condition) btnWalk.Enabled = false;
  }
}
Title: Re: Disabled control gets automatically enabled when character changes room
Post by: Pumaman on Tue 07/07/2009 20:33:28
This is a good point, it's because Walk buttons get automatically linked to the "Player character visible" room setting.

The easiest way round it is to change the button from doing a Set Cursor Mode to a Run Script, and then just put some script in it to set the cursor mode to Walk. That way, AGS won't automatically link it to the Player Character Visible setting.