Please note that this is only for TFS 1.0+ and Tibia version 9.7 or later.
Modal windows are windows that you can form by adding certain things to it like buttons, choice input, text.
Modal windows can be useful a large variety of things, all it requires is knowledge and creativity.
Click here for a list of all the ModalWindow functions
I'm not gonna go in-depth on modal windows, but I'm gonna give you an example with a play-by-play to show you how to properly work with modal windows. If you don't your server to crash, please follow this carefully.
Pick your free colored tapestry!
You need something that will trigger and send a modal window to the player.
In my example, I used a simple item. You can do it in any other way you want, this is purely for example.
Constructing the modal window and sending to player:
ModalWindow:sendToPlayer() only sends the window, when the window has been answered (press of button, etc) the onModalWindow() event in CreatureScripts will be triggered!
Keep in mind, the player has to have the event registered first before sending the modal window!
CreatureEvent onModalWindow():
Summary
Modal windows are windows that you can form by adding certain things to it like buttons, choice input, text.
Modal windows can be useful a large variety of things, all it requires is knowledge and creativity.
Click here for a list of all the ModalWindow functions
I'm not gonna go in-depth on modal windows, but I'm gonna give you an example with a play-by-play to show you how to properly work with modal windows. If you don't your server to crash, please follow this carefully.
Pick your free colored tapestry!
You need something that will trigger and send a modal window to the player.
In my example, I used a simple item. You can do it in any other way you want, this is purely for example.
Constructing the modal window and sending to player:
ModalWindow:sendToPlayer() only sends the window, when the window has been answered (press of button, etc) the onModalWindow() event in CreatureScripts will be triggered!
Keep in mind, the player has to have the event registered first before sending the modal window!
CreatureEvent onModalWindow():
Summary
- You want to register the modal window CreatureEvent before sending it to the player or else the player will not receive anything
- You want to unregister the modal window CreatureEvent when the player receives it. That way the player can receive the modal window cleanly and appropriately again in the future
- Modal windows, buttons, and choices all have IDs that you need to define. This will allow you to check which modal window, which button, which choice the player has selected in onModalWindow()
- Buttons and choices are all optional. You can have a modal window that only has buttons. You can even have 4 buttons instead of 2 (4 is maximum though). It's pretty darn flexible.
- The setDefaultEnter/EscapeButton(id) takes only 1 parameter, the id of the button
- setDefaultEnterButton triggered when double-clicking or Enter key pressed
- setDefaultEscapeButton triggered when Escape key pressed
- Be creative! Modal windows have opened up a lot of opportunities for developers to create!