Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global variable and default value for resource names #3363

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Nico8340
Copy link
Contributor

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
)

A global variable named resourceName that always contains the name of the given resource.
Adds a default value to the getResourceName function, if no resource is defined, it handles the current resource, like other similar functions.
@Nico8340
Copy link
Contributor Author

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

@Nico8340 Nico8340 requested a review from TracerDS April 14, 2024 16:28
@TracerDS
Copy link
Contributor

@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

Copy link
Contributor

@TracerDS TracerDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make getResourceName take current resource as a default argument
2 participants