preload event and F5 don't play nice

The place to post your WML questions and answers.

Moderators: Developers, 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.

preload event and F5 don't play nice

Postby doofus-01 » September 26th, 2011, 2:48 am

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...
Bad Moon Rising | Trinity(WIP) | Archaic Era | Tales of the Setting Sun(On Hold/Abandoned)
Available for BfW 1.10 but only actively developed for BfW 1.11/1.12
User avatar
doofus-01
Art Contributor
 
Posts: 2767
Joined: January 6th, 2008, 9:27 pm
Location: USA

Re: preload event and F5 don't play nice

Postby Anonymissimus » September 26th, 2011, 1:55 pm

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
Anonymissimus
Developer
 
Posts: 2411
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: preload event and F5 don't play nice

Postby Alarantalara » September 26th, 2011, 11:12 pm

MIA = missing in action. Sort of like dead, but you can't find the body.
User avatar
Alarantalara
Mac OS X Packager
 
Posts: 755
Joined: April 23rd, 2010, 8:17 pm
Location: Canada


Return to WML Workshop

Who is online

Users browsing this forum: Bing [Bot] and 2 guests