[SOLVED] WML and Lua: Lua engine parsing too much?

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

Moderators: Forum Moderators, Developers

Post Reply
Can-ned_Food
Posts: 152
Joined: December 17th, 2015, 10:27 pm

[SOLVED] WML and Lua: Lua engine parsing too much?

Post by Can-ned_Food » October 20th, 2017, 12:33 pm

I'm not certain how to document this, report it as a glitch, or whether either of those should be done.

The lua engine seems to parse through any lines between a code= and the [/lua]. I know this because i had something like

Code: Select all

[lua]
    code=<<
        local party = 'Do you love me?'
        wesnoth.message(
            'Big Brother' ,
            party
             )
         >>
#       local bad-name = 'junk'
[/lua]
And, of course, i got complaints of the 0x2D being unexpected and all that jazz.
Last edited by Can-ned_Food on November 12th, 2017, 4:10 am, edited 1 time in total.

Tad_Carlucci
Developer
Posts: 273
Joined: April 24th, 2016, 4:18 pm

Re: WML and Lua: Lua engine parsing too much?

Post by Tad_Carlucci » October 20th, 2017, 2:19 pm

I forked real life and now I'm getting merge conflicts.

User avatar
Pentarctagon
Forum Administrator
Posts: 3418
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: WML and Lua: Lua engine parsing too much?

Post by Pentarctagon » October 20th, 2017, 3:23 pm

Can-ned_Food wrote:I'm not certain how to document this, report it as a glitch, or whether either of those should be done.

The lua engine seems to parse through any lines between a code= and the [/lua]. I know this because i had something like

Code: Select all

[lua]
    code=<<
        local party = 'Do you love me?'
        wesnoth.message(
            'Big Brother' ,
            party
             )
         >>
#       local bad-name = 'junk'
[/lua]
And, of course, i got complaints of the 0x2D being unexpected and all that jazz.
That code fragment causes no errors for me. I'm not sure what you were expecting it to do though - if the problem is it causes an error when that variable is uncommented, then that seems like it'd be expected, since you're declaring a lua variable outside of where lua code is understood.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

User avatar
shadowm
Site Administrator
Posts: 6415
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: WML and Lua: Lua engine parsing too much?

Post by shadowm » October 20th, 2017, 4:20 pm

The Lua engine only runs the contents of the code attribute, by the way. The <<text here>> syntax is part of the WML preprocessor (added specifically to enable writing embedded Lua) and it specifies that the string contained is to have any " characters and all preprocessor directives in it ignored, including brace substitutions since braces are part of the Lua syntax. So if there really is a problem it’s not from the Lua engine.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Elsewhere: shadowmBlogFollow me on Twitter

Can-ned_Food
Posts: 152
Joined: December 17th, 2015, 10:27 pm

Re: WML and Lua: Lua engine parsing too much?

Post by Can-ned_Food » October 20th, 2017, 7:05 pm

Well, gee, it must've been a problem with the caching. I cannot delete this topic now that it has replies, but it should be deleted.

Post Reply