Yamakaja / commanditems

Assign commands to items
https://www.spigotmc.org/resources/command-items.42556/
MIT License
8 stars 15 forks source link

[Feature Request] RAND Operator #23

Closed ForeverZer0 closed 3 years ago

ForeverZer0 commented 3 years ago

I wish to request a feature that I believe many users could find useful: the addition of a RAND function as possible operator that can be used within the op parameter when using CALC.

The a and b parameters would function as a minimum and maximum threshold, and the value could then of course be stored in the target parameter for further processing.

Example Usage:

# Select a random  value between 100 and 500
{ action: CALC, a: "100", b: "500", op: RAND, target: "n", actions: [
  # Further processing or actions using this value
  { action: COMMAND, by: CONSOLE, command: "eco give {player} {n}" }
]} 
Yamakaja commented 3 years ago

Hey, i agree that a RAND op could be useful, but it is going to need some extra parameters:

I'll see what i can do this week

ForeverZer0 commented 3 years ago

Sounds great! I was giving a low-complexity example, but the more nuanced features you stated would make it even more powerful and useful, allowing for even more possibilities. I look forward to seeing what you can achieve with this plugin, it has already become a standard addition to any server I run, great work.

Yamakaja commented 3 years ago

@ForeverZer0 Is the new MATH_EXPR something you can work with? https://github.com/Yamakaja/commanditems#math_expr

For some examples see the default config.yml

ForeverZer0 commented 3 years ago

Looks great, well above and beyond what I could have hoped for. Thank you very much for considering this request and implementing it so quickly.