Why not LUA?

Discussion among members of the development team.

Moderator: Forum Moderators

Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Re:

Post by Dave »

mihoshi wrote:
Sapient wrote: This I did not know... can we see some examples of LUA being used as a highly nested markup language?
http://code.google.com/p/luadialogexamp ... BottlesDlg
There are also scripts that work with that structure here http://code.google.com/p/luadialogexamp ... /FrontPage, but they are with comments in Russian.
A few things:

- sure one can write Lua like this, but how is it written back out programatically? Is there a standard for writing and storing Lua?
- doing things like this would require us using Lua's C API to access the data structures. We'd either have to load and convert, or use the C API throughout. In a word, 'ugh'.
- this kind of thing is likely unconducive as a saved game format or to send data over the network with.
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Re: Re:

Post by mihoshi »

Dave wrote: A few things:

- sure one can write Lua like this, but how is it written back out programatically? Is there a standard for writing and storing Lua?
Well, that's just a constructor of a Lua data object. Except for "return" word in the beginning of file.
Data can be serialized from Lua in a similar fashion - generate constructor, write it to file and then evaluate it to load.

There are binary serialization tools for Lua too http://luaforge.net/projects/pluto/
- doing things like this would require us using Lua's C API to access the data structures. We'd either have to load and convert, or use the C API throughout. In a word, 'ugh'.
You can keep config.hpp mostly intact, just changing config.cpp to use Lua tree of Lua tables instead of tree of string maps. That way most of code that work with config will stay intact, I believe.

Also there are code wrappers for different languages, including several for c++.
http://lua-users.org/wiki/LuaAddons
- this kind of thing is likely unconducive as a saved game format or to send data over the network with.
It can be as compact, safe and readable as WML, at least. And as I said, there are tools for binary seralization.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Why not LUA?

Post by Sapient »

mihoshi wrote: How is that better than

Code: Select all

...
?
It wasn't a comparison, it was a (slightly Off-Topic) idea. But, it was an interesting idea, nonetheless.

mihoshi -- after reviewing all your arguments, I am still not convinced that LUA (a generic scripting language) would be better for coding Wesnoth scenarios than WML (a language designed specifically for coding Wesnoth scenarios). It really boils down to reduced verbosity for complex new tasks (with LUA) versus ease of use for non-coders (with WML). The other arguments are really minor and/or subjective in my view. Wesnoth has chosen ease of use for non-coders, and I agree with that decision.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Re: Why not LUA?

Post by appleide »

mihoshi wrote:
appleide wrote:...
Taking a somewhat conservative stance, I can explain all the advantages in two words:
Less changes.
Why did the fish laugh? Because the sea weed.
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Re: Why not LUA?

Post by mihoshi »

Sapient wrote: mihoshi -- after reviewing all your arguments, I am still not convinced that LUA (a generic scripting language) would be better for coding Wesnoth scenarios than WML (a language designed specifically for coding Wesnoth scenarios). It really boils down to reduced verbosity for complex new tasks (with LUA) versus ease of use for non-coders (with WML). The other arguments are really minor and/or subjective in my view. Wesnoth has chosen ease of use for non-coders, and I agree with that decision.
Well then, I'll return to this question when I'll be able to back my arguments better.

Just one question now - what is a "non-coder"? Someone who can't/won't undestand concept of variables and conditionals? Can you point any great Wesnoth campaign that is done by non-coder?
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Why not LUA?

Post by Dave »

mihoshi wrote:
Sapient wrote: mihoshi -- after reviewing all your arguments, I am still not convinced that LUA (a generic scripting language) would be better for coding Wesnoth scenarios than WML (a language designed specifically for coding Wesnoth scenarios). It really boils down to reduced verbosity for complex new tasks (with LUA) versus ease of use for non-coders (with WML). The other arguments are really minor and/or subjective in my view. Wesnoth has chosen ease of use for non-coders, and I agree with that decision.
Well then, I'll return to this question when I'll be able to back my arguments better.

Just one question now - what is a "non-coder"? Someone who can't/won't undestand concept of variables and conditionals? Can you point any great Wesnoth campaign that is done by non-coder?
I would say most of them are.

Under the Burning Suns. The Rise of Wesnoth. Any of Turin's campaigns.
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Re: Why not LUA?

Post by mihoshi »

Dave wrote:
mihoshi wrote: Well then, I'll return to this question when I'll be able to back my arguments better.

Just one question now - what is a "non-coder"? Someone who can't/won't undestand concept of variables and conditionals? Can you point any great Wesnoth campaign that is done by non-coder?
I would say most of them are.

Under the Burning Suns. The Rise of Wesnoth. Any of Turin's campaigns.
They all use variables and conditionals :) Especially Under the Burning sun. I really don't understand what is "non-coder" then...
User avatar
appleide
Posts: 1003
Joined: November 8th, 2003, 10:03 pm
Location: Sydney,OZ

Re: Why not LUA?

Post by appleide »

Non-coders can be described as those whose first 'programming' language is WML, and also those who uses CampGen to create campaigns instead of writing their own WML.
Why did the fish laugh? Because the sea weed.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Re: Why not LUA?

Post by turin »

Let's put it like this - I would almost certainly never have attempted to make my own campaign if campaigns had been scripted in Lua (or Python) when I joined...
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Re: Why not LUA?

Post by mihoshi »

turin wrote:Let's put it like this - I would almost certainly never have attempted to make my own campaign if campaigns had been scripted in Lua (or Python) when I joined...
Woah, I underestimated dread factor of "real programming language" :p
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Why not LUA?

Post by Dave »

mihoshi wrote: They all use variables and conditionals :) Especially Under the Burning sun. I really don't understand what is "non-coder" then...
It's someone who hasn't done code before joining Wesnoth. Someone who has never used Python or Ruby or Perl or Lua or Java or anything the least bit advanced in a shell script or any of that.

I think in most Open Source game projects that use 'traditional' plugin languages most content creators end up being coders -- people with a coding background. Wesnoth isn't like this. Content creators have told me many times that they love how easy Wesnoth is to start creating scenarios for, and how they'd never be able to do it if it was in a 'normal' programming language.

To most of these people, WML is about as hard as HTML, which they see as tractable.

The thing to understand is that to a coder, Lua or Python or similar would be much easier than WML, but to a non-coder, WML is much much easier.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
pauxlo
Posts: 1047
Joined: September 19th, 2006, 8:54 pm

Re: Why not LUA?

Post by pauxlo »

Dave wrote:
mihoshi wrote: They all use variables and conditionals :) Especially Under the Burning sun. I really don't understand what is "non-coder" then...
It's someone who hasn't done code before joining Wesnoth. Someone who has never used Python or Ruby or Perl or Lua or Java or anything the least bit advanced in a shell script or any of that.
[...] Content creators have told me many times that they love how easy Wesnoth is to start creating scenarios for, and how they'd never be able to do it if it was in a 'normal' programming language.

To most of these people, WML is about as hard as HTML, which they see as tractable.

The thing to understand is that to a coder, Lua or Python or similar would be much easier than WML, but to a non-coder, WML is much much easier.
So it seems mostly psychological, then. Really, there is (from my "coder view") no big difference between

Code: Select all

#textdomain wesnoth-tutorial
[unit]
    id=Quintain
    name= _ "Quintain"
    race=wose
    image="units/quintain.png"
    movement=1
    hitpoints=57
    level=1
    cost=10
    usage=mixed fighter
    movement_type=treefolk
    alignment=neutral
    unit_description= _ "Quintains are used to practice swordplay and jousting on. It would be extremely unusual to be attacked by one."
    [resistance]
        blade=100
        pierce=100
    [/resistance]
    get_hit_sound=staff.wav
    [attack]
        name=flail
        description= _"flail"
        # closest image available
        icon=attacks/morning-star.png
        type=impact
        range=melee
        [specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage=3
        number=5
    [/attack]
    [attack_anim]
        [attack_filter]
            name=flail
        [/attack_filter]
        hits=yes
        [frame]
            begin=-200
            end=-100
            image=units/quintain.png
        [/frame]
        [frame]
            begin=-100
            end=50
            image=units/quintain-attack1.png
            sound=mace.wav
        [/frame]
        [frame]
            begin=50
            end=125
            image=units/quintain-attack2.png
        [/frame]
        [frame]
            begin=125
            end=200
            image=units/quintain.png
        [/frame]
    [/attack_anim]
    [attack_anim]
        [attack_filter]
            name=flail
        [/attack_filter]
        hits=no
        [frame]
            begin=-200
            end=-100
            image=units/quintain.png
        [/frame]
        [frame]
            begin=-100
            end=50
            image=units/quintain-attack1.png
            sound={SOUND_LIST:MISS}
        [/frame]
        [frame]
            begin=50
            end=125
            image=units/quintain-attack2.png
        [/frame]
        [frame]
            begin=125
            end=200
            image=units/quintain.png
        [/frame]
    [/attack_anim]
[/unit]
and

Code: Select all

textdomain = wesnoth-tutorial
return unit {
    id='Quintain',
    name= "Quintain",
    race='wose',
    image="units/quintain.png",
    movement=1,
    hitpoints=57,
    level=1,
    cost=10,
    usage='mixed fighter',
    movement_type='treefolk',
    alignment='neutral',
    unit_description= "Quintains are used to practice swordplay and jousting on. It would be extremely unusual to be attacked by one.",
    resistance = {
        blade=100,
        pierce=100,
    },
    get_hit_sound='staff.wav',
    attack {
        name='flail',
        description= "flail",
        -- closest image available
        icon='attacks/morning-star.png',
        type='impact',
        range='melee',
		  specials {
				WAEPON_SEPCIAL_MAGICAL
        },
        damage=3,
        number=5
    },
	 attack_anim {
        attack_filter {
            name=flail,
        },
        hits=yes,
        frame {
            begin=-200,
            end=-100,
            image='units/quintain.png'
        },
        frame {
            begin=-100,
            end=50,
            image='units/quintain-attack1.png',
            sound='mace.wav',
        },
        frame {
            begin=50,
            end=125,
            image='units/quintain-attack2.png',
        },
        frame {
            begin=125,
            end=200,
            image='units/quintain.png',
        },
    },
    attack_anim {
        attack_filter {
            name=flail,
        }
        hits=no,
        frame {
            begin=-200,
            end=-100,
            image='units/quintain.png',
        },
        frame {
            begin=-100,
            end=50,
            image='units/quintain-attack1.png',
            sound= SOUND_LIST.MISS,
        },
        frame {
            begin=50,
            end=125,
            image='units/quintain-attack2.png',
        },
        frame {
            begin=125,
            end=200,
            image='units/quintain.png',
        },
    },
}
(I took this random example from the tutorial ... maybe I could have selected something shorter.) I don't really now Lua, just looked through the manual to find the things I needed to translate this (and I didn't try this out, so you don't need to point now out some syntax errors.)
mihoshi
Posts: 52
Joined: February 16th, 2008, 10:18 pm

Re: Why not LUA?

Post by mihoshi »

Dave wrote: The thing to understand is that to a coder, Lua or Python or similar would be much easier than WML, but to a non-coder, WML is much much easier.
I see. Well, if it is a case, what do you think about using Lua as auxilary to WML? Using WML generally, but allowing Lua fragments here and there, where WML power is not enough, mainly in conditionals and expressions (about same way as SkeletonCrew proposed). And may be allow Lua structures as an option to describe static data - like in pauxlo's example.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Why not LUA?

Post by Dave »

mihoshi wrote:
Dave wrote: The thing to understand is that to a coder, Lua or Python or similar would be much easier than WML, but to a non-coder, WML is much much easier.
I see. Well, if it is a case, what do you think about using Lua as auxilary to WML? Using WML generally, but allowing Lua fragments here and there, where WML power is not enough, mainly in conditionals and expressions (about same way as SkeletonCrew proposed). And may be allow Lua structures as an option to describe static data - like in pauxlo's example.
Well, I think I'd rather use Python, since we already use that and I think our development community is more familiar with it.

I'm also working on a pure functional language to be embedded in and augment WML, that I hope non-developers will find easy enough to use.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Why not LUA?

Post by Sapient »

pauxlo wrote: (I took this random example from the tutorial ... maybe I could have selected something shorter.) I don't really now Lua, just looked through the manual to find the things I needed to translate this (and I didn't try this out, so you don't need to point now out some syntax errors.)
Not an exhaustive list, but here's the first things that came to mind:

1) When reading the file later, you have to scan upwards to figure out which '}' matches the other (Keep in mind that some of our WML authors use Notepad or Wordpad, with no syntax highlighting). Once you unbalance the thing it can become a real mess to figure out where you went wrong.

If you look in our C++ files you will always find lines like this:

Code: Select all

} // end of namespace gui
There's a reason that comment is in there... and notice it is more verbose than "[/namespace]"

2) All string literals have to be enclosed with appropriate quote marks

3) Thus, there must be an escape syntax for special characters within strings

4) very easy to forget a comma
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Post Reply