Skip to content

Commit e4d3522

Browse files
committed
Minor fixes (XML)
- Code formatting - Typos
1 parent 6fe9eda commit e4d3522

23 files changed

+48
-56
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
local node = xmlLoadFile ( ":ctv/settings.xml" )
1+
local node = xmlLoadFile(":ctv/settings.xml")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
local node = XML.load ( ":ctv/settings.xml" )
1+
local node = XML.load(":ctv/settings.xml")

functions/XML/examples/xmlNodeGetAttributes-1.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local info = xmlFindChild(meta, "info", 0)
33

44
if (info) then
55
local attrs = xmlNodeGetAttributes(info)
6-
for name,value in pairs (attrs) do
6+
for name,value in pairs(attrs) do
77
outputConsole(name.." = "..value)
88
end
99
end
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
addEventHandler("onResourceStart", getResourceRootElement(),
2-
function()
3-
local xml = xmlLoadFile("welcome.xml") -- open the XML file
4-
local messageNodes = xmlNodeGetChildren(xml) -- get all child nodes of the root node (<messages>)
5-
g_WelcomeMessages = {} -- create a new global variable to store the welcome messages
6-
for i,node in ipairs(messageNodes) do -- loop over all the message nodes
7-
g_WelcomeMessages[i] = xmlNodeGetValue(node) -- retrieve the text in each node
8-
end
9-
xmlUnloadFile(xml) -- close the XML file
1+
addEventHandler("onResourceStart", getResourceRootElement(), function()
2+
local xml = xmlLoadFile("welcome.xml") -- open the XML file
3+
local messageNodes = xmlNodeGetChildren(xml) -- get all child nodes of the root node (<messages>)
4+
g_WelcomeMessages = {} -- create a new global variable to store the welcome messages
5+
for i, node in ipairs(messageNodes) do -- loop over all the message nodes
6+
g_WelcomeMessages[i] = xmlNodeGetValue(node) -- retrieve the text in each node
107
end
11-
)
8+
xmlUnloadFile(xml) -- close the XML file
9+
end)
1210

13-
addEventHandler("onPlayerJoin", getRootElement(),
14-
function()
15-
local numMessages = #g_WelcomeMessages -- get the number of messages
16-
local message = g_WelcomeMessages[math.random(numMessages)] -- pick a random message
17-
outputChatBox(message, source, 0, 255, 0) -- display it to the joining player
18-
end
19-
)
11+
addEventHandler("onPlayerJoin", getRootElement(), function()
12+
local numMessages = #g_WelcomeMessages -- get the number of messages
13+
local message = g_WelcomeMessages[math.random(numMessages)] -- pick a random message
14+
outputChatBox(message, source, 0, 255, 0) -- display it to the joining player
15+
end)
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
addEventHandler("onResourceStart", getResourceRootElement(),
2-
function()
3-
local xml = XML.load("welcome.xml") -- open the XML file
4-
local messageNodes = xml.children -- get all child nodes of the root node (<messages>)
5-
g_WelcomeMessages = {} -- create a new global variable to store the welcome messages
6-
for i,node in ipairs(messageNodes) do -- loop over all the message nodes
7-
g_WelcomeMessages[i] = node.value -- retrieve the text in each node
8-
end
9-
xml:unload() -- close the XML file
1+
addEventHandler("onResourceStart", getResourceRootElement(), function()
2+
local xml = XML.load("welcome.xml") -- open the XML file
3+
local messageNodes = xml.children -- get all child nodes of the root node (<messages>)
4+
g_WelcomeMessages = {} -- create a new global variable to store the welcome messages
5+
for i, node in ipairs(messageNodes) do -- loop over all the message nodes
6+
g_WelcomeMessages[i] = node.value -- retrieve the text in each node
107
end
11-
)
8+
xml:unload() -- close the XML file
9+
end)
1210

13-
addEventHandler("onPlayerJoin", getRootElement(),
14-
function()
15-
local numMessages = #g_WelcomeMessages -- get the number of messages
16-
local message = g_WelcomeMessages[math.random(numMessages)] -- pick a random message
17-
source:outputChat(message, 0, 255, 0) -- display it to the joining player
18-
end
19-
)
11+
addEventHandler("onPlayerJoin", getRootElement(), function()
12+
local numMessages = #g_WelcomeMessages -- get the number of messages
13+
local message = g_WelcomeMessages[math.random(numMessages)] -- pick a random message
14+
source:outputChat(message, 0, 255, 0) -- display it to the joining player
15+
end)

functions/XML/examples/xmlNodeGetValue-1.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ if (xmlFile) then -- If it's indeed opened
55
xmlUnloadFile(xmlFile)
66

77
if (success) then -- Check if it was successful
8-
outputChatBox (tostring(success)) -- Output "somevalue" to the chatbox
8+
outputChatBox(tostring(success)) -- Output "somevalue" to the chatbox
99
end
10-
end
10+
end

functions/XML/xmlCreateChild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ shared: &shared
1414
description: 'The type of the child node that will be created.'
1515
returns:
1616
description: |
17-
Returns the created [xmlnode](/xmlnode) if successful, false otherwise.
17+
Returns the created [xmlnode](/xmlnode) if successful, **false** otherwise.
1818
values:
1919
- type: 'xmlnode|false'
2020
name: 'xmlnode'

functions/XML/xmlCreateFile.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ shared: &shared
2222
description: 'The name of the root node in the XML document.'
2323
returns:
2424
description: |
25-
Returns the root [xmlnode](/xmlnode) object of the new XML file if successful, or false otherwise.
25+
Returns the root [xmlnode](/xmlnode) object of the new XML file if successful, or **false** otherwise.
2626
values:
2727
- type: 'xmlnode|false'
2828
name: 'xmlnode'

functions/XML/xmlDestroyNode.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ shared: &shared
1111
description: "The [xmlnode](/xmlnode) you want to destroy."
1212
returns:
1313
description: |
14-
Returns true if the xml node was successfully destroyed, false otherwise.
14+
Returns **true** if the xml node was successfully destroyed, **false** otherwise.
1515
values:
1616
- type: 'bool'
1717
name: 'bool'

functions/XML/xmlFindChild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ shared: &shared
1818
This is the 0-based index of the node you wish to find. For example, to find the 5th subnode with a particular name, you would use 4 as the index value. To find the first occurence, use 0.
1919
returns:
2020
description: |
21-
Returns an [xmlnode](/xmlnode) if the node was found, false otherwise.
21+
Returns an [xmlnode](/xmlnode) if the node was found, **false** otherwise.
2222
values:
2323
- type: 'xmlnode|false'
2424
name: 'xmlnode'

0 commit comments

Comments
 (0)