custom ON event

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderators: Forum Moderators, Developers

Forum rules
Before posting a new idea, you must read the following:
Post Reply
enclave
Posts: 835
Joined: December 15th, 2007, 8:52 am

custom ON event

Post by enclave » May 21st, 2018, 8:37 pm

Hi,

Could there be a custom on event creator for something?

For example, I have array or variable with some name "player[1].gold" and ON modification of that array or variable the custom event would fire...
for example:

Code: Select all

[custom_on_event]
variable=player[1..9].gold
event=custom_event1
[/custom_on_event]

[event]
name=custom_event1
[modify_side]
		side=$side_number
		gold=$player[$side_number].gold
[/modify_side]
[/event]
This could save some coding necessity in some cases... I'm sure there could be more uses for that than my example.. not sure what though :)
I guess it would be slow as well...

PS. the potential application I could see would be to make multiple addons compatible with each other..
where eg. one of addons uses some macro or event to modify some array or side gold.. and the other addon would be able to react on that, providing it's own code as addition to that..

PPS. I guess what I offered is already doable.. if I put a code into wesnoth.theme_items that would check some array for changes... and on seing a change, fire some event... never thought of it before... but such hack is not very coder friendly (not for a basic WML content maker for sure)

User avatar
Ravana
Moderator
Posts: 1831
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: custom ON event

Post by Ravana » May 21st, 2018, 9:03 pm

You can implement this as metatable.

Post Reply