SaveMapData: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Improve example.) |
||
(10 intermediate revisions by 6 users not shown) | |||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> bool saveMapData(xmlnode node, element baseElement)</syntaxhighlight> | <syntaxhighlight lang="lua"> bool saveMapData ( xmlnode node, element baseElement [, bool childrenOnly = false ] )</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''node''': An existing node that should contain the contents of baseElement | *'''node''': An existing node that should contain the contents of baseElement | ||
*'''baseElement''': The first element to output to the | *'''baseElement''': The first element to output to the XML tree. This element and all its children (and their children, etc) will be output. | ||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
*'''childrenOnly''': Defines if you want to only save children of the specified element. | |||
===Returns=== | ===Returns=== | ||
==Example== | ==Example== | ||
Saving your resource's data to an [https://forum.mtasa.com/topic/126081-map-files map file] (untested) | |||
<syntaxhighlight lang="lua"> | |||
local mapFile = xmlCreateFile("saved.map", "map") | |||
if mapFile then | |||
saveMapData(mapFile, resourceRoot) | |||
xmlSaveFile(mapFile) | |||
xmlUnloadFile(mapFile) | |||
end | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Map functions}} | {{Map functions}} | ||
Latest revision as of 23:19, 11 January 2023
This converts a set of elements in the element tree into XML. This is a format that can then be loaded as a map file. Each element represents a single XML node.
Syntax
bool saveMapData ( xmlnode node, element baseElement [, bool childrenOnly = false ] )
Required Arguments
- node: An existing node that should contain the contents of baseElement
- baseElement: The first element to output to the XML tree. This element and all its children (and their children, etc) will be output.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- childrenOnly: Defines if you want to only save children of the specified element.
Returns
Example
Saving your resource's data to an map file (untested)
local mapFile = xmlCreateFile("saved.map", "map") if mapFile then saveMapData(mapFile, resourceRoot) xmlSaveFile(mapFile) xmlUnloadFile(mapFile) end
See Also