Njol / Skript

Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
http://njol.ch/projects/skript
104 stars 65 forks source link

Conditioned aliases/options #364

Open Tsugaga opened 9 years ago

Tsugaga commented 9 years ago

It would be awesome if aliases and options could be set based on certain conditions.

MostFunGuy commented 9 years ago

I've 0 idea what you mean, can you explain? If you want changable options, use variables

I've no idea what you want with changable aliases

Tsugaga commented 9 years ago

Variables as options work, but they are less neat and less practical, and they aren't useful for aliases.

options: ..if condition: ....option1 = "stuff" ....option2 = "stuff" ..if else: ....option1 = "stuff2" ....option2 = "stuff2"

Same with aliases. I have many servers that all use the same scripts, and instead of every server having duplicated files, all script folders are linked to 1 central server instead, so they all load the same script folder. This is so I don't have to add/remove/edit scripts on 10 different servers every time I change something. This doesn't work with some of my scripts that use some aliases/options which vary between servers, so I'd like to be able to do:

aliases: ..if {serverID} = "server1": ....customBlock = 560 ..else if {serverID} = "server2": ....customBlock = 790

This way I can still have just 1 central file but have the aliases/options conditioned for each server.

MostFunGuy commented 9 years ago

The options section is directly what variables are used for :P You can set them, or just use them :-) I use an "On script load" event to load up variables as the script gets reloaded. Something like:

on script load: set {serverstuff::currentserver} to "KitPVP1" set {var::thisotherthing} to "thatotherthing" set {var::etc} to "etc" set {var::etcetc} to "etcetc"

The centralized skripts thing is good, I tried and failed to do that before, how are you doing it? We had 5 machines and were running a cron job to mirror the folders across multiple machines, but kept running into security issues and it getting rejected on certain machines each time.

Tsugaga commented 9 years ago

Yeah I know I can use variables for options and that's how I set them too, this is mainly for aliases though. Using a banned items script as an example, on different modpacks the "BannedItem" alias is different since each pack as different items with different IDs. Currently I have that script duplicated on each server with separate settings, which is a pain, I'd like to have it in my central script folder and just have it set the alias based on which server is loading it.

Not sure about multiple machines, but I just have one linux server, and I centralized the scripts by creating a symbolic link in every mc server script folder which links to the central scripts folder so they share all of the files in it.

ismooch commented 9 years ago

I have a centralized AND local script folder for each machine.. While i can see what OP wants being useful, i think the implementation of options would make it difficult to be efficient. Options are simply pasted in their appropriate areas upon compiling.. Meaning that if a variable changed after that script has been loaded, it would need to be reloaded for the conditionals to run and replace respectively. Im not saying it wouldnt be useful. Honestly, anyone with a multiserver setup and a centralized script folder would probably find use in this. On Dec 21, 2014 5:08 AM, "MostFunGuy" notifications@github.com wrote:

The options section is directly what variables are used for :P You can set them, or just use them :-) I use an "On script load" event to load up variables as the script gets reloaded. Something like:

on script load: set {serverstuff::currentserver} to "KitPVP1" set {var::thisotherthing} to "thatotherthing" set {var::etc} to "etc" set {var::etcetc} to "etcetc"

The centralized skripts thing is good, I tried and failed to do that before, how are you doing it? We were running a cron job to mirror the folders across multiple machines, but kept running into security issues and it getting rejected.

— Reply to this email directly or view it on GitHub https://github.com/Njol/Skript/issues/364#issuecomment-67766910.

MostFunGuy commented 9 years ago

Hello Smooch long time no see <3

MostFunGuy commented 9 years ago

How are you guys mirriring the folders?

Tsugaga commented 9 years ago

I'm not mirroring anything, I told you I'm using a symbolic link. A symbolic link points a directory to another directory, basically linking them. If you have server1/plugins/Skript/scripts/LinkedScripts and you create a symbolic link in server2/plugins/Skript/scripts named "LinkedScripts"(link name can be anything) to server1/plugins/Skript/scripts/LinkedScripts, then any scripts in the LinkedScripts folder on server1 will be loaded by server2 because it's linked to server1.

MostFunGuy commented 9 years ago

Like this?

http://help.hardhathosting.com/question.php/95

So the server will act like the symbolically linked folder is apart of it's own directory and load the skripts from the central location?

Tsugaga commented 9 years ago

Yes and yes.

As far as file permissions go, the symlink permission doesn't matter, but the server will need permission to the files inside the linked folder.

ismooch commented 9 years ago

@mostfunguy yeah.. I still lurk around :P. And symbolic links will work On single machine.. But to have the same folder shared across multiple physical machines, it requires publishing/sharing the folder and then mounting it on the other machine. A little tricky.. But works nice once you get it set up.

DISCLAIMER

I can only confirms that this work with linux servers.. If you are working on a windows server (why?) i cant gurantee anything.