[SOLVED] [variable] Get a variable from the "game settings" panel

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
Zatiranyk
Posts: 13
Joined: May 4th, 2018, 8:00 pm

[SOLVED] [variable] Get a variable from the "game settings" panel

Post by Zatiranyk »

Hello!

So I'm building a small multiplayer scenario and I want to get a variable from the "game settings" panel when the user creates his game. For example here I want to know if the user choose to set a random start time for his game. So i want to get this value from my WML code and use it in a "if" tag, like this:

Code: Select all

[if]
    [variable]
        name="random_start_time"
        equals=yes 
    [/variable]
    [then]
        ...
    [/then]
[/if]
where "random_start_time" should be the value defined by the user in the "game settings" panel. I would accept LUA solution too.

Thanks!
Last edited by Zatiranyk on June 30th, 2019, 8:43 pm, edited 2 times in total.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: [variable] Get a variable from the "game settings" pannel

Post by Ravana »

In Lua it is wesnoth.game_config.mp_settings.mp_random_start_time.
User avatar
Pentarctagon
Project Manager
Posts: 5527
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: [variable] Get a variable from the "game settings" panel

Post by Pentarctagon »

You could also put that into a WML variable via:

Code: Select all

[lua]
	code=<<
		wml.variables["random_start_time"] = wesnoth.game_config.mp_settings.mp_random_start_time
	>>
[/lua]
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Zatiranyk
Posts: 13
Joined: May 4th, 2018, 8:00 pm

Re: [variable] Get a variable from the "game settings" panel

Post by Zatiranyk »

So i guess there is no pure WML solution for that ^^ I'll try this! Ty very much, you reply so quickly :)
Post Reply