Annoying error: <lua> Repeated [endlevel] execution, ignored

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Spannerbag
Posts: 553
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Annoying error: <lua> Repeated [endlevel] execution, ignored

Post by Spannerbag »

Hi,
I have a situation where a number of units may be [kill]ed simultaneously.

Code: Select all

    [kill]
      [filter_location]
        find_in=fb
      [/filter_location]
      animate=yes
      fire_event=yes			# Player loses if leader killed
      [primary_attack]
        type=fire
      [/primary_attack]
    [/kill]
The scenario also has multiple leaders and if any leader dies the player loses.
If 2+ leaders are [kill]ed simultaneously their respective last breath and die events fire.
Their last breaths are all delivered then an on-screen message appears saying <lua> Repeated [endlevel] execution, ignored (1 less than number of leaders killed, which makes sense to me).
I can see why the message appears; there will indeed be several encounters with the same endlevel code:

Code: Select all

  [endlevel]
    result=defeat
  [/endlevel]
Thinking it was maybe because I had this code in the last breath I moved it into a separate die event, but I'm still seeing the message.

If I reduce the number of leaders to 1 everything works fine.

So I know (I hope) why the error is occurring but I'd like to know if there is any way to suppress it or change the code so it doesn't appear on screen?

Options I can think of:
  • Downgrade all but one leaders to heroes, but it wouldn't fit with the story.
  • Kill units individually so die events fire do the same.
    This would work (I imagine) but it would look odd in the context of the scenario where multiple units are clearly affected at once.
  • Use harm_unit to animate damage but do not kill any units.
    Then manually kill them singly afterwards, but this seems a bit messy and awkward.
So... any other ideas/suggestions?
Am I missing something obvious?

Cheers,
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Ravana
Forum Moderator
Posts: 3064
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Annoying error: <lua> Repeated [endlevel] execution, ignored

Post by Ravana »

[fire_event] the [endlevel] call, but have the event containing [end_level] first_time_only=yes.
User avatar
Spannerbag
Posts: 553
Joined: December 18th, 2016, 6:14 pm
Location: Yes

[RESOLVED]<lua> Repeated [endlevel] execution, ignored

Post by Spannerbag »

Ravana wrote: May 6th, 2024, 6:57 pm [fire_event] the [endlevel] call, but have the event containing [end_level] first_time_only=yes.
Thanks for the reply, much appreciated!

Heh, was just going to post to say I'd fixed it; as often happens right after posting, I had a bit of inspiration.
Wish I had it before posting... :annoyed:

The die events were "global" (in _main.cfg) so I bodged it by adding a flag to leave the last breaths alone but suppress the die event whilst multiple kills were being actioned.
The I tested to see if at least one leader was missing with [have_unit] and if so fire a losing endlevel.

It's an 'orrible hack but this was my solution (bear in mind I wanted the die events to work as they used to elsewhere).
Haven't rigorously tested the logic yet but it works as expected in other parts of this scenario when a single leader dies so I'm pretty confident.

Thanks again for taking the trouble to reply and sorry I wasted your time.

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
lhybrideur
Posts: 376
Joined: July 9th, 2019, 1:46 pm

Re: Annoying error: <lua> Repeated [endlevel] execution, ignored

Post by lhybrideur »

The horrible way I did it was to set a variable in the event and have an if at the beginning of the event that was triggering its content only if the variable is not set. I then clear the variable later.

Code: Select all

        [event]
                name=last breath
                first_time_only=no
                [...]
                [if]
			[variable]
				name=todo
				equals=no
			[/variable]
			[else]
			       {VARIABLE todo no}
			       [...]	
			[/else]
		[/if]
	[/event]
User avatar
Spannerbag
Posts: 553
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Annoying error: <lua> Repeated [endlevel] execution, ignored

Post by Spannerbag »

lhybrideur wrote: May 7th, 2024, 7:00 am The horrible way I did...
Yep, similar concept/logic.
Great minds... :)

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
Post Reply