plethora
plethora copied to clipboard
Configuration settings implemented into default settings API.
Have configuration settings loaded in to settings API. For example, an author can use this to find out the current range of the block scanner without having to ask the player:
local scannerRange = settings.get("plethora.scanRadius")
local scannerWidth = scannerRange * 2 + 1
local manipulator = peripheral.find("manipulator")
local pos = vector.new(1, -5, 2)
local blocks = manipulator.scan()
print(blocks[scannerWidth ^ 2 * (pos.x + scannerRange) + scannerWidth * (pos.y + scannerRange) + (pos.z + scannerRange) + 1].name)
I'm in two minds about this: I can definitely see why getting the range would be useful, I'm just not sure the settings
API is the best way to expose it. As changing a single key will cause all settings to be saved to disk, it's not really suitable for values which may change.
It would be possible to add various getter methods for the scan/sense radius, maximum potency on lasers and kinetic augment, though that could end up being a tad verbose. I'll have a think about it.
In the case of scanner radius, it should be possible to get the width from (#blocks)^(1/3)
, though I haven't tested that.
SquidDev said:
In the case of scanner radius, it should be possible to get the width from
(#blocks)^(1/3)
, though I haven't tested that.
I realized that shortly after posting, but then I figured that it would be nice to access the scan range BEFORE using the scan()
method.
SquidDev said:
It would be possible to add various getter methods for the scan/sense radius, maximum potency on lasers and kinetic augment, though that could end up being a tad verbose. I'll have a think about it.
I also feel that having getters and setters would clutter the existing API. And to create a custom settings function for Plethora would be nothing short of re-inventing the wheel.
SquidDev said:
As changing a single key will cause all settings to be saved to disk, it's not really suitable for values which may change.
Then maybe this should be a change to the settings
API pushed to CCTweaks, as I often use alongside Plethora. But maintain compatibility with the PR release of ComputerCraft. I know if I'm going to push for this change, I'll have to post the issue on the corresponding repo, but I digress.
Then maybe this should be a change to the
settings
API
There's definitely improvements which could be made to it with regards to saving things. However, the settings API is mostly designed for computer-specific, user-configurable configuration. It's really not suitable for reading server configs.
SquidDev said:
There's definitely improvements which could be made to it with regards to saving things. However, the settings API is mostly designed for computer-specific, user-configurable configuration. It's really not suitable for reading server configs.
Oh yeah. Then how about a global table like _PLETHORA_SETTINGS
?
Oh yeah. Then how about a global table like
_PLETHORA_SETTINGS
?
That's sadly not possible with CC's API. I could probably register a custom API which just provides getters for config options, but that's a tad ugly too.
Well, we could have a single method moduleConfig(key)
add to org.squiddev.plethora.api.module.IModuleContainer.