FAQ: wrong number of parameters in call to unhandled_event

Started by Pumaman, Thu 01/01/2004 15:16:49

Previous topic - Next topic

Pumaman

Error message "wrong number of parameters in call to unhandled_event"
(might get similar message for dialog_request, on_mouse_click or on_key_press)

This means you have declared a specific AGS script function with the wrong number of parameters. For example, the unhandled_event function is defined as having two parameters, so it must look like this in your global script:

function unhandled_event(int what, int type) {
 Display("You can't do that.");
}

If you do not have the "what" and "type" parameters, you will get this error.

"But it worked in 2.56", you say. Correct, but the 2.56 compiler was not as strict and did not check for these errors. It may have seemed to work anyway, but could have caused some underlying problems and strange bugs later on. The new compiler makes sure you do it right.

What are the "what" and "type" parameters for? They allow you to distinguish between different types of unhandled event - so that you can give a different message if the player tried to talk to something, than if they tried to look at something. See the manual for a full list of the what and type meanings.


SMF spam blocked by CleanTalk