on_event context
Moderator: Forum Moderators
-
- Posts: 1456
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: on_event context
You want to use on_event to create a preload event? I really don't think that will work, since on_event would need to be in preload. You'd be creating an event after it has already started, or just hoping your new one would be called once the current one is done. Even if it worked, I'm missing the point (though that happens a lot).
Speak softly, and carry Doombringer.
- hermestrismi
- Posts: 730
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: on_event context
it is just a theoric approach. I was thinking that all I need is the table (potion_location) and the image file. so, I thought of two solutions: either create a wml variables (x,y,pot,image) and then a wml event (turn refresh ..) to check and redraw. or stick with lua and pass the table as a parameter or condition (if #potion_location ~= 0 then..) to a 'on_event preload'.white_haired_uncle wrote: ↑July 21st, 2024, 5:31 am You want to use on_event to create a preload event? I really don't think that will work, since on_event would need to be in preload. You'd be creating an event after it has already started, or just hoping your new one would be called once the current one is done. Even if it worked, I'm missing the point (though that happens a lot).
well, the second option is not possible from the wiki. preload events can't handle such lua code
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
Re: on_event context
on_event has to run during preload, you can just do what you need instead of creating new preload event that will never be used.
-
- Posts: 1456
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: on_event context
I looked at the persistent_tags wiki entry and couldn't make much sense of it.hermestrismi wrote: ↑July 21st, 2024, 5:38 am
it is just a theoric approach. I was thinking that all I need is the table (potion_location) and the image file. so, I thought of two solutions: either create a wml variables (x,y,pot,image) and then a wml event (turn refresh ..) to check and redraw. or stick with lua and pass the table as a parameter or condition (if #potion_location ~= 0 then..) to a 'on_event preload'.
well, the second option is not possible from the wiki. preload events can't handle such lua code
Personally, I would just use wml.array_access.get and wml.array_access.set to keep potion_location in sync with a WML array, and then create my events with
wesnoth.add_event_handler.
I suspect wml.array_access.get_proxy would be preferable to wml.array_access.get and wml.array_access.set, but I've never played with it.
Speak softly, and carry Doombringer.
Re: on_event context
There appears to be a working example of persistent tags in the tutorial campaign.hermestrismi wrote: ↑July 21st, 2024, 5:24 am thank you for details. I should know that, really. I get much time to code it. I tried to use persistent tags but I m not familiar with and looks hard for me (I need much time of try and lose).
is there any exemple (commented for steps and details) that can help other than the one in the wiki?
- hermestrismi
- Posts: 730
- Joined: February 6th, 2016, 11:28 pm
- Location: Tunisia
- Contact:
Re: on_event context
thank you. I am surprised that it is easier than I thought with this tutorialgnombat wrote: ↑July 21st, 2024, 10:41 amThere appears to be a working example of persistent tags in the tutorial campaign.hermestrismi wrote: ↑July 21st, 2024, 5:24 am thank you for details. I should know that, really. I get much time to code it. I tried to use persistent tags but I m not familiar with and looks hard for me (I need much time of try and lose).
is there any exemple (commented for steps and details) that can help other than the one in the wiki?
The Dark Master, The Dark Hordes (Unofficial version), Return of the Legion , Eternal Kingdom, An Elvish Scout,Unrest in Elfland , Hidden War ...
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
The Dark Master Project, Arabic tra. maintainer
"But he loves you" G. Carlin
- Celtic_Minstrel
- Developer
- Posts: 2371
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: on_event context
There are some examples in core, I believehermestrismi wrote: ↑July 21st, 2024, 5:24 am is there any exemple (commented for steps and details) that can help other than the one in the wiki?
I think there's mostly no point in doing that. It probably works if you put it in a global Lua tag, but at that point, what's the difference from just putting your code there without using an event? There may be some cases where that's useful, but this isn't one of them.hermestrismi wrote: ↑July 21st, 2024, 5:24 am and what if I on_event to create a preload_event just like the move to one?