LightFighter's Lua Lab

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

Moderators: Forum Moderators, Developers

Re: LightFighter's Lua Lab

Postby silene » November 27th, 2010, 9:13 am

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"])
silene
 
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: LightFighter's Lua Lab

Postby bumbadadabum » November 27th, 2010, 11:16 am

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:
User avatar
bumbadadabum
Developer
 
Posts: 1005
Joined: March 20th, 2008, 5:54 pm
Location: Netherlands

Previous

Return to Lua Labs

Who is online

Users browsing this forum: No registered users and 3 guests