Difference between revisions of "SoC2011 Student Page Aethaeryn"

From The Battle for Wesnoth Wiki
m (Questionnaire: formatting)
m (link cleanup)
 
(41 intermediate revisions by 3 users not shown)
Line 2: Line 2:
  
 
==Description==
 
==Description==
<h4>Michael Babich - Improving Lua Add-ons' Abilities in Interfaces</h4>
+
<h4>Michael Babich - Improving Lua's User Interface Capabilities</h4>
This main goal of this proposal is to improve the capability of the Lua scripting language when used for creating add-ons, specifically with the various interfaces visible to the users while playing the game. This project will focus on providing simple, but powerful syntax for a broad range of features that enable add-on creators to have improved and easier access to features that mostly already exist within the game engine so that they are free to creatively provide more innovative content. The purpose of this project is to act as a middleman between the game engine and the add-on creators using the Lua scripting language so that simple and powerful add-on creation can help revolutionize future MP, just as [set_menu_item] and [option] allowed for a great evolution in the quality of add-ons since 1.3. This interface framework needs to be as broad as possible in the time given and the scope allowed so that creative add-on authors themselves can stretch Wesnoth content far beyond its traditional style, but it also must provide a simplified Lua helper library so that everyone can use it without necessarily having to delve deeply into the complexity that exists in the currently-existing GUI.
+
I intend to improve the ability for add-ons to customize the user interface through Lua. I will focus on providing simple, but powerful syntax for a set of functions that will enable add-on creators to have improved, easier access to features that already exist within the game engine so that they are free to creatively provide more innovative content.
  
==The Necessity of Improvements to Simplify and Extend Lua's Add-on Capabilities==
+
The purpose of this project is to act as a middleman between the game engine and the add-on creators using the Lua scripting language so that simple and powerful add-on creation can help revolutionize future MP, just as [set_menu_item] and [option] allowed for a great evolution in the quality of add-ons since 1.3. This interface framework needs to be as broad as possible in the time given and the scope allowed so that creative add-on authors themselves can stretch Wesnoth content far beyond its traditional style, but it also must provide a simplified Lua helper library so that everyone can use it without necessarily having to delve deeply into the complexity that exists in the currently-existing GUI.
 +
 
 +
==IRC==
 +
Aethaeryn, Aeth
 +
 
 +
==Introduction==
 
I have been making content for Wesnoth since 2007 and I have been gradually porting much of my more advanced content to Lua since late 2009. While doing so, I have noticed certain limitations to the current implementation of Lua as it relates to add-on creation, especially with certain elements only possible through WML or the rather poorly readable WML tables. As the title suggests, I wish to simply and extend the add-on creation capabilities in Lua. In particular, I will be working with various elements of the interface code because this is currently where Lua is weak and often just relying on WML tables. There are several problems with using WML tables in these areas:
 
I have been making content for Wesnoth since 2007 and I have been gradually porting much of my more advanced content to Lua since late 2009. While doing so, I have noticed certain limitations to the current implementation of Lua as it relates to add-on creation, especially with certain elements only possible through WML or the rather poorly readable WML tables. As the title suggests, I wish to simply and extend the add-on creation capabilities in Lua. In particular, I will be working with various elements of the interface code because this is currently where Lua is weak and often just relying on WML tables. There are several problems with using WML tables in these areas:
 
* '''Poor readability, clumsy syntax, and verbosity.''' The metatable in the helper library helps with readability, but does not always work (for instance on [or] and [and] boxes, where those words are reserved in Lua) and it still hides the underlying issue that true native Lua support is not there. It also is fairly difficult in certain applications where the XML-style WML syntax is clearly inferior and much more verbose than something done in pure Lua.
 
* '''Poor readability, clumsy syntax, and verbosity.''' The metatable in the helper library helps with readability, but does not always work (for instance on [or] and [and] boxes, where those words are reserved in Lua) and it still hides the underlying issue that true native Lua support is not there. It also is fairly difficult in certain applications where the XML-style WML syntax is clearly inferior and much more verbose than something done in pure Lua.
Line 11: Line 16:
 
* '''Calling Lua from WML tables is hacky.''' Currently, if one wants to call a Lua function from T.option {}, one has to set a string that is a call on a global Lua function.
 
* '''Calling Lua from WML tables is hacky.''' Currently, if one wants to call a Lua function from T.option {}, one has to set a string that is a call on a global Lua function.
  
Fortunately, there solution is rather obvious. Lua needs to be extended to access features that almost all already exist in the game engine and these must be implemented through Lua functions and tables instead of WML tables so that the full benefits of using Lua for scripting can be realized. Although the problem and solution are fairly easy to describe, certain precautions must be taken to make ensure that save games are not broken and no new issues are introduced. In addition, the individual proposed changes must be enumerated for clarity as to the scope of the project.
+
An ideal scenario or campaign would be one that uses WML to define the basic structure and then call on Lua for any more advanced elements. As I spend most of my Wesnoth time making -- or playing -- content for MP that do things that WML was not originally intended to do, such as making Wesnoth an RPG instead of a TBS, I have noticed that WML does not scale very well as a general purpose language doing advanced scripting. Any traditional language, such as Lua, can handle certain advanced things in a much more readable and efficient manner, but there are certain gaps in Lua where WML tables must be integrated with the Lua, which defeats many of the primary reasons to use Lua in the first place.
 +
 
 +
Fortunately, the solution is rather obvious to the WML table problem. Lua needs to be extended to access features that almost all already exist in the game engine and these must be implemented through Lua functions and tables instead of WML tables so that the full benefits of using Lua for scripting can be realized. Although the problem and solution are fairly easy to describe, certain precautions must be taken to make ensure that save games are not broken and no new issues are introduced. In addition, the individual proposed changes must be enumerated for clarity as to the scope of the project.
  
 
==The Implementation: Overview==
 
==The Implementation: Overview==
Line 19: Line 26:
 
First, src/scripting/lua.cpp should be split into smaller, logically-organized files so that the file does not grow too large and unmanageable with the improvements planned. This has the additional effect of allowing me to get familiar with the core Lua code.
 
First, src/scripting/lua.cpp should be split into smaller, logically-organized files so that the file does not grow too large and unmanageable with the improvements planned. This has the additional effect of allowing me to get familiar with the core Lua code.
  
Next, various UI tags shall be implemented in native Lua without WML tables. The hardest portion of this is ensuring that the Lua changes can be implemented without breaking save files. Most of the existing WML code can be reused, so a key purpose of this is to get rid of the need for WML tables for this portion of the code so that it better interacts with files written purely in Lua and so it is in a consistent style with code in the later portion of this project. The tags that need to be ported to Lua functions:
+
Next, various UI tags shall be implemented in native Lua without WML tables. The hardest portion of this is ensuring that the Lua changes can be implemented without breaking save files. Most of the existing WML code can be reused, so a key purpose of this is to get rid of the need for WML tables for this portion of the code so that it better interacts with files written purely in Lua and so it is in a consistent style with code in the later portion of this project. The trickiest part will be implementing the callback, which will allow menu options to trigger Lua functions.
 +
 
 +
Because the code already exists to handle the WML tags, most of the work is allowing these Lua functions to utilize already-existing code in the engine. In this phase, the Lua functions to be created more or less map one-to-one with WML tags, which is why this would be a "Phase 0". On the surface, the changes may seem subtle, but it will allow for a more Lua way of implementing these than WML tables, which will improve interaction with Lua scripting functions while also making the Lua side of Wesnoth scripting easier to learn. In addition, it will ensure that these very central UI actions are consistent with Phase 1 syntax.
 +
 
 +
The related WML tags that need to be ported to Lua functions:
 
* [message]
 
* [message]
 
** [option]
 
** [option]
Line 26: Line 37:
  
 
===Phase 1: Complex Interface Changes===
 
===Phase 1: Complex Interface Changes===
 +
<!-- fixme: rewrite in the style of the two phases and expand -->
 +
''Note: This section is outdated, I know, but I have to get to it after I actually write the wesnoth.gui_message{} function so I get a feel for the C API and how much time is necessary to do these tasks. I'm probably going to have to add at least two more weeks worth of work on top of what I originally intended.
 +
 
* Implement improved Lua access to the in-scenario GUI stuff, again without WML table hacks.
 
* Implement improved Lua access to the in-scenario GUI stuff, again without WML table hacks.
** This includes improving the syntax and implementation of the [http://wiki.wesnoth.org/LuaWML:Display#wesnoth.show_dialog dialog Lua].
+
** This includes improving the syntax and implementation of the [[LuaWML:Display#wesnoth.show_dialog|dialog Lua]].
 
* A way to take in text commands in a way similar to debug mode's :lua, but only using specific commands to do specific actions as defined by Lua code in the add-on.
 
* A way to take in text commands in a way similar to debug mode's :lua, but only using specific commands to do specific actions as defined by Lua code in the add-on.
  
 
===Phase 2: Simplify Add-on Creation===
 
===Phase 2: Simplify Add-on Creation===
* Implement Lua "ui" package similar to helper that adds an additional abstraction layer on top of Phase 1 to simplify it for add-on creators.
+
Phase 0 and Phase 1 might seem somewhat unrelated, but Phase 2 is intended to unify them under a common, easily-accessible package of sorts that provides a highly-abstracted, clean syntax for add-on authors to manipulate various elements of the UI. The original implementation from Phases 0 and 1 will still exist for those who want more control and customization, while Phase 2 will make things available for those who do not wish to necessarily deal with the complexity. There are two areas that will allow the improvements to be immediately accessible in an easy manner to content authors:
* Create a similar implementation to the above through newly-defined WML tags.
+
* I will implement a Lua "wesnoth.ui" that adds an additional abstraction layer on top of the already existing syntax, simplifying the appearance of the code at the expense of some finer control.
* (The original implemenation will still exist for those who want more control and customizability, while this implementation is available for those who do not wish to deal with the complexity that the interface can actually provide.)
+
* If I have the time, I will create new, defined-in-Lua WML tags that utilize wesnoth.ui so that one does not have to use Lua to benefit from the improvements to Lua.
  
 
==The Implementation: Details==
 
==The Implementation: Details==
 +
<!-- expand -->
 +
 
===Phase 0===
 
===Phase 0===
====gui_message()====
+
The goal of this phase is to implement similar behavior in Lua to important UI-related WML tags so that these elements can be used in Lua without WML tables, thus eliminating clumsy syntax and ensuring complete implementation. Currently, certain parts, including [option], require clumsy workarounds when implemented in WML tables due to the nature of the tag. This also sets the stage for the later phases by establishing a starting point for more complex feature additions.
====option====
+
 
 +
====Sample Syntax====
 +
-- The function can be triggered directly by defining the table in the function call to gui_message{}.
 +
gui_message{
 +
    message  = "Hello world!",
 +
    speaker = "narrator",
 +
    image  = "wesnoth.png",
 +
    options  = {
 +
          { text='hello', callback = foobar() },
 +
          { text='goodbye', callback = say_goodbye() }
 +
    }
 +
}
 +
 +
-- The function can be used indirectly by setting it to a table first, and then using the table's
 +
-- reference variable as an argument for gui_message().
 +
msg = {
 +
    message = "What's your name?",
 +
    -- if the tag is not there, reasonable defaults are set
 +
    -- text_input takes either a table containing the information, or a table of tables that are all valid text_input
 +
    text_input = {variable = "foo", label = "Name: ", max_length = 42}
 +
}
 +
 +
 +
function foobar()
 +
    gui_message(msg)
 +
 
 +
====gui_message{}====
 +
The basic portion of gui_message{} is an implementation of the [message] WML tag without any of the subtags. Through the extensions below it allows absolutely everything in WML [message] to be converted except for the filters, which are better done through plain Lua. Note that the use of {} instead of () for the function means that it technically is fed in a Lua keyed table, meaning that the order of the arguments does not matter as long as they match the key. Default values are used for arguments that are not defined, just like the WML behavior.
 +
 
 +
gui_message {
 +
    message    = string,
 +
    speaker    = string,
 +
    side_for    = integer, -- or a table with a set of integers
 +
    image      = string,
 +
    caption    = string,
 +
    scroll      = boolean,
 +
    duration    = integer,
 +
    sound      = string,
 +
    options    = table, -- see below
 +
    text_input  = table, -- see below
 +
}
 +
 
 +
The best part about this is that the core function (excluding the options and text_input tables) can be easily converted into a form recognizable by WML and handled using the same function that handles the existing [message] code. Complexity and a difference from the WML definition only really enter when implementing [option] and [text_input].
 +
 
 +
The alternative form of gui_message{} is gui_message(table) where table is a table with keys that match the definition of gui_message{}.
 +
 
 +
====options====
 +
<!-- expand -->
 +
 
 +
Options has two possible syntax. If there is only one option, it can directly contain the option table:
 +
 
 +
options = {
 +
    text    = string,
 +
    filter  = condition, -- must evaluate to true for the option to show
 +
    callback = function, -- the actual effect of the command
 +
}
 +
 
 +
If there is more than one option, it must have a table containing tables:
 +
 
 +
options = {
 +
    {
 +
      text    = string,
 +
      filter  = condition, -- must evaluate to true for the option to show
 +
      callback = function, -- the actual effect of the command
 +
    }, {
 +
      text    = string,
 +
      filter  = condition, -- must evaluate to true for the option to show
 +
      callback = function, -- the actual effect of the command
 +
    },
 +
}
 +
 
 +
====callback====
 +
<!-- expand -->
 +
 
 
====text_input====
 
====text_input====
 +
<!-- expand -->
 +
 
====set_menu_item()====
 
====set_menu_item()====
====Calling on Lua Code From a Message====
+
<!-- expand -->
  
 
===Phase 1===
 
===Phase 1===
 +
<!-- expand -->
 +
 
====Dialog Improvements====
 
====Dialog Improvements====
 
====GUI 2 Access====
 
====GUI 2 Access====
====Commands?====
+
====Optional: Commands====
 +
Graphical User Interfaces are great for most tasks, but there are situations where text-based input is a better way for commands to be run. If possible, it would greatly improve the capabilities of Lua if it were able to interpret chat messages. Lua already has the capability to output to chat, but input from chat would allow for Lua to become even more powerful in this area. Commands could be thought of in two different types, each with different use cases:
 +
 
 +
'''Public chat.''' With Lua given the capability to parse public MP chat, this allows for the computer side, the AI, to be able to interact with the players given certain keywords, which would give certain scenarios a more immersive feel. Instead of being merely cosmetic, this chat could have an actual effect on gameplay. For instance, certain taunts could anger the AI, causing it to change tactics to attack a different player or recruit different units.
 +
 
 +
'''Private commands with a /lua command.''' One is currently able to run Lua through :lua when debug mode is on, but this is infeasible for multiplayer. Being able to interpret "/lua command", especially if it were context aware for which hex is currently selected, would allow for several possibilities. For instance, allied AI could uses Lua to respond to your input so that it can formulate a strategy with you. Also, advanced content that could use certain /lua commands to trigger actions, allowing for anything from an MP-compatible "debug mode" to more restrictive triggers that are fitting to the particular scenario. Perhaps the host would use "/lua difficulty hard" to change the difficulty mid-scenario, or a player could use "/lua inventory" on their turn to pop up an RPG-style inventory screen without having to use any right click menus at all.
 +
 
 +
Essentially, the Lua would be able to use certain input as a trigger for executing Lua functions, enabling a far broader range of possibilities for content creators. This would not actually implement any changes to the way the game is played. Rather, it would provide the ability for others to use this new feature in their own scenarios, eras, AI, etc.
  
 
===Phase 2===
 
===Phase 2===
 +
<!-- expand -->
 +
 +
====Sample syntax====
 +
The final goal is to use wesnoth.ui.show() to hide almost all of the interface details by providing a syntactical shortcut to the functions in Phase 0 and Phase 1. More complexity will be possible, as in sample2, but the extremely basic sample1 will be legal syntax as well.
 +
 +
sample1  = {message = "Hello world"}
 +
sample2 = {message = {"Hello world", options = {speaker = "Konrad", side_for = 1}}}
 +
wesnoth.ui.show(sample1)
 +
wesnoth.ui.show(sample2)
 +
 +
This will allow for possibilities like the following, where the GUI message is literally as simple as providing one string:
 +
 +
function message_all(messageText)
 +
    wesnoth.ui.show{message = messageText}
 +
 
====wesnoth.ui====
 
====wesnoth.ui====
  
Line 54: Line 169:
  
 
==The Implementation: Timeline==
 
==The Implementation: Timeline==
 +
''Note: This timeline will be rewritten because I have to get Phase 0 in sooner than I anticipated, thus requiring me to shift up and expand Phase 1, as well as elaborate it in subtasks on the timeline.
 +
 
{| border="1"
 
{| border="1"
| now || April&nbsp;08&nbsp;-&nbsp;April&nbsp;22&nbsp;&nbsp; || Discuss details of the implementation with the various developers so that the proposal is ready for the summer. Work on basic patches, especially in the early areas of Phase 0, so that commit access can be granted before the designated GSOC period. Most of the design needs to be finalized in this period.
+
| now || April&nbsp;08&nbsp;-&nbsp;April&nbsp;22&nbsp;&nbsp; || <h4>Pre-Summer I</h4>
 +
Finalize design.
 +
 
 +
Get most of Phase 0 working.
 
|-
 
|-
| || April 23 - May 08 || Continue to familiarize myself with the project and its code by doing more of Phase 0.
+
| || April 23 - May 08 ||
 +
Finish Phase 0.
 
|-
 
|-
| || May 09 - May 18 || Spring semester ends. Availability may be limited during this period. (The days might be slightly off depending on what the final exam schedule is.)
+
| || May 09 - May 18 || '''Spring semester ends.''' Availability may be limited during this period.
 
|-
 
|-
| || May 19 - May 30 || My schedule should be ''entirely'' free in this time span, so Phase 0 should be completed (if it isn't already finished) and substantial progress should be made on Phase 1.
+
| || May 19 - May 30 || <h4>Summer I</h4>
 +
'''Phase 1 beings.''' (My schedule is be ''entirely'' free in this time span.)
 
|-
 
|-
| || May 31 - June 30 || The entire month of June will be spent on Phase 1.
+
| || May 31 - June 30 || <h4>Summer II</h4>
 +
My summer semester starts. I should still have Fridays through Sundays entirely free.
 
|-
 
|-
 
| || July 4 - July 8 || Expected busy week as my one summer course wraps up.
 
| || July 4 - July 8 || Expected busy week as my one summer course wraps up.
 
|-
 
|-
| || July 9 - July 17 || Phase 1, the bulk of the project, should be concluding around this point. Since this is around the middle evaluation point, part of the focus should be on reviewing the design and plans for the second half of GSOC. If I am ahead of schedule or behind schedule, adjustments can be made.
+
| || July 9 - July 17 || <h4>Middle of GSOC</h4>
 +
'''Phase 1 ends.''' The largest portion of the project, Phase 1, should be concluding around this point.
 +
 
 +
Since this is around the middle evaluation point, part of the focus should be on reviewing the design and plans for the second half of GSOC. If I am ahead of schedule or behind schedule, adjustments can be made.
 
|-
 
|-
| || July 18 - July 22 || Expected busy week as my other summer course wraps up.
+
| || July 18 - July 22 || '''Summer semester ends.''' Expected busy week as my other summer course wraps up.
 
|-
 
|-
| || July&nbsp;23&nbsp;-&nbsp;August&nbsp;15&nbsp; || Phase 2. Again, my schedule should be ''entirely'' free to focus on the project.
+
| || July&nbsp;23&nbsp;-&nbsp;August&nbsp;15&nbsp; || <h4>Summer III</h4>
 +
'''Phase 2 begins.''' Again, my schedule should be ''entirely'' free to focus on the project.
 
|-
 
|-
| || August 15 || According to Google: "'pencils down' date. Take a week to scrub code, write tests, improve documentation, etc."
+
| || August 15 || <h4>Pencils Down Date</h4>
 +
According to Google: "Take a week to scrub code, write tests, improve documentation, etc."
 
|-
 
|-
 
| || lim t<br>t→∞  || Continue to work on Wesnoth's Lua scripting capabilities because it certainly will take more than just one summer to perfect it.
 
| || lim t<br>t→∞  || Continue to work on Wesnoth's Lua scripting capabilities because it certainly will take more than just one summer to perfect it.
Line 80: Line 208:
  
 
==Goals==
 
==Goals==
 +
<!-- expand -->
  
 
==Patches==
 
==Patches==
''Work on the Phase 0 patches will resume immediately after this document is finished and submitted.
+
''Currently, the Phase 0 patches are in progress.
  
 
==Questionnaire==
 
==Questionnaire==
 
+
{| class="collapsible collapsed wikitable"
 +
|-
 +
! Aethaeryn's Questionnaire
 +
|-
 +
|
 
===Basics===
 
===Basics===
  
 
'''1.1) Write a small introduction to yourself.'''
 
'''1.1) Write a small introduction to yourself.'''
  
I am Michael Babich, better known to the Wesnoth community as "Aethaeryn". I'm 20 and I'm from Baltimore, Maryland, USA. I'm currently in my third of five years at [http://www.umbc.edu/ UMBC]. I've been using Linux as my primary operating system since 2005 and I've been involved in the Wesnoth community since 2007. I'm a very big proponent of Linux and open source software, which is why I am currently an officer in my university's Linux Users' Group.
+
I am Michael Babich, better known to the Wesnoth community as "Aethaeryn". I'm 20 and I'm from Baltimore, Maryland, USA. I'm currently in my third of five years at [http://www.umbc.edu/ UMBC]. I've been using Linux as my primary operating system since 2005 and I've been involved in the Wesnoth community since 2007. I love Linux and open source software, which is why I am currently an officer in my university's Linux Users' Group.
  
 
'''1.2) State your preferred email address.'''
 
'''1.2) State your preferred email address.'''
  
[spambot paranoia]
+
[see GSOC submission page]
  
 
'''1.3) If you have chosen a nick for IRC and Wesnoth forums, what is it?'''
 
'''1.3) If you have chosen a nick for IRC and Wesnoth forums, what is it?'''
Line 102: Line 235:
 
'''1.4) Why do you want to participate in summer of code?'''
 
'''1.4) Why do you want to participate in summer of code?'''
  
I love coding, especially for Wesnoth, where I have five in-progress add-ons (they'll be ready when they're ready), one published add-on, and several obsolete add-ons on older versions of Wesnoth (trust me, they weren't that great). I'm also a college student, which means that I don't have much money, and getting paid to sit at my computer and do the kind of stuff I would do anyway rather than having to get a job unrelated to what I do for fun is a perfect opportunity.
+
I love coding, especially for Wesnoth, where I have five in-progress add-ons (they'll be ready when they're ready), one published add-on, and several obsolete add-ons on older versions of Wesnoth (trust me, the old stuff wasn't that great). Even though I'd hypothetically try to contribute the code related to these patches without GSOC paying me, I probably wouldn't be able to follow through on any significantly large mainline project without the GSOC incentive. It would count as an internship so I'd have added motivation to push through even the most difficult parts and I wouldn't have to get a day job so I would actually have ''time'' to code, which is very important. Often, I have lots of things I would code given the time, but I simply don't have the time to accomplish everything I would like to accomplish. GSOC is essentially an excuse to do what I want to do '''and''' have it be my top priority at the same time.
 
 
Of course, even though I'd hypothetically do it anyway without GSOC, I probably wouldn't be able to follow through on any significantly large mainline project without the GSOC incentive because (1) it would go on my resumé as an internship so I'd have added motivation to push through even the most difficult parts and (2) I wouldn't have to get a day job so I would actually have ''time'' to code, which is an important thing too.  
 
  
 
'''1.5) What are you studying, subject, level and school?'''
 
'''1.5) What are you studying, subject, level and school?'''
  
I go to University of Maryland Baltimore County (UMBC), a university that happens to be located in Baltimore County, Maryland.
+
I go to University of Maryland Baltimore County (UMBC). I am an undergraduate in my third year out of five, studying Computer Science, Mathematics, and Philosophy. As of the end of this semester, I have met all of my requirements in Philosophy. For Computer Science and Mathematics, I'm about 1/3 to 1/2 of the way through those programs. While I'm certainly majoring in Computer Science and Philosophy, I might minor in Mathematics instead of majoring in it. I'll have to see how the upper level courses are.
 
 
I am an undergraduate in my third year out of five, studying Computer Science, Mathematics, and Philosophy. As of the end of this semester, I have met all of my requirements in Philosophy. For Computer Science and Mathematics, I'm about 1/3 to 1/2 of the way through those programs. While I'm certainly majoring in Computer Science and Philosophy, I might minor in Mathematics instead of majoring in it. I'll have to see how the upper level courses are.
 
  
 
My GPA is currently 3.713, but it's currently 4.0 in computer science, mathematics, and logic-related philosophy.
 
My GPA is currently 3.713, but it's currently 4.0 in computer science, mathematics, and logic-related philosophy.
Line 116: Line 245:
 
'''1.6) What country are you from, at what time are you most likely to be able to join IRC?'''
 
'''1.6) What country are you from, at what time are you most likely to be able to join IRC?'''
  
I'm from the United States, on the east coast, and I'm almost always on IRC when I'm not at classes. During the summer, I should be on IRC all-day Friday, all-day Saturday, all-day Sunday, and evenings (probably 4pm or 5pm EDT to midnight or later) the rest of the days. I may also be able to be online at other times, such as the mornings. If necessary, I can even host my "screen irssi" on a remote server and simply ssh into it, which would enable me to be "on" IRC even when I'm not on my computer.
+
I'm from the United States, on the east coast, and I'm almost always on IRC when I'm not in class. During much of the summer, I should be on IRC all-day Friday, all-day Saturday, all-day Sunday, and evenings (probably 4pm or 5pm EDT to midnight or later) the rest of the days. I may also be able to be online at other times, such as the mornings. If necessary, I can even host my "screen irssi" on a remote server and simply ssh into it, which would enable me to be "on" IRC even when I'm not on my computer. For other parts of the summer I'll literally be on 24/7 except when RL interferes. See (1.7) and the timeline for when I have other commitments.
  
 
'''1.7) Do you have other commitments for the summer period ? Do you plan to take any vacations ? If yes, when.'''
 
'''1.7) Do you have other commitments for the summer period ? Do you plan to take any vacations ? If yes, when.'''
  
Because of my overly-ambitious academic goals, there's no way to get around taking summer classes, but I'm only going to be taking two (last summer I took four). I have a Monday/Wednesday/Thursday math class from 9:00 AM to 11:05 AM (eastern US time), May 31st to July 8th. I have a Monday/Tuesday/Thursday math class from 1:00 PM to 3:05 PM, May 31st to July 22nd. Other than that, I have no social life outside of school (and it's summer break) and IRC (all except two on my default join list are Wesnoth-related channels). I never go on any vacations.
+
Because of my overly-ambitious academic goals, there's no way to not take summer classes if I ever intend on graduating, but I'm only going to be taking two (last summer I took four). I have a Monday/Wednesday/Thursday math class from 9:00 AM to 11:05 AM (eastern US time), May 31st to July 8th. I have a Monday/Tuesday/Thursday math class from 1:00 PM to 3:05 PM, May 31st to July 22nd. Other than that, I have no social life outside of school (and it's summer break) and IRC (all except two on my default join list are Wesnoth-related channels). I never go on any vacations. So yes, those time slots are literally my only other time commitments for the entirety of summer. For much of May and all of August, I will be doing nothing of importance at all and probably would be spending it on Wesnoth anyway.
 +
 
 +
|-
 +
|
  
 
===Experience===
 
===Experience===
  
My primary strength in terms of experience is that I've been with the Wesnoth project, doing almost everything possible except developing for the game engine itself over the course of almost four years. I know the Lua because I've made add-ons in Lua and will continue to port my active add-ons to Lua as time goes on. I know the community because I am part of it. I know the IRC channels because I've regularly been in many of the channels for years. I'm familiar with a lot of things over the years that might take other people a while to pick up. I've even been using SVN as my means of downloading/updating/playing Wesnoth for at least two years now (for stable, development, and trunk).
+
My primary strength in terms of experience is that I've been with the Wesnoth project, doing almost everything possible except developing for the game engine itself over the course of almost four years. I know the Lua because I've made add-ons in Lua and will continue to port my active add-ons to Lua as time goes on. I know the community because I am part of it. I know the IRC channels because I've regularly been in many of the channels for years. I've even been using S&shy;&shy;V&shy;&shy;N as my means of downloading/updating/playing Wesnoth for at least two years now (for stable, development, and trunk).
  
 
'''2.1) What programs/software have you worked on before?'''
 
'''2.1) What programs/software have you worked on before?'''
  
I have worked on coding projects for school (nothing truly substantial since the time-span to work on them is relatively short), and I have some local things that I have never published. In terms of code that's actually out there on the Internet, published, I have numerous Wesnoth add-ons. These are the ones that are accessible in some way (much of my earlier, unfinished work before wesnoth-umc-dev is currently inaccessible and not that demonstrative of skill, anyway):
+
I have worked on coding projects for school (nothing truly substantial since the time-span to work on them is relatively short), and I have some local things that I have never published. In terms of code that's actually out there on the Internet, published, I have numerous Wesnoth add-ons. In general I have preferred writing Wesnoth MP add-ons instead of my own games from scratch. These are the add-ons that are accessible in some way (not an exhaustive list):
  
 
* [http://files.wesnoth.org/addons/1.6/Just_for_Fun.tar.bz2 (Just For Fun, 1.6 add-on server only)]
 
* [http://files.wesnoth.org/addons/1.6/Just_for_Fun.tar.bz2 (Just For Fun, 1.6 add-on server only)]
Line 140: Line 272:
 
* [http://wesnoth-umc-dev.svn.sourceforge.net/viewvc/wesnoth-umc-dev/trunk/Master_of_Dungeons/ (Master of Dungeons, trunk)]
 
* [http://wesnoth-umc-dev.svn.sourceforge.net/viewvc/wesnoth-umc-dev/trunk/Master_of_Dungeons/ (Master of Dungeons, trunk)]
  
I have collaborated with others on Thunderstone Era/Trilogy and Wesalwyn. I also collaborated on story/dialog parts of Underlands RPG. Some of my earlier works, including some of Era of Tyrants and the oldest scenarios in Aethaeryn's Maps, reused with permission certain code from other GPL'd sources, but MoD is from-scratch, especially since I rewrote most of it in Lua earlier this year. Most of my work here is mostly individual, though. The most substantial and recent example of my coding in Wesnoth add-ons, in Lua, is Master of Dungeons.
+
Also see [[User:Aethaeryn|my user page]]. The most substantial and recent example of my coding in Wesnoth add-ons, in Lua, is Master of Dungeons.
 
 
In general, I have preferred writing Wesnoth MP add-ons instead of my own full games from scratch (at least, in things that I've managed to finish).
 
  
 
'''2.2) Have you developed software in a team environment before? (As opposed to hacking on something on your own)'''
 
'''2.2) Have you developed software in a team environment before? (As opposed to hacking on something on your own)'''
  
I have utilized the Wesnoth-umc-dev SVN repository for my add-ons for two years, and have collaborated with several other users of that repository for a few add-ons, especially Thunderstone Era. Most of my work, especially the unpublished stuff, has been individual, though.
+
I have utilized the Wesnoth-umc-dev SVN repository for my add-ons for two years, and have collaborated with several other users of that repository for a few add-ons. I have collaborated with others on Thunderstone Era/Trilogy and Wesalwyn. I also collaborated on story/dialog parts of Underlands RPG. Some of my earlier works, including some of Era of Tyrants and the oldest scenarios in Aethaeryn's Maps, reused with permission certain code from other GPL'd sources, but MoD is from-scratch, especially since I rewrote most of it in Lua earlier this year. Most of my work has been individual, though.
  
 
'''2.3) Have you participated to the Google Summer of Code before? As a mentor or a student? In what project? Were you successful? If not, why?'''
 
'''2.3) Have you participated to the Google Summer of Code before? As a mentor or a student? In what project? Were you successful? If not, why?'''
  
I have not participated in GSOC before, but I have as part of the Wesnoth community observed GSOC as an outsider. I've always wanted to do a GSOC when I gained enough formal (university) and informal experience with programming and I believe that I am finally ready.
+
I have not participated in GSOC before.
  
 
'''2.4) Are you already involved with any open source development projects? If yes, please describe the project and the scope of your involvement.'''
 
'''2.4) Are you already involved with any open source development projects? If yes, please describe the project and the scope of your involvement.'''
Line 156: Line 286:
 
I have been involved in the Wesnoth community since 2007:
 
I have been involved in the Wesnoth community since 2007:
 
* add-ons (since 2007; published since 1.3.x)
 
* add-ons (since 2007; published since 1.3.x)
* Lua-based add-ons (since 2010)
 
* wesnoth-umc-dev SVN repository (since 2009)
 
 
* unofficial Wesnoth-style sprite art (since 2008)
 
* unofficial Wesnoth-style sprite art (since 2008)
 +
* wesnoth-umc-dev S&shy;&shy;V&shy;&shy;N repository (since 2009)
 +
* wiki moderator (since 2009)
 
* Latin translator (since 2009)
 
* Latin translator (since 2009)
* wiki moderator (since 2009)
+
* Lua-based add-ons (since 2010)
Usually I'm more active in the Wesnoth project during vacations and weekends due to university work taking up a lot of time during the school year.
 
  
 
'''2.5) Gaming experience - Are you a gamer?'''
 
'''2.5) Gaming experience - Are you a gamer?'''
 +
 +
Yes.
  
 
'''2.5.1) What type of gamer are you?'''
 
'''2.5.1) What type of gamer are you?'''
Line 171: Line 302:
 
'''2.5.2) What type of games?'''
 
'''2.5.2) What type of games?'''
  
I love strategy games. I used to be big on RTS games, but ever since I found Wesnoth, the "strategy" part in RTS games seems more and more like a joke because turn based strategy games are far superior in terms of actually giving one enough time to formulate a '''strategy'''. I've played various mainstream/commercial games, such as RTSes, FPSes, and action games, but the only OS I have been using for the past few years is Fedora Linux and I've been focusing on my academics and on programming, so I haven't really kept up to date on the latest games out there. In addition, Wesnoth has shown me that making games can be more fun than playing games (and playing things one makes is the best of both worlds).
+
I love strategy games. I used to be big on RTS games, but ever since I found Wesnoth, the "strategy" part in RTS games seems more and more like a joke because turn based strategy games are far superior in terms of actually giving one enough time to formulate a strategy. I have in the past played various mainstream/commercial games, such as RTSes, FPSes, and action games. However, the only OS I have been using for the past few years is Fedora Linux. I've also been focusing on my academics and on gaining programming experience, so I haven't really kept up to date on the latest games out there. In addition, Wesnoth has shown me that making games can be more fun than playing games (and playing my own games is the best of both worlds).
  
 
'''2.5.3) What type of opponents do you prefer?'''
 
'''2.5.3) What type of opponents do you prefer?'''
Line 183: Line 314:
 
'''2.5.5) Have you played Wesnoth? If so, tell us roughly for how long and whether you lean towards single player or multiplayer.'''
 
'''2.5.5) Have you played Wesnoth? If so, tell us roughly for how long and whether you lean towards single player or multiplayer.'''
  
Almost four years experience, mostly MP but also a significant amount of SP when I first started playing Wesnoth. I've been playing since the 1.2/1.3 versions.
+
Almost four years experience, mostly MP but also a significant amount of SP, especially when I first started playing Wesnoth. I've been playing since the 1.2/1.3 versions.
 +
 
 +
'''2.6) If you have contributed any patches to Wesnoth, please list them below. You can also list patches that have been submitted but not committed yet and patches that have not been specifically written for GSoC. If you have gained commit access to our S&shy;&shy;V&shy;&shy;N (during the evaluation period or earlier) please state so.'''
  
'''2.6) If you have contributed any patches to Wesnoth, please list them below. You can also list patches that have been submitted but not committed yet and patches that have not been specifically written for GSoC. If you have gained commit access to our SVN (during the evaluation period or earlier) please state so.'''
+
I will not be able to submit a patch by the application deadline, but they will be [[SoC2011_Student_Page_Aethaeryn#Patches|here]] when I have the time.
  
I will not be able to submit a patch by the application deadline, but they will be [http://wiki.wesnoth.org/SoC2011_Student_Page_Aethaeryn#Patches here] when I have the time.
+
|-
 +
|
  
 
===Communication skills===
 
===Communication skills===
Line 205: Line 339:
 
'''3.4) Do you give constructive advice?'''
 
'''3.4) Do you give constructive advice?'''
  
Yes.
+
Yes, although I do not believe that I would be able to evaluate myself in an unbiased manner on such an issue. I can only assume that I give good enough advice because people ask me for advice (more than once, of course). I suppose if you were really skeptical Espreon would vouch for me here. I hope.
  
 
'''3.5) Do you receive advice well?'''
 
'''3.5) Do you receive advice well?'''
  
Yes.
+
Yes. I'm a student, so I see myself as a constant learner. If I already knew everything, I wouldn't be applying for GSOC.
  
 
'''3.6) Are you good at sorting useful criticisms from useless ones?'''
 
'''3.6) Are you good at sorting useful criticisms from useless ones?'''
  
Yes.
+
Yes. The Internet these days is all about separating useful from useless content so it's a valuable skill to develop. I'd have no time at all if I was bogged down reading everything out there.
  
 
'''3.7) How autonomous are you when developing? Would you rather discuss intensively changes and not start coding until you know what you want to do or would you rather code a proof of concept to "see how it turn out", taking the risk of having it thrown away if it doesn't match what the project want?'''
 
'''3.7) How autonomous are you when developing? Would you rather discuss intensively changes and not start coding until you know what you want to do or would you rather code a proof of concept to "see how it turn out", taking the risk of having it thrown away if it doesn't match what the project want?'''
  
 
I have no problem with coding many, many hours on my own once I know what I'm supposed to be coding, but I definitely don't want to waste hours working on something that's just going to be thrown out, so I definitely will seek feedback as much as necessary in order to not waste any time/effort.
 
I have no problem with coding many, many hours on my own once I know what I'm supposed to be coding, but I definitely don't want to waste hours working on something that's just going to be thrown out, so I definitely will seek feedback as much as necessary in order to not waste any time/effort.
 +
 +
|-
 +
|
  
 
===Project===
 
===Project===
Line 231: Line 368:
 
'''4.3) Why did you choose this project?'''
 
'''4.3) Why did you choose this project?'''
  
As a long-time add-on creator for Wesnoth, I am aware of certain limitations currently present when one is creating add-ons. Because I have started to port my add-ons into Lua, I have noticed that there are some features that have to be done through hackish WML Tables (essentially coding WML through Lua) because of what appears to be a currently incomplete implementation of Lua. I have noticed that most of these issues seem to be related to various parts of the interface and so that is where I have chosen to focus my efforts, after consulting Crab_ and others on IRC. My eventual, long-term goal is to make Lua powerful enough to handle most of the event-driven scripting side of Wesnoth content while leaving WML to do what it does best, mainly the basic definitional things.
+
As a long-time add-on creator for Wesnoth, I am aware of certain limitations currently present when one is creating add-ons. Because I have started to port my add-ons into Lua, I have noticed that there are some features that have to be done through hackish and inelegant WML Tables (essentially coding WML through Lua) because of what appears to be a currently incomplete implementation of Lua. I have noticed that most of these issues seem to be related to various parts of the interface and so that is where I have chosen to focus my efforts, after consulting Crab_ and others on IRC. My eventual, long-term goal is to make Lua powerful enough to handle most of the event-driven scripting side of Wesnoth content while leaving WML to do what it does best, mainly the basic definitional things. So, yes, this project is one I invented, but I wouldn't say that I invented it on my own because I did ask for advice on IRC in narrowing my topic from the very broad scope of "Lua" to something more specific.
 
 
An ideal scenario or campaign would be one that uses WML to define the basic structure and then call on Lua for any more advanced elements. As I spend most of my Wesnoth time making -- or playing -- content for MP that do things that WML was not originally intended to do, such as making Wesnoth an RPG instead of a TBS, I have noticed that WML does not scale very well as a general purpose language doing advanced scripting. Any traditional language, such as Lua, can handle certain advanced things in a much more readable and efficient manner, but there are certain gaps in Lua where WML tables must be integrated with the Lua, which defeats many of the primary reasons to use Lua in the first place.
 
  
 
'''4.4) Include an estimated timeline for your work on the project. Don't forget to mention special things like "I booked holidays between A and B" and "I got an exam at ABC and won't be doing much then".'''
 
'''4.4) Include an estimated timeline for your work on the project. Don't forget to mention special things like "I booked holidays between A and B" and "I got an exam at ABC and won't be doing much then".'''
  
[http://wiki.wesnoth.org/SoC2011_Student_Page_Aethaeryn#The_Implementation:_Timeline See here for the timeline.]
+
[[SoC2011_Student_Page_Aethaeryn#The_Implementation:_Timeline|See here for the timeline.]]
  
 
'''4.5) Include as much technical detail about your implementation as you can'''
 
'''4.5) Include as much technical detail about your implementation as you can'''
Line 245: Line 380:
 
'''4.6) What do you expect to gain from this project?'''
 
'''4.6) What do you expect to gain from this project?'''
  
* Experience working with a large project with many developers and a mature code-base. The project is massive compared to anything done in university work, so it will provide practical computer science experience that will make programming projects for classes seem extremely trivial.
+
* Experience working with a large project with many developers and a mature code-base. The project is massive compared to anything done in university work, so it will provide practical programming and software engineering experience that will make the programming projects for classes seem extremely trivial.
  
* Experience with open source. While Linux and FOSS have been passions of mine for more than five years, I need tangible, quantifiable experience that can demonstrate my commitment to FOSS values and GSOC presents the perfect opportunity to do so. Although I have been involved with the Wesnoth community since 2007, I have never actually gotten involved with the mainline code and do not have commit access, so this will provide a unique perspective to the Wesnoth project and FOSS communities in general.
+
* Experience with open source. While Linux and FOSS have been passions of mine for more than five years, I need tangible, quantifiable experience that can demonstrate my commitment to FOSS values and GSOC presents the perfect opportunity to do so. Although I have been involved with the Wesnoth community since 2007, I have never actually gotten involved with the mainline code and do not have commit access, so this will provide a unique perspective I have not yet seen to the Wesnoth project, and FOSS communities in general.
  
* Selfishly improving my capabilities as an add-on creator. I would be lying if I didn't mention the suspicious correlation between me wanting to improve Lua's capabilities as an add-on scripting language and me having a substantial amount of add-ons either in Lua or about to be rewritten into Lua. Actually improving what I can do in add-ons using Lua might be the primary thing I expect to gain from this GSOC. >:D
+
* Improving what I can do with Lua as an add-on creator. I would be lying if I didn't mention the suspicious correlation between me wanting to improve Lua's capabilities as an add-on scripting language and me having a substantial amount of add-ons either in Lua or about to be rewritten into Lua. Actually improving what I can do in add-ons using Lua might be the primary thing I expect to gain from this GSOC. >:D
  
 
'''4.7) What would make you stay in the Wesnoth community after the conclusion of SOC?'''
 
'''4.7) What would make you stay in the Wesnoth community after the conclusion of SOC?'''
  
 
I've been with the Wesnoth community since 2007. I'm staying.
 
I've been with the Wesnoth community since 2007. I'm staying.
 +
 +
|-
 +
|
  
 
===Practical considerations===
 
===Practical considerations===
Line 259: Line 397:
 
'''5.1) Are you familiar with any of the following tools or languages?'''
 
'''5.1) Are you familiar with any of the following tools or languages?'''
  
* Subversion (used for all commits)
+
* Sub&shy;&shy;version (used for all commits)
 
** Yes, I've used it for both wesnoth (updates only) and wesnoth-umc-dev (updates and commits) for several years.
 
** Yes, I've used it for both wesnoth (updates only) and wesnoth-umc-dev (updates and commits) for several years.
 
* C++ (language used for all the normal source code)
 
* C++ (language used for all the normal source code)
Line 276: Line 414:
 
'''5.2) Which tools do you normally use for development? Why do you use them?'''
 
'''5.2) Which tools do you normally use for development? Why do you use them?'''
  
I use GNU emacs, which I supplement with traditional UNIX tools, such as grep and gdb, as well as various scripts, mostly in Python. I've been using Linux as my primary (and often, including now, my only) operating system since 2005 so I have familiarity with the Linux way of doing things. I believe things like this are a matter of taste as long as one has experience with the tools one uses and the tools are appropriate for the task. One of the great things about Linux, and FOSS software in general, is that there's typically at least two good options for any given need, so I really don't want to start an editor war by saying that emacs is clearly superior to something else.
+
I use GNU emacs, which I supplement with traditional UNIX tools, such as grep and gdb, as well as various scripts, mostly in Python. I've been using Linux as my primary (and often, including now, my only) operating system since 2005 so I have familiarity with the Linux way of doing things.
 +
 
 +
I believe that choices like these are a matter of taste as long as one has experience with the tools... and as long as those tools are appropriate for the task, of course! One of the great things about Linux, and FOSS software in general, is that there's typically at least two good options for any given need, so I really don't want to start an editor war by saying that emacs is clearly superior to something else.
  
 
'''5.3) What programming languages are you fluent in?'''
 
'''5.3) What programming languages are you fluent in?'''
Line 284: Line 424:
 
'''5.4) Would you mind talking with your mentor on telephone / internet phone? We would like to have a backup way for communications for the case that somehow emails and IRC do fail. If you are willing to do so, please do list a phone number (including international code) so that we are able to contact you. You should probably *only* add this number in the application for you submit to google since the info in the wiki is available in public. We will *not* make any use of your number unless some case of "there is no way to contact you" does arise!'''
 
'''5.4) Would you mind talking with your mentor on telephone / internet phone? We would like to have a backup way for communications for the case that somehow emails and IRC do fail. If you are willing to do so, please do list a phone number (including international code) so that we are able to contact you. You should probably *only* add this number in the application for you submit to google since the info in the wiki is available in public. We will *not* make any use of your number unless some case of "there is no way to contact you" does arise!'''
  
[spambot paranoia]
+
[see GSOC submission page]
 +
|}
 +
 
 +
==SoC Application==
 +
[http://www.google-melange.com/gsoc/proposal/review/google/gsoc2011/aethaeryn/1 Battle for Wesnoth - Google Summer of Code Application]

Latest revision as of 02:38, 24 April 2023


This page is related to Summer of Code 2011
See the list of Summer of Code 2011 Ideas



This is a Summer of Code 2011 student page
Project: SoC_Ideas_Your_Own_Ideas2011



Description

Michael Babich - Improving Lua's User Interface Capabilities

I intend to improve the ability for add-ons to customize the user interface through Lua. I will focus on providing simple, but powerful syntax for a set of functions that will enable add-on creators to have improved, easier access to features that already exist within the game engine so that they are free to creatively provide more innovative content.

The purpose of this project is to act as a middleman between the game engine and the add-on creators using the Lua scripting language so that simple and powerful add-on creation can help revolutionize future MP, just as [set_menu_item] and [option] allowed for a great evolution in the quality of add-ons since 1.3. This interface framework needs to be as broad as possible in the time given and the scope allowed so that creative add-on authors themselves can stretch Wesnoth content far beyond its traditional style, but it also must provide a simplified Lua helper library so that everyone can use it without necessarily having to delve deeply into the complexity that exists in the currently-existing GUI.

IRC

Aethaeryn, Aeth

Introduction

I have been making content for Wesnoth since 2007 and I have been gradually porting much of my more advanced content to Lua since late 2009. While doing so, I have noticed certain limitations to the current implementation of Lua as it relates to add-on creation, especially with certain elements only possible through WML or the rather poorly readable WML tables. As the title suggests, I wish to simply and extend the add-on creation capabilities in Lua. In particular, I will be working with various elements of the interface code because this is currently where Lua is weak and often just relying on WML tables. There are several problems with using WML tables in these areas:

  • Poor readability, clumsy syntax, and verbosity. The metatable in the helper library helps with readability, but does not always work (for instance on [or] and [and] boxes, where those words are reserved in Lua) and it still hides the underlying issue that true native Lua support is not there. It also is fairly difficult in certain applications where the XML-style WML syntax is clearly inferior and much more verbose than something done in pure Lua.
  • You're essentially using WML. This defeats the purpose of using Lua in the first place if the majority of your code in a particular area is in WML. This is made even more severe when one realizes that many of the areas that must currently be done via WML tables are complex things that are the kind of things best done in a real language in the first place. In particular, the [message], [option], and [set_menu_item] have no real Lua equivalent.
  • Calling Lua from WML tables is hacky. Currently, if one wants to call a Lua function from T.option {}, one has to set a string that is a call on a global Lua function.

An ideal scenario or campaign would be one that uses WML to define the basic structure and then call on Lua for any more advanced elements. As I spend most of my Wesnoth time making -- or playing -- content for MP that do things that WML was not originally intended to do, such as making Wesnoth an RPG instead of a TBS, I have noticed that WML does not scale very well as a general purpose language doing advanced scripting. Any traditional language, such as Lua, can handle certain advanced things in a much more readable and efficient manner, but there are certain gaps in Lua where WML tables must be integrated with the Lua, which defeats many of the primary reasons to use Lua in the first place.

Fortunately, the solution is rather obvious to the WML table problem. Lua needs to be extended to access features that almost all already exist in the game engine and these must be implemented through Lua functions and tables instead of WML tables so that the full benefits of using Lua for scripting can be realized. Although the problem and solution are fairly easy to describe, certain precautions must be taken to make ensure that save games are not broken and no new issues are introduced. In addition, the individual proposed changes must be enumerated for clarity as to the scope of the project.

The Implementation: Overview

The information can roughly be broken down into three separate phases, 0 through 2. First, I shall go through an overview so as to be straightforward with the overall planned changes, then I shall provide the details of each individual section, and finally I shall propose a detailed timeline as to when each part can be accomplished.

Phase 0: The Initial Changes

First, src/scripting/lua.cpp should be split into smaller, logically-organized files so that the file does not grow too large and unmanageable with the improvements planned. This has the additional effect of allowing me to get familiar with the core Lua code.

Next, various UI tags shall be implemented in native Lua without WML tables. The hardest portion of this is ensuring that the Lua changes can be implemented without breaking save files. Most of the existing WML code can be reused, so a key purpose of this is to get rid of the need for WML tables for this portion of the code so that it better interacts with files written purely in Lua and so it is in a consistent style with code in the later portion of this project. The trickiest part will be implementing the callback, which will allow menu options to trigger Lua functions.

Because the code already exists to handle the WML tags, most of the work is allowing these Lua functions to utilize already-existing code in the engine. In this phase, the Lua functions to be created more or less map one-to-one with WML tags, which is why this would be a "Phase 0". On the surface, the changes may seem subtle, but it will allow for a more Lua way of implementing these than WML tables, which will improve interaction with Lua scripting functions while also making the Lua side of Wesnoth scripting easier to learn. In addition, it will ensure that these very central UI actions are consistent with Phase 1 syntax.

The related WML tags that need to be ported to Lua functions:

  • [message]
    • [option]
    • [text_input]
  • [set_menu_item]

Phase 1: Complex Interface Changes

Note: This section is outdated, I know, but I have to get to it after I actually write the wesnoth.gui_message{} function so I get a feel for the C API and how much time is necessary to do these tasks. I'm probably going to have to add at least two more weeks worth of work on top of what I originally intended.

  • Implement improved Lua access to the in-scenario GUI stuff, again without WML table hacks.
    • This includes improving the syntax and implementation of the dialog Lua.
  • A way to take in text commands in a way similar to debug mode's :lua, but only using specific commands to do specific actions as defined by Lua code in the add-on.

Phase 2: Simplify Add-on Creation

Phase 0 and Phase 1 might seem somewhat unrelated, but Phase 2 is intended to unify them under a common, easily-accessible package of sorts that provides a highly-abstracted, clean syntax for add-on authors to manipulate various elements of the UI. The original implementation from Phases 0 and 1 will still exist for those who want more control and customization, while Phase 2 will make things available for those who do not wish to necessarily deal with the complexity. There are two areas that will allow the improvements to be immediately accessible in an easy manner to content authors:

  • I will implement a Lua "wesnoth.ui" that adds an additional abstraction layer on top of the already existing syntax, simplifying the appearance of the code at the expense of some finer control.
  • If I have the time, I will create new, defined-in-Lua WML tags that utilize wesnoth.ui so that one does not have to use Lua to benefit from the improvements to Lua.

The Implementation: Details

Phase 0

The goal of this phase is to implement similar behavior in Lua to important UI-related WML tags so that these elements can be used in Lua without WML tables, thus eliminating clumsy syntax and ensuring complete implementation. Currently, certain parts, including [option], require clumsy workarounds when implemented in WML tables due to the nature of the tag. This also sets the stage for the later phases by establishing a starting point for more complex feature additions.

Sample Syntax

-- The function can be triggered directly by defining the table in the function call to gui_message{}.
gui_message{
   message  = "Hello world!",
   speaker = "narrator",
   image   = "wesnoth.png",
   options  = {
         { text='hello', callback = foobar() },
         { text='goodbye', callback = say_goodbye() }
   }
}

-- The function can be used indirectly by setting it to a table first, and then using the table's
-- reference variable as an argument for gui_message().
msg = {
   message = "What's your name?",
   -- if the tag is not there, reasonable defaults are set
   -- text_input takes either a table containing the information, or a table of tables that are all valid text_input
   text_input = {variable = "foo", label = "Name: ", max_length = 42}
}


function foobar()
   gui_message(msg)

gui_message{}

The basic portion of gui_message{} is an implementation of the [message] WML tag without any of the subtags. Through the extensions below it allows absolutely everything in WML [message] to be converted except for the filters, which are better done through plain Lua. Note that the use of {} instead of () for the function means that it technically is fed in a Lua keyed table, meaning that the order of the arguments does not matter as long as they match the key. Default values are used for arguments that are not defined, just like the WML behavior.

gui_message {
   message     = string,
   speaker     = string,
   side_for    = integer, -- or a table with a set of integers
   image       = string,
   caption     = string,
   scroll      = boolean,
   duration    = integer,
   sound       = string,
   options     = table, -- see below
   text_input  = table, -- see below
}

The best part about this is that the core function (excluding the options and text_input tables) can be easily converted into a form recognizable by WML and handled using the same function that handles the existing [message] code. Complexity and a difference from the WML definition only really enter when implementing [option] and [text_input].

The alternative form of gui_message{} is gui_message(table) where table is a table with keys that match the definition of gui_message{}.

options

Options has two possible syntax. If there is only one option, it can directly contain the option table:

options = {
   text     = string,
   filter   = condition, -- must evaluate to true for the option to show
   callback = function, -- the actual effect of the command
}

If there is more than one option, it must have a table containing tables:

options = {
   {
      text     = string,
      filter   = condition, -- must evaluate to true for the option to show
      callback = function, -- the actual effect of the command
   }, {
      text     = string,
      filter   = condition, -- must evaluate to true for the option to show
      callback = function, -- the actual effect of the command
   },
}

callback

text_input

set_menu_item()

Phase 1

Dialog Improvements

GUI 2 Access

Optional: Commands

Graphical User Interfaces are great for most tasks, but there are situations where text-based input is a better way for commands to be run. If possible, it would greatly improve the capabilities of Lua if it were able to interpret chat messages. Lua already has the capability to output to chat, but input from chat would allow for Lua to become even more powerful in this area. Commands could be thought of in two different types, each with different use cases:

Public chat. With Lua given the capability to parse public MP chat, this allows for the computer side, the AI, to be able to interact with the players given certain keywords, which would give certain scenarios a more immersive feel. Instead of being merely cosmetic, this chat could have an actual effect on gameplay. For instance, certain taunts could anger the AI, causing it to change tactics to attack a different player or recruit different units.

Private commands with a /lua command. One is currently able to run Lua through :lua when debug mode is on, but this is infeasible for multiplayer. Being able to interpret "/lua command", especially if it were context aware for which hex is currently selected, would allow for several possibilities. For instance, allied AI could uses Lua to respond to your input so that it can formulate a strategy with you. Also, advanced content that could use certain /lua commands to trigger actions, allowing for anything from an MP-compatible "debug mode" to more restrictive triggers that are fitting to the particular scenario. Perhaps the host would use "/lua difficulty hard" to change the difficulty mid-scenario, or a player could use "/lua inventory" on their turn to pop up an RPG-style inventory screen without having to use any right click menus at all.

Essentially, the Lua would be able to use certain input as a trigger for executing Lua functions, enabling a far broader range of possibilities for content creators. This would not actually implement any changes to the way the game is played. Rather, it would provide the ability for others to use this new feature in their own scenarios, eras, AI, etc.

Phase 2

Sample syntax

The final goal is to use wesnoth.ui.show() to hide almost all of the interface details by providing a syntactical shortcut to the functions in Phase 0 and Phase 1. More complexity will be possible, as in sample2, but the extremely basic sample1 will be legal syntax as well.

sample1  = {message = "Hello world"}
sample2 = {message = {"Hello world", options = {speaker = "Konrad", side_for = 1}}}
wesnoth.ui.show(sample1)
wesnoth.ui.show(sample2)

This will allow for possibilities like the following, where the GUI message is literally as simple as providing one string:

function message_all(messageText)
   wesnoth.ui.show{message = messageText}

wesnoth.ui

WML additions

The Implementation: Timeline

Note: This timeline will be rewritten because I have to get Phase 0 in sooner than I anticipated, thus requiring me to shift up and expand Phase 1, as well as elaborate it in subtasks on the timeline.

now April 08 - April 22  

Pre-Summer I

Finalize design.

Get most of Phase 0 working.

April 23 - May 08

Finish Phase 0.

May 09 - May 18 Spring semester ends. Availability may be limited during this period.
May 19 - May 30

Summer I

Phase 1 beings. (My schedule is be entirely free in this time span.)

May 31 - June 30

Summer II

My summer semester starts. I should still have Fridays through Sundays entirely free.

July 4 - July 8 Expected busy week as my one summer course wraps up.
July 9 - July 17

Middle of GSOC

Phase 1 ends. The largest portion of the project, Phase 1, should be concluding around this point.

Since this is around the middle evaluation point, part of the focus should be on reviewing the design and plans for the second half of GSOC. If I am ahead of schedule or behind schedule, adjustments can be made.

July 18 - July 22 Summer semester ends. Expected busy week as my other summer course wraps up.
July 23 - August 15 

Summer III

Phase 2 begins. Again, my schedule should be entirely free to focus on the project.

August 15

Pencils Down Date

According to Google: "Take a week to scrub code, write tests, improve documentation, etc."

lim t
t→∞
Continue to work on Wesnoth's Lua scripting capabilities because it certainly will take more than just one summer to perfect it.

Goals

Patches

Currently, the Phase 0 patches are in progress.

Questionnaire

SoC Application

Battle for Wesnoth - Google Summer of Code Application

This page was last edited on 24 April 2023, at 02:38.