preload event and F5 don't play nice

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
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

preload event and F5 don't play nice

Post by doofus-01 »

I was trying to use a status icon in the sidebar, like is mentioned here: http://wiki.wesnoth.org/LuaWML:Display# ... heme_items

I put it in a preload event:

Code: Select all

[event]
    name=preload
    first_time_only=no
    [lua]
        code=<<
            local _ = wesnoth.textdomain "wesnoth-Bad_Moon_Rising"
            local old_unit_status = wesnoth.theme_items.unit_status
            function wesnoth.theme_items.unit_status()
                local u = wesnoth.get_displayed_unit()
                if not u then return {} end
                local s = old_unit_status()
                if u.status.freezing then  
                    table.insert(s, { "element", {
                        image = "misc/icy.png",
                        tooltip = _"freezing: This unit will die if it stays in frost terrain."
                    } })
                end
                return s
            end
        >>
    [/lua]
    [set_variable]
        name=bmr_lua_tooltip
        value=fired
    [/set_variable]
[/event]
It did work, a few times. Mostly, it doesn't - it just doesn't show up. I have no idea why it worked when it did, I used the same WML and same save-file, and got different results.

I'm attaching what I think is the relevant WML(EDIT:no need, see below), but the nickel summary is: All the other status handling does work, the intended effects happen, so this isn't a vanilla WML problem, I don't think. I put that [set_variable] "bmr_lua_tooltip" thing in the preload event so that I could check if the event fired with :inspect, but I never see it (I also haven't gotten the status icon to show up since then).

Does a variable set in preload just get thrown out? Does it mean the event isn't firing (which would explain things)? When does preload event fire? At the moment, I do not believe what the wiki says.

I'm using 1.9.9, linux, source, if that matters
---------------------------------
EDIT: not long after posting, I figured it out (isn't that the way it goes...) Reloading the cache with F5 causes the preload event to not fire. If I kill wesnoth and restart, the event fires -> the variable is visible in :inspect, the status icon shows up. If I go back to title screen, press F5, then load the same save-file, and go through the same motions, the status icon and "bmr_lua_tooltip" variable are MIA. Re-loading the save-file has no effect.

I'll visit the bug tracker...
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: preload event and F5 don't play nice

Post by Anonymissimus »

Should be fixed as of r51290.
What is MIA btw ?
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
Alarantalara
Art Contributor
Posts: 786
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: preload event and F5 don't play nice

Post by Alarantalara »

MIA = missing in action. Sort of like dead, but you can't find the body.
Post Reply