Why not LUA?
Moderator: Forum Moderators
Re: Re:
A few things:mihoshi wrote:http://code.google.com/p/luadialogexamp ... BottlesDlgSapient wrote: This I did not know... can we see some examples of LUA being used as a highly nested markup language?
There are also scripts that work with that structure here http://code.google.com/p/luadialogexamp ... /FrontPage, but they are with comments in Russian.
- 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
Re: Re:
Well, that's just a constructor of a Lua data object. Except for "return" word in the beginning of file.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?
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/
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.- 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'.
Also there are code wrappers for different languages, including several for c++.
http://lua-users.org/wiki/LuaAddons
It can be as compact, safe and readable as WML, at least. And as I said, there are tools for binary seralization.- this kind of thing is likely unconducive as a saved game format or to send data over the network with.
Re: Why not LUA?
It wasn't a comparison, it was a (slightly Off-Topic) idea. But, it was an interesting idea, nonetheless.mihoshi wrote: How is that better than?Code: Select all
...
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."
Re: Why not LUA?
Taking a somewhat conservative stance, I can explain all the advantages in two words:mihoshi wrote:appleide wrote:...
Less changes.
Why did the fish laugh? Because the sea weed.
Re: Why not LUA?
Well then, I'll return to this question when I'll be able to back my arguments better.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.
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?
Re: Why not LUA?
I would say most of them are.mihoshi wrote:Well then, I'll return to this question when I'll be able to back my arguments better.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.
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?
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
Re: Why not LUA?
They all use variables and conditionals Especially Under the Burning sun. I really don't understand what is "non-coder" then...Dave wrote:I would say most of them are.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?
Under the Burning Suns. The Rise of Wesnoth. Any of Turin's campaigns.
Re: Why not LUA?
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.
Re: Why not LUA?
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
And I hate stupid people.
The World of Orbivm
Re: Why not LUA?
Woah, I underestimated dread factor of "real programming language" :pturin 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...
Re: Why not LUA?
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.mihoshi wrote: They all use variables and conditionals Especially Under the Burning sun. I really don't understand what is "non-coder" then...
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
Re: Why not LUA?
So it seems mostly psychological, then. Really, there is (from my "coder view") no big difference betweenDave wrote: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.mihoshi wrote: They all use variables and conditionals Especially Under the Burning sun. I really don't understand what is "non-coder" then...
[...] 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.
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]
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',
},
},
}
Re: Why not LUA?
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 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.
Re: Why not LUA?
Well, I think I'd rather use Python, since we already use that and I think our development community is more familiar with it.mihoshi wrote: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 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'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
Re: Why not LUA?
Not an exhaustive list, but here's the first things that came to mind: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.)
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
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."