EngineHub / CraftBook

đŸ”§ Machines, ICs, PLCs, and more!
https://enginehub.org/craftbook/
GNU General Public License v3.0
304 stars 163 forks source link

Make Variables Private as opposed to Public #582

Closed LadyCailinBot closed 4 years ago

LadyCailinBot commented 11 years ago

CRAFTBOOK-2617 - Reported by cadika_orade

Concept: While I love the idea of variables, I think they would be somewhat more useful if they could be made private to the player who declares them.

Implementation: Essentially, an additional optional argument at the end of "/cb var define" that flags a variable such that they can only be changed by the player who defined them. Ideally, these variables could only be used on signs by the player who defined them, allowing players to re-use variable names without conflict so long as they are declared as private. Unfortunately, I cannot fathom how that could be implemented.

Justification: When I first found variables, my immediate thought had been to use them to set the offset values for my Timebomb-based nuclear device that has every other faction on my server trembling in fear. The only thing stopping me at this point is the fear that the variable names could be discovered by an enemy and reset to target my city instead. Faction politics aside, variables could be more useful to players if they have some measure of security.

Note: Sorry this is marked as CommandBook. It doesn't allow me to change it to CraftBook.

LadyCailinBot commented 11 years ago

Comment by me4502

This was my initial intention when making variables. I then ran into issues like, how would I store these? How would I reference them? I thought of %Name:Variable%, but that may be too long for some sign lines.

LadyCailinBot commented 11 years ago

Comment by pmpmpm

What about an ID for each player, stored in Players_ID.txt?

LadyCailinBot commented 11 years ago

Comment by me4502

That's a messy and complicated way

LadyCailinBot commented 11 years ago

Comment by pmpmpm

Then what about IDs defined by the admin (only numbers, such as 042 or 32723) with corresponding permission? (" craftbook.id.# ")

LadyCailinBot commented 11 years ago

Comment by me4502

I find that way too messy and complex.

LadyCailinBot commented 11 years ago

Comment by me4502

Private variables have now been completed. They use a namespace system similar to ToggleAreas.

LadyCailinBot commented 11 years ago

Comment by cadika_orade

Shucks. I'm glad to see it added, but namespaces might pose an issue. One of my moderators has a username 15 letters long, which breaks namespaces.

LadyCailinBot commented 11 years ago

Comment by me4502

Thats why I added namespaces instead of enforcing player names. Basically, you can provide them with a custom namespace to use.

LadyCailinBot commented 11 years ago

Comment by me4502

Okay, I've added .self permissions for namespaces.

LadyCailinBot commented 11 years ago

Comment by me4502

Build 2317 has a stable working version of Namespace Variables.