Changing OnClick event through script

Started by artium, Mon 03/09/2018 20:54:14

Previous topic - Next topic

artium

Is it possible to assign a function as OnClick event to a bunch of buttons through script (at runtime)?

Khris

You cannot change which function runs initially after a click at runtime, but you can of course change the button's behavior in other ways, namely by then calling other functions / code based on variables.

If you tell us what your goal is, we can tell you the best way to achieve it.

artium

Inuse the VerbCoin template.

I was thinking of ways make the VerbCoin script easier to integrate into existing games(add the script and make as few editor and main script changes as possible)

Currently, to work properly it requires to register a callback in the main script for the  OnClick event for each verb button, and call VerbCoin::OnClick function from inside it.

I was thinking that since this button is registered at the beginning in RegisterButton, I could also set it's OnClick cllback.

SMF spam blocked by CleanTalk