<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=User%3AShiki</id>
	<title>User:Shiki - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/index.php?action=history&amp;feed=atom&amp;title=User%3AShiki"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Shiki&amp;action=history"/>
	<updated>2026-05-31T08:49:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Shiki&amp;diff=67936&amp;oldid=prev</id>
		<title>Shiki: /* xxx */</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Shiki&amp;diff=67936&amp;oldid=prev"/>
		<updated>2021-05-20T00:43:57Z</updated>

		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;xxx&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 00:43, 20 May 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l137&quot; &gt;Line 137:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 137:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; while&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;( &lt;/del&gt;a &amp;lt; 20 &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; while a &amp;lt; 20 &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; do&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; do&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; print(&amp;quot;value of a:&amp;quot;, a)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; print(&amp;quot;value of a:&amp;quot;, a)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l153&quot; &gt;Line 153:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 153:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160;  print(&amp;quot;value of a:&amp;quot;, a)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160;  print(&amp;quot;value of a:&amp;quot;, a)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160;  a = a+1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160;  a = a+1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; until a==20&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160; until a == 20&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Shiki</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Shiki&amp;diff=67933&amp;oldid=prev</id>
		<title>Shiki: Created page with &quot;Practical Info for Lua beginners.  This is a concept to create a similar (but different and shorter) resource like WML_for_Complete_Beginners. The aim is to make people fe...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Shiki&amp;diff=67933&amp;oldid=prev"/>
		<updated>2021-05-20T00:06:53Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Practical Info for Lua beginners.  This is a concept to create a similar (but different and shorter) resource like &lt;a href=&quot;/WML_for_Complete_Beginners&quot; title=&quot;WML for Complete Beginners&quot;&gt;WML_for_Complete_Beginners&lt;/a&gt;. The aim is to make people fe...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Practical Info for Lua beginners.&lt;br /&gt;
&lt;br /&gt;
This is a concept to create a similar (but different and shorter) resource like [[WML_for_Complete_Beginners]]. The aim is to make people feel comfortable with Lua and the Lua Console (the UI). It's not aiming to tell how to build something, which [[LuaWML]] does already.&lt;br /&gt;
&lt;br /&gt;
What's written here should someday get into the Wiki, &lt;br /&gt;
i.e. onto an own page such as LuaSyntax or LuaIntro.&lt;br /&gt;
&lt;br /&gt;
=== Datatypes ===&lt;br /&gt;
&lt;br /&gt;
Lua table&lt;br /&gt;
 Lua has only one data type.&lt;br /&gt;
 This should be made clear, and that data type should be shown in detail.&lt;br /&gt;
 Especially: - how does it look, i.e, showing a&lt;br /&gt;
 table with all the braces and commas to the reader.&lt;br /&gt;
&lt;br /&gt;
=== Resembling other Datatypes ===&lt;br /&gt;
&lt;br /&gt;
Explaining (some) of these as special cases.  &lt;br /&gt;
Also, naming how other languages call these concepts if they exist there.&lt;br /&gt;
&lt;br /&gt;
 Array&lt;br /&gt;
 WML Table&lt;br /&gt;
 Proxy Table&lt;br /&gt;
 vconfig (whatever that is)&lt;br /&gt;
 Set &amp;amp; Bag&lt;br /&gt;
 Indexed Table&lt;br /&gt;
 Sorted Table&lt;br /&gt;
 MetaTable&lt;br /&gt;
&lt;br /&gt;
However, examples should be taken somewhere from Wesnoth, not completely fictional.&lt;br /&gt;
&lt;br /&gt;
=== Return Codes ===&lt;br /&gt;
&lt;br /&gt;
Should be explained somewhere, but later down or somewhere else,&amp;lt;br&amp;gt;&lt;br /&gt;
especially the part that a Lua function can have more than one return code&amp;lt;br&amp;gt;&lt;br /&gt;
and that it can return a table.&lt;br /&gt;
&lt;br /&gt;
=== The Lua Console ===&lt;br /&gt;
&lt;br /&gt;
/* Practical Part */&lt;br /&gt;
&lt;br /&gt;
/* Telling the reader how to play with Lua */&lt;br /&gt;
&lt;br /&gt;
/* How to find your way into experimenting with what you read here */&lt;br /&gt;
&lt;br /&gt;
# Activate Debug Mode: There's 2 ways to achieve that&lt;br /&gt;
#* Either start the Wesnoth application with the -d or --debug option.&lt;br /&gt;
#* Or use ingame the :debug [[CommandMode|command]].&lt;br /&gt;
# Open the Lua Console:&lt;br /&gt;
#: If you are not in debug mode, nothing will happen when you try to open it.&lt;br /&gt;
#: The Lua Console can be opened by pressing the hotkey '''`''' (the [http://en.wikipedia.org/wiki/Grave_accent grave accent sign])&lt;br /&gt;
#: If it does not work, please change the hotkey in the settings.&lt;br /&gt;
#: (It likely won't work out of the box on non-American keyboards.)&lt;br /&gt;
&lt;br /&gt;
=== Inspecting Data ===&lt;br /&gt;
&lt;br /&gt;
With simple data, e.g. a unit.&lt;br /&gt;
&lt;br /&gt;
Try out these commands. Play around. And find the secret behind&lt;br /&gt;
 a = … some Lua command here …&lt;br /&gt;
 print (a)&lt;br /&gt;
 a&lt;br /&gt;
 print (a[1])&lt;br /&gt;
 print (a[1][1])&lt;br /&gt;
 print (a[1].side_name)&lt;br /&gt;
 print (a[2].gold)&lt;br /&gt;
 print (a[923])&lt;br /&gt;
 type  (a[1])&lt;br /&gt;
 print (a[1].__cfg)&lt;br /&gt;
&lt;br /&gt;
/* The intention is to get a feeling of what Lua is. What are tables. How can one access specific information. etc. This is the main part. */&lt;br /&gt;
&lt;br /&gt;
=== Iterating ===&lt;br /&gt;
&lt;br /&gt;
Iterating is one central tool in Lua.&lt;br /&gt;
It fills the same role like the WML tags [foreach] or [while].&amp;lt;br&amp;gt;&lt;br /&gt;
You always need to iterate when you want to make the same action for multiple units or sides or  …&amp;lt;br&amp;gt;&lt;br /&gt;
In short — when the print(a[1].side_name) is not enough for your needs anymore, when you want to print it for all sides.&lt;br /&gt;
&lt;br /&gt;
==== ipairs ====&lt;br /&gt;
&lt;br /&gt;
Below is an often seen piece of code: &lt;br /&gt;
: '''i''' stands for index, it's a convention that this variable is named i.&lt;br /&gt;
: '''v''' stands for value.&lt;br /&gt;
The argument to ipairs, in this case a, is a table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
 for i, v in ipairs(a) do&lt;br /&gt;
     print(i, v.faction, v.color)&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ipairs only prints the elements of the table, which have a number as index.&lt;br /&gt;
(As opposed to anything else as index, i.e. a string. Remember, tables are the only data structure in Lua,&lt;br /&gt;
and they can contain lot of different things which do not necessarily make sense).&lt;br /&gt;
&lt;br /&gt;
Relevant WML tag: [[ConditionalActionsWML#.5Bforeach.5D|[foreach]]]&lt;br /&gt;
&lt;br /&gt;
==== pairs ====&lt;br /&gt;
&lt;br /&gt;
Very similar, but for some reason used less, the pairs function.&amp;lt;br&amp;gt;&lt;br /&gt;
Instead of index and value, it's '''key''' and '''value'''.&amp;lt;br&amp;gt;&lt;br /&gt;
(Bad example, output is the same.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
 for k, v in pairs(a) do&lt;br /&gt;
    print(k, v.faction, v.color)&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This mechanism is for tables which do not use a numerical key.&lt;br /&gt;
&lt;br /&gt;
Relevant WML tag: [[ConditionalActionsWML#.5Bforeach.5D|[foreach]]]&lt;br /&gt;
&lt;br /&gt;
=== xxx ===&lt;br /&gt;
&lt;br /&gt;
/* Mentioning this only for sake of completeness */&lt;br /&gt;
&lt;br /&gt;
/* This should rather be on a separate wiki page */&lt;br /&gt;
&lt;br /&gt;
==== in-keyword ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== for-loop ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
 for a = 1, 20, 1&lt;br /&gt;
 do&lt;br /&gt;
     print(&amp;quot;value of a:&amp;quot;, a)&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Relevant WML tag: [[ConditionalActionsWML#.5Bfor.5D|[for]]]&lt;br /&gt;
&lt;br /&gt;
==== while-loop ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
 while( a &amp;lt; 20 )&lt;br /&gt;
 do&lt;br /&gt;
    print(&amp;quot;value of a:&amp;quot;, a)&lt;br /&gt;
    a = a+1&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Relevant WML tag: [[ConditionalActionsWML#.5Bwhile.5D|[while]]]&lt;br /&gt;
&lt;br /&gt;
==== repeat-statement ====&lt;br /&gt;
Lua is an old language, it also knows the repeat statement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang='lua'&amp;gt;&lt;br /&gt;
 repeat&lt;br /&gt;
     print(&amp;quot;value of a:&amp;quot;, a)&lt;br /&gt;
     a = a+1&lt;br /&gt;
 until a==20&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is similar to the while loop above, but the code inside is &lt;br /&gt;
executed at least once, as the condition is checked at the end.&lt;br /&gt;
In other languages this is known as do-while-loop.&lt;br /&gt;
&lt;br /&gt;
The WML tag [[ConditionalActionsWML#.5Brepeat.5D|[repeat]]], has not the same possibilities as Lua's repeat,&lt;br /&gt;
as the WML tag only allows to repeat for a number of times, while Lua's&lt;br /&gt;
repeat allows for any kind of condition, like [[#while-loop|while]] does.&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous Links ===&lt;br /&gt;
&lt;br /&gt;
[http://underpop.online.fr/l/lua-gts-stolberg-de/ Introduction to Programming and Lua in German, English, Spanish, French and partially Italian]&lt;/div&gt;</summary>
		<author><name>Shiki</name></author>
		
	</entry>
</feed>