dumb questions about lua
Moderator: Forum Moderators
dumb questions about lua
Hello!
I am planning an empire builder, and after checking other works, I figured I was going to need to learn Lua. So after reading the wiki page, I'm still slightly confused.
What does Lua do that normal wml cannot?
How and when is Lua used in an event?
Thanks!
I am planning an empire builder, and after checking other works, I figured I was going to need to learn Lua. So after reading the wiki page, I'm still slightly confused.
What does Lua do that normal wml cannot?
How and when is Lua used in an event?
Thanks!
Guys I never thought I'd come back to this forum after 8 years this is wild
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: dumb questions about lua
Most importantly, it can "reload" and execute changed action lua (or wml) on-the-fly, that means, without the need to go to the mainscreen, press F5, and restart the scenario in order to reflect changes, making developing/debugging addons *much* more fast and convenient. (This was the main reason for me to start with lua.)Boldek wrote:What does Lua do that normal wml cannot?
There is quite a number of powerful features which are not available in wml and also can't be made available easily. wesnoth.synchronize_choice and the wesnoth.game_events.x stuff for instance.
I leave the other questions for our growing lua coder community.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: dumb questions about lua
A lot of things. Lua can be used even to create new WML tags, and the Wesnoth Lua Pack is an example of this. Also, Lua is much faster than WML, at the point that in the Lua equivalent of the {FADE_*} macros, I had to add an additional key to control the speed of fading.Boldek wrote:What does Lua do that normal wml cannot?
I usually use Lua to create additional tags; in certain situations, one can also embed Lua code in a WML file, by using the [lua] tag, but then the on-the-fly reload won't work anymore.Boldek wrote:How and when is Lua used in an event?
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- artisticdude
- Moderator Emeritus
- Posts: 2424
- Joined: December 15th, 2009, 12:37 pm
- Location: Somewhere in the middle of everything
Re: dumb questions about lua
If you're just starting Lua and you don't have a whole lot of programming experience other than WML, I'd suggest taking a look at these links (they helped me get started). They aren't Wesnoth-specific, but they'll help you get to know the language to some extent, which should make programming lua for Wesnoth purposes a bit easier.
http://lua.gts-stolberg.de/en/index.php
http://foldit.wikia.com/wiki/Lua_Script ... eginner_1)
The Lua reference manual on http://www.lua.org can also be helpful, but since it's a reference rather than a tutorial it might not necessarily be the best place to start from if you haven't had a whole lot of programming experience in the past.
EDIT: Some of the links in this thread on the Unreal Software forums lead to some very nice Lua tutorials designed for beginners.
http://lua.gts-stolberg.de/en/index.php
http://foldit.wikia.com/wiki/Lua_Script ... eginner_1)
The Lua reference manual on http://www.lua.org can also be helpful, but since it's a reference rather than a tutorial it might not necessarily be the best place to start from if you haven't had a whole lot of programming experience in the past.
EDIT: Some of the links in this thread on the Unreal Software forums lead to some very nice Lua tutorials designed for beginners.
"I'm never wrong. One time I thought I was wrong, but I was mistaken."
Re: dumb questions about lua
And here's a short reference which I found very useful too.
Re: dumb questions about lua
Thanks everyone!
Guys I never thought I'd come back to this forum after 8 years this is wild
- battlestar
- Posts: 690
- Joined: January 1st, 2007, 7:12 am
Re: dumb questions about lua
I'm reading this book:
I find it an enjoyable easy read, especially with a lot of examples. But reading a whole book probably covers more than what's necessary.
I find it an enjoyable easy read, especially with a lot of examples. But reading a whole book probably covers more than what's necessary.
LUA: Llama Under Apprenticeship
Hell faction: completed
Hell faction: completed
- Roraborialis
- Posts: 12
- Joined: April 15th, 2012, 10:41 pm
Re: dumb questions about lua
So I could, for instance, make a tag that would do to defense ratings what steadfast does to resistances, and reuse it whenever I need to make a new ability for handling a defense rating boosting ability, or damaging attack? Or a tag for causing a given ability to target your target instead of yourself? One which causes an effect to last for a turn?Elvish_Hunter wrote:I usually use Lua to create additional tags; in certain situations, one can also embed Lua code in a WML file, by using the [lua] tag, but then the on-the-fly reload won't work anymore.Boldek wrote:How and when is Lua used in an event?
Is WML's tag framework written in lua?
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: dumb questions about lua
Partly it is. The other parts are in C++.
Do note that you can only create new action tags. For abilities you'd need event-driven ones.
Do note that you can only create new action tags. For abilities you'd need event-driven ones.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
- Roraborialis
- Posts: 12
- Joined: April 15th, 2012, 10:41 pm
Re: dumb questions about lua
So I cannot do an entire skill via lua, Not exactly what I was asking, but I should have worded it and it is good to know. Thank you.Anonymissimus wrote:Partly it is. The other parts are in C++.
Do note that you can only create new action tags. For abilities you'd need event-driven ones.
So, Of the following, what could possibly be made into a working tag:
Use a tag for variable logic.
Trigger a predetermined WML event using variables written within the tag:
Examples:
Code: Select all
[DefRating]
sub=20
##Add, sub, divide, or multiply are all valid.
terrain=
##Uses normal terrain values. Leave blank or omit to include all terrains.
dur=turn
##Where Turn, Cure, and till Move are valid. Omit for it to be active whenever the conditions for it to be met.
[/DefRating]
Example usage: Units that have increased defense ratings at night. An attack that causes the target to become more likely to become hit.
Code: Select all
[Filter]
[Trigger]
Trigger on=2
##Trigger on being the value that T will trigger the event
And=4
##Secondary variable needed for the trigger to work, omit or leave blank. It is represented by A.
Not=1
##Teritiary variable that if met, will prevent the trigger from activating.
[/Trigger]
[/Filter]
Example usage in practice: If the unit hits twice and has attacked four times without getting hit, trigger extra attacks.
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: dumb questions about lua
Please note that, from 1.11.0, support for [object] duration=turn will be available.Roraborialis wrote:One which causes an effect to last for a turn?
This seems me like a thing that can be done with event-driven abiities. The right place for asking these things will be the WML Workshop then.Roraborialis wrote:Example usage in practice: If the unit hits twice and has attacked four times without getting hit, trigger extra attacks.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: dumb questions about lua
...If you want to use WML. If you want to use Lua, you should start your own thread here in Lua Labs, or have this one split.Elvish_Hunter wrote:The right place for asking these things will be the WML Workshop then.