RenameResource: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{New feature|3.0120|1.2| __NOTOC__ {{Server function}} This function renames a resource. ==Syntax== <syntaxhighlight lang="lua"> bool renameResource ( string resourceName, string newResourc...") |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(13 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
Line 6: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool renameResource ( string | bool renameResource ( string/resource theResource, string newResourceName, [ string organizationalPath ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[resource]]:rename|name|getResourceName}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''theResource:''' The name of resource or the resource you want to rename. | ||
*'''newResourceName:''' The name of what the resource should be renamed to. | *'''newResourceName:''' The name of what the resource should be renamed to. | ||
Line 20: | Line 19: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | This example renames the resource "reload" to "reload2": | ||
<syntaxhighlight lang="lua">function renameReloadResource() | |||
renameResource("reload", "reload2"); | |||
end | |||
addEventHandler("onResourceStart", resourceRoot, renameReloadResource); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Resource_functions | {{Resource_functions|server}} | ||
}} |
Latest revision as of 15:33, 7 November 2024
This function renames a resource.
Syntax
bool renameResource ( string/resource theResource, string newResourceName, [ string organizationalPath ] )
OOP Syntax Help! I don't understand this!
- Method: resource:rename(...)
- Variable: .name
- Counterpart: getResourceName
Required Arguments
- theResource: The name of resource or the resource you want to rename.
- newResourceName: The name of what the resource should be renamed to.
Optional Arguments
- organizationalPath: If you want to store the new resource inside a category.
Returns
Returns true if the resource has been renamed successfully, false otherwise. This could fail if the resource name already is in use, if a directory already exists with the name you've specified (but this isn't a valid resource) or if the name you specify isn't valid. It could also fail if the disk was full or for other similar reasons. Won't work on a started resource or if the resource is not loaded (not known by MTA (use /refresh))
Example
This example renames the resource "reload" to "reload2":
function renameReloadResource() renameResource("reload", "reload2"); end addEventHandler("onResourceStart", resourceRoot, renameReloadResource);
See Also
- addResourceConfig
- addResourceMap
- callRemote
- copyResource
- createResource
- deleteResource
- getResourceACLRequests
- getResourceInfo
- getResourceLastStartTime
- getResourceLoadFailureReason
- getResourceLoadTime
- getResourceMapRootElement
- getResourceOrganizationalPath
- getResources
- isResourceArchived
- isResourceProtected
- refreshResources
- removeResourceFile
- renameResource
- restartResource
- setResourceInfo
- startResource
- stopResource
- updateResourceACLRequest
- Shared
- abortRemoteRequest
- call
- fetchRemote
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceName
- getResourceRootElement
- getResourceState
- getThisResource
- getRemoteRequests
- getRemoteRequestInfo