Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Release dev/0.4.1-dev

Compare
Choose a tag to compare
@github-actions github-actions released this 22 Nov 21:00
  • Fixed an issue whenever you pass nothing to a function instead of a string it will crash the server.
  • getResourceFromName renamed to getResourceByName.
  • Resource.getFromName renamed to Resource.getByName.
  • Add the possibility to read both server.cfg and resource.cfg files. There is a global object called serverConfig (it will return a userdata:Config type) which you can access everywhere and can read keys from the config file with getKey(string key) function. For resource objects you can access it by config property or getConfig() function (also in each resource there is a variable called localResource which is an object for the current resource the script is running in).

Examples:

print(serverConfig:getKey("announce"))
print(serverConfig:getKey("name"))
print(serverConfig:getKey("description"))
print(inspect(serverConfig:getKey("resources")))
print(inspect(serverConfig:getKey("modules")))

print(localResource.config)
print(localResource.config:getKey("main"))
print(inspect(localResource:getConfig():getKey("required-permissions")))

print(import("resourcename").config:getKey("main")) --import is just an alias for getResourceByName
print(import("resourcename"):getConfig():getKey("main")) --import is just an alias for getResourceByName
print(inspect(Resource.getByName("resourcename"):getConfig():getKey("test-value"))) --you can also access unique keys as well
print(inspect(getResourceByName("resourcename"):getConfig():getKey("test-value"))) --you can also access unique keys as well
print(inspect(getResourceByName("resourcename").config:getKey("test-value"))) --you can also access unique keys as well