print scenario id

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
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

print scenario id

Post by vghetto »

Hi,
I want to print the scenario id to the console so I could tell which scenarios produced the console errors and warnings.
Anyone knows how to grab the id of the current scenario?

Code: Select all

    -- This event is loaded in each scenario
    [event]
        name=prestart

        [wml_message]
            message="Loading scenario <$what should go here???>"
            logger=err
        [/wml_message]
    [/event]
Thanks!
User avatar
octalot
General Code Maintainer
Posts: 786
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: print scenario id

Post by octalot »

I've called the variable here nfw_... just because this code is in the Non-Fatal Wounds mod:

Code: Select all

    [lua]
        # This seems to be readable only via Lua
        code=<<
            wml.variables["nfw_current_scenario_id"] = wesnoth.scenario.id
        >>
    [/lua]
    
    # WML can use the value in nfw_current_scenario_id here
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: print scenario id

Post by vghetto »

octalot wrote: January 8th, 2022, 7:25 am I've called the variable here nfw_... just because this code is in the Non-Fatal Wounds mod:

Code: Select all

    [lua]
        # This seems to be readable only via Lua
        code=<<
            wml.variables["nfw_current_scenario_id"] = wesnoth.scenario.id
        >>
    [/lua]
    
    # WML can use the value in nfw_current_scenario_id here
Ah, thank you!
wesnoth.scenario.id didn't work on 1.14, but taking a peek at 1.14's Non-Fatal Wounds I found wesnoth.game_config.scenario_id.
Neither of which are documented under the wiki's LuaWML/LuaAPI pages btw.
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: print scenario id

Post by Celtic_Minstrel »

wesnoth.scenario is documented on the main Wesnoth module page; wesnoth.game_config.scenario_id is still documented on one of the LuaWML subpages for the time being.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: print scenario id

Post by beetlenaut »

Is there any reason why we don't have a [store_scenario] tag? There are several values in a scenario that aren't exposed to WML.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: print scenario id

Post by Celtic_Minstrel »

I don't think there's any reason, other than that no-one bothered to add it.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: print scenario id

Post by vghetto »

Celtic_Minstrel wrote: January 9th, 2022, 7:11 pm wesnoth.scenario is documented on the main Wesnoth module page; wesnoth.game_config.scenario_id is still documented on one of the LuaWML subpages for the time being.
Ah, I missed them. Thank you.
Post Reply