Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: SupSuper on Wed 31/05/2006 16:40:49

Title: Is it possible to change OnClick at runtime?
Post by: SupSuper on Wed 31/05/2006 16:40:49
Is it possible to change a button's OnClick function at runtime? (through code)

Basically, I'm creating a customizable confirm box, and I'd like to be able to change what the Yes button does without having to use Global Variables or some such. Heck, if I could create a Win32 MessageBox function lookalike that returns whatever button is pressed, that'd be grand.
Title: Re: Is it possible to change OnClick at runtime?
Post by: Ashen on Wed 31/05/2006 16:48:55
You could use a variable inside the OnClick function to change what effect it has, but AFAIK that's the only way to 'change' it's functioning.

Someone (probably SSH) released a confirmation GUI/Module a while back that does pretty much what it sounds like you're after. I can't find it right now unfortunately, but it's out there.

EDIT: OK, apparently it's bundled with SSH's SaveGames with Screenshots (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23320.0) Module. You might also be interested in this thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23869.0), unless I've misunderstood the question.
Title: Re: Is it possible to change OnClick at runtime?
Post by: SSH on Wed 31/05/2006 17:05:58
It doesn't work very well, though, that one. I've thought about redoing it, recently...
Title: Re: Is it possible to change OnClick at runtime?
Post by: edmundito on Wed 31/05/2006 18:28:20
All you need to do is split what each click does to different functions, and then control them through the onClick. For example, let's say that I when I click the first time ever it does something, but the second time it does something different. Here's a simple solution for that:


short clickturn = 0;

function onClick(...)
{
    if(clickturn == 0) doOneThing();
    else doAnotherThing();
    clickturn = clickturn + 1;
}
Title: Re: Is it possible to change OnClick at runtime?
Post by: SSH on Thu 01/06/2006 12:51:16
For a customisable confirm box, try my  new DialogBox module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26842.0)