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

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

Moderator: Forum Moderators

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

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

Post by Can-ned_Food »

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
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

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

Post by Tad_Carlucci »

I forked real life and now I'm getting merge conflicts.
User avatar
Pentarctagon
Project Manager
Posts: 5496
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

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

Post by Pentarctagon »

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
Iris
Site Administrator
Posts: 6796
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

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

Post by Iris »

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.
Can-ned_Food
Posts: 217
Joined: December 17th, 2015, 10:27 pm

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

Post by Can-ned_Food »

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