mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Global variable and default value for resource names

Open Nico8340 opened this issue 10 months ago • 2 comments

Description

This pull request creates a global variable named resourceName, which always contains the name of the current resource, and sets the current resource as the default value to the function getResourceName, so if it is not defined as an argument, it is based on that, like in case of other similar functions. Closes #2927.

Example

addEventHandler("onResourceStart", resourceRoot,
    function()
        local myResourceName = resourceName or getResourceName()
        local myResourceMessage = string.format("Resource successfully started: %s", myResourceName)

        outputChatBox(myResourceMessage)
    end
)

Nico8340 avatar Apr 14 '24 01:04 Nico8340

@TracerDS Thanks for the suggestions. Although I didn't write this piece of code, I updated it according to modern standards.

Nico8340 avatar Apr 14 '24 16:04 Nico8340

@TracerDS Thanks for the suggestions. Although I didn't write this piece of code, I updated it according to modern standards.

You could also format it to use ArgumentParser, but I think it would be best for a separate PR somewhere in the future

TracerDS avatar Apr 14 '24 16:04 TracerDS

Bump 😈

Fernando-A-Rocha avatar Jun 18 '24 12:06 Fernando-A-Rocha

Enough code reviews and approvals have been submitted, thanks!

Dutchman101 avatar Jun 30 '24 03:06 Dutchman101