LightFighter's Lua Lab

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: LightFighter's Lua Lab

Post by silene »

LightFighter wrote:

Code: Select all

wesnoth.set_variable("cfg.save_in", cfg[wesnoth.get_variable "difficulty"])
Because of the quotes, that will store the value into a variable called "cfg.save_in" (that is, "[cfg]save_in=") instead of the correct place. Also it may be userfriendlier to provide a default variable name:

Code: Select all

wesnoth.set_variable(cfg.save_in or "quantity", cfg[wesnoth.get_variable "difficulty"])
User avatar
Astoria
Inactive Developer
Posts: 1007
Joined: March 20th, 2008, 5:54 pm
Location: Netherlands

Re: LightFighter's Lua Lab

Post by Astoria »

silene wrote:
LightFighter wrote:

Code: Select all

wesnoth.set_variable("cfg.save_in", cfg[wesnoth.get_variable "difficulty"])
Because of the quotes, that will store the value into a variable called "cfg.save_in" (that is, "[cfg]save_in=") instead of the correct place. Also it may be userfriendlier to provide a default variable name:

Code: Select all

wesnoth.set_variable(cfg.save_in or "quantity", cfg[wesnoth.get_variable "difficulty"])
I know I have a lot to learn... :oops:
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
Post Reply