From bb33ed752506e4216d58ced916efaba7c7531846 Mon Sep 17 00:00:00 2001
From: Simone Starace <simone.starace93@gmail.com>
Date: Sat, 9 Apr 2022 19:39:41 +0200
Subject: [PATCH 1/3] Bold text on some examples.

---
 src/stratagus/script_player.cpp | 50 ++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/stratagus/script_player.cpp b/src/stratagus/script_player.cpp
index f67cb5333..d8da7b0c9 100644
--- a/src/stratagus/script_player.cpp
+++ b/src/stratagus/script_player.cpp
@@ -505,7 +505,7 @@ static int CclGiveUnitsToPlayer(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>GetThisPlayer()</code></div>
+** <div class="example"><code><strong>GetThisPlayer</strong>()</code></div>
 */
 static int CclGetThisPlayer(lua_State *l)
 {
@@ -545,11 +545,11 @@ static int CclSetThisPlayer(lua_State *l)
 ** Example:
 **
 ** <div class="example"><code>-- 9 units can be selected together.
-**		  SetMaxSelectable(9)
+**		  <strong>SetMaxSelectable</strong>(9)
 **		  -- 18 units can be selected together.
-**		  SetMaxSelectable(18)
+**		  <strong>SetMaxSelectable</strong>(18)
 **		  -- 50 units can be selected together.
-**		  SetMaxSelectable(50)</code></div>
+**		  <strong>SetMaxSelectable</strong>(50)</code></div>
 */
 static int CclSetMaxSelectable(lua_State *l)
 {
@@ -569,7 +569,7 @@ static int CclSetMaxSelectable(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>SetAllPlayersUnitLimit(200)</code></div>
+** <div class="example"><code><strong>SetAllPlayersUnitLimit</strong>(200)</code></div>
 */
 static int CclSetAllPlayersUnitLimit(lua_State *l)
 {
@@ -591,7 +591,7 @@ static int CclSetAllPlayersUnitLimit(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>SetAllPlayersBuildingLimit(200)</code></div>
+** <div class="example"><code><strong>SetAllPlayersBuildingLimit</strong>(200)</code></div>
 */
 static int CclSetAllPlayersBuildingLimit(lua_State *l)
 {
@@ -613,7 +613,7 @@ static int CclSetAllPlayersBuildingLimit(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>SetAllPlayersTotalUnitLimit(400)</code></div>
+** <div class="example"><code><strong>SetAllPlayersTotalUnitLimit</strong>(400)</code></div>
 */
 static int CclSetAllPlayersTotalUnitLimit(lua_State *l)
 {
@@ -637,11 +637,11 @@ static int CclSetAllPlayersTotalUnitLimit(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>SetDiplomacy(0,"allied",1)
-**		SetDiplomacy(1,"allied",0)
+** <div class="example"><code><strong>SetDiplomacy</strong>(0,"allied",1)
+**		<strong>SetDiplomacy</strong>(1,"allied",0)
 **		
-**		SetDiplomacy(0,"enemy",2)
-**		SetDiplomacy(1,"enemy",2)</code></div>
+**		<strong>SetDiplomacy</strong>(0,"enemy",2)
+**		<strong>SetDiplomacy</strong>(1,"enemy",2)</code></div>
 */
 static int CclSetDiplomacy(lua_State *l)
 {
@@ -710,11 +710,11 @@ static int CclGetDiplomacy(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>SetSharedVision(0,true,1)
-**		SetSharedVision(1,true,0)
+** <div class="example"><code><strong>SetSharedVision</strong>(0,true,1)
+**		<strong>SetSharedVision</strong>(1,true,0)
 **		
-**		SetSharedVision(0,false,2)
-**		SetSharedVision(1,false,2)</code></div>
+**		<strong>SetSharedVision</strong>(0,false,2)
+**		<strong>SetSharedVision</strong>(1,false,2)</code></div>
 */
 static int CclSetSharedVision(lua_State *l)
 {
@@ -750,9 +750,9 @@ static int CclSharedVision(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>SetRevelationType("no-revelation")
-** 		SetRevelationType("buildings-only")
-** 		SetRevelationType("all-units")</code></div>
+** <div class="example"><code><strong>SetRevelationType</strong>("no-revelation")
+** 		<strong>SetRevelationType</strong>("buildings-only")
+** 		<strong>SetRevelationType</strong>("all-units")</code></div>
 **
 */
 static int CclSetRevelationType(lua_State *l)
@@ -835,7 +835,7 @@ static int CclDefineRaceNames(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>DefinePlayerColors({
+** <div class="example"><code><strong>DefinePlayerColors</strong>({
 **		"red", {{164, 0, 0}, {124, 0, 0}, {92, 4, 0}, {68, 4, 0}},
 **		"blue", {{12, 72, 204}, {4, 40, 160}, {0, 20, 116}, {0, 4, 76}},
 **		"green", {{44, 180, 148}, {20, 132, 92}, {4, 84, 44}, {0, 40, 12}},
@@ -950,7 +950,7 @@ static int CclDefinePlayerColorIndex(lua_State *l)
 **
 ** Example:
 **
-** <div class="example"><code>GetPlayerData(0,"TotalNumUnits")</code></div>
+** <div class="example"><code><strong>GetPlayerData</strong>(0,"TotalNumUnits")</code></div>
 */
 static int CclGetPlayerData(lua_State *l)
 {
@@ -1112,10 +1112,10 @@ static int CclGetPlayerData(lua_State *l)
 ** Example:
 **
 ** <div class="example"><code>
-**  SetPlayerData(0,"Name","Nation of Stromgarde") -- set the name of this player
-**	SetPlayerData(0,"RaceName","human") -- the the race to human
-** 	SetPlayerData(0,"Resources","gold",1700) -- set the player to have 1700 gold
-**  SetPlayerData(0, "Allow", "upgrade-paladin", "R") -- give the player the Paladin upgrade
+**  <strong>SetPlayerData</strong>(0,"Name","Nation of Stromgarde") -- set the name of this player
+**	<strong>SetPlayerData</strong>(0,"RaceName","human") -- the the race to human
+** 	<strong>SetPlayerData</strong>(0,"Resources","gold",1700) -- set the player to have 1700 gold
+**  <strong>SetPlayerData</strong>(0, "Allow", "upgrade-paladin", "R") -- give the player the Paladin upgrade
 ** </code></div>
 */
 static int CclSetPlayerData(lua_State *l)
@@ -1231,7 +1231,7 @@ static int CclSetPlayerData(lua_State *l)
 ** Example: 
 ** 
 ** <div class="example"> <code> -- Player 1 has a passive A.I 
-**		  SetAiType(1, "Passive")</code></div>
+**		  <strong>SetAiType</strong>(1, "Passive")</code></div>
 */
 static int CclSetAiType(lua_State *l)
 {

From 8db9d17da3d2e27eefa39e5f0a0c621911539a0e Mon Sep 17 00:00:00 2001
From: Simone Starace <simone.starace93@gmail.com>
Date: Sat, 9 Apr 2022 20:26:07 +0200
Subject: [PATCH 2/3] Added examples in shaders.cpp

---
 src/video/shaders.cpp | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/video/shaders.cpp b/src/video/shaders.cpp
index eda2d1f93..4f7dad821 100644
--- a/src/video/shaders.cpp
+++ b/src/video/shaders.cpp
@@ -402,6 +402,16 @@ bool RenderWithShader(SDL_Renderer *renderer, SDL_Window* win, SDL_Texture* back
 	return true;
 }
 
+/**
+** <b>Description</b>
+**
+**  Get the active shader.
+**
+** Example:
+**
+** <div class="example"><code>shader_name = <strong>GetShader</strong>()
+**	print(shader_name)</code></div>
+*/
 static int CclGetShader(lua_State *l) {
 	LuaCheckArgs(l, 0);
 	const char* shaderName = shaderNames[currentShaderIdx];
@@ -413,6 +423,16 @@ static int CclGetShader(lua_State *l) {
 	return 1;
 }
 
+/**
+** <b>Description</b>
+**
+**  Apply a shader.
+**
+** Example:
+**
+** <div class="example"><code>-- Apply a VHS shader
+**	<strong>SetShader</strong>("VHS")</code></div>
+*/
 static int CclSetShader(lua_State *l) {
 	LuaCheckArgs(l, 1);
 	const char* shaderName = LuaToString(l, 1);
@@ -434,6 +454,18 @@ static int CclSetShader(lua_State *l) {
 	return 1;
 }
 
+/**
+** <b>Description</b>
+**
+**  Get the list of shaders.
+**
+** Example:
+**
+** <div class="example"><code>shaders = <strong>GetShaderNames</strong>()
+**	for i,name in ipairs(shaders) do
+**		print(name)
+**	end</code></div>
+*/
 static int CclGetShaderNames(lua_State *l) {
 	LuaCheckArgs(l, 0);
 	lua_newtable(l);

From 75749b84094c4fbc61e2f3a07128e17b33ba8ff8 Mon Sep 17 00:00:00 2001
From: Simone Starace <simone.starace93@gmail.com>
Date: Sun, 10 Apr 2022 12:10:53 +0200
Subject: [PATCH 3/3] Added more example codes for units scripts.

---
 src/stratagus/script.cpp |  4 +++
 src/unit/script_unit.cpp | 58 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/src/stratagus/script.cpp b/src/stratagus/script.cpp
index 6ae8fde19..c78615e3b 100644
--- a/src/stratagus/script.cpp
+++ b/src/stratagus/script.cpp
@@ -1800,6 +1800,10 @@ static int CclInverseVideo(lua_State *l)
 **  @param l  Lua state.
 **
 **  @return   equivalent lua table.
+**
+** Example:
+**
+** <div class="example"><code>u_data = <strong>UnitType</strong>("unit-footman")</code></div>
 */
 static int CclUnitName(lua_State *l)
 {
diff --git a/src/unit/script_unit.cpp b/src/unit/script_unit.cpp
index 84ceef76a..a4c7774bd 100644
--- a/src/unit/script_unit.cpp
+++ b/src/unit/script_unit.cpp
@@ -94,6 +94,11 @@ static int CclSetTrainingQueue(lua_State *l)
 **  @param l  Lua state.
 **
 **  @return   The old state of the flag
+**
+** Example:
+**
+** <div class="example"><code><strong>SetBuildingCapture</strong>(true)
+**	<strong>SetBuildingCapture</strong>(false)</code></div>
 */
 static int CclSetBuildingCapture(lua_State *l)
 {
@@ -108,6 +113,11 @@ static int CclSetBuildingCapture(lua_State *l)
 **  @param l  Lua state.
 **
 **  @return   The old state of the flag
+**
+** Example:
+**
+** <div class="example"><code><strong>SetRevealAttacker</strong>(true)
+**	<strong>SetRevealAttacker</strong>(false)</code></div>
 */
 static int CclSetRevealAttacker(lua_State *l)
 {
@@ -120,6 +130,15 @@ static int CclSetRevealAttacker(lua_State *l)
 **  Set cost multiplier to RepairCost for buildings additional workers helping (0 = no additional cost)
 **
 **  @param l  Lua state.
+**
+** Example:
+**
+** <div class="example"><code>-- No cost
+**	<strong>ResourcesMultiBuildersMultiplier</strong>(0)
+**	-- Each builder helping will cost 1 resource
+**	<strong>ResourcesMultiBuildersMultiplier</strong>(1)
+**	-- Each builder helping will cost 10 resource
+**	<strong>ResourcesMultiBuildersMultiplier</strong>(10)</code></div>
 */
 static int CclResourcesMultiBuildersMultiplier(lua_State *l)
 {
@@ -282,6 +301,26 @@ static void CclParseOrders(lua_State *l, CUnit &unit)
 **
 **  @todo  Verify that vision table is always correct (transporter)
 **  @todo (PlaceUnit() and host-info).
+**
+** Example:
+**
+** <div class="example"><code>footman = CreateUnit("unit-footman", 0, {0, 1})
+**	-- The unit will appear selected
+**	<strong>Unit</strong>(footman,{"selected"})
+**	-- The unit will be considered destroyed
+**	<strong>Unit</strong>(footman,{"destroyed"})
+**	-- The unit will be considered removed
+**	<strong>Unit</strong>(footman,{"removed"})
+**	-- The unit will be considered as a summoned unit
+**	<strong>Unit</strong>(footman,{"summoned",500})
+**	-- The unit will face on south
+**	<strong>Unit</strong>(footman,{"direction",0})
+**	-- The unit will be displayed with his 3rd frame
+**	<strong>Unit</strong>(footman,{"frame", 3})
+**	-- The footman will have a high sight
+**	<strong>Unit</strong>(footman,{"current-sight-range",9})
+**	-- Change the unit color to be the ones from player 1
+**	<strong>Unit</strong>(footman,{"rescued-from",1})</code></div>
 */
 static int CclUnit(lua_State *l)
 {
@@ -615,6 +654,13 @@ static int CclUnit(lua_State *l)
 **  @param l  Lua state.
 **
 **  @return   Returns the slot number of the made placed.
+**
+** Example:
+**
+** <div class="example"><code>-- Create the unit
+**	footman = CreateUnit("unit-footman", 0, {7, 4})
+**	-- Move the unit to position 20 (x) and 10 (y)
+**	<strong>MoveUnit</strong>(footman,{20,10})</code></div>
 */
 static int CclMoveUnit(lua_State *l)
 {
@@ -1065,6 +1111,14 @@ static int CclKillUnitAt(lua_State *l)
 **  @param l  Lua state.
 **
 **  @return   Array of units.
+**
+** Example:
+**
+** <div class="example"><code>-- Get units from player 0
+**	units = <strong>GetUnits</strong>(0)
+**	for i, id_unit in ipairs(units) do
+**	    print(id_unit)
+**	end</code></div>
 */
 static int CclGetUnits(lua_State *l)
 {
@@ -1294,9 +1348,7 @@ static int CclGetUnitVariable(lua_State *l)
 **
 ** Example:
 **
-** <div class="example">
-** <code>
-** -- Create a blacksmith for player 2
+** <div class="example"><code>-- Create a blacksmith for player 2
 ** blacksmith = CreateUnit("unit-human-blacksmith", 2, {66, 71})
 ** -- Specify the amount of hit points to assign to the blacksmith
 ** <strong>SetUnitVariable</strong>(blacksmith,"HitPoints",344)